From 1821c52db05ffee8006c54f681503ebaf82922a1 Mon Sep 17 00:00:00 2001 From: deniz1a Date: Sun, 1 Jun 2014 03:31:57 +0300 Subject: [PATCH] Make "Ready" text alternate between red and white Make color of "Ready" text alternate between red and white. Made the code cleaner. Whitespace correction. Whitespace correction again. Change color from red to green and make it moddable Use enum for ReadyTextStyle Use enum for cnc Made variables public and simplified if statements fix enum fix enum and ) ReadyText settings in ra yaml ReadyText settings in cnc yaml Move values from code to ra yaml Move values from code to cnc yaml revert code changes cnc revert code changes ra move around a bit in ra yaml move around a bit in cnc yaml Add values to d2k yaml --- .../Widgets/ProductionPaletteWidget.cs | 14 ++++++++++---- OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs | 15 +++++++++++---- mods/cnc/chrome/ingame.yaml | 2 ++ mods/d2k/chrome/ingame-player.yaml | 2 ++ mods/ra/chrome/ingame-player.yaml | 2 ++ 5 files changed, 27 insertions(+), 8 deletions(-) diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs index f034f07991..047e2f7088 100644 --- a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs @@ -33,6 +33,9 @@ namespace OpenRA.Mods.Cnc.Widgets public class ProductionPaletteWidget : Widget { + public enum ReadyTextStyleOptions { Solid, AlternatingColor, Blinking } + public readonly ReadyTextStyleOptions ReadyTextStyle = ReadyTextStyleOptions.AlternatingColor; + public readonly Color ReadyTextAltColor = Color.LimeGreen; public readonly int Columns = 3; public readonly string TabClick = null; public readonly string DisabledTabClick = null; @@ -248,11 +251,14 @@ namespace OpenRA.Mods.Cnc.Widgets var waiting = first != CurrentQueue.CurrentItem() && !first.Done; if (first.Done) { - // Blink the ready text - if (orderManager.LocalFrameNumber / 9 % 2 == 0) + if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0) overlayFont.DrawTextWithContrast(ReadyText, - icon.Pos + readyOffset, - Color.White, Color.Black, 1); + icon.Pos + readyOffset, + Color.White, Color.Black, 1); + else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor) + overlayFont.DrawTextWithContrast(ReadyText, + icon.Pos + readyOffset, + ReadyTextAltColor, Color.Black, 1); } else if (first.Paused) overlayFont.DrawTextWithContrast(HoldText, diff --git a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs index 0420661678..bfa5c1a9a5 100644 --- a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs @@ -24,6 +24,9 @@ namespace OpenRA.Mods.RA.Widgets { class BuildPaletteWidget : Widget { + public enum ReadyTextStyleOptions { Solid, AlternatingColor, Blinking } + public readonly ReadyTextStyleOptions ReadyTextStyle = ReadyTextStyleOptions.AlternatingColor; + public readonly Color ReadyTextAltColor = Color.LimeGreen; public int Columns = 3; public int Rows = 5; @@ -275,8 +278,12 @@ namespace OpenRA.Mods.RA.Widgets foreach (var tb in textBits) { var size = font.Measure(tb.Second); - font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0), - Color.White, Color.Black, 1); + if (ReadyTextStyle == ReadyTextStyleOptions.Solid || orderManager.LocalFrameNumber / 9 % 2 == 0 || tb.Second != ReadyText) + font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0), + Color.White, Color.Black, 1); + else if (ReadyTextStyle == ReadyTextStyleOptions.AlternatingColor) + font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0), + ReadyTextAltColor, Color.Black, 1); } // Tooltip @@ -305,7 +312,7 @@ namespace OpenRA.Mods.RA.Widgets return HoldText; if (item.Done) - return orderManager.LocalFrameNumber / 9 % 2 == 0 ? ReadyText : ""; + return ReadyText; return WidgetUtils.FormatTime(item.RemainingTimeActual); } @@ -545,4 +552,4 @@ namespace OpenRA.Mods.RA.Widgets return true; } } -} \ No newline at end of file +} diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 17d9a09f36..584e1808c6 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -382,6 +382,8 @@ Container@PLAYER_WIDGETS: Y: 287 TooltipContainer: TOOLTIP_CONTAINER ReadyText: Ready + ReadyTextStyle: AlternatingColor + ReadyTextAltColor: 50,205,50 HoldText: On Hold Background@FMVPLAYER: diff --git a/mods/d2k/chrome/ingame-player.yaml b/mods/d2k/chrome/ingame-player.yaml index 6ee4ed106d..e1388dd6ae 100644 --- a/mods/d2k/chrome/ingame-player.yaml +++ b/mods/d2k/chrome/ingame-player.yaml @@ -112,6 +112,8 @@ Container@PLAYER_WIDGETS: Width: 238 Height: 500 ReadyText: READY + ReadyTextStyle: AlternatingColor + ReadyTextAltColor: 50,205,50 HoldText: ON HOLD RequiresText: Requires {0} IconWidth: 60 diff --git a/mods/ra/chrome/ingame-player.yaml b/mods/ra/chrome/ingame-player.yaml index a77facb70e..41111a64a7 100644 --- a/mods/ra/chrome/ingame-player.yaml +++ b/mods/ra/chrome/ingame-player.yaml @@ -110,6 +110,8 @@ Container@PLAYER_WIDGETS: Width: 250 Height: 500 ReadyText: READY + ReadyTextStyle: AlternatingColor + ReadyTextAltColor: 50,205,50 HoldText: ON HOLD RequiresText: Requires {0}