From f107f8a87b5b20a1627f7a62b474b648b36a12de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 22 Dec 2012 18:25:18 +0100 Subject: [PATCH 1/3] expose strings from build palette widget to chrome yaml prepare for localisation efforts --- OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs | 10 +++++++--- mods/ra/chrome/ingame.yaml | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs index ea4a28b562..5130287d12 100755 --- a/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs +++ b/OpenRA.Mods.RA/Widgets/BuildPaletteWidget.cs @@ -26,6 +26,10 @@ namespace OpenRA.Mods.RA.Widgets public int Columns = 3; public int Rows = 5; + public string ReadyText = ""; + public string HoldText = ""; + public string RequiresText = ""; + ProductionQueue CurrentQueue; List VisibleQueues; @@ -291,8 +295,8 @@ namespace OpenRA.Mods.RA.Widgets string GetOverlayForItem(ProductionItem item) { - if (item.Paused) return "ON HOLD"; - if (item.Done) return "READY"; + if (item.Paused) return HoldText; + if (item.Done) return ReadyText; return WidgetUtils.FormatTime(item.RemainingTimeActual); } @@ -484,7 +488,7 @@ namespace OpenRA.Mods.RA.Widgets var prereqs = buildable.Prerequisites .Select( a => Description( a ) ); Game.Renderer.Fonts["Regular"].DrawText( - "Requires {0}".F(prereqs.JoinWith(", ")), + "{0} {1}".F(RequiresText, prereqs.JoinWith(", ")), p.ToInt2(), Color.White); diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml index fcfb2fb387..5ece2aa301 100644 --- a/mods/ra/chrome/ingame.yaml +++ b/mods/ra/chrome/ingame.yaml @@ -58,6 +58,9 @@ Container@INGAME_ROOT: Y:280 Width:250 Height:500 + ReadyText: READY + HoldText: ON HOLD + RequiresText: Requires Button@INGAME_OPTIONS_BUTTON: X:0 Y:0 From 39884e16fad4de322d48a5b63442d45f05d9cded Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 22 Dec 2012 18:59:45 +0100 Subject: [PATCH 2/3] customisable text printed on RA support power icons --- OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs | 5 ++++- mods/ra/chrome/ingame.yaml | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs b/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs index ea76439f58..52b2fc5768 100755 --- a/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs +++ b/OpenRA.Mods.RA/Widgets/SupportPowerBinWidget.cs @@ -20,6 +20,9 @@ namespace OpenRA.Mods.RA.Widgets { class SupportPowerBinWidget : Widget { + public string ReadyText = ""; + public string HoldText = ""; + Dictionary spsprites; Animation clock; readonly List>> buttons = new List>>(); @@ -148,7 +151,7 @@ namespace OpenRA.Mods.RA.Widgets WidgetUtils.DrawSHP(clock.Image, drawPos, worldRenderer); - var overlay = sp.Ready ? "READY" : sp.Active ? null : "ON HOLD"; + var overlay = sp.Ready ? ReadyText : sp.Active ? null : HoldText; var font = Game.Renderer.Fonts["TinyBold"]; if (overlay != null) { diff --git a/mods/ra/chrome/ingame.yaml b/mods/ra/chrome/ingame.yaml index 5ece2aa301..511e5fcd40 100644 --- a/mods/ra/chrome/ingame.yaml +++ b/mods/ra/chrome/ingame.yaml @@ -53,6 +53,8 @@ Container@INGAME_ROOT: SupportPowerBin@INGAME_POWERS_BIN: X:0 Y:25 + ReadyText: READY + HoldText: ON HOLD BuildPalette@INGAME_BUILD_PALETTE: X:WINDOW_RIGHT - 250 Y:280 From c3b959846c951b026eb59fe2a80a0a1dea974aa3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sat, 22 Dec 2012 19:21:05 +0100 Subject: [PATCH 3/3] customisable Ready/Hold text for CnC mod make those strings also translatable --- .../Widgets/ProductionPaletteWidget.cs | 23 +++++++++++-------- .../Widgets/SupportPowersWidget.cs | 21 +++++++++-------- mods/cnc/chrome/ingame.yaml | 4 ++++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs index 35ca604e43..d8f4470004 100755 --- a/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/ProductionPaletteWidget.cs @@ -36,6 +36,9 @@ namespace OpenRA.Mods.Cnc.Widgets public readonly string TooltipContainer; public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP"; + public readonly string ReadyText = ""; + public readonly string HoldText = ""; + public string TooltipActor { get; private set; } public readonly World world; @@ -54,8 +57,8 @@ namespace OpenRA.Mods.Cnc.Widgets Animation cantBuild, clock; Rectangle eventBounds = Rectangle.Empty; readonly WorldRenderer worldRenderer; - readonly SpriteFont overlayFont; - readonly float2 holdOffset, readyOffset, timeOffset, queuedOffset; + SpriteFont overlayFont; + float2 holdOffset, readyOffset, timeOffset, queuedOffset; [ObjectCreator.UseCtor] public ProductionPaletteWidget(World world, WorldRenderer worldRenderer) @@ -75,12 +78,6 @@ namespace OpenRA.Mods.Cnc.Widgets u => u.Name, u => Game.modData.SpriteLoader.LoadAllSprites( u.Traits.Get().Icon ?? (u.Name + "icon"))[0]); - - overlayFont = Game.Renderer.Fonts["TinyBold"]; - holdOffset = new float2(32,24) - overlayFont.Measure("On Hold") / 2; - readyOffset = new float2(32,24) - overlayFont.Measure("Ready") / 2; - timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; - queuedOffset = new float2(4,2); } public override void Tick() @@ -210,6 +207,12 @@ namespace OpenRA.Mods.Cnc.Widgets public override void Draw() { + overlayFont = Game.Renderer.Fonts["TinyBold"]; + timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; + queuedOffset = new float2(4,2); + holdOffset = new float2(32,24) - overlayFont.Measure(HoldText) / 2; + readyOffset = new float2(32,24) - overlayFont.Measure(ReadyText) / 2; + if (CurrentQueue == null) return; @@ -247,11 +250,11 @@ namespace OpenRA.Mods.Cnc.Widgets var first = icon.Queued[0]; var waiting = first != CurrentQueue.CurrentItem() && !first.Done; if (first.Done) - overlayFont.DrawTextWithContrast("Ready", + overlayFont.DrawTextWithContrast(ReadyText, icon.Pos + readyOffset, Color.White, Color.Black, 1); else if (first.Paused) - overlayFont.DrawTextWithContrast("On Hold", + overlayFont.DrawTextWithContrast(HoldText, icon.Pos + holdOffset, Color.White, Color.Black, 1); else if (!waiting) diff --git a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs index c7bd81d4cd..375ec3ee97 100755 --- a/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Cnc/Widgets/SupportPowersWidget.cs @@ -23,6 +23,9 @@ namespace OpenRA.Mods.Cnc.Widgets { public int Spacing = 10; + public readonly string ReadyText = ""; + public readonly string HoldText = ""; + Dictionary iconSprites; Animation clock; Dictionary Icons = new Dictionary(); @@ -36,8 +39,8 @@ namespace OpenRA.Mods.Cnc.Widgets public override Rectangle EventBounds { get { return eventBounds; } } readonly WorldRenderer worldRenderer; readonly SupportPowerManager spm; - readonly SpriteFont overlayFont; - readonly float2 holdOffset, readyOffset, timeOffset; + SpriteFont overlayFont; + float2 holdOffset, readyOffset, timeOffset; [ObjectCreator.UseCtor] public SupportPowersWidget(World world, WorldRenderer worldRenderer) @@ -54,11 +57,6 @@ namespace OpenRA.Mods.Cnc.Widgets u => Game.modData.SpriteLoader.LoadAllSprites(u)[0]); clock = new Animation("clock"); - - overlayFont = Game.Renderer.Fonts["TinyBold"]; - holdOffset = new float2(32,24) - overlayFont.Measure("On Hold") / 2; - readyOffset = new float2(32,24) - overlayFont.Measure("Ready") / 2; - timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; } public class SupportPowerIcon @@ -94,6 +92,11 @@ namespace OpenRA.Mods.Cnc.Widgets public override void Draw() { + overlayFont = Game.Renderer.Fonts["TinyBold"]; + holdOffset = new float2(32,24) - overlayFont.Measure(HoldText) / 2; + readyOffset = new float2(32,24) - overlayFont.Measure(ReadyText) / 2; + timeOffset = new float2(32,24) - overlayFont.Measure(WidgetUtils.FormatTime(0)) / 2; + // Background foreach (var rect in Icons.Keys) WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1,1,1,1)); @@ -115,11 +118,11 @@ namespace OpenRA.Mods.Cnc.Widgets foreach (var p in Icons.Values) { if (p.Power.Ready) - overlayFont.DrawTextWithContrast("Ready", + overlayFont.DrawTextWithContrast(ReadyText, p.Pos + readyOffset, Color.White, Color.Black, 1); else if (!p.Power.Active) - overlayFont.DrawTextWithContrast("On Hold", + overlayFont.DrawTextWithContrast(HoldText, p.Pos + holdOffset, Color.White, Color.Black, 1); else diff --git a/mods/cnc/chrome/ingame.yaml b/mods/cnc/chrome/ingame.yaml index 7b5ec7b0a5..779d911eed 100644 --- a/mods/cnc/chrome/ingame.yaml +++ b/mods/cnc/chrome/ingame.yaml @@ -87,6 +87,8 @@ Container@PLAYER_WIDGETS: TooltipContainer:TOOLTIP_CONTAINER X:10 Y:10 + ReadyText:Ready + HoldText:On Hold Background@SIDEBAR_BACKGROUND: X:WINDOW_RIGHT - 204 Y:30 @@ -257,6 +259,8 @@ Container@PLAYER_WIDGETS: X:WINDOW_RIGHT - 204 Y:287 TooltipContainer:TOOLTIP_CONTAINER + ReadyText:Ready + HoldText:On Hold Background@FMVPLAYER: Width:WINDOW_RIGHT Height:WINDOW_BOTTOM