RCS0056 - roslynator_max_line_length = 180
This commit is contained in:
committed by
Matthias Mailänder
parent
822a29aa76
commit
9d5d2ab493
@@ -976,8 +976,15 @@ dotnet_diagnostic.CA2259.severity = suggestion # TODO: Change to warning once us
|
||||
|
||||
# We disable the rule category by setting severity to none.
|
||||
# Below we enable specific rules by setting severity to warning.
|
||||
# Rules are listed below with any options available.
|
||||
# Options are commented out if they match the defaults.
|
||||
dotnet_analyzer_diagnostic.category-roslynator.severity = none
|
||||
|
||||
# A line is too long.
|
||||
dotnet_diagnostic.RCS0056.severity = warning
|
||||
roslynator_max_line_length = 180 #140
|
||||
#roslynator_tab_length = 4
|
||||
|
||||
# Remove redundant 'sealed' modifier.
|
||||
dotnet_diagnostic.RCS1034.severity = warning
|
||||
|
||||
|
||||
@@ -56,5 +56,6 @@
|
||||
<PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.435" PrivateAssets="All" />
|
||||
<!-- Roslynator analyzers fail to run under Mono (AD0001) -->
|
||||
<PackageReference Include="Roslynator.Analyzers" Version="4.2.0" PrivateAssets="All" Condition="'$(MSBuildRuntimeType)'!='Mono'" />
|
||||
<PackageReference Include="Roslynator.Formatting.Analyzers" Version="4.2.0" PrivateAssets="All" Condition="'$(MSBuildRuntimeType)'!='Mono'" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
||||
@@ -58,13 +58,16 @@ namespace OpenRA.Graphics
|
||||
var tintModifiers = CurrentSequence.IgnoreWorldTint ? TintModifiers.IgnoreWorldTint : TintModifiers.None;
|
||||
var alpha = CurrentSequence.GetAlpha(CurrentFrame);
|
||||
var (image, rotation) = CurrentSequence.GetSpriteWithRotation(CurrentFrame, facingFunc());
|
||||
var imageRenderable = new SpriteRenderable(image, pos, offset, CurrentSequence.ZOffset + zOffset, palette, CurrentSequence.Scale, alpha, float3.Ones, tintModifiers, IsDecoration,
|
||||
rotation);
|
||||
var imageRenderable = new SpriteRenderable(
|
||||
image, pos, offset, CurrentSequence.ZOffset + zOffset, palette,
|
||||
CurrentSequence.Scale, alpha, float3.Ones, tintModifiers, IsDecoration, rotation);
|
||||
|
||||
var shadow = CurrentSequence.GetShadow(CurrentFrame, facingFunc());
|
||||
if (shadow != null)
|
||||
{
|
||||
var shadowRenderable = new SpriteRenderable(shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette, CurrentSequence.Scale, 1f, float3.Ones, tintModifiers,
|
||||
var shadowRenderable = new SpriteRenderable(
|
||||
shadow, pos, offset, CurrentSequence.ShadowZOffset + zOffset, palette,
|
||||
CurrentSequence.Scale, 1f, float3.Ones, tintModifiers,
|
||||
true, rotation);
|
||||
return new IRenderable[] { shadowRenderable, imageRenderable };
|
||||
}
|
||||
|
||||
@@ -216,7 +216,8 @@ namespace OpenRA.Graphics
|
||||
parent.DrawRGBAQuad(vertices, blendMode);
|
||||
}
|
||||
|
||||
public void FillRect(in float3 a, in float3 b, in float3 c, in float3 d, Color topLeftColor, Color topRightColor, Color bottomRightColor, Color bottomLeftColor, BlendMode blendMode = BlendMode.Alpha)
|
||||
public void FillRect(in float3 a, in float3 b, in float3 c, in float3 d,
|
||||
Color topLeftColor, Color topRightColor, Color bottomRightColor, Color bottomLeftColor, BlendMode blendMode = BlendMode.Alpha)
|
||||
{
|
||||
vertices[0] = VertexWithColor(a + Offset, topLeftColor);
|
||||
vertices[1] = VertexWithColor(b + Offset, topRightColor);
|
||||
|
||||
@@ -45,7 +45,8 @@ namespace OpenRA.Graphics
|
||||
this.loaders = loaders;
|
||||
}
|
||||
|
||||
public int ReserveSprites(string filename, IEnumerable<int> frames, MiniYamlNode.SourceLocation location, Func<ISpriteFrame, ISpriteFrame> adjustFrame = null, bool premultiplied = false)
|
||||
public int ReserveSprites(string filename, IEnumerable<int> frames, MiniYamlNode.SourceLocation location,
|
||||
Func<ISpriteFrame, ISpriteFrame> adjustFrame = null, bool premultiplied = false)
|
||||
{
|
||||
var token = nextReservationToken++;
|
||||
spriteReservations[token] = (frames?.ToArray(), location, adjustFrame, premultiplied);
|
||||
|
||||
@@ -410,10 +410,16 @@ namespace OpenRA
|
||||
{
|
||||
UpdateMaps();
|
||||
var map = string.IsNullOrEmpty(initialUid) ? null : previews[initialUid];
|
||||
if (map == null || map.Status != MapStatus.Available || !map.Visibility.HasFlag(MapVisibility.Lobby) || (map.Class != MapClassification.System && map.Class != MapClassification.User))
|
||||
if (map == null ||
|
||||
map.Status != MapStatus.Available ||
|
||||
!map.Visibility.HasFlag(MapVisibility.Lobby) ||
|
||||
(map.Class != MapClassification.System && map.Class != MapClassification.User))
|
||||
{
|
||||
var selected = previews.Values.Where(IsSuitableInitialMap).RandomOrDefault(random) ??
|
||||
previews.Values.FirstOrDefault(m => m.Status == MapStatus.Available && m.Visibility.HasFlag(MapVisibility.Lobby) && (m.Class == MapClassification.System || m.Class == MapClassification.User));
|
||||
previews.Values.FirstOrDefault(m =>
|
||||
m.Status == MapStatus.Available &&
|
||||
m.Visibility.HasFlag(MapVisibility.Lobby) &&
|
||||
(m.Class == MapClassification.System || m.Class == MapClassification.User));
|
||||
return selected == null ? string.Empty : selected.Uid;
|
||||
}
|
||||
|
||||
|
||||
@@ -339,7 +339,8 @@ namespace OpenRA
|
||||
}, null);
|
||||
}
|
||||
|
||||
public void UpdateFromMap(IReadOnlyPackage p, IReadOnlyPackage parent, MapClassification classification, string[] mapCompatibility, MapGridType gridType, IEnumerable<List<MiniYamlNode>> modDataRules)
|
||||
public void UpdateFromMap(IReadOnlyPackage p, IReadOnlyPackage parent, MapClassification classification,
|
||||
string[] mapCompatibility, MapGridType gridType, IEnumerable<List<MiniYamlNode>> modDataRules)
|
||||
{
|
||||
Dictionary<string, MiniYaml> yaml;
|
||||
using (var yamlStream = p.GetStream("map.yaml"))
|
||||
|
||||
@@ -463,7 +463,8 @@ namespace OpenRA
|
||||
}
|
||||
catch (ArgumentException)
|
||||
{
|
||||
throw new YamlException($"{n.Location}: Parent type `{n.Value.Value}` was already inherited by this yaml tree at {inherited[n.Value.Value]} (note: may be from a derived tree)");
|
||||
throw new YamlException(
|
||||
$"{n.Location}: Parent type `{n.Value.Value}` was already inherited by this yaml tree at {inherited[n.Value.Value]} (note: may be from a derived tree)");
|
||||
}
|
||||
|
||||
foreach (var r in ResolveInherits(parent, tree, inherited))
|
||||
|
||||
@@ -78,7 +78,8 @@ namespace OpenRA
|
||||
readonly Target target;
|
||||
readonly Target visualFeedbackTarget;
|
||||
|
||||
Order(string orderString, Actor subject, in Target target, string targetString, bool queued, Actor[] extraActors, CPos extraLocation, uint extraData, Actor[] groupedActors = null)
|
||||
Order(string orderString, Actor subject, in Target target, string targetString, bool queued,
|
||||
Actor[] extraActors, CPos extraLocation, uint extraData, Actor[] groupedActors = null)
|
||||
{
|
||||
OrderString = orderString ?? "";
|
||||
Subject = subject;
|
||||
|
||||
@@ -337,7 +337,8 @@ namespace OpenRA
|
||||
// Render the compositor buffers to the screen
|
||||
// HACK / PERF: Fudge the coordinates to cover the actual window while keeping the buffer viewport parameters
|
||||
// This saves us two redundant (and expensive) SetViewportParams each frame
|
||||
RgbaSpriteRenderer.DrawSprite(screenSprite, new float3(0, lastBufferSize.Height, 0), new float3(lastBufferSize.Width / screenSprite.Size.X, -lastBufferSize.Height / screenSprite.Size.Y, 1f));
|
||||
RgbaSpriteRenderer.DrawSprite(screenSprite, new float3(0, lastBufferSize.Height, 0),
|
||||
new float3(lastBufferSize.Width / screenSprite.Size.X, -lastBufferSize.Height / screenSprite.Size.Y, 1f));
|
||||
Flush();
|
||||
|
||||
Window.PumpInput(inputHandler);
|
||||
|
||||
@@ -24,7 +24,10 @@ namespace OpenRA.Server
|
||||
readonly Action<Connection, int, int, byte[]> dispatchOrdersToClient;
|
||||
readonly Action<Connection, string, Dictionary<string, object>> sendLocalizedMessageTo;
|
||||
|
||||
public PlayerMessageTracker(Server server, Action<Connection, int, int, byte[]> dispatchOrdersToClient, Action<Connection, string, Dictionary<string, object>> sendLocalizedMessageTo)
|
||||
public PlayerMessageTracker(
|
||||
Server server,
|
||||
Action<Connection, int, int, byte[]> dispatchOrdersToClient,
|
||||
Action<Connection, string, Dictionary<string, object>> sendLocalizedMessageTo)
|
||||
{
|
||||
this.server = server;
|
||||
this.dispatchOrdersToClient = dispatchOrdersToClient;
|
||||
|
||||
@@ -44,7 +44,11 @@ namespace OpenRA
|
||||
Log.Write("exception", $"Date: {DateTime.UtcNow:u}");
|
||||
Log.Write("exception", $"Operating System: {Platform.CurrentPlatform} ({Platform.CurrentArchitecture}, {Environment.OSVersion})");
|
||||
Log.Write("exception", $"Runtime Version: {Platform.RuntimeVersion}");
|
||||
Log.Write("exception", $"Installed Language: {CultureInfo.InstalledUICulture.TwoLetterISOLanguageName} (Installed) {CultureInfo.CurrentCulture.TwoLetterISOLanguageName} (Current) {CultureInfo.CurrentUICulture.TwoLetterISOLanguageName} (Current UI)");
|
||||
Log.Write("exception",
|
||||
"Installed Language: " +
|
||||
$"{CultureInfo.InstalledUICulture.TwoLetterISOLanguageName} (Installed) " +
|
||||
$"{CultureInfo.CurrentCulture.TwoLetterISOLanguageName} (Current) " +
|
||||
$"{CultureInfo.CurrentUICulture.TwoLetterISOLanguageName} (Current UI)");
|
||||
|
||||
var rpt = BuildExceptionReport(ex).ToString();
|
||||
Log.Write("exception", rpt);
|
||||
|
||||
@@ -629,7 +629,8 @@ namespace OpenRA.Support
|
||||
if (lastToken.RightOperand == token.LeftOperand)
|
||||
{
|
||||
if (lastToken.RightOperand)
|
||||
throw new InvalidDataException($"Missing value or sub-expression or there is an extra operator `{lastToken.Symbol}` at index {lastToken.Index} or `{token.Symbol}` at index {token.Index}");
|
||||
throw new InvalidDataException(
|
||||
$"Missing value or sub-expression or there is an extra operator `{lastToken.Symbol}` at index {lastToken.Index} or `{token.Symbol}` at index {token.Index}");
|
||||
throw new InvalidDataException($"Missing binary operation before `{token.Symbol}` at index {token.Index}");
|
||||
}
|
||||
}
|
||||
@@ -736,7 +737,10 @@ namespace OpenRA.Support
|
||||
return IfThenElse(expression, One, Zero);
|
||||
}
|
||||
|
||||
throw new InvalidProgramException($"Unable to convert ExpressionType.{Enum<ExpressionType>.GetValues()[(int)fromType]} to ExpressionType.{Enum<ExpressionType>.GetValues()[(int)toType]}");
|
||||
throw new InvalidProgramException(
|
||||
"Unable to convert " +
|
||||
$"ExpressionType.{Enum<ExpressionType>.GetValues()[(int)fromType]} to " +
|
||||
$"ExpressionType.{Enum<ExpressionType>.GetValues()[(int)toType]}");
|
||||
}
|
||||
|
||||
public Expression Pop(ExpressionType type)
|
||||
|
||||
@@ -21,7 +21,8 @@ namespace OpenRA
|
||||
/// <summary>
|
||||
/// 1d world distance - 1024 units = 1 cell.
|
||||
/// </summary>
|
||||
public readonly struct WDist : IComparable, IComparable<WDist>, IEquatable<WDist>, IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding
|
||||
public readonly struct WDist : IComparable, IComparable<WDist>, IEquatable<WDist>,
|
||||
IScriptBindable, ILuaAdditionBinding, ILuaSubtractionBinding, ILuaEqualityBinding, ILuaTableBinding
|
||||
{
|
||||
public readonly int Length;
|
||||
public long LengthSquared => (long)Length * Length;
|
||||
|
||||
@@ -49,9 +49,13 @@ namespace OpenRA.Mods.Cnc.Installer
|
||||
|
||||
Action<long> onProgress = null;
|
||||
if (stream.Length < InstallFromSourceLogic.ShowPercentageThreshold)
|
||||
updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.Extracing, Translation.Arguments("filename", displayFilename)));
|
||||
updateMessage(TranslationProvider.GetString(
|
||||
InstallFromSourceLogic.Extracing,
|
||||
Translation.Arguments("filename", displayFilename)));
|
||||
else
|
||||
onProgress = b => updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.ExtractingProgress, Translation.Arguments("filename", displayFilename, "progress", 100 * b / stream.Length)));
|
||||
onProgress = b => updateMessage(TranslationProvider.GetString(
|
||||
InstallFromSourceLogic.ExtractingProgress,
|
||||
Translation.Arguments("filename", displayFilename, "progress", 100 * b / stream.Length)));
|
||||
|
||||
using (var target = File.OpenWrite(targetPath))
|
||||
{
|
||||
|
||||
@@ -204,7 +204,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
|
||||
// HACK: Consider ourselves blocked if we have moved by less than 64 WDist in the last five ticks
|
||||
// Stop if we are blocked and close enough
|
||||
if (previousPositions.Count == previousPositions.Capacity && (previousPositions.First() - previousPositions.Last()).LengthSquared < 4096 && delta.HorizontalLengthSquared <= nearEnough.LengthSquared)
|
||||
if (previousPositions.Count == previousPositions.Capacity &&
|
||||
(previousPositions.First() - previousPositions.Last()).LengthSquared < 4096 &&
|
||||
delta.HorizontalLengthSquared <= nearEnough.LengthSquared)
|
||||
return true;
|
||||
|
||||
// The next move would overshoot, so consider it close enough or set final position if we CanSlide
|
||||
|
||||
@@ -38,7 +38,9 @@ namespace OpenRA.Mods.Common.Activities
|
||||
// Make sure we can still repair the target before entering
|
||||
// (but not before, because this may stop the actor in the middle of nowhere)
|
||||
var stance = self.Owner.RelationshipWith(enterActor.Owner);
|
||||
if (enterHealth == null || enterHealth.DamageState == DamageState.Undamaged || enterInstantlyRepariable == null || enterInstantlyRepariable.IsTraitDisabled || !info.ValidRelationships.HasRelationship(stance))
|
||||
if (enterHealth == null || enterHealth.DamageState == DamageState.Undamaged ||
|
||||
enterInstantlyRepariable == null || enterInstantlyRepariable.IsTraitDisabled ||
|
||||
!info.ValidRelationships.HasRelationship(stance))
|
||||
{
|
||||
Cancel(self, true);
|
||||
return false;
|
||||
|
||||
@@ -228,7 +228,11 @@ namespace OpenRA.Mods.Common.Activities
|
||||
{
|
||||
moveCooldownHelper.NotifyMoveQueued();
|
||||
foreach (var cell in rp.Path)
|
||||
QueueChild(new AttackMoveActivity(self, () => move.MoveTo(cell, 1, ignoreActor: repairableNear != null ? null : host.Actor, targetLineColor: aircraft.Info.TargetLineColor)));
|
||||
QueueChild(new AttackMoveActivity(self, () => move.MoveTo(
|
||||
cell,
|
||||
1,
|
||||
ignoreActor: repairableNear != null ? null : host.Actor,
|
||||
targetLineColor: aircraft.Info.TargetLineColor)));
|
||||
}
|
||||
else
|
||||
QueueChild(new TakeOff(self));
|
||||
|
||||
@@ -38,14 +38,15 @@ namespace OpenRA.Mods.Common.Commands
|
||||
[TranslationReference]
|
||||
const string ActorTagsOverlayDescripition = "description-actor-tags-overlay";
|
||||
|
||||
readonly IDictionary<string, (string Description, Action<DebugVisualizations, DeveloperMode> Handler)> commandHandlers = new Dictionary<string, (string Description, Action<DebugVisualizations, DeveloperMode> Handler)>
|
||||
{
|
||||
{ "combat-geometry", (CombatGeometryDescription, CombatGeometry) },
|
||||
{ "render-geometry", (RenderGeometryDescription, RenderGeometry) },
|
||||
{ "screen-map", (ScreenMapOverlayDescription, ScreenMap) },
|
||||
{ "depth-buffer", (DepthBufferDescription, DepthBuffer) },
|
||||
{ "actor-tags", (ActorTagsOverlayDescripition, ActorTags) },
|
||||
};
|
||||
readonly IDictionary<string, (string Description, Action<DebugVisualizations, DeveloperMode> Handler)> commandHandlers =
|
||||
new Dictionary<string, (string Description, Action<DebugVisualizations, DeveloperMode> Handler)>
|
||||
{
|
||||
{ "combat-geometry", (CombatGeometryDescription, CombatGeometry) },
|
||||
{ "render-geometry", (RenderGeometryDescription, RenderGeometry) },
|
||||
{ "screen-map", (ScreenMapOverlayDescription, ScreenMap) },
|
||||
{ "depth-buffer", (DepthBufferDescription, DepthBuffer) },
|
||||
{ "actor-tags", (ActorTagsOverlayDescripition, ActorTags) },
|
||||
};
|
||||
|
||||
DebugVisualizations debugVis;
|
||||
DeveloperMode devMode;
|
||||
|
||||
@@ -36,10 +36,15 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
int length;
|
||||
readonly int skip;
|
||||
|
||||
public ContrailRenderable(World world, Actor owner, Color startcolor, bool usePlayerStartColor, Color endcolor, bool usePlayerEndColor, WDist startWidth, WDist endWidth, int length, int skip, int zOffset)
|
||||
: this(world, owner, new WPos[length], startWidth, endWidth, 0, 0, skip, startcolor, usePlayerStartColor, endcolor, usePlayerEndColor, zOffset) { }
|
||||
public ContrailRenderable(
|
||||
World world, Actor owner, Color startcolor, bool usePlayerStartColor, Color endcolor, bool usePlayerEndColor,
|
||||
WDist startWidth, WDist endWidth, int length, int skip, int zOffset)
|
||||
: this(world, owner, new WPos[length], startWidth, endWidth, 0, 0, skip,
|
||||
startcolor, usePlayerStartColor, endcolor, usePlayerEndColor, zOffset)
|
||||
{ }
|
||||
|
||||
ContrailRenderable(World world, Actor owner, WPos[] trail, WDist startWidth, WDist endWidth, int next, int length, int skip, Color startColor, bool usePlayerStartColor, Color endColor, bool usePlayerEndColor, int zOffset)
|
||||
ContrailRenderable(World world, Actor owner, WPos[] trail, WDist startWidth, WDist endWidth,
|
||||
int next, int length, int skip, Color startColor, bool usePlayerStartColor, Color endColor, bool usePlayerEndColor, int zOffset)
|
||||
{
|
||||
this.world = world;
|
||||
this.owner = owner;
|
||||
@@ -60,12 +65,17 @@ namespace OpenRA.Mods.Common.Graphics
|
||||
public int ZOffset { get; }
|
||||
public bool IsDecoration => true;
|
||||
|
||||
public IRenderable WithZOffset(int newOffset) { return new ContrailRenderable(world, owner, (WPos[])trail.Clone(), startWidth, endWidth, next, length, skip, startColor, usePlayerStartColor, endColor, usePlayerEndColor, newOffset); }
|
||||
public IRenderable WithZOffset(int newOffset) =>
|
||||
new ContrailRenderable(
|
||||
world, owner, (WPos[])trail.Clone(), startWidth, endWidth, next,
|
||||
length, skip, startColor, usePlayerStartColor, endColor, usePlayerEndColor, newOffset);
|
||||
public IRenderable OffsetBy(in WVec vec)
|
||||
{
|
||||
// Lambdas can't use 'in' variables, so capture a copy for later
|
||||
var offset = vec;
|
||||
return new ContrailRenderable(world, owner, trail.Select(pos => pos + offset).ToArray(), startWidth, endWidth, next, length, skip, startColor, usePlayerStartColor, endColor, usePlayerEndColor, ZOffset);
|
||||
return new ContrailRenderable(
|
||||
world, owner, trail.Select(pos => pos + offset).ToArray(), startWidth, endWidth, next,
|
||||
length, skip, startColor, usePlayerStartColor, endColor, usePlayerEndColor, ZOffset);
|
||||
}
|
||||
|
||||
public IRenderable AsDecoration() { return this; }
|
||||
|
||||
@@ -44,9 +44,13 @@ namespace OpenRA.Mods.Common.Installer
|
||||
|
||||
Action<long> onProgress = null;
|
||||
if (length < InstallFromSourceLogic.ShowPercentageThreshold)
|
||||
updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.CopyingFilename, Translation.Arguments("filename", displayFilename)));
|
||||
updateMessage(TranslationProvider.GetString(
|
||||
InstallFromSourceLogic.CopyingFilename,
|
||||
Translation.Arguments("filename", displayFilename)));
|
||||
else
|
||||
onProgress = b => updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.CopyingFilenameProgress, Translation.Arguments("filename", displayFilename, "progress", 100 * b / length)));
|
||||
onProgress = b => updateMessage(
|
||||
TranslationProvider.GetString(InstallFromSourceLogic.CopyingFilenameProgress,
|
||||
Translation.Arguments("filename", displayFilename, "progress", 100 * b / length)));
|
||||
|
||||
InstallerUtils.CopyStream(source, target, length, onProgress);
|
||||
}
|
||||
|
||||
@@ -66,9 +66,13 @@ namespace OpenRA.Mods.Common.Installer
|
||||
|
||||
Action<long> onProgress = null;
|
||||
if (length < InstallFromSourceLogic.ShowPercentageThreshold)
|
||||
updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.Extracing, Translation.Arguments("filename", displayFilename)));
|
||||
updateMessage(TranslationProvider.GetString(
|
||||
InstallFromSourceLogic.Extracing,
|
||||
Translation.Arguments("filename", displayFilename)));
|
||||
else
|
||||
onProgress = b => updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.ExtractingProgress, Translation.Arguments("filename", displayFilename, "progress", 100 * b / length)));
|
||||
onProgress = b => updateMessage(TranslationProvider.GetString(
|
||||
InstallFromSourceLogic.ExtractingProgress,
|
||||
Translation.Arguments("filename", displayFilename, "progress", 100 * b / length)));
|
||||
|
||||
using (var target = File.OpenWrite(targetPath))
|
||||
{
|
||||
|
||||
@@ -62,7 +62,9 @@ namespace OpenRA.Mods.Common.Installer
|
||||
{
|
||||
Log.Write("install", $"Extracting {sourcePath} -> {targetPath}");
|
||||
var displayFilename = Path.GetFileName(Path.GetFileName(targetPath));
|
||||
void OnProgress(int percent) => updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.ExtractingProgress, Translation.Arguments("filename", displayFilename, "progress", percent)));
|
||||
void OnProgress(int percent) => updateMessage(TranslationProvider.GetString(
|
||||
InstallFromSourceLogic.ExtractingProgress,
|
||||
Translation.Arguments("filename", displayFilename, "progress", percent)));
|
||||
reader.ExtractFile(node.Value.Value, target, OnProgress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,7 +44,9 @@ namespace OpenRA.Mods.Common.Installer
|
||||
{
|
||||
Log.Write("install", $"Extracting {sourcePath} -> {targetPath}");
|
||||
var displayFilename = Path.GetFileName(Path.GetFileName(targetPath));
|
||||
void OnProgress(int percent) => updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.ExtractingProgress, Translation.Arguments("filename", displayFilename, "progress", percent)));
|
||||
void OnProgress(int percent) => updateMessage(TranslationProvider.GetString(
|
||||
InstallFromSourceLogic.ExtractingProgress,
|
||||
Translation.Arguments("filename", displayFilename, "progress", percent)));
|
||||
reader.ExtractFile(node.Value.Value, target, OnProgress);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,7 +61,9 @@ namespace OpenRA.Mods.Common.Installer
|
||||
if (length < InstallFromSourceLogic.ShowPercentageThreshold)
|
||||
updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.Extracing, Translation.Arguments("filename", displayFilename)));
|
||||
else
|
||||
onProgress = b => updateMessage(TranslationProvider.GetString(InstallFromSourceLogic.ExtractingProgress, Translation.Arguments("filename", displayFilename, "progress", 100 * b / length)));
|
||||
onProgress = b => updateMessage(TranslationProvider.GetString(
|
||||
InstallFromSourceLogic.ExtractingProgress,
|
||||
Translation.Arguments("filename", displayFilename, "progress", 100 * b / length)));
|
||||
|
||||
using (var target = File.OpenWrite(targetPath))
|
||||
{
|
||||
|
||||
@@ -19,7 +19,9 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
public void Run(Action<string> emitError, Action<string> emitWarning, ModData modData, Map map)
|
||||
{
|
||||
var scriptBindings = Game.ModData.ObjectCreator.GetTypesImplementing<ScriptGlobal>().Select(t => Utility.GetCustomAttributes<ScriptGlobalAttribute>(t, true)[0].Name).ToHashSet();
|
||||
var scriptBindings = Game.ModData.ObjectCreator.GetTypesImplementing<ScriptGlobal>()
|
||||
.Select(t => Utility.GetCustomAttributes<ScriptGlobalAttribute>(t, true)[0].Name)
|
||||
.ToHashSet();
|
||||
foreach (var actor in map.ActorDefinitions)
|
||||
{
|
||||
var name = actor.Value.Value;
|
||||
|
||||
@@ -96,7 +96,8 @@ namespace OpenRA.Mods.Common.Lint
|
||||
{
|
||||
// TODO: Remove prefixed sequence references and instead use explicit lists of lintable references.
|
||||
if (!sequences.Sequences(i).Any(s => s.StartsWith(sequence, StringComparison.Ordinal)))
|
||||
emitWarning($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{i}`.");
|
||||
emitWarning(
|
||||
$"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` defines a prefix `{sequence}` that does not match any sequences on image `{i}`.");
|
||||
}
|
||||
else if (!sequences.HasSequence(i, sequence))
|
||||
emitError($"Actor type `{actorInfo.Value.Name}` trait `{traitName}` field `{field.Name}` references an undefined sequence `{sequence}` on image `{i}`.");
|
||||
|
||||
@@ -245,7 +245,10 @@ namespace OpenRA.Mods.Common.Lint
|
||||
var resourceTypeTranslationReference = Utility.GetCustomAttributes<TranslationReferenceAttribute>(resourceTypeNameField, true)[0];
|
||||
testedFields.Add(resourceTypeNameField);
|
||||
foreach (var resourceTypes in info.ResourceTypes)
|
||||
usedKeys.Add(resourceTypes.Value.Name, resourceTypeTranslationReference, $"`{nameof(ResourceRendererInfo.ResourceTypeInfo)}.{nameof(ResourceRendererInfo.ResourceTypeInfo.Name)}`");
|
||||
usedKeys.Add(
|
||||
resourceTypes.Value.Name,
|
||||
resourceTypeTranslationReference,
|
||||
$"`{nameof(ResourceRendererInfo.ResourceTypeInfo)}.{nameof(ResourceRendererInfo.ResourceTypeInfo.Name)}`");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[Desc("The maximum/constant/incremental inaccuracy used in conjunction with the InaccuracyType property.")]
|
||||
public readonly WDist Inaccuracy = WDist.Zero;
|
||||
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are 'Maximum' - scale from 0 to max with range, 'PerCellIncrement' - scale from 0 with range and 'Absolute' - use set value regardless of range.")]
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are " +
|
||||
"'Maximum' - scale from 0 to max with range, " +
|
||||
"'PerCellIncrement' - scale from 0 with range, " +
|
||||
"'Absolute' - use set value regardless of range.")]
|
||||
public readonly InaccuracyType InaccuracyType = InaccuracyType.Maximum;
|
||||
|
||||
[Desc("Can this projectile be blocked when hitting actors with an IBlocksProjectiles trait.")]
|
||||
|
||||
@@ -30,7 +30,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[Desc("The maximum/constant/incremental inaccuracy used in conjunction with the InaccuracyType property.")]
|
||||
public readonly WDist Inaccuracy = WDist.Zero;
|
||||
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are 'Maximum' - scale from 0 to max with range, 'PerCellIncrement' - scale from 0 with range and 'Absolute' - use set value regardless of range.")]
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are " +
|
||||
"'Maximum' - scale from 0 to max with range, " +
|
||||
"'PerCellIncrement' - scale from 0 with range, " +
|
||||
"'Absolute' - use set value regardless of range.")]
|
||||
public readonly InaccuracyType InaccuracyType = InaccuracyType.Maximum;
|
||||
|
||||
[Desc("Image to display.")]
|
||||
|
||||
@@ -24,7 +24,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[Desc("The maximum/constant/incremental inaccuracy used in conjunction with the InaccuracyType property.")]
|
||||
public readonly WDist Inaccuracy = WDist.Zero;
|
||||
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are 'Maximum' - scale from 0 to max with range, 'PerCellIncrement' - scale from 0 with range and 'Absolute' - use set value regardless of range.")]
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are " +
|
||||
"'Maximum' - scale from 0 to max with range, " +
|
||||
"'PerCellIncrement' - scale from 0 with range, " +
|
||||
"'Absolute' - use set value regardless of range.")]
|
||||
public readonly InaccuracyType InaccuracyType = InaccuracyType.Maximum;
|
||||
|
||||
[Desc("Projectile can be blocked.")]
|
||||
|
||||
@@ -52,7 +52,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[Desc("The maximum/constant/incremental inaccuracy used in conjunction with the InaccuracyType property.")]
|
||||
public readonly WDist Inaccuracy = WDist.Zero;
|
||||
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are 'Maximum' - scale from 0 to max with range, 'PerCellIncrement' - scale from 0 with range and 'Absolute' - use set value regardless of range.")]
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are " +
|
||||
"'Maximum' - scale from 0 to max with range, " +
|
||||
"'PerCellIncrement' - scale from 0 with range, " +
|
||||
"'Absolute' - use set value regardless of range.")]
|
||||
public readonly InaccuracyType InaccuracyType = InaccuracyType.Maximum;
|
||||
|
||||
[Desc("Beam can be blocked.")]
|
||||
|
||||
@@ -77,7 +77,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[Desc("The maximum/constant/incremental inaccuracy used in conjunction with the InaccuracyType property.")]
|
||||
public readonly WDist Inaccuracy = WDist.Zero;
|
||||
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are 'Maximum' - scale from 0 to max with range, 'PerCellIncrement' - scale from 0 with range and 'Absolute' - use set value regardless of range.")]
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are " +
|
||||
"'Maximum' - scale from 0 to max with range, " +
|
||||
"'PerCellIncrement' - scale from 0 with range, " +
|
||||
"'Absolute' - use set value regardless of range.")]
|
||||
public readonly InaccuracyType InaccuracyType = InaccuracyType.Absolute;
|
||||
|
||||
[Desc("Inaccuracy override when successfully locked onto target. Defaults to Inaccuracy if negative.")]
|
||||
|
||||
@@ -28,7 +28,10 @@ namespace OpenRA.Mods.Common.Projectiles
|
||||
[Desc("The maximum/constant/incremental inaccuracy used in conjunction with the InaccuracyType property.")]
|
||||
public readonly WDist Inaccuracy = WDist.Zero;
|
||||
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are 'Maximum' - scale from 0 to max with range, 'PerCellIncrement' - scale from 0 with range and 'Absolute' - use set value regardless of range.")]
|
||||
[Desc("Controls the way inaccuracy is calculated. Possible values are " +
|
||||
"'Maximum' - scale from 0 to max with range, " +
|
||||
"'PerCellIncrement' - scale from 0 with range, " +
|
||||
"'Absolute' - use set value regardless of range.")]
|
||||
public readonly InaccuracyType InaccuracyType = InaccuracyType.Maximum;
|
||||
|
||||
[Desc("Can this projectile be blocked when hitting actors with an IBlocksProjectiles trait.")]
|
||||
|
||||
@@ -45,10 +45,12 @@ namespace OpenRA.Mods.Common.Terrain
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
if (!int.TryParse(node.Key, out var key))
|
||||
throw new YamlException($"Tileset `{terrainInfo.Id}` template `{Id}` defines a frame `{node.Key}` that is not a valid integer.");
|
||||
throw new YamlException(
|
||||
$"Tileset `{terrainInfo.Id}` template `{Id}` defines a frame `{node.Key}` that is not a valid integer.");
|
||||
|
||||
if (key < 0 || key >= tileInfo.Length)
|
||||
throw new YamlException($"Tileset `{terrainInfo.Id}` template `{Id}` references frame {key}, but only [0..{tileInfo.Length - 1}] are valid for a {Size.X}x{Size.Y} Size template.");
|
||||
throw new YamlException(
|
||||
$"Tileset `{terrainInfo.Id}` template `{Id}` references frame {key}, but only [0..{tileInfo.Length - 1}] are valid for a {Size.X}x{Size.Y} Size template.");
|
||||
|
||||
tileInfo[key] = LoadTileInfo(terrainInfo, node.Value);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
// Inform all idle carriers
|
||||
var carriers = self.World.ActorsWithTrait<AutoCarryall>()
|
||||
.Where(c => c.Trait.State == Carryall.CarryallState.Idle && !c.Trait.IsTraitDisabled && c.Trait.EnableAutoCarry && !c.Actor.IsDead && c.Actor.Owner == self.Owner && c.Actor.IsInWorld)
|
||||
.Where(c =>
|
||||
c.Trait.State == Carryall.CarryallState.Idle && !c.Trait.IsTraitDisabled &&
|
||||
c.Trait.EnableAutoCarry && !c.Actor.IsDead && c.Actor.Owner == self.Owner && c.Actor.IsInWorld)
|
||||
.OrderBy(p => (self.Location - p.Actor.Location).LengthSquared);
|
||||
|
||||
// Enumerate idle carriers to find the first that is able to transport us
|
||||
|
||||
@@ -225,8 +225,21 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
|
||||
var vec = new CVec(Info.MineFieldRadius, Info.MineFieldRadius);
|
||||
bot.QueueOrder(new Order("PlaceMinefield", null, Target.FromCell(world, minelayingPosition + vec), false, groupedActors: orderedActors.ToArray()) { ExtraLocation = minelayingPosition - vec });
|
||||
bot.QueueOrder(new Order("Move", null, Target.FromCell(world, orderedActors[0].Location), true, groupedActors: orderedActors.ToArray()));
|
||||
bot.QueueOrder(
|
||||
new Order(
|
||||
"PlaceMinefield",
|
||||
null,
|
||||
Target.FromCell(world, minelayingPosition + vec),
|
||||
false,
|
||||
groupedActors: orderedActors.ToArray())
|
||||
{ ExtraLocation = minelayingPosition - vec });
|
||||
bot.QueueOrder(
|
||||
new Order(
|
||||
"Move",
|
||||
null,
|
||||
Target.FromCell(world, orderedActors[0].Location),
|
||||
true,
|
||||
groupedActors: orderedActors.ToArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -35,7 +35,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
[Desc("Cooldown (in ticks) to reach full charge.")]
|
||||
public readonly int ChargeDuration = 500;
|
||||
|
||||
[Desc("The ammount of charge that needs to be present for deploy to be issued. If set to -1, threshold is set to full charge. If activated without full charge " + nameof(ConditionDuration) + " is percentally smaller.")]
|
||||
[Desc("The amount of charge that needs to be present for deploy to be issued. " +
|
||||
"If set to -1, threshold is set to full charge. " +
|
||||
"If activated without full charge " + nameof(ConditionDuration) + " is percentally smaller.")]
|
||||
public readonly int ChargeThreshhold = -1;
|
||||
|
||||
[Desc("How long (in ticks) should the condition stay active?")]
|
||||
@@ -78,7 +80,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
}
|
||||
}
|
||||
|
||||
public class GrantConditionOnDeployWithCharge : PausableConditionalTrait<GrantConditionOnDeployWithChargeInfo>, IIssueOrder, IResolveOrder, ITick, ISelectionBar, IOrderVoice, ISync, IIssueDeployOrder
|
||||
public class GrantConditionOnDeployWithCharge : PausableConditionalTrait<GrantConditionOnDeployWithChargeInfo>,
|
||||
IIssueOrder, IResolveOrder, ITick, ISelectionBar, IOrderVoice, ISync, IIssueDeployOrder
|
||||
{
|
||||
[Sync]
|
||||
int chargeTick = 0;
|
||||
|
||||
@@ -42,7 +42,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public override object Create(ActorInitializer init) { return new ProximityExternalCondition(init.Self, this); }
|
||||
}
|
||||
|
||||
public class ProximityExternalCondition : ConditionalTrait<ProximityExternalConditionInfo>, ITick, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOtherProduction, INotifyProximityOwnerChanged
|
||||
public class ProximityExternalCondition : ConditionalTrait<ProximityExternalConditionInfo>,
|
||||
ITick, INotifyAddedToWorld, INotifyRemovedFromWorld, INotifyOtherProduction, INotifyProximityOwnerChanged
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
|
||||
@@ -322,7 +322,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
else
|
||||
{
|
||||
return docks
|
||||
.OrderBy(dock => (clientActor.Location - clientActor.World.Map.CellContaining(dock.Trait.DockPosition)).LengthSquared + dock.Trait.ReservationCount * client.OccupancyCostModifier)
|
||||
.OrderBy(dock =>
|
||||
(clientActor.Location - clientActor.World.Map.CellContaining(dock.Trait.DockPosition)).LengthSquared +
|
||||
dock.Trait.ReservationCount * client.OccupancyCostModifier)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
public override object Create(ActorInitializer init) { return new DockHost(init.Self, this); }
|
||||
}
|
||||
|
||||
public class DockHost : ConditionalTrait<DockHostInfo>, IDockHost, IDockHostDrag, ITick, INotifySold, INotifyCapture, INotifyOwnerChanged, ISync, INotifyKilled, INotifyActorDisposing
|
||||
public class DockHost : ConditionalTrait<DockHostInfo>,
|
||||
IDockHost, IDockHostDrag, ITick, INotifySold, INotifyCapture, INotifyOwnerChanged, ISync, INotifyKilled, INotifyActorDisposing
|
||||
{
|
||||
readonly Actor self;
|
||||
|
||||
|
||||
@@ -55,7 +55,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (info.Tileset != null && !string.Equals(info.Tileset, world.Map.Tileset, StringComparison.InvariantCultureIgnoreCase))
|
||||
return;
|
||||
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => (i == info.TransparentIndex) ? 0 : Color.FromArgb(255, i, i, i).ToArgb())), info.AllowModifiers);
|
||||
wr.AddPalette(info.Name, new ImmutablePalette(
|
||||
Enumerable.Range(0, Palette.Size).Select(i => (i == info.TransparentIndex) ? 0 : Color.FromArgb(255, i, i, i).ToArgb())),
|
||||
info.AllowModifiers);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -219,7 +219,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
.GroupBy(i => i.Item)
|
||||
.ToList()
|
||||
.Count;
|
||||
return item.RemainingTimeActual * parallelBuilds * info.ParallelPenaltyBuildTimeMultipliers[Math.Min(parallelBuilds - 1, info.ParallelPenaltyBuildTimeMultipliers.Length - 1)] / 100;
|
||||
return item.RemainingTimeActual *
|
||||
parallelBuilds *
|
||||
info.ParallelPenaltyBuildTimeMultipliers[Math.Min(parallelBuilds - 1, info.ParallelPenaltyBuildTimeMultipliers.Length - 1)] / 100;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,8 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var body = init.Self.TraitOrDefault<BodyOrientation>();
|
||||
var facing = init.Self.TraitOrDefault<IFacing>();
|
||||
|
||||
overlay = new Animation(init.World, renderSprites.GetImage(init.Self), facing == null ? () => WAngle.Zero : (body == null ? () => facing.Facing : () => body.QuantizeFacing(facing.Facing)))
|
||||
overlay = new Animation(init.World, renderSprites.GetImage(init.Self),
|
||||
facing == null ? () => WAngle.Zero : (body == null ? () => facing.Facing : () => body.QuantizeFacing(facing.Facing)))
|
||||
{
|
||||
IsDecoration = info.IsDecoration
|
||||
};
|
||||
|
||||
@@ -95,7 +95,9 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
var facing = self.TraitOrDefault<IFacing>();
|
||||
|
||||
var image = info.Image ?? rs.GetImage(self);
|
||||
overlay = new Animation(self.World, image, facing == null ? () => WAngle.Zero : (body == null ? () => facing.Facing : () => body.QuantizeFacing(facing.Facing)), () => IsTraitPaused)
|
||||
overlay = new Animation(self.World, image,
|
||||
facing == null ? () => WAngle.Zero : (body == null ? () => facing.Facing : () => body.QuantizeFacing(facing.Facing)),
|
||||
() => IsTraitPaused)
|
||||
{
|
||||
IsDecoration = info.IsDecoration
|
||||
};
|
||||
|
||||
@@ -18,7 +18,8 @@ using OpenRA.Traits;
|
||||
namespace OpenRA.Mods.Common.Traits.Render
|
||||
{
|
||||
[Desc("Play an animation when a unit exits or blocks the exit after production finished.")]
|
||||
sealed class WithProductionDoorOverlayInfo : ConditionalTraitInfo, IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>, Requires<BuildingInfo>
|
||||
sealed class WithProductionDoorOverlayInfo : ConditionalTraitInfo,
|
||||
IRenderActorPreviewSpritesInfo, Requires<RenderSpritesInfo>, Requires<BodyOrientationInfo>, Requires<BuildingInfo>
|
||||
{
|
||||
[SequenceReference]
|
||||
public readonly string Sequence = "build-door";
|
||||
|
||||
@@ -137,7 +137,11 @@ namespace OpenRA.Mods.Common.Traits.Render
|
||||
|
||||
var anim = new AnimationWithOffset(overlay,
|
||||
() => body.LocalToWorld(info.Offset.Rotate(body.QuantizeOrientation(self.Orientation))),
|
||||
() => IsTraitDisabled || (Info.SwitchingSequence == null && chargeSpeed != 0) || (Info.EnabledSequence == null && switchingLevel > Info.SwitchingLevel) || (Info.DisabledSequence == null && switchingLevel < 0),
|
||||
() =>
|
||||
IsTraitDisabled ||
|
||||
(Info.SwitchingSequence == null && chargeSpeed != 0) ||
|
||||
(Info.EnabledSequence == null && switchingLevel > Info.SwitchingLevel) ||
|
||||
(Info.DisabledSequence == null && switchingLevel < 0),
|
||||
p => RenderUtils.ZOffsetFromCenter(self, p, 1));
|
||||
|
||||
rs.Add(anim, info.Palette, info.IsPlayerPalette);
|
||||
|
||||
@@ -82,7 +82,8 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return false;
|
||||
}
|
||||
|
||||
Color MakeValid(float hue, float sat, float val, MersenneTwister random, IReadOnlyCollection<Color> terrainColors, IReadOnlyCollection<Color> playerColors, Action<string> onError)
|
||||
Color MakeValid(float hue, float sat, float val, MersenneTwister random,
|
||||
IReadOnlyCollection<Color> terrainColors, IReadOnlyCollection<Color> playerColors, Action<string> onError)
|
||||
{
|
||||
// Clamp saturation without triggering a warning
|
||||
// This can only happen due to rounding errors (common) or modified clients (rare)
|
||||
@@ -132,7 +133,10 @@ namespace OpenRA.Mods.Common.Traits
|
||||
|
||||
Color[] IColorPickerManagerInfo.PresetColors => PresetColors;
|
||||
|
||||
Color IColorPickerManagerInfo.RandomPresetColor(MersenneTwister random, IReadOnlyCollection<Color> terrainColors, IReadOnlyCollection<Color> playerColors)
|
||||
Color IColorPickerManagerInfo.RandomPresetColor(
|
||||
MersenneTwister random,
|
||||
IReadOnlyCollection<Color> terrainColors,
|
||||
IReadOnlyCollection<Color> playerColors)
|
||||
{
|
||||
foreach (var color in PresetColors.Shuffle(random))
|
||||
{
|
||||
@@ -148,13 +152,21 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return MakeValid(randomHue, randomSat, randomVal, random, terrainColors, playerColors, null);
|
||||
}
|
||||
|
||||
Color IColorPickerManagerInfo.MakeValid(Color color, MersenneTwister random, IReadOnlyCollection<Color> terrainColors, IReadOnlyCollection<Color> playerColors, Action<string> onError)
|
||||
Color IColorPickerManagerInfo.MakeValid(
|
||||
Color color,
|
||||
MersenneTwister random,
|
||||
IReadOnlyCollection<Color> terrainColors,
|
||||
IReadOnlyCollection<Color> playerColors,
|
||||
Action<string> onError)
|
||||
{
|
||||
var (_, h, s, v) = color.ToAhsv();
|
||||
return MakeValid(h, s, v, random, terrainColors, playerColors, onError);
|
||||
}
|
||||
|
||||
Color IColorPickerManagerInfo.RandomValidColor(MersenneTwister random, IReadOnlyCollection<Color> terrainColors, IReadOnlyCollection<Color> playerColors)
|
||||
Color IColorPickerManagerInfo.RandomValidColor(
|
||||
MersenneTwister random,
|
||||
IReadOnlyCollection<Color> terrainColors,
|
||||
IReadOnlyCollection<Color> playerColors)
|
||||
{
|
||||
var h = random.NextFloat();
|
||||
var s = float2.Lerp(HsvSaturationRange[0], HsvSaturationRange[1], random.NextFloat());
|
||||
@@ -162,7 +174,12 @@ namespace OpenRA.Mods.Common.Traits
|
||||
return MakeValid(h, s, v, random, terrainColors, playerColors, null);
|
||||
}
|
||||
|
||||
void IColorPickerManagerInfo.ShowColorDropDown(DropDownButtonWidget dropdownButton, Color initialColor, string initialFaction, WorldRenderer worldRenderer, Action<Color> onExit)
|
||||
void IColorPickerManagerInfo.ShowColorDropDown(
|
||||
DropDownButtonWidget dropdownButton,
|
||||
Color initialColor,
|
||||
string initialFaction,
|
||||
WorldRenderer worldRenderer,
|
||||
Action<Color> onExit)
|
||||
{
|
||||
dropdownButton.RemovePanel();
|
||||
|
||||
@@ -177,7 +194,9 @@ namespace OpenRA.Mods.Common.Traits
|
||||
if (initialFaction == null || !FactionPreviewActors.TryGetValue(initialFaction, out var actorType))
|
||||
{
|
||||
if (PreviewActor == null)
|
||||
throw new YamlException($"{nameof(ColorPickerManager)} does not define a preview actor" + (initialFaction == null ? "." : $"for faction {initialFaction}."));
|
||||
throw new YamlException(
|
||||
$"{nameof(ColorPickerManager)} does not define a preview actor" +
|
||||
(initialFaction == null ? "." : $" for faction {initialFaction}."));
|
||||
|
||||
actorType = PreviewActor;
|
||||
}
|
||||
|
||||
@@ -18,7 +18,9 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
{
|
||||
public override string Name => "Rename contrail color properties";
|
||||
|
||||
public override string Description => "Rename contrail color properties `Color` to `StartColor` and `UsePlayerColor` to `StartColorUsePlayerColor` in traits and weapons to account for added `EndColor` functionality";
|
||||
public override string Description =>
|
||||
"Rename contrail color properties `Color` to `StartColor` and `UsePlayerColor` to `StartColorUsePlayerColor` " +
|
||||
"in traits and weapons to account for added `EndColor` functionality";
|
||||
|
||||
public override IEnumerable<string> UpdateActorNode(ModData modData, MiniYamlNodeBuilder actorNode)
|
||||
{
|
||||
|
||||
@@ -19,7 +19,20 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
MiniYamlNodeBuilder defences;
|
||||
|
||||
// Excludes AttackBomber and AttackTDGunboatTurreted as actors with these AttackBase traits aren't supposed to be controlled.
|
||||
readonly string[] attackBase = { "AttackLeap", "AttackPopupTurreted", "AttackAircraft", "AttackTesla", "AttackCharges", "AttackFollow", "AttackTurreted", "AttackFrontal", "AttackGarrisoned", "AttackOmni", "AttackSwallow" };
|
||||
readonly string[] attackBase =
|
||||
{
|
||||
"AttackLeap",
|
||||
"AttackPopupTurreted",
|
||||
"AttackAircraft",
|
||||
"AttackTesla",
|
||||
"AttackCharges",
|
||||
"AttackFollow",
|
||||
"AttackTurreted",
|
||||
"AttackFrontal",
|
||||
"AttackGarrisoned",
|
||||
"AttackOmni",
|
||||
"AttackSwallow"
|
||||
};
|
||||
readonly string[] buildings = { "Building", "EnergyWall", "D2kBuilding" };
|
||||
|
||||
bool anyAdded;
|
||||
|
||||
@@ -19,7 +19,20 @@ namespace OpenRA.Mods.Common.UpdateRules.Rules
|
||||
readonly List<MiniYamlNodeBuilder> addNodes = new();
|
||||
|
||||
// Excludes AttackBomber and AttackTDGunboatTurreted as actors with these AttackBase traits aren't supposed to be controlled.
|
||||
readonly string[] attackBase = { "AttackLeap", "AttackPopupTurreted", "AttackAircraft", "AttackTesla", "AttackCharges", "AttackFollow", "AttackTurreted", "AttackFrontal", "AttackGarrisoned", "AttackOmni", "AttackSwallow" };
|
||||
readonly string[] attackBase =
|
||||
{
|
||||
"AttackLeap",
|
||||
"AttackPopupTurreted",
|
||||
"AttackAircraft",
|
||||
"AttackTesla",
|
||||
"AttackCharges",
|
||||
"AttackFollow",
|
||||
"AttackTurreted",
|
||||
"AttackFrontal",
|
||||
"AttackGarrisoned",
|
||||
"AttackOmni",
|
||||
"AttackSwallow"
|
||||
};
|
||||
readonly string[] vipsNames = { "Harvester", "BaseBuilding" };
|
||||
readonly string[] buildings = { "Building", "EnergyWall", "D2kBuilding" };
|
||||
readonly string[] excludedBuildings = { "LineBuild", "Plug" };
|
||||
|
||||
@@ -52,7 +52,9 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
if (!IsConditionalTrait(t))
|
||||
continue;
|
||||
|
||||
var overridesCreated = t.GetMethod($"{interfaceType.FullName}.{methodName}", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly) != null;
|
||||
var overridesCreated = t.GetMethod(
|
||||
$"{interfaceType.FullName}.{methodName}",
|
||||
BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.DeclaredOnly) != null;
|
||||
if (overridesCreated)
|
||||
{
|
||||
Console.WriteLine("{0} must override ConditionalTrait's {1} method instead of implementing {2} directly", t.Name, methodName, interfaceType.Name);
|
||||
|
||||
@@ -314,8 +314,16 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
public static void FindUntranslatedStringFields(ModData modData)
|
||||
{
|
||||
var types = modData.ObjectCreator.GetTypes();
|
||||
foreach (var (type, fields) in types.Where(t => t.Name.EndsWith("Widget", StringComparison.InvariantCulture) && t.IsSubclassOf(typeof(Widget))).ToDictionary(t => t.Name[..^6],
|
||||
t => t.GetFields().Where(f => f.Name != "Id" && f.IsPublic && f.FieldType == typeof(string) && !f.HasAttribute<TranslationReferenceAttribute>()).Distinct().Select(f => f.Name).ToList()))
|
||||
foreach (var (type, fields) in types
|
||||
.Where(t => t.Name.EndsWith("Widget", StringComparison.InvariantCulture) && t.IsSubclassOf(typeof(Widget)))
|
||||
.ToDictionary(
|
||||
t => t.Name[..^6],
|
||||
t => t
|
||||
.GetFields()
|
||||
.Where(f => f.Name != "Id" && f.IsPublic && f.FieldType == typeof(string) && !f.HasAttribute<TranslationReferenceAttribute>())
|
||||
.Distinct()
|
||||
.Select(f => f.Name)
|
||||
.ToList()))
|
||||
if (fields.Count > 0)
|
||||
Console.WriteLine($"{type}Widget:\n {string.Join("\n ", fields)}");
|
||||
}
|
||||
|
||||
@@ -336,10 +336,12 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
||||
}
|
||||
|
||||
if (isActivity)
|
||||
Console.WriteLine($"{new string(' ', indentation * 4)}--- *Queued Activity*");
|
||||
Console.WriteLine(
|
||||
$"{new string(' ', indentation * 4)}--- *Queued Activity*");
|
||||
|
||||
if (requiredTraits.Length != 0)
|
||||
Console.WriteLine($"{new string(' ', indentation * 4)}--- **Requires {(requiredTraits.Length == 1 ? "Trait" : "Traits")}:** {requiredTraits.Select(GetDocumentationUrl).JoinWith(", ")}");
|
||||
Console.WriteLine(
|
||||
$"{new string(' ', indentation * 4)}--- **Requires {(requiredTraits.Length == 1 ? "Trait" : "Traits")}:** {requiredTraits.Select(GetDocumentationUrl).JoinWith(", ")}");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,7 +103,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
bool passwordOffsetAdjusted;
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public ConnectionFailedLogic(Widget widget, ModData modData, OrderManager orderManager, NetworkConnection connection, string password, Action onAbort, Action onQuit, Action<string> onRetry)
|
||||
public ConnectionFailedLogic(Widget widget, ModData modData, OrderManager orderManager,
|
||||
NetworkConnection connection, string password, Action onAbort, Action onQuit, Action<string> onRetry)
|
||||
{
|
||||
var panel = widget;
|
||||
var abortButton = panel.Get<ButtonWidget>("ABORT_BUTTON");
|
||||
@@ -133,7 +134,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
widget.Get<LabelWidget>("CONNECTING_DESC").GetText = () => connectingDescText;
|
||||
|
||||
var connectionError = widget.Get<LabelWidget>("CONNECTION_ERROR");
|
||||
var connectionErrorText = orderManager.ServerError != null ? TranslationProvider.GetString(orderManager.ServerError) : connection.ErrorMessage ?? TranslationProvider.GetString(UnknownError);
|
||||
var connectionErrorText = orderManager.ServerError != null
|
||||
? TranslationProvider.GetString(orderManager.ServerError)
|
||||
: connection.ErrorMessage ?? TranslationProvider.GetString(UnknownError);
|
||||
connectionError.GetText = () => connectionErrorText;
|
||||
|
||||
var panelTitle = widget.Get<LabelWidget>("TITLE");
|
||||
|
||||
@@ -156,7 +156,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
var diagonalLength = Math.Round(Math.Sqrt(Math.Pow(selectionSize.X, 2) + Math.Pow(selectionSize.Y, 2)), 3);
|
||||
var resourceValueInRegion = editorResourceLayer.CalculateRegionValue(selectedRegion);
|
||||
|
||||
var areaSelectionLabel = $"{TranslationProvider.GetString(AreaSelection)} ({DimensionsAsString(selectionSize)}) {PositionAsString(selectedRegion.TopLeft)} : {PositionAsString(selectedRegion.BottomRight)}";
|
||||
var areaSelectionLabel =
|
||||
$"{TranslationProvider.GetString(AreaSelection)} ({DimensionsAsString(selectionSize)}) " +
|
||||
$"{PositionAsString(selectedRegion.TopLeft)} : {PositionAsString(selectedRegion.BottomRight)}";
|
||||
|
||||
AreaEditTitle.GetText = () => areaSelectionLabel;
|
||||
DiagonalLabel.GetText = () => $"{diagonalLength}";
|
||||
|
||||
@@ -51,7 +51,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
ptw.Background += suffix;
|
||||
}
|
||||
else
|
||||
throw new InvalidOperationException("AddFactionSuffixLogic only supports ButtonWidget, ImageWidget, BackgroundWidget, TextFieldWidget, ScrollPanelWidget and ProductionTabsWidget");
|
||||
throw new InvalidOperationException(
|
||||
"AddFactionSuffixLogic only supports ButtonWidget, ImageWidget, BackgroundWidget, TextFieldWidget, ScrollPanelWidget and ProductionTabsWidget");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,7 +24,14 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
{
|
||||
public enum ObserverStatsPanel { None, Basic, Economy, Production, SupportPowers, Combat, Army, Graph, ArmyGraph }
|
||||
|
||||
[ChromeLogicArgsHotkeys("StatisticsBasicKey", "StatisticsEconomyKey", "StatisticsProductionKey", "StatisticsSupportPowersKey", "StatisticsCombatKey", "StatisticsArmyKey", "StatisticsGraphKey",
|
||||
[ChromeLogicArgsHotkeys(
|
||||
"StatisticsBasicKey",
|
||||
"StatisticsEconomyKey",
|
||||
"StatisticsProductionKey",
|
||||
"StatisticsSupportPowersKey",
|
||||
"StatisticsCombatKey",
|
||||
"StatisticsArmyKey",
|
||||
"StatisticsGraphKey",
|
||||
"StatisticsArmyGraphKey")]
|
||||
public class ObserverStatsLogic : ChromeLogic
|
||||
{
|
||||
@@ -450,15 +457,18 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
template.Get<LabelWidget>("ASSETS").GetText = () => assetsText.Update(stats.AssetsValue);
|
||||
|
||||
var harvesters = template.Get<LabelWidget>("HARVESTERS");
|
||||
harvesters.GetText = () => world.ActorsWithTrait<Harvester>().Count(a => a.Actor.Owner == player && !a.Actor.IsDead && !a.Trait.IsTraitDisabled).ToString(NumberFormatInfo.CurrentInfo);
|
||||
harvesters.GetText = () => world.ActorsWithTrait<Harvester>()
|
||||
.Count(a => a.Actor.Owner == player && !a.Actor.IsDead && !a.Trait.IsTraitDisabled).ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
var carryalls = template.GetOrNull<LabelWidget>("CARRYALLS");
|
||||
if (carryalls != null)
|
||||
carryalls.GetText = () => world.ActorsWithTrait<AutoCarryall>().Count(a => a.Actor.Owner == player && !a.Actor.IsDead).ToString(NumberFormatInfo.CurrentInfo);
|
||||
carryalls.GetText = () => world.ActorsWithTrait<AutoCarryall>()
|
||||
.Count(a => a.Actor.Owner == player && !a.Actor.IsDead).ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
var derricks = template.GetOrNull<LabelWidget>("DERRICKS");
|
||||
if (derricks != null)
|
||||
derricks.GetText = () => world.ActorsHavingTrait<UpdatesDerrickCount>().Count(a => a.Owner == player && !a.IsDead).ToString(NumberFormatInfo.CurrentInfo);
|
||||
derricks.GetText = () => world.ActorsHavingTrait<UpdatesDerrickCount>()
|
||||
.Count(a => a.Owner == player && !a.IsDead).ToString(NumberFormatInfo.CurrentInfo);
|
||||
|
||||
return template;
|
||||
}
|
||||
|
||||
@@ -521,7 +521,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
};
|
||||
}
|
||||
|
||||
public static void SetupEditableColorWidget(Widget parent, Session.Slot s, Session.Client c, OrderManager orderManager, WorldRenderer worldRenderer, IColorPickerManagerInfo colorManager)
|
||||
public static void SetupEditableColorWidget(Widget parent, Session.Slot s, Session.Client c,
|
||||
OrderManager orderManager, WorldRenderer worldRenderer, IColorPickerManagerInfo colorManager)
|
||||
{
|
||||
var colorDropdown = parent.Get<DropDownButtonWidget>("COLOR");
|
||||
colorDropdown.IsDisabled = () => (s != null && s.LockColor) || orderManager.LocalClient.IsReady;
|
||||
|
||||
@@ -41,7 +41,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
readonly Dictionary<PreviewStatus, Widget[]> previewWidgets = new();
|
||||
readonly Func<(MapPreview Map, Session.MapStatus Status)> getMap;
|
||||
|
||||
enum PreviewStatus { Unknown, Playable, Incompatible, Validating, DownloadAvailable, Searching, Downloading, DownloadError, Unavailable, UpdateAvailable, UpdateDownloadAvailable }
|
||||
enum PreviewStatus
|
||||
{
|
||||
Unknown,
|
||||
Playable,
|
||||
Incompatible,
|
||||
Validating,
|
||||
DownloadAvailable,
|
||||
Searching,
|
||||
Downloading,
|
||||
DownloadError,
|
||||
Unavailable,
|
||||
UpdateAvailable,
|
||||
UpdateDownloadAvailable,
|
||||
}
|
||||
|
||||
PreviewStatus currentStatus;
|
||||
bool blink;
|
||||
int blinkTick;
|
||||
|
||||
@@ -97,7 +97,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
}
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public DisplaySettingsLogic(Action<string, string, Func<Widget, Func<bool>>, Func<Widget, Action>> registerPanel, string panelID, string label, ModData modData, WorldRenderer worldRenderer)
|
||||
public DisplaySettingsLogic(
|
||||
Action<string, string, Func<Widget, Func<bool>>, Func<Widget, Action>> registerPanel,
|
||||
string panelID, string label, ModData modData, WorldRenderer worldRenderer)
|
||||
{
|
||||
this.worldRenderer = worldRenderer;
|
||||
this.modData = modData;
|
||||
|
||||
@@ -50,7 +50,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
||||
static HotkeysSettingsLogic() { }
|
||||
|
||||
[ObjectCreator.UseCtor]
|
||||
public HotkeysSettingsLogic(Action<string, string, Func<Widget, Func<bool>>, Func<Widget, Action>> registerPanel, string panelID, string label, ModData modData, Dictionary<string, MiniYaml> logicArgs)
|
||||
public HotkeysSettingsLogic(
|
||||
Action<string, string, Func<Widget, Func<bool>>, Func<Widget, Action>> registerPanel,
|
||||
string panelID, string label, ModData modData, Dictionary<string, MiniYaml> logicArgs)
|
||||
{
|
||||
this.modData = modData;
|
||||
this.logicArgs = logicArgs;
|
||||
|
||||
@@ -256,7 +256,10 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
if (TooltipIcon != null && productionIconsBounds.Count > lastIconIdx && productionIcons[lastIconIdx].Actor == TooltipIcon.Actor && productionIconsBounds[lastIconIdx].Contains(Viewport.LastMousePos))
|
||||
if (TooltipIcon != null &&
|
||||
productionIconsBounds.Count > lastIconIdx &&
|
||||
productionIcons[lastIconIdx].Actor == TooltipIcon.Actor &&
|
||||
productionIconsBounds[lastIconIdx].Contains(Viewport.LastMousePos))
|
||||
return;
|
||||
|
||||
for (var i = 0; i < productionIconsBounds.Count; i++)
|
||||
|
||||
@@ -175,7 +175,10 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
return;
|
||||
}
|
||||
|
||||
if (TooltipIcon != null && lastIconIdx < supportPowerIconsBounds.Count && supportPowerIconsIcons[lastIconIdx].Power == TooltipIcon.Power && supportPowerIconsBounds[lastIconIdx].Contains(Viewport.LastMousePos))
|
||||
if (TooltipIcon != null &&
|
||||
lastIconIdx < supportPowerIconsBounds.Count &&
|
||||
supportPowerIconsIcons[lastIconIdx].Power == TooltipIcon.Power &&
|
||||
supportPowerIconsBounds[lastIconIdx].Contains(Viewport.LastMousePos))
|
||||
return;
|
||||
|
||||
for (var i = 0; i < supportPowerIconsBounds.Count; i++)
|
||||
|
||||
@@ -201,11 +201,15 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
var leftArrowImage = getLeftArrowImage.Update((leftDisabled, leftPressed, leftHover, false, false));
|
||||
WidgetUtils.DrawSprite(leftArrowImage,
|
||||
new float2(leftButtonRect.Left + (int)((leftButtonRect.Width - leftArrowImage.Size.X) / 2), leftButtonRect.Top + (int)((leftButtonRect.Height - leftArrowImage.Size.Y) / 2)));
|
||||
new float2(
|
||||
leftButtonRect.Left + (int)((leftButtonRect.Width - leftArrowImage.Size.X) / 2),
|
||||
leftButtonRect.Top + (int)((leftButtonRect.Height - leftArrowImage.Size.Y) / 2)));
|
||||
|
||||
var rightArrowImage = getRightArrowImage.Update((rightDisabled, rightPressed, rightHover, false, false));
|
||||
WidgetUtils.DrawSprite(rightArrowImage,
|
||||
new float2(rightButtonRect.Left + (int)((rightButtonRect.Width - rightArrowImage.Size.X) / 2), rightButtonRect.Top + (int)((rightButtonRect.Height - rightArrowImage.Size.Y) / 2)));
|
||||
new float2(
|
||||
rightButtonRect.Left + (int)((rightButtonRect.Width - rightArrowImage.Size.X) / 2),
|
||||
rightButtonRect.Top + (int)((rightButtonRect.Height - rightArrowImage.Size.Y) / 2)));
|
||||
|
||||
// Draw tab buttons
|
||||
Game.Renderer.EnableScissor(new Rectangle(leftButtonRect.Right, rb.Y + 1, rightButtonRect.Left - leftButtonRect.Right - 1, rb.Height));
|
||||
|
||||
@@ -105,7 +105,12 @@ namespace OpenRA.Mods.D2k.Traits
|
||||
if ((c.Value & filter) == 0)
|
||||
continue;
|
||||
|
||||
var isUnsafe = checkUnsafeTiles && wr.World.Map.Contains(c.Key) && candidateSafeTiles.Contains(c.Key) && info.UnsafeTerrainTypes.Contains(wr.World.Map.GetTerrainInfo(c.Key).Type);
|
||||
var isUnsafe =
|
||||
checkUnsafeTiles &&
|
||||
wr.World.Map.Contains(c.Key) &&
|
||||
candidateSafeTiles.Contains(c.Key) &&
|
||||
info.UnsafeTerrainTypes.Contains(wr.World.Map.GetTerrainInfo(c.Key).Type);
|
||||
|
||||
var tile = (c.Value & PlaceBuildingCellType.Invalid) != 0 ? blockedTile : isUnsafe ? unsafeTile : validTile;
|
||||
var sequenceAlpha = (c.Value & PlaceBuildingCellType.Invalid) != 0 ? blockedAlpha : isUnsafe ? unsafeAlpha : validAlpha;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user