From ecd3809bc2d7083bd8f7394ff09152b5a8075a8c Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Sun, 14 Dec 2014 17:04:37 +1300 Subject: [PATCH] Fix a collection of whitespace-style issues in Mods.Common. --- OpenRA.Mods.Common/CommonTraitsInterfaces.cs | 10 +++--- OpenRA.Mods.Common/Effects/LaserZap.cs | 1 - OpenRA.Mods.Common/Effects/NukeLaunch.cs | 1 - .../Effects/RallyPointIndicator.cs | 2 +- OpenRA.Mods.Common/Graphics/BeamRenderable.cs | 4 +-- .../Graphics/ContrailRenderable.cs | 12 +++---- .../Graphics/RangeCircleRenderable.cs | 4 +-- OpenRA.Mods.Common/Graphics/TextRenderable.cs | 6 ++-- .../Graphics/VoxelRenderable.cs | 22 ++++++------- .../LoadScreens/ModChooserLoadScreen.cs | 2 +- .../LoadScreens/NullLoadScreen.cs | 7 ++-- .../Orders/DeployOrderTargeter.cs | 6 ++-- .../Orders/EnterAlliedActorTargeter.cs | 2 +- .../Scripting/Global/MediaGlobal.cs | 1 + OpenRA.Mods.Common/Scripting/Media.cs | 3 +- .../Scripting/Properties/PowerProperties.cs | 2 +- .../Scripting/ScriptTriggers.cs | 2 +- .../ServerTraits/ColorValidator.cs | 2 +- OpenRA.Mods.Common/Traits/BlocksBullets.cs | 2 +- OpenRA.Mods.Common/Traits/CustomSellValue.cs | 2 +- OpenRA.Mods.Common/Traits/Demolishable.cs | 3 +- OpenRA.Mods.Common/Traits/Immobile.cs | 2 +- .../Traits/Modifiers/UpgradeOverlay.cs | 2 +- .../Traits/Player/ProvidesTechPrerequisite.cs | 2 +- OpenRA.Mods.Common/Traits/Player/TechTree.cs | 1 + .../Traits/Render/RenderSprites.cs | 5 ++- .../Traits/Render/WithResources.cs | 2 +- .../Traits/Sound/ActorLostNotification.cs | 2 +- .../Traits/Sound/AnnounceOnKill.cs | 3 +- .../Traits/Sound/SoundOnDamageTransition.cs | 4 +-- .../Traits/World/LoadWidgetAtGameStart.cs | 12 +++---- .../Traits/World/MPStartLocations.cs | 7 ++-- .../Traits/World/PlayMusicOnMapLoad.cs | 5 ++- .../Traits/World/ShroudPalette.cs | 20 ++++++------ .../Traits/World/TerrainGeometryOverlay.cs | 4 +-- .../UtilityCommands/ExtractLuaDocsCommand.cs | 2 ++ .../ExtractTraitDocsCommand.cs | 1 + .../UtilityCommands/GenerateMinimapCommand.cs | 2 +- .../UtilityCommands/LegacyMapImporter.cs | 1 - .../UtilityCommands/RemapShpCommand.cs | 4 +-- .../UtilityCommands/UpgradeRules.cs | 32 ++++++++++--------- .../Warheads/CreateEffectWarhead.cs | 6 +--- .../Widgets/ColorMixerWidget.cs | 26 ++++++++------- .../Widgets/ConfirmationDialogs.cs | 10 ------ OpenRA.Mods.Common/Widgets/HueSliderWidget.cs | 1 + .../Widgets/LabelWithTooltipWidget.cs | 2 +- .../Widgets/Logic/ColorPickerLogic.cs | 3 +- .../Widgets/Logic/ModBrowserLogic.cs | 1 - .../Widgets/Logic/SettingsLogic.cs | 13 +++++--- OpenRA.Mods.Common/Widgets/RadarWidget.cs | 2 +- .../Widgets/ResourceBarWidget.cs | 18 +++++------ 51 files changed, 142 insertions(+), 149 deletions(-) diff --git a/OpenRA.Mods.Common/CommonTraitsInterfaces.cs b/OpenRA.Mods.Common/CommonTraitsInterfaces.cs index 8ad3d71086..faff0be555 100644 --- a/OpenRA.Mods.Common/CommonTraitsInterfaces.cs +++ b/OpenRA.Mods.Common/CommonTraitsInterfaces.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.Common } public interface INotifyChat { bool OnChat(string from, string message); } - public interface IRenderActorPreviewInfo { IEnumerable RenderPreview (ActorPreviewInitializer init); } + public interface IRenderActorPreviewInfo { IEnumerable RenderPreview(ActorPreviewInitializer init); } public interface ICruiseAltitudeInfo { WRange GetCruiseAltitude(); } public interface IUpgradable @@ -46,9 +46,9 @@ namespace OpenRA.Mods.Common public interface ITechTreeElement { - void PrerequisitesAvailable (string key); - void PrerequisitesUnavailable (string key); - void PrerequisitesItemHidden (string key); - void PrerequisitesItemVisible (string key); + void PrerequisitesAvailable(string key); + void PrerequisitesUnavailable(string key); + void PrerequisitesItemHidden(string key); + void PrerequisitesItemVisible(string key); } } diff --git a/OpenRA.Mods.Common/Effects/LaserZap.cs b/OpenRA.Mods.Common/Effects/LaserZap.cs index d698675f61..1edf07aa3c 100644 --- a/OpenRA.Mods.Common/Effects/LaserZap.cs +++ b/OpenRA.Mods.Common/Effects/LaserZap.cs @@ -16,7 +16,6 @@ using OpenRA.Graphics; using OpenRA.Mods.Common.Graphics; using OpenRA.Traits; - namespace OpenRA.Mods.Common.Effects { [Desc("Not a sprite, but an engine effect.")] diff --git a/OpenRA.Mods.Common/Effects/NukeLaunch.cs b/OpenRA.Mods.Common/Effects/NukeLaunch.cs index 8f0ef74060..14cbd0d5e5 100644 --- a/OpenRA.Mods.Common/Effects/NukeLaunch.cs +++ b/OpenRA.Mods.Common/Effects/NukeLaunch.cs @@ -59,7 +59,6 @@ namespace OpenRA.Mods.Common.Effects ticks = turn; } - public void Tick(World world) { anim.Tick(); diff --git a/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs b/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs index ebdf18cb0e..931381426d 100644 --- a/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs +++ b/OpenRA.Mods.Common/Effects/RallyPointIndicator.cs @@ -62,7 +62,7 @@ namespace OpenRA.Mods.Common.Effects return SpriteRenderable.None; var pos = wr.world.Map.CenterOfCell(cachedLocation); - var palette = wr.Palette(palettePrefix+building.Owner.InternalName); + var palette = wr.Palette(palettePrefix + building.Owner.InternalName); return circles.Render(pos, palette).Concat(flag.Render(pos, palette)); } } diff --git a/OpenRA.Mods.Common/Graphics/BeamRenderable.cs b/OpenRA.Mods.Common/Graphics/BeamRenderable.cs index 022a94fed9..560a2ca30e 100644 --- a/OpenRA.Mods.Common/Graphics/BeamRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/BeamRenderable.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Graphics public IRenderable OffsetBy(WVec vec) { return new BeamRenderable(pos + vec, zOffset, length, width, color); } public IRenderable AsDecoration() { return this; } - public void BeforeRender(WorldRenderer wr) {} + public void BeforeRender(WorldRenderer wr) { } public void Render(WorldRenderer wr) { var wlr = Game.Renderer.WorldLineRenderer; @@ -55,6 +55,6 @@ namespace OpenRA.Mods.Common.Graphics wlr.LineWidth = oldWidth; } - public void RenderDebugGeometry(WorldRenderer wr) {} + public void RenderDebugGeometry(WorldRenderer wr) { } } } diff --git a/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs b/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs index 10092374cc..45195b4e7f 100644 --- a/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/ContrailRenderable.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Graphics readonly int zOffset; public ContrailRenderable(World world, Color color, int length, int skip, int zOffset) - : this(world, new WPos[length], 0, 0, skip, color, zOffset) {} + : this(world, new WPos[length], 0, 0, skip, color, zOffset) { } ContrailRenderable(World world, WPos[] trail, int next, int length, int skip, Color color, int zOffset) { @@ -43,7 +43,7 @@ namespace OpenRA.Mods.Common.Graphics this.zOffset = zOffset; } - public WPos Pos { get { return trail[idx(next-1)]; } } + public WPos Pos { get { return trail[idx(next - 1)]; } } public float Scale { get { return 1f; } } public PaletteReference Palette { get { return null; } } public int ZOffset { get { return zOffset; } } @@ -55,7 +55,7 @@ namespace OpenRA.Mods.Common.Graphics public IRenderable OffsetBy(WVec vec) { return new ContrailRenderable(world, trail.Select(pos => pos + vec).ToArray(), next, length, skip, color, zOffset); } public IRenderable AsDecoration() { return this; } - public void BeforeRender(WorldRenderer wr) {} + public void BeforeRender(WorldRenderer wr) { } public void Render(WorldRenderer wr) { // Need at least 4 points to smooth the contrail over @@ -73,7 +73,7 @@ namespace OpenRA.Mods.Common.Graphics for (var i = 0; i < length - skip - 4; i++) { var j = next - skip - i - 2; - var nextPos = Average(trail[idx(j)], trail[idx(j-1)], trail[idx(j-2)], trail[idx(j-3)]); + var nextPos = Average(trail[idx(j)], trail[idx(j - 1)], trail[idx(j - 2)], trail[idx(j - 3)]); var nextCell = wr.world.Map.CellContaining(nextPos); var nextColor = Exts.ColorLerp(i * 1f / (length - 4), color, Color.Transparent); @@ -88,7 +88,7 @@ namespace OpenRA.Mods.Common.Graphics wlr.LineWidth = oldWidth; } - public void RenderDebugGeometry(WorldRenderer wr) {} + public void RenderDebugGeometry(WorldRenderer wr) { } // Array index modulo length int idx(int i) @@ -105,7 +105,7 @@ namespace OpenRA.Mods.Common.Graphics public void Update(WPos pos) { trail[next] = pos; - next = idx(next+1); + next = idx(next + 1); if (length < trail.Length) length++; diff --git a/OpenRA.Mods.Common/Graphics/RangeCircleRenderable.cs b/OpenRA.Mods.Common/Graphics/RangeCircleRenderable.cs index 577a0143d6..ef2fdc6fe6 100644 --- a/OpenRA.Mods.Common/Graphics/RangeCircleRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/RangeCircleRenderable.cs @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Graphics public IRenderable OffsetBy(WVec vec) { return new RangeCircleRenderable(centerPosition + vec, radius, zOffset, color, contrastColor); } public IRenderable AsDecoration() { return this; } - public void BeforeRender(WorldRenderer wr) {} + public void BeforeRender(WorldRenderer wr) { } public void Render(WorldRenderer wr) { var wlr = Game.Renderer.WorldLineRenderer; @@ -54,6 +54,6 @@ namespace OpenRA.Mods.Common.Graphics wlr.LineWidth = oldWidth; } - public void RenderDebugGeometry(WorldRenderer wr) {} + public void RenderDebugGeometry(WorldRenderer wr) { } } } diff --git a/OpenRA.Mods.Common/Graphics/TextRenderable.cs b/OpenRA.Mods.Common/Graphics/TextRenderable.cs index d0c03fa601..a67e981735 100644 --- a/OpenRA.Mods.Common/Graphics/TextRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/TextRenderable.cs @@ -43,10 +43,10 @@ namespace OpenRA.Mods.Common.Graphics public IRenderable OffsetBy(WVec vec) { return new TextRenderable(font, pos + vec, zOffset, color, text); } public IRenderable AsDecoration() { return this; } - public void BeforeRender(WorldRenderer wr) {} + public void BeforeRender(WorldRenderer wr) { } public void Render(WorldRenderer wr) { - var screenPos = wr.Viewport.Zoom*(wr.ScreenPosition(pos) - wr.Viewport.TopLeft.ToFloat2()) - 0.5f*font.Measure(text).ToFloat2(); + var screenPos = wr.Viewport.Zoom * (wr.ScreenPosition(pos) - wr.Viewport.TopLeft.ToFloat2()) - 0.5f * font.Measure(text).ToFloat2(); var screenPxPos = new float2((float)Math.Round(screenPos.X), (float)Math.Round(screenPos.Y)); font.DrawTextWithContrast(text, screenPxPos, color, Color.Black, 1); } @@ -54,7 +54,7 @@ namespace OpenRA.Mods.Common.Graphics public void RenderDebugGeometry(WorldRenderer wr) { var size = font.Measure(text).ToFloat2(); - var offset = wr.ScreenPxPosition(pos) - 0.5f*size; + var offset = wr.ScreenPxPosition(pos) - 0.5f * size; Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + size, Color.Red); } } diff --git a/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs b/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs index 259fb1c4d3..bcc6029b83 100644 --- a/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs +++ b/OpenRA.Mods.Common/Graphics/VoxelRenderable.cs @@ -87,7 +87,7 @@ namespace OpenRA.Mods.Common.Graphics public IRenderable AsDecoration() { return this; } // This will need generalizing once we support TS/RA2 terrain - static readonly float[] groundNormal = new float[] {0,0,1,1}; + static readonly float[] groundNormal = new float[] { 0, 0, 1, 1 }; public void BeforeRender(WorldRenderer wr) { var draw = voxels.Where(v => v.DisableFunc == null || !v.DisableFunc()); @@ -107,7 +107,7 @@ namespace OpenRA.Mods.Common.Graphics var groundZ = ts.Height * (groundPos.Z - pos.Z) / 1024f; var pxOrigin = wr.ScreenPosition(pos); - var shadowOrigin = pxOrigin - groundZ*(new float2(renderProxy.ShadowDirection, 1)); + var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1)); var psb = renderProxy.ProjectedShadowBounds; var sa = shadowOrigin + psb[0]; @@ -115,17 +115,17 @@ namespace OpenRA.Mods.Common.Graphics var sc = shadowOrigin + psb[1]; var sd = shadowOrigin + psb[3]; Game.Renderer.WorldRgbaSpriteRenderer.DrawSprite(renderProxy.ShadowSprite, sa, sb, sc, sd); - Game.Renderer.WorldRgbaSpriteRenderer.DrawSprite(renderProxy.Sprite, pxOrigin - 0.5f*renderProxy.Sprite.size); + Game.Renderer.WorldRgbaSpriteRenderer.DrawSprite(renderProxy.Sprite, pxOrigin - 0.5f * renderProxy.Sprite.size); } public void RenderDebugGeometry(WorldRenderer wr) { var pxOrigin = wr.ScreenPosition(pos); - var groundZ = 0.5f*(pxOrigin.Y - wr.ScreenZPosition(pos, 0)); - var shadowOrigin = pxOrigin - groundZ*(new float2(renderProxy.ShadowDirection, 1)); + var groundZ = 0.5f * (pxOrigin.Y - wr.ScreenZPosition(pos, 0)); + var shadowOrigin = pxOrigin - groundZ * (new float2(renderProxy.ShadowDirection, 1)); // Draw sprite rect - var offset = pxOrigin + renderProxy.Sprite.offset - 0.5f*renderProxy.Sprite.size; + var offset = pxOrigin + renderProxy.Sprite.offset - 0.5f * renderProxy.Sprite.size; Game.Renderer.WorldLineRenderer.DrawRect(offset, offset + renderProxy.Sprite.size, Color.Red); // Draw transformed shadow sprite rect @@ -145,7 +145,7 @@ namespace OpenRA.Mods.Common.Graphics { var bounds = v.Voxel.Bounds(v.FrameFunc()); var worldTransform = v.RotationFunc().Reverse().Aggregate(scaleTransform, - (x,y) => Util.MatrixMultiply(x, Util.MakeFloatMatrix(y.AsMatrix()))); + (x, y) => Util.MatrixMultiply(x, Util.MakeFloatMatrix(y.AsMatrix()))); var pxOffset = wr.ScreenVector(v.OffsetFunc()); var pxPos = pxOrigin + new float2(pxOffset[0], pxOffset[1]); @@ -154,15 +154,15 @@ namespace OpenRA.Mods.Common.Graphics } } - static readonly uint[] ix = new uint[] {0,0,0,0,3,3,3,3}; - static readonly uint[] iy = new uint[] {1,1,4,4,1,1,4,4}; - static readonly uint[] iz = new uint[] {2,5,2,5,2,5,2,5}; + static readonly uint[] ix = new uint[] { 0, 0, 0, 0, 3, 3, 3, 3 }; + static readonly uint[] iy = new uint[] { 1, 1, 4, 4, 1, 1, 4, 4 }; + static readonly uint[] iz = new uint[] { 2, 5, 2, 5, 2, 5, 2, 5 }; static void DrawBoundsBox(float2 pxPos, float[] transform, float[] bounds, Color c) { var corners = new float2[8]; for (var i = 0; i < 8; i++) { - var vec = new float[] {bounds[ix[i]], bounds[iy[i]], bounds[iz[i]], 1}; + var vec = new float[] { bounds[ix[i]], bounds[iy[i]], bounds[iz[i]], 1 }; var screen = Util.MatrixVectorMultiply(transform, vec); corners[i] = pxPos + new float2(screen[0], screen[1]); } diff --git a/OpenRA.Mods.Common/LoadScreens/ModChooserLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/ModChooserLoadScreen.cs index 25b66ed4dc..f5ec655a05 100644 --- a/OpenRA.Mods.Common/LoadScreens/ModChooserLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/ModChooserLoadScreen.cs @@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.LoadScreens var sheet = new Sheet(info["Image"]); var res = Game.Renderer.Resolution; bounds = new Rectangle(0, 0, res.Width, res.Height); - sprite = new Sprite(sheet, new Rectangle(0,0,1024,480), TextureChannel.Alpha); + sprite = new Sprite(sheet, new Rectangle(0, 0, 1024, 480), TextureChannel.Alpha); } public void Display() diff --git a/OpenRA.Mods.Common/LoadScreens/NullLoadScreen.cs b/OpenRA.Mods.Common/LoadScreens/NullLoadScreen.cs index 34318d38cb..122a2b1dfe 100644 --- a/OpenRA.Mods.Common/LoadScreens/NullLoadScreen.cs +++ b/OpenRA.Mods.Common/LoadScreens/NullLoadScreen.cs @@ -15,7 +15,7 @@ namespace OpenRA.Mods.Common.LoadScreens { public class NullLoadScreen : ILoadScreen { - public void Init(Manifest m, Dictionary info) {} + public void Init(Manifest m, Dictionary info) { } public void Display() { @@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.LoadScreens // Draw a black screen Game.Renderer.BeginFrame(int2.Zero, 1f); - Game.Renderer.EndFrame( new NullInputHandler() ); + Game.Renderer.EndFrame(new NullInputHandler()); } public void StartGame() @@ -32,5 +32,4 @@ namespace OpenRA.Mods.Common.LoadScreens Ui.ResetAll(); } } -} - +} \ No newline at end of file diff --git a/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs b/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs index 4ba434393b..8c9816dce8 100644 --- a/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs +++ b/OpenRA.Mods.Common/Orders/DeployOrderTargeter.cs @@ -18,12 +18,12 @@ namespace OpenRA.Mods.Common.Orders { readonly Func useDeployCursor; - public DeployOrderTargeter( string order, int priority ) - : this( order, priority, () => true ) + public DeployOrderTargeter(string order, int priority) + : this(order, priority, () => true) { } - public DeployOrderTargeter( string order, int priority, Func useDeployCursor ) + public DeployOrderTargeter(string order, int priority, Func useDeployCursor) { this.OrderID = order; this.OrderPriority = priority; diff --git a/OpenRA.Mods.Common/Orders/EnterAlliedActorTargeter.cs b/OpenRA.Mods.Common/Orders/EnterAlliedActorTargeter.cs index f1d93c8181..6f69b41cd8 100644 --- a/OpenRA.Mods.Common/Orders/EnterAlliedActorTargeter.cs +++ b/OpenRA.Mods.Common/Orders/EnterAlliedActorTargeter.cs @@ -20,7 +20,7 @@ namespace OpenRA.Mods.Common.Orders public EnterAlliedActorTargeter(string order, int priority, Func canTarget, Func useEnterCursor) - : base (order, priority, "enter", false, true) + : base(order, priority, "enter", false, true) { this.canTarget = canTarget; this.useEnterCursor = useEnterCursor; diff --git a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs index 0d35e28a6f..59d6b729bc 100644 --- a/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs +++ b/OpenRA.Mods.Common/Scripting/Global/MediaGlobal.cs @@ -23,6 +23,7 @@ namespace OpenRA.Mods.Common.Scripting { world = context.World; } + [Desc("Play an announcer voice listed in notifications.yaml")] public void PlaySpeechNotification(Player player, string notification) { diff --git a/OpenRA.Mods.Common/Scripting/Media.cs b/OpenRA.Mods.Common/Scripting/Media.cs index 79716f348d..1fce1383dc 100644 --- a/OpenRA.Mods.Common/Scripting/Media.cs +++ b/OpenRA.Mods.Common/Scripting/Media.cs @@ -36,8 +36,9 @@ namespace OpenRA.Mods.Common.Scripting // Mute world sounds var oldModifier = Sound.SoundVolumeModifier; + // TODO: this also modifies vqa audio - //Sound.SoundVolumeModifier = 0f; + // Sound.SoundVolumeModifier = 0f; // Stop music while fmv plays var music = Sound.MusicPlaying; diff --git a/OpenRA.Mods.Common/Scripting/Properties/PowerProperties.cs b/OpenRA.Mods.Common/Scripting/Properties/PowerProperties.cs index ff3013ac1b..16db8df24f 100644 --- a/OpenRA.Mods.Common/Scripting/Properties/PowerProperties.cs +++ b/OpenRA.Mods.Common/Scripting/Properties/PowerProperties.cs @@ -13,9 +13,9 @@ using System.Collections.Generic; using System.Linq; using Eluant; using OpenRA.Mods.Common.Traits; -using PowerTrait = OpenRA.Mods.Common.Traits.Power; using OpenRA.Scripting; using OpenRA.Traits; +using PowerTrait = OpenRA.Mods.Common.Traits.Power; namespace OpenRA.Mods.Common.Scripting { diff --git a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs index f2226e659c..b700203191 100644 --- a/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs +++ b/OpenRA.Mods.Common/Scripting/ScriptTriggers.cs @@ -19,7 +19,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Scripting { public enum Trigger { OnIdle, OnDamaged, OnKilled, OnProduction, OnOtherProduction, OnPlayerWon, OnPlayerLost, - OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated, OnAddedToWorld, OnRemovedFromWorld }; + OnObjectiveAdded, OnObjectiveCompleted, OnObjectiveFailed, OnCapture, OnInfiltrated, OnAddedToWorld, OnRemovedFromWorld } [Desc("Allows map scripts to attach triggers to this actor via the Triggers global.")] public class ScriptTriggersInfo : ITraitInfo diff --git a/OpenRA.Mods.Common/ServerTraits/ColorValidator.cs b/OpenRA.Mods.Common/ServerTraits/ColorValidator.cs index bee0f54c95..87b995c27e 100644 --- a/OpenRA.Mods.Common/ServerTraits/ColorValidator.cs +++ b/OpenRA.Mods.Common/ServerTraits/ColorValidator.cs @@ -205,7 +205,7 @@ namespace OpenRA.Mods.Common.Server var client = server.GetClient(conn); // Validate whether color is allowed and get an alternative if it isn't - if (client.Slot == null ||!server.LobbyInfo.Slots[client.Slot].LockColor) + if (client.Slot == null || !server.LobbyInfo.Slots[client.Slot].LockColor) client.Color = ColorValidator.ValidatePlayerColorAndGetAlternative(server, client.Color, client.Index); } diff --git a/OpenRA.Mods.Common/Traits/BlocksBullets.cs b/OpenRA.Mods.Common/Traits/BlocksBullets.cs index 2dc94917f2..88d4a3826d 100644 --- a/OpenRA.Mods.Common/Traits/BlocksBullets.cs +++ b/OpenRA.Mods.Common/Traits/BlocksBullets.cs @@ -13,7 +13,7 @@ using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { - //TODO: Add functionality like a customizable Height that is compared to projectile altitude + // TODO: Add functionality like a customizable Height that is compared to projectile altitude [Desc("This actor blocks bullets and missiles without 'High' property.")] public class BlocksBulletsInfo : TraitInfo { } public class BlocksBullets : IBlocksBullets { } diff --git a/OpenRA.Mods.Common/Traits/CustomSellValue.cs b/OpenRA.Mods.Common/Traits/CustomSellValue.cs index 9c98faba1e..8496cc074c 100644 --- a/OpenRA.Mods.Common/Traits/CustomSellValue.cs +++ b/OpenRA.Mods.Common/Traits/CustomSellValue.cs @@ -22,7 +22,7 @@ namespace OpenRA.Mods.Common.Traits public static class CustomSellValueExts { - public static int GetSellValue( this Actor a ) + public static int GetSellValue(this Actor a) { var csv = a.Info.Traits.GetOrDefault(); if (csv != null) return csv.Value; diff --git a/OpenRA.Mods.Common/Traits/Demolishable.cs b/OpenRA.Mods.Common/Traits/Demolishable.cs index 4784350777..d4453cb8bc 100644 --- a/OpenRA.Mods.Common/Traits/Demolishable.cs +++ b/OpenRA.Mods.Common/Traits/Demolishable.cs @@ -32,5 +32,4 @@ namespace OpenRA.Mods.Common.Traits return true; } } -} - +} \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/Immobile.cs b/OpenRA.Mods.Common/Traits/Immobile.cs index d858984c37..d54d0e33c7 100644 --- a/OpenRA.Mods.Common/Traits/Immobile.cs +++ b/OpenRA.Mods.Common/Traits/Immobile.cs @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Traits position = init.world.Map.CenterOfCell(location); if (info.OccupiesSpace) - occupied = new [] { Pair.New(TopLeft, SubCell.FullCell) }; + occupied = new[] { Pair.New(TopLeft, SubCell.FullCell) }; else occupied = new Pair[0]; } diff --git a/OpenRA.Mods.Common/Traits/Modifiers/UpgradeOverlay.cs b/OpenRA.Mods.Common/Traits/Modifiers/UpgradeOverlay.cs index c0c2d429e7..e7e5af7a6c 100644 --- a/OpenRA.Mods.Common/Traits/Modifiers/UpgradeOverlay.cs +++ b/OpenRA.Mods.Common/Traits/Modifiers/UpgradeOverlay.cs @@ -26,7 +26,7 @@ namespace OpenRA.Mods.Common.Traits public class UpgradeOverlay : UpgradableTrait, IRenderModifier { public UpgradeOverlay(UpgradeOverlayInfo info) - : base (info) { } + : base(info) { } public IEnumerable ModifyRender(Actor self, WorldRenderer wr, IEnumerable r) { diff --git a/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs b/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs index 234f75bff8..1014e80c85 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProvidesTechPrerequisite.cs @@ -16,7 +16,7 @@ namespace OpenRA.Mods.Common.Traits public class ProvidesTechPrerequisiteInfo : ITraitInfo { public readonly string Name; - public readonly string[] Prerequisites = {}; + public readonly string[] Prerequisites = { }; public object Create(ActorInitializer init) { return new ProvidesTechPrerequisite(this, init); } } diff --git a/OpenRA.Mods.Common/Traits/Player/TechTree.cs b/OpenRA.Mods.Common/Traits/Player/TechTree.cs index e82ae8743c..182769aa2e 100644 --- a/OpenRA.Mods.Common/Traits/Player/TechTree.cs +++ b/OpenRA.Mods.Common/Traits/Player/TechTree.cs @@ -140,6 +140,7 @@ namespace OpenRA.Mods.Common.Traits public void Update(Cache> ownedPrerequisites) { var hasReachedLimit = limit > 0 && ownedPrerequisites.ContainsKey(Key) && ownedPrerequisites[Key].Count >= limit; + // The '!' annotation inverts prerequisites: "I'm buildable if this prerequisite *isn't* met" var nowHasPrerequisites = HasPrerequisites(ownedPrerequisites) && !hasReachedLimit; var nowHidden = IsHidden(ownedPrerequisites); diff --git a/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs b/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs index 168308ff5a..82a88194e7 100644 --- a/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs +++ b/OpenRA.Mods.Common/Traits/Render/RenderSprites.cs @@ -13,8 +13,8 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Graphics; using OpenRA.Mods.Common.Graphics; -using OpenRA.Traits; using OpenRA.Primitives; +using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { @@ -49,7 +49,6 @@ namespace OpenRA.Mods.Common.Traits foreach (var preview in spi.RenderPreviewSprites(init, this, image, facings, palette)) yield return preview; } - } public class RenderSprites : IRender, ITick, INotifyOwnerChanged, INotifyEffectiveOwnerChanged @@ -202,7 +201,7 @@ namespace OpenRA.Mods.Common.Traits { return anims.Values.Where(b => b.IsVisible && b.Animation.Animation.CurrentSequence != null) - .Select(a => (a.Animation.Animation.Image.size*info.Scale).ToInt2()) + .Select(a => (a.Animation.Animation.Image.size * info.Scale).ToInt2()) .FirstOrDefault(); } } diff --git a/OpenRA.Mods.Common/Traits/Render/WithResources.cs b/OpenRA.Mods.Common/Traits/Render/WithResources.cs index 8db2c70931..a178535f2c 100644 --- a/OpenRA.Mods.Common/Traits/Render/WithResources.cs +++ b/OpenRA.Mods.Common/Traits/Render/WithResources.cs @@ -46,7 +46,7 @@ namespace OpenRA.Mods.Common.Traits anim, null, () => !buildComplete, 1024)); } - public void BuildingComplete( Actor self ) + public void BuildingComplete(Actor self) { buildComplete = true; } diff --git a/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs b/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs index 7bf6746d83..583b3e585f 100644 --- a/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs +++ b/OpenRA.Mods.Common/Traits/Sound/ActorLostNotification.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits public void Killed(Actor self, AttackInfo e) { - var player = (info.NotifyAll) ? self.World.LocalPlayer : self.Owner; + var player = info.NotifyAll ? self.World.LocalPlayer : self.Owner; Sound.PlayNotification(self.World.Map.Rules, player, "Speech", info.Notification, self.Owner.Country.Race); } } diff --git a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnKill.cs b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnKill.cs index d5ec7015af..8a7ec178ca 100644 --- a/OpenRA.Mods.Common/Traits/Sound/AnnounceOnKill.cs +++ b/OpenRA.Mods.Common/Traits/Sound/AnnounceOnKill.cs @@ -35,7 +35,8 @@ namespace OpenRA.Mods.Common.Traits public void AppliedDamage(Actor self, Actor damaged, AttackInfo e) { - if (e.DamageState == DamageState.Dead && damaged != e.Attacker) // don't notify suicides + // Don't notify suicides + if (e.DamageState == DamageState.Dead && damaged != e.Attacker) { if (self.World.WorldTick - lastAnnounce > info.Interval * 25) Sound.PlayVoice("Kill", self, self.Owner.Country.Race); diff --git a/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs b/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs index bdde773a31..74b33fd2af 100644 --- a/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs +++ b/OpenRA.Mods.Common/Traits/Sound/SoundOnDamageTransition.cs @@ -17,14 +17,14 @@ namespace OpenRA.Mods.Common.Traits public readonly string DamagedSound; public readonly string DestroyedSound; - public object Create(ActorInitializer init) { return new SoundOnDamageTransition(this);} + public object Create(ActorInitializer init) { return new SoundOnDamageTransition(this); } } public class SoundOnDamageTransition : INotifyDamageStateChanged { readonly SoundOnDamageTransitionInfo Info; - public SoundOnDamageTransition( SoundOnDamageTransitionInfo info ) + public SoundOnDamageTransition(SoundOnDamageTransitionInfo info) { Info = info; } diff --git a/OpenRA.Mods.Common/Traits/World/LoadWidgetAtGameStart.cs b/OpenRA.Mods.Common/Traits/World/LoadWidgetAtGameStart.cs index 009e83e058..0112471355 100644 --- a/OpenRA.Mods.Common/Traits/World/LoadWidgetAtGameStart.cs +++ b/OpenRA.Mods.Common/Traits/World/LoadWidgetAtGameStart.cs @@ -21,21 +21,21 @@ namespace OpenRA.Mods.Common.Traits public object Create(ActorInitializer init) { return new LoadWidgetAtGameStart(this); } } - public class LoadWidgetAtGameStart: IWorldLoaded + public class LoadWidgetAtGameStart : IWorldLoaded { - readonly LoadWidgetAtGameStartInfo Info; - public LoadWidgetAtGameStart(LoadWidgetAtGameStartInfo Info) + readonly LoadWidgetAtGameStartInfo info; + public LoadWidgetAtGameStart(LoadWidgetAtGameStartInfo info) { - this.Info = Info; + this.info = info; } public void WorldLoaded(World world, WorldRenderer wr) { // Clear any existing widget state - if (Info.ClearRoot) + if (info.ClearRoot) Ui.ResetAll(); - Game.LoadWidget(world, Info.Widget, Ui.Root, new WidgetArgs()); + Game.LoadWidget(world, info.Widget, Ui.Root, new WidgetArgs()); } } } \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/World/MPStartLocations.cs b/OpenRA.Mods.Common/Traits/World/MPStartLocations.cs index d20a247f9f..b732b67531 100644 --- a/OpenRA.Mods.Common/Traits/World/MPStartLocations.cs +++ b/OpenRA.Mods.Common/Traits/World/MPStartLocations.cs @@ -30,7 +30,7 @@ namespace OpenRA.Mods.Common.Traits { var spawns = world.Map.GetSpawnPoints().ToList(); var taken = world.LobbyInfo.Clients.Where(c => c.SpawnPoint != 0 && c.Slot != null) - .Select(c => spawns[c.SpawnPoint-1]).ToList(); + .Select(c => spawns[c.SpawnPoint - 1]).ToList(); var available = spawns.Except(taken).ToList(); // Set spawn @@ -42,7 +42,7 @@ namespace OpenRA.Mods.Common.Traits var client = world.LobbyInfo.ClientInSlot(kv.Key); var spid = (client == null || client.SpawnPoint == 0) ? ChooseSpawnPoint(world, available, taken) - : spawns[client.SpawnPoint-1]; + : spawns[client.SpawnPoint - 1]; Start.Add(player, spid); @@ -85,5 +85,4 @@ namespace OpenRA.Mods.Common.Traits return sp; } } -} - +} \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/World/PlayMusicOnMapLoad.cs b/OpenRA.Mods.Common/Traits/World/PlayMusicOnMapLoad.cs index d963f41d48..20f367633c 100644 --- a/OpenRA.Mods.Common/Traits/World/PlayMusicOnMapLoad.cs +++ b/OpenRA.Mods.Common/Traits/World/PlayMusicOnMapLoad.cs @@ -40,12 +40,11 @@ namespace OpenRA.Mods.Common.Traits void PlayMusic() { - var onComplete = info.Loop ? (Action)PlayMusic : () => {}; + var onComplete = info.Loop ? (Action)PlayMusic : () => { }; if (Game.Settings.Sound.MapMusic && world.Map.Rules.Music.ContainsKey(info.Music)) Sound.PlayMusicThen(world.Map.Rules.Music[info.Music], onComplete); } } -} - +} \ No newline at end of file diff --git a/OpenRA.Mods.Common/Traits/World/ShroudPalette.cs b/OpenRA.Mods.Common/Traits/World/ShroudPalette.cs index 4021140a45..d61639260a 100644 --- a/OpenRA.Mods.Common/Traits/World/ShroudPalette.cs +++ b/OpenRA.Mods.Common/Traits/World/ShroudPalette.cs @@ -39,22 +39,24 @@ namespace OpenRA.Mods.Common.Traits wr.AddPalette(info.Name, new ImmutablePalette(Enumerable.Range(0, Palette.Size).Select(i => (uint)c[i % 8].ToArgb()))); } - static Color[] Fog = new[] { + static Color[] Fog = new[] + { Color.Transparent, Color.Green, Color.Blue, Color.Yellow, - Color.FromArgb(128,0,0,0), - Color.FromArgb(96,0,0,0), - Color.FromArgb(64,0,0,0), - Color.FromArgb(32,0,0,0) + Color.FromArgb(128, 0, 0, 0), + Color.FromArgb(96, 0, 0, 0), + Color.FromArgb(64, 0, 0, 0), + Color.FromArgb(32, 0, 0, 0) }; - static Color[] Shroud = new[] { + static Color[] Shroud = new[] + { Color.Transparent, Color.Green, Color.Blue, Color.Yellow, Color.Black, - Color.FromArgb(160,0,0,0), - Color.FromArgb(128,0,0,0), - Color.FromArgb(64,0,0,0) + Color.FromArgb(160, 0, 0, 0), + Color.FromArgb(128, 0, 0, 0), + Color.FromArgb(64, 0, 0, 0) }; } } diff --git a/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs b/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs index 08c73bfd93..40fd050966 100644 --- a/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs +++ b/OpenRA.Mods.Common/Traits/World/TerrainGeometryOverlay.cs @@ -9,11 +9,11 @@ #endregion using System; -using System.Drawing; using System.Collections.Generic; +using System.Drawing; using System.Linq; -using OpenRA.Traits; using OpenRA.Graphics; +using OpenRA.Traits; namespace OpenRA.Mods.Common.Traits { diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs index fabd05b284..233398805a 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractLuaDocsCommand.cs @@ -64,6 +64,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var desc = m.HasAttribute() ? m.GetCustomAttributes(true).First().Lines.JoinWith("\n") : ""; Console.WriteLine("{0}{1}".F(m.LuaDocString(), desc)); } + Console.WriteLine(""); } @@ -108,6 +109,7 @@ namespace OpenRA.Mods.Common.UtilityCommands Console.WriteLine(""); } + Console.WriteLine(""); } diff --git a/OpenRA.Mods.Common/UtilityCommands/ExtractTraitDocsCommand.cs b/OpenRA.Mods.Common/UtilityCommands/ExtractTraitDocsCommand.cs index 169836d385..9b8fa04874 100644 --- a/OpenRA.Mods.Common/UtilityCommands/ExtractTraitDocsCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/ExtractTraitDocsCommand.cs @@ -84,6 +84,7 @@ namespace OpenRA.Mods.Common.UtilityCommands doc.Append(line + " "); doc.AppendLine(""); } + doc.AppendLine(""); } diff --git a/OpenRA.Mods.Common/UtilityCommands/GenerateMinimapCommand.cs b/OpenRA.Mods.Common/UtilityCommands/GenerateMinimapCommand.cs index 8b2142605f..42c2410d86 100644 --- a/OpenRA.Mods.Common/UtilityCommands/GenerateMinimapCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/GenerateMinimapCommand.cs @@ -13,8 +13,8 @@ using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; -using OpenRA.Graphics; using OpenRA.FileSystem; +using OpenRA.Graphics; namespace OpenRA.Mods.Common.UtilityCommands { diff --git a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs index cd06a77a2a..ad08442540 100644 --- a/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs +++ b/OpenRA.Mods.Common/UtilityCommands/LegacyMapImporter.cs @@ -269,7 +269,6 @@ namespace OpenRA.Mods.Common.UtilityCommands for (var j = 0; j < mapSize; j++) for (var i = 0; i < mapSize; i++) map.MapTiles.Value[new CPos(i, j)] = new TerrainTile(types[i, j], ms.ReadUInt8()); - } void UnpackRAOverlayData(MemoryStream ms) diff --git a/OpenRA.Mods.Common/UtilityCommands/RemapShpCommand.cs b/OpenRA.Mods.Common/UtilityCommands/RemapShpCommand.cs index 995c8208b8..9644f38fc9 100644 --- a/OpenRA.Mods.Common/UtilityCommands/RemapShpCommand.cs +++ b/OpenRA.Mods.Common/UtilityCommands/RemapShpCommand.cs @@ -14,11 +14,11 @@ using System.Drawing; using System.IO; using System.Linq; using System.Text; -using OpenRA.Traits; -using OpenRA.Graphics; using OpenRA.FileFormats; using OpenRA.FileSystem; +using OpenRA.Graphics; using OpenRA.Mods.Common.SpriteLoaders; +using OpenRA.Traits; namespace OpenRA.Mods.Common.UtilityCommands { diff --git a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs index f8061685e4..54fc20a214 100644 --- a/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs +++ b/OpenRA.Mods.Common/UtilityCommands/UpgradeRules.cs @@ -261,7 +261,7 @@ namespace OpenRA.Mods.Common.UtilityCommands // make animation is now its own trait if (engineVersion < 20140621) { - if (depth == 1 && (node.Key.StartsWith("RenderBuilding"))) + if (depth == 1 && node.Key.StartsWith("RenderBuilding")) node.Value.Nodes.RemoveAll(n => n.Key == "HasMakeAnimation"); if (node.Value.Nodes.Any(n => n.Key.StartsWith("RenderBuilding")) @@ -382,7 +382,6 @@ namespace OpenRA.Mods.Common.UtilityCommands node.Value.Nodes.RemoveAll(_ => true); node.Value.Nodes.Add(new MiniYamlNode("PanelName", new MiniYaml("SKIRMISH_STATS"))); } - } // Veterancy was changed to use the upgrades system @@ -459,6 +458,7 @@ namespace OpenRA.Mods.Common.UtilityCommands node.Value.Value = string.Join(", ", node.Value.Value.Split(',') .Select(s => ((int)(100 * 100 / float.Parse(s))).ToString())); } + if (depth == 3 && parentKey == "Upgrades") node.Value.Value = node.Value.Value.Replace("armor", "damage"); } @@ -477,7 +477,6 @@ namespace OpenRA.Mods.Common.UtilityCommands // InfDeath was renamed to DeathType if (engineVersion < 20140830) { - if (depth == 2 && parentKey.StartsWith("DeathSounds") && node.Key == "InfDeaths") node.Key = "DeathTypes"; @@ -735,6 +734,7 @@ namespace OpenRA.Mods.Common.UtilityCommands ConvertPxToRange(ref node.Value.Value, 2, 5); break; } + default: break; } @@ -768,7 +768,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var invalidTargets = node.Value.Nodes.FirstOrDefault(n => n.Key == "InvalidTargets"); // Weapon's InvalidTargets need to be copied to the warheads, so find it var warheadCounter = 0; - foreach(var curNode in node.Value.Nodes.ToArray()) + foreach (var curNode in node.Value.Nodes.ToArray()) { if (curNode.Key.Contains("Warhead") && curNode.Value.Value == null) { @@ -794,7 +794,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var keywords = new List { "Damage", "InfDeath", "PreventProne", "ProneModifier", "Delay" }; - foreach(var keyword in keywords) + foreach (var keyword in keywords) { var temp2 = curNode.Value.Nodes.FirstOrDefault(n => n.Key == keyword); if (temp2 != null) @@ -830,7 +830,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var keywords = new List { "Damage", "InfDeath", "PreventProne", "ProneModifier", "Delay" }; - foreach(var keyword in keywords) + foreach (var keyword in keywords) { var temp2 = curNode.Value.Nodes.FirstOrDefault(n => n.Key == keyword); if (temp2 != null) @@ -857,7 +857,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var keywords = new List { "Spread", "Damage", "InfDeath", "PreventProne", "ProneModifier", "Delay" }; - foreach(var keyword in keywords) + foreach (var keyword in keywords) { var temp = curNode.Value.Nodes.FirstOrDefault(n => n.Key == keyword); if (temp != null) @@ -885,7 +885,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var newYaml = new List(); var keywords = new List { "Size", "Delay", "ValidTargets", "InvalidTargets" }; - foreach(var keyword in keywords) + foreach (var keyword in keywords) { var temp = curNode.Value.Nodes.FirstOrDefault(n => n.Key == keyword); if (temp != null) @@ -904,7 +904,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var keywords = new List { "AddsResourceType", "Size", "Delay", "ValidTargets", "InvalidTargets" }; - foreach(var keyword in keywords) + foreach (var keyword in keywords) { var temp = curNode.Value.Nodes.FirstOrDefault(n => n.Key == keyword); if (temp != null) @@ -923,7 +923,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var keywords = new List { "SmudgeType", "Size", "Delay", "ValidTargets", "InvalidTargets" }; - foreach(var keyword in keywords) + foreach (var keyword in keywords) { var temp = curNode.Value.Nodes.FirstOrDefault(n => n.Key == keyword); if (temp != null) @@ -943,14 +943,14 @@ namespace OpenRA.Mods.Common.UtilityCommands var keywords = new List { "Explosion", "ImpactSound", "Delay", "ValidTargets", "InvalidTargets", "ValidImpactTypes", "InvalidImpactTypes" }; - foreach(var keyword in keywords) + foreach (var keyword in keywords) { var temp = curNode.Value.Nodes.FirstOrDefault(n => n.Key == keyword); if (temp != null) newYaml.Add(new MiniYamlNode(keyword, temp.Value.Value)); } - newYaml.Add(new MiniYamlNode("InvalidImpactTypes", "Water")); + newYaml.Add(new MiniYamlNode("InvalidImpactTypes", "Water")); newNodes.Add(new MiniYamlNode("Warhead@" + warheadCounter.ToString() + "Eff" + oldNodeAtName, "CreateEffect", newYaml)); } @@ -964,7 +964,7 @@ namespace OpenRA.Mods.Common.UtilityCommands var keywords = new List { "WaterExplosion", "WaterImpactSound", "Delay", "ValidTargets", "InvalidTargets", "ValidImpactTypes", "InvalidImpactTypes" }; - foreach(var keyword in keywords) + foreach (var keyword in keywords) { var temp = curNode.Value.Nodes.FirstOrDefault(n => n.Key == keyword); if (temp != null) @@ -976,11 +976,13 @@ namespace OpenRA.Mods.Common.UtilityCommands newYaml.Add(new MiniYamlNode(temp.Key, temp.Value.Value)); } } + newYaml.Add(new MiniYamlNode("ValidImpactTypes", "Water")); newNodes.Add(new MiniYamlNode("Warhead@" + warheadCounter.ToString() + "Eff" + oldNodeAtName, "CreateEffect", newYaml)); } - node.Value.Nodes.InsertRange(node.Value.Nodes.IndexOf(curNode),newNodes); + + node.Value.Nodes.InsertRange(node.Value.Nodes.IndexOf(curNode), newNodes); node.Value.Nodes.Remove(curNode); } } @@ -1028,11 +1030,11 @@ namespace OpenRA.Mods.Common.UtilityCommands if (depth == 2 && parentKey == "TerrainType" && node.Key.Split('@').First() == "Type") addNodes.Add(new MiniYamlNode("TargetTypes", node.Value.Value == "Water" ? "Water" : "Ground")); } + UpgradeTileset(engineVersion, ref node.Value.Nodes, node, depth + 1); } nodes.AddRange(addNodes); } - } } diff --git a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs index 55d47125a4..52976ab2dc 100644 --- a/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs +++ b/OpenRA.Mods.Common/Warheads/CreateEffectWarhead.cs @@ -12,8 +12,8 @@ using System.Collections.Generic; using System.Linq; using OpenRA.Effects; using OpenRA.GameRules; -using OpenRA.Traits; using OpenRA.Mods.Common.Effects; +using OpenRA.Traits; namespace OpenRA.Mods.Common { @@ -42,16 +42,12 @@ namespace OpenRA.Mods.Common if (isAir && !isDirectHit) return ImpactType.Air; - else if (isWater && !isDirectHit) return ImpactType.Water; - else if (isAir && isDirectHit) return ImpactType.AirHit; - else if (isWater && isDirectHit) return ImpactType.WaterHit; - else if (isDirectHit) return ImpactType.GroundHit; diff --git a/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs b/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs index 3e90ec4465..0994ec9bb6 100644 --- a/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ColorMixerWidget.cs @@ -18,9 +18,9 @@ namespace OpenRA.Mods.Common.Widgets { public class ColorMixerWidget : Widget { - public float[] SRange = {0.0f, 1.0f}; - public float[] VRange = {0.2f, 1.0f}; - public event Action OnChange = () => {}; + public float[] SRange = { 0.0f, 1.0f }; + public float[] VRange = { 0.2f, 1.0f }; + public event Action OnChange = () => { }; float H, S, V; byte[] front, back; @@ -32,7 +32,7 @@ namespace OpenRA.Mods.Common.Widgets Thread workerThread; bool workerAlive; - public ColorMixerWidget() {} + public ColorMixerWidget() { } public ColorMixerWidget(ColorMixerWidget other) : base(other) { @@ -47,10 +47,10 @@ namespace OpenRA.Mods.Common.Widgets base.Initialize(args); // Bitmap data is generated in a background thread and then flipped - front = new byte[4*256*256]; - back = new byte[4*256*256]; + front = new byte[4 * 256 * 256]; + back = new byte[4 * 256 * 256]; - var rect = new Rectangle((int)(255*SRange[0]), (int)(255*(1 - VRange[1])), (int)(255*(SRange[1] - SRange[0]))+1, (int)(255*(VRange[1] - VRange[0])) + 1); + var rect = new Rectangle((int)(255 * SRange[0]), (int)(255 * (1 - VRange[1])), (int)(255 * (SRange[1] - SRange[0])) + 1, (int)(255 * (VRange[1] - VRange[0])) + 1); var mixerSheet = new Sheet(new Size(256, 256)); mixerSheet.GetTexture().SetData(front, 256, 256); mixerSprite = new Sprite(mixerSheet, rect, TextureChannel.Alpha); @@ -87,6 +87,7 @@ namespace OpenRA.Mods.Common.Widgets workerAlive = false; break; } + update = false; // Take a local copy of the hue to generate to avoid tearing @@ -142,8 +143,8 @@ namespace OpenRA.Mods.Common.Widgets void SetValueFromPx(int2 xy) { var rb = RenderBounds; - var s = SRange[0] + xy.X*(SRange[1] - SRange[0])/rb.Width; - var v = SRange[1] - xy.Y*(VRange[1] - VRange[0])/rb.Height; + var s = SRange[0] + xy.X * (SRange[1] - SRange[0]) / rb.Width; + var v = SRange[1] - xy.Y * (VRange[1] - VRange[0]) / rb.Height; S = s.Clamp(SRange[0], SRange[1]); V = v.Clamp(VRange[0], VRange[1]); } @@ -151,8 +152,8 @@ namespace OpenRA.Mods.Common.Widgets int2 PxFromValue() { var rb = RenderBounds; - var x = RenderBounds.Width*(S - SRange[0])/(SRange[1] - SRange[0]); - var y = RenderBounds.Height*(1 - (V - VRange[0])/(VRange[1] - VRange[0])); + var x = RenderBounds.Width * (S - SRange[0]) / (SRange[1] - SRange[0]); + var y = RenderBounds.Height * (1 - (V - VRange[0]) / (VRange[1] - VRange[0])); return new int2((int)x.Clamp(0, rb.Width), (int)y.Clamp(0, rb.Height)); } @@ -184,6 +185,7 @@ namespace OpenRA.Mods.Common.Widgets SetValueFromPx(mi.Location - RenderOrigin); OnChange(); } + break; } @@ -204,7 +206,7 @@ namespace OpenRA.Mods.Common.Widgets public void Set(HSLColor color) { - float h,s,v; + float h, s, v; color.ToHSV(out h, out s, out v); if (H != h || S != s || V != v) diff --git a/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs b/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs index a5f043f8ac..02caf3a59f 100644 --- a/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs +++ b/OpenRA.Mods.Common/Widgets/ConfirmationDialogs.cs @@ -49,19 +49,13 @@ namespace OpenRA.Mods.Common.Widgets Func doValidate = null; ButtonWidget acceptButton = null, cancelButton = null; - // // Title - // panel.Get("PROMPT_TITLE").GetText = () => title; - // // Prompt - // panel.Get("PROMPT_TEXT").GetText = () => prompt; - // // Text input - // var input = panel.Get("INPUT_TEXT"); var isValid = false; input.Text = initialText; @@ -86,9 +80,7 @@ namespace OpenRA.Mods.Common.Widgets input.CursorPosition = input.Text.Length; input.OnTextEdited = () => doValidate(); - // // Buttons - // acceptButton = panel.Get("ACCEPT_BUTTON"); if (!string.IsNullOrEmpty(acceptText)) acceptButton.GetText = () => acceptText; @@ -113,9 +105,7 @@ namespace OpenRA.Mods.Common.Widgets onCancel(); }; - // // Validation - // doValidate = () => { if (inputValidator == null) diff --git a/OpenRA.Mods.Common/Widgets/HueSliderWidget.cs b/OpenRA.Mods.Common/Widgets/HueSliderWidget.cs index 2681d50c78..6e8aeabde5 100644 --- a/OpenRA.Mods.Common/Widgets/HueSliderWidget.cs +++ b/OpenRA.Mods.Common/Widgets/HueSliderWidget.cs @@ -39,6 +39,7 @@ namespace OpenRA.Mods.Common.Widgets for (var h = 0; h < 256; h++) *(c + h) = HSLColor.FromHSV(h / 255f, 1, 1).RGB.ToArgb(); } + hueBitmap.UnlockBits(bitmapData); hueSheet.GetTexture().SetData(hueBitmap); } diff --git a/OpenRA.Mods.Common/Widgets/LabelWithTooltipWidget.cs b/OpenRA.Mods.Common/Widgets/LabelWithTooltipWidget.cs index 70a6863c10..25d59d4ade 100644 --- a/OpenRA.Mods.Common/Widgets/LabelWithTooltipWidget.cs +++ b/OpenRA.Mods.Common/Widgets/LabelWithTooltipWidget.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Widgets if (TooltipContainer == null) return; - tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() {{ "getText", GetTooltipText }}); + tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", GetTooltipText } }); } public override void MouseExited() diff --git a/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs index 304fa02780..670321992b 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ColorPickerLogic.cs @@ -74,5 +74,4 @@ namespace OpenRA.Mods.Common.Widgets.Logic color.AttachPanel(colorChooser, onExit); } } -} - +} \ No newline at end of file diff --git a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs index 3a11df0556..1ea99373f4 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/ModBrowserLogic.cs @@ -94,7 +94,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic catch (Exception) { } } - ModMetadata initialMod = null; ModMetadata.AllMods.TryGetValue(Game.Settings.Game.PreviousMod, out initialMod); SelectMod(initialMod ?? ModMetadata.AllMods["ra"]); diff --git a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs index e4b63d9e92..315bcceef3 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/SettingsLogic.cs @@ -333,6 +333,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic var productionTemplate = hotkeyList.Get("PRODUCTION_TEMPLATE"); hotkeyList.RemoveChildren(); + Func returnTrue = () => true; + Action doNothing = () => { }; + // Game { var hotkeys = new Dictionary() @@ -358,7 +361,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { "TogglePixelDoubleKey", "Toggle pixel doubling" }, }; - var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {}); + var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing); header.Get("LABEL").GetText = () => "Game Commands"; hotkeyList.AddChild(header); @@ -374,7 +377,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { "ObserverWorldView", "Disable Shroud" } }; - var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {}); + var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing); header.Get("LABEL").GetText = () => "Observer Commands"; hotkeyList.AddChild(header); @@ -394,7 +397,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { "GuardKey", "Guard" } }; - var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {}); + var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing); header.Get("LABEL").GetText = () => "Unit Commands"; hotkeyList.AddChild(header); @@ -408,7 +411,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic for (var i = 1; i <= 24; i++) hotkeys.Add("Production{0:D2}Key".F(i), "Slot {0}".F(i)); - var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {}); + var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing); header.Get("LABEL").GetText = () => "Production Commands"; hotkeyList.AddChild(header); @@ -423,7 +426,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic { "DevReloadChromeKey", "Reload Chrome" } }; - var header = ScrollItemWidget.Setup(hotkeyHeader, () => true, () => {}); + var header = ScrollItemWidget.Setup(hotkeyHeader, returnTrue, doNothing); header.Get("LABEL").GetText = () => "Developer commands"; hotkeyList.AddChild(header); diff --git a/OpenRA.Mods.Common/Widgets/RadarWidget.cs b/OpenRA.Mods.Common/Widgets/RadarWidget.cs index a1d44b1b3e..a859fc8607 100644 --- a/OpenRA.Mods.Common/Widgets/RadarWidget.cs +++ b/OpenRA.Mods.Common/Widgets/RadarWidget.cs @@ -27,7 +27,7 @@ namespace OpenRA.Mods.Common.Widgets public Func IsEnabled = () => true; public Action AfterOpen = () => { }; public Action AfterClose = () => { }; - public Action Animating = _ => {}; + public Action Animating = _ => { }; float radarMinimapHeight; int frame; diff --git a/OpenRA.Mods.Common/Widgets/ResourceBarWidget.cs b/OpenRA.Mods.Common/Widgets/ResourceBarWidget.cs index 0c13ed6274..38c326499e 100644 --- a/OpenRA.Mods.Common/Widgets/ResourceBarWidget.cs +++ b/OpenRA.Mods.Common/Widgets/ResourceBarWidget.cs @@ -48,7 +48,7 @@ namespace OpenRA.Mods.Common.Widgets return; Func getText = () => TooltipFormat.F(GetUsed(), GetProvided()); - tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() {{ "getText", getText }}); + tooltipContainer.Value.SetTooltip(TooltipTemplate, new WidgetArgs() { { "getText", getText } }); } public override void MouseExited() @@ -67,8 +67,8 @@ namespace OpenRA.Mods.Common.Widgets while (max >= scaleBy) scaleBy *= 2; - var providedFrac = providedLerp.Update(provided/scaleBy); - var usedFrac = usedLerp.Update(used/scaleBy); + var providedFrac = providedLerp.Update(provided / scaleBy); + var usedFrac = usedLerp.Update(used / scaleBy); var b = RenderBounds; var indicator = ChromeProvider.GetImage(IndicatorCollection, IndicatorImage); @@ -83,10 +83,10 @@ namespace OpenRA.Mods.Common.Widgets { color = (i - 1 < b.Height / 2) ? color : colorDark; var bottom = new float2(b.Left + i, b.Bottom); - var top = new float2(b.Left + i, b.Bottom + providedFrac*b.Height); + var top = new float2(b.Left + i, b.Bottom + providedFrac * b.Height); // Indent corners - if ((i == 0 || i == b.Width - 1) && providedFrac*b.Height > 1) + if ((i == 0 || i == b.Width - 1) && providedFrac * b.Height > 1) { bottom.Y += 1; top.Y -= 1; @@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.Widgets } else Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, (int)float2.Lerp(b.Bottom, b.Top, providedFrac), - b.Width, (int)(providedFrac*b.Height)), color); + b.Width, (int)(providedFrac * b.Height)), color); var x = (b.Left + b.Right - indicator.size.X) / 2; var y = float2.Lerp(b.Bottom, b.Top, usedFrac) - indicator.size.Y / 2; @@ -112,10 +112,10 @@ namespace OpenRA.Mods.Common.Widgets { color = (i - 1 < b.Height / 2) ? color : colorDark; var left = new float2(b.Left, b.Top + i); - var right = new float2(b.Left + providedFrac*b.Width, b.Top + i); + var right = new float2(b.Left + providedFrac * b.Width, b.Top + i); // Indent corners - if ((i == 0 || i == b.Height - 1) && providedFrac*b.Width > 1) + if ((i == 0 || i == b.Height - 1) && providedFrac * b.Width > 1) { left.X += 1; right.X -= 1; @@ -125,7 +125,7 @@ namespace OpenRA.Mods.Common.Widgets } } else - Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, b.Y, (int)(providedFrac*b.Width), b.Height), color); + Game.Renderer.LineRenderer.FillRect(new Rectangle(b.X, b.Y, (int)(providedFrac * b.Width), b.Height), color); var x = float2.Lerp(b.Left, b.Right, usedFrac) - indicator.size.X / 2; var y = (b.Bottom + b.Top - indicator.size.Y) / 2;