diff --git a/OpenRA.Mods.D2k/Traits/AutoCarryall.cs b/OpenRA.Mods.D2k/Traits/AutoCarryall.cs index 42c931daa6..ebcb128ed9 100644 --- a/OpenRA.Mods.D2k/Traits/AutoCarryall.cs +++ b/OpenRA.Mods.D2k/Traits/AutoCarryall.cs @@ -95,7 +95,6 @@ namespace OpenRA.Mods.D2k.Traits }) .OrderBy(p => (self.Location - p.Actor.Location).LengthSquared); - foreach (var p in carryables) { // Check if its actually me who's the best candidate diff --git a/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs b/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs index 538281ea47..08161fd446 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/LaysTerrain.cs @@ -21,7 +21,7 @@ namespace OpenRA.Mods.D2k.Traits public readonly ushort Template = 0; [Desc("The terrain types that this template will be placed on")] - public readonly string[] TerrainTypes = {}; + public readonly string[] TerrainTypes = { }; [Desc("Offset relative to the actor TopLeft. Not used if the template is PickAny")] public readonly CVec Offset = CVec.Zero; diff --git a/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs index 1103afdfd0..2415070bb6 100644 --- a/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.D2k/Widgets/BuildPaletteWidget.cs @@ -41,6 +41,10 @@ namespace OpenRA.Mods.D2k.Widgets public int IconWidth = 64; public int IconHeight = 48; + readonly WorldRenderer worldRenderer; + readonly World world; + readonly OrderManager orderManager; + ProductionQueue CurrentQueue; List VisibleQueues; @@ -59,10 +63,6 @@ namespace OpenRA.Mods.D2k.Widgets Animation cantBuild; Animation clock; - readonly WorldRenderer worldRenderer; - readonly World world; - readonly OrderManager orderManager; - [ObjectCreator.UseCtor] public BuildPaletteWidget(OrderManager orderManager, World world, WorldRenderer worldRenderer) { @@ -79,7 +79,7 @@ namespace OpenRA.Mods.D2k.Widgets public override void Initialize(WidgetArgs args) { - paletteOpenOrigin = new float2(Game.Renderer.Resolution.Width - Columns*IconWidth - 23, 280); + paletteOpenOrigin = new float2(Game.Renderer.Resolution.Width - Columns * IconWidth - 23, 280); paletteClosedOrigin = new float2(Game.Renderer.Resolution.Width - 16, 280); paletteOrigin = paletteClosedOrigin; base.Initialize(args); @@ -87,7 +87,7 @@ namespace OpenRA.Mods.D2k.Widgets public override Rectangle EventBounds { - get { return new Rectangle((int)(paletteOrigin.X) - 24, (int)(paletteOrigin.Y), 239, Math.Max(IconHeight * numActualRows, 40 * tabs.Count + 9)); } + get { return new Rectangle((int)paletteOrigin.X - 24, (int)paletteOrigin.Y, 239, Math.Max(IconHeight * numActualRows, 40 * tabs.Count + 9)); } } public override void Tick() @@ -108,6 +108,7 @@ namespace OpenRA.Mods.D2k.Widgets else if (CurrentQueue == queue) CurrentQueue = null; } + if (CurrentQueue == null) CurrentQueue = VisibleQueues.FirstOrDefault(); @@ -195,9 +196,10 @@ namespace OpenRA.Mods.D2k.Widgets public override void Draw() { - if (!IsVisible()) return; - // TODO: fix + if (!IsVisible()) + return; + // TODO: fix DrawPalette(CurrentQueue); DrawBuildTabs(world); } @@ -231,7 +233,6 @@ namespace OpenRA.Mods.D2k.Widgets WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "bottom"), new float2(origin.X - 9, origin.Y - 1 + IconHeight * numActualRows)); - // Icons string tooltipItem = null; var tooltipHotkey = Hotkey.Invalid; @@ -279,7 +280,9 @@ namespace OpenRA.Mods.D2k.Widgets if (++x == Columns) { x = 0; y++; } i++; } - if (x != 0) y++; + + if (x != 0) + y++; foreach (var ob in overlayBits) WidgetUtils.DrawSHPCentered(ob.First, ob.Second + iconOffset, worldRenderer); @@ -334,7 +337,7 @@ namespace OpenRA.Mods.D2k.Widgets Sound.PlayNotification(world.Map.Rules, null, "Sounds", "TabClick", null); if (name != null) - HandleBuildPalette(world, name, (mi.Button == MouseButton.Left)); + HandleBuildPalette(world, name, mi.Button == MouseButton.Left); }; } @@ -499,11 +502,11 @@ namespace OpenRA.Mods.D2k.Widgets var power = pl.PlayerActor.Trait(); DrawRightAligned("${0}".F(cost), pos + new int2(-5, 5), - (resources.DisplayCash + resources.DisplayResources >= cost ? Color.White : Color.Red)); + resources.DisplayCash + resources.DisplayResources >= cost ? Color.White : Color.Red); var lowpower = power.PowerState != PowerState.Normal; var time = CurrentQueue.GetBuildTime(info.Name) - * ((lowpower) ? CurrentQueue.Info.LowPowerSlowdown : 1); + * (lowpower ? CurrentQueue.Info.LowPowerSlowdown : 1); DrawRightAligned(WidgetUtils.FormatTime(time), pos + new int2(-5, 35), lowpower ? Color.Red : Color.White); var pis = info.Traits.WithInterface().Where(i => i.UpgradeMinEnabledLevel < 1); @@ -572,6 +575,7 @@ namespace OpenRA.Mods.D2k.Widgets SetCurrentTab(nextQueue); return true; } + return true; } } diff --git a/OpenRA.Mods.D2k/Widgets/Logic/IngameChromeLogic.cs b/OpenRA.Mods.D2k/Widgets/Logic/IngameChromeLogic.cs index a4c64fba71..aa64a72e42 100644 --- a/OpenRA.Mods.D2k/Widgets/Logic/IngameChromeLogic.cs +++ b/OpenRA.Mods.D2k/Widgets/Logic/IngameChromeLogic.cs @@ -11,8 +11,8 @@ using System; using System.Drawing; using System.Linq; -using OpenRA.Mods.Common.Widgets; using OpenRA.Mods.Common.Traits; +using OpenRA.Mods.Common.Widgets; using OpenRA.Mods.D2k.Widgets; using OpenRA.Mods.RA; using OpenRA.Mods.RA.Widgets; @@ -63,7 +63,7 @@ namespace OpenRA.Mods.D2k.Widgets.Logic Game.LoadWidget(world, "OBSERVER_WIDGETS", playerRoot, new WidgetArgs()); } - enum RadarBinState { Closed, BinAnimating, RadarAnimating, Open }; + enum RadarBinState { Closed, BinAnimating, RadarAnimating, Open } void InitPlayerWidgets() { var playerWidgets = Game.LoadWidget(world, "PLAYER_WIDGETS", playerRoot, new WidgetArgs()); @@ -80,11 +80,11 @@ namespace OpenRA.Mods.D2k.Widgets.Logic radarMap.AfterOpen = () => binState = RadarBinState.Open; radarMap.AfterClose = () => binState = RadarBinState.BinAnimating; - radarBin.Get("RADAR_BIN_BG").GetImageCollection = () => "chrome-"+world.LocalPlayer.Country.Race; + radarBin.Get("RADAR_BIN_BG").GetImageCollection = () => "chrome-" + world.LocalPlayer.Country.Race; var powerManager = world.LocalPlayer.PlayerActor.Trait(); var powerBar = radarBin.Get("POWERBAR"); - powerBar.IndicatorCollection = "power-"+world.LocalPlayer.Country.Race; + powerBar.IndicatorCollection = "power-" + world.LocalPlayer.Country.Race; powerBar.GetProvided = () => powerManager.PowerProvided; powerBar.GetUsed = () => powerManager.PowerDrained; powerBar.TooltipFormat = "Power Usage: {0}/{1}"; @@ -106,7 +106,7 @@ namespace OpenRA.Mods.D2k.Widgets.Logic .Any(a => a.Actor.Owner == world.LocalPlayer && a.Trait.IsActive); if (radarActive != cachedRadarActive) - Sound.PlayNotification(world.Map.Rules, null, "Sounds", (radarActive ? "RadarUp" : "RadarDown"), null); + Sound.PlayNotification(world.Map.Rules, null, "Sounds", radarActive ? "RadarUp" : "RadarDown", null); cachedRadarActive = radarActive; // Switch to observer mode after win/loss diff --git a/OpenRA.Mods.D2k/Widgets/MoneyBinWidget.cs b/OpenRA.Mods.D2k/Widgets/MoneyBinWidget.cs index db056e2b72..5136c2e7c5 100644 --- a/OpenRA.Mods.D2k/Widgets/MoneyBinWidget.cs +++ b/OpenRA.Mods.D2k/Widgets/MoneyBinWidget.cs @@ -29,8 +29,11 @@ namespace OpenRA.Mods.D2k.Widgets public override void Draw() { - if( world.LocalPlayer == null ) return; - if( world.LocalPlayer.WinState != WinState.Undefined ) return; + if (world.LocalPlayer == null) + return; + + if (world.LocalPlayer.WinState != WinState.Undefined) + return; var digitCollection = "digits-" + world.LocalPlayer.Country.Race; var chromeCollection = "chrome-" + world.LocalPlayer.Country.Race; diff --git a/OpenRA.Mods.D2k/Widgets/SlidingContainerWidget.cs b/OpenRA.Mods.D2k/Widgets/SlidingContainerWidget.cs index 0f700ac4e1..b559b7e634 100644 --- a/OpenRA.Mods.D2k/Widgets/SlidingContainerWidget.cs +++ b/OpenRA.Mods.D2k/Widgets/SlidingContainerWidget.cs @@ -20,8 +20,8 @@ namespace OpenRA.Mods.D2k.Widgets public int2 ClosedOffset = int2.Zero; public int AnimationLength = 0; public Func IsOpen = () => false; - public Action AfterOpen = () => {}; - public Action AfterClose = () => {}; + public Action AfterOpen = () => { }; + public Action AfterClose = () => { }; int2 offset; int frame; diff --git a/OpenRA.Mods.D2k/Widgets/SupportPowerBinWidget.cs b/OpenRA.Mods.D2k/Widgets/SupportPowerBinWidget.cs index 646d22f8c3..b97ac8d84f 100644 --- a/OpenRA.Mods.D2k/Widgets/SupportPowerBinWidget.cs +++ b/OpenRA.Mods.D2k/Widgets/SupportPowerBinWidget.cs @@ -27,13 +27,14 @@ namespace OpenRA.Mods.D2k.Widgets public int IconWidth = 64; public int IconHeight = 48; - Animation icon; - Animation clock; - readonly List>> buttons = new List>>(); + readonly List>> buttons = new List>>(); readonly World world; readonly WorldRenderer worldRenderer; + Animation icon; + Animation clock; + [ObjectCreator.UseCtor] public SupportPowerBinWidget(World world, WorldRenderer worldRenderer) { @@ -74,7 +75,8 @@ namespace OpenRA.Mods.D2k.Widgets { buttons.Clear(); - if( world.LocalPlayer == null ) return; + if (world.LocalPlayer == null) + return; var manager = world.LocalPlayer.PlayerActor.Trait(); var powers = manager.Powers.Where(p => !p.Value.Disabled); @@ -82,7 +84,7 @@ namespace OpenRA.Mods.D2k.Widgets if (numPowers == 0) return; var rectBounds = RenderBounds; - WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-top"),new float2(rectBounds.X,rectBounds.Y)); + WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-top"), new float2(rectBounds.X, rectBounds.Y)); for (var i = 1; i < numPowers; i++) WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-middle"), new float2(rectBounds.X, rectBounds.Y + i * 51)); WidgetUtils.DrawRGBA(WidgetUtils.GetChromeImage(world, "specialbin-bottom"), new float2(rectBounds.X, rectBounds.Y + numPowers * 51)); @@ -104,17 +106,17 @@ namespace OpenRA.Mods.D2k.Widgets if (rect.Contains(Viewport.LastMousePos)) { var pos = drawPos.ToInt2(); - var tl = new int2(pos.X-3,pos.Y-3); - var m = new int2(pos.X+64+3,pos.Y+48+3); - var br = tl + new int2(64+3+20,40); + var tl = new int2(pos.X - 3, pos.Y - 3); + var m = new int2(pos.X + 64 + 3, pos.Y + 48 + 3); + var br = tl + new int2(64 + 3 + 20, 40); if (sp.TotalTime > 0) - br += new int2(0,20); + br += new int2(0, 20); if (sp.Info.LongDesc != null) br += Game.Renderer.Fonts["Regular"].Measure(sp.Info.LongDesc.Replace("\\n", "\n")); else - br += new int2(300,0); + br += new int2(300, 0); var border = WidgetUtils.GetBorderSizes("dialog4"); @@ -130,9 +132,9 @@ namespace OpenRA.Mods.D2k.Widgets if (sp.TotalTime > 0) { - pos += new int2(0,20); + pos += new int2(0, 20); Game.Renderer.Fonts["Bold"].DrawText(WidgetUtils.FormatTime(sp.RemainingTime), pos, Color.White); - Game.Renderer.Fonts["Bold"].DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45,0), Color.White); + Game.Renderer.Fonts["Bold"].DrawText("/ {0}".F(WidgetUtils.FormatTime(sp.TotalTime)), pos + new int2(45, 0), Color.White); } if (sp.Info.LongDesc != null) @@ -160,7 +162,7 @@ namespace OpenRA.Mods.D2k.Widgets font.DrawTextWithContrast(overlay, overlayPos - new float2(size.X / 2, 0), Color.White, Color.Black, 1); } - buttons.Add(Pair.New(rect,HandleSupportPower(kv.Key, manager))); + buttons.Add(Pair.New(rect, HandleSupportPower(kv.Key, manager))); y += 51; }