Merge pull request #2526 from Mailaender/strings

made all in-game strings customisable via .yaml files
This commit is contained in:
Chris Forbes
2012-12-22 12:25:33 -08:00
6 changed files with 45 additions and 23 deletions

View File

@@ -36,6 +36,9 @@ namespace OpenRA.Mods.Cnc.Widgets
public readonly string TooltipContainer; public readonly string TooltipContainer;
public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP"; public readonly string TooltipTemplate = "PRODUCTION_TOOLTIP";
public readonly string ReadyText = "";
public readonly string HoldText = "";
public string TooltipActor { get; private set; } public string TooltipActor { get; private set; }
public readonly World world; public readonly World world;
@@ -54,8 +57,8 @@ namespace OpenRA.Mods.Cnc.Widgets
Animation cantBuild, clock; Animation cantBuild, clock;
Rectangle eventBounds = Rectangle.Empty; Rectangle eventBounds = Rectangle.Empty;
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
readonly SpriteFont overlayFont; SpriteFont overlayFont;
readonly float2 holdOffset, readyOffset, timeOffset, queuedOffset; float2 holdOffset, readyOffset, timeOffset, queuedOffset;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public ProductionPaletteWidget(World world, WorldRenderer worldRenderer) public ProductionPaletteWidget(World world, WorldRenderer worldRenderer)
@@ -75,12 +78,6 @@ namespace OpenRA.Mods.Cnc.Widgets
u => u.Name, u => u.Name,
u => Game.modData.SpriteLoader.LoadAllSprites( u => Game.modData.SpriteLoader.LoadAllSprites(
u.Traits.Get<TooltipInfo>().Icon ?? (u.Name + "icon"))[0]); u.Traits.Get<TooltipInfo>().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() public override void Tick()
@@ -210,6 +207,12 @@ namespace OpenRA.Mods.Cnc.Widgets
public override void Draw() 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) if (CurrentQueue == null)
return; return;
@@ -247,11 +250,11 @@ namespace OpenRA.Mods.Cnc.Widgets
var first = icon.Queued[0]; var first = icon.Queued[0];
var waiting = first != CurrentQueue.CurrentItem() && !first.Done; var waiting = first != CurrentQueue.CurrentItem() && !first.Done;
if (first.Done) if (first.Done)
overlayFont.DrawTextWithContrast("Ready", overlayFont.DrawTextWithContrast(ReadyText,
icon.Pos + readyOffset, icon.Pos + readyOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
else if (first.Paused) else if (first.Paused)
overlayFont.DrawTextWithContrast("On Hold", overlayFont.DrawTextWithContrast(HoldText,
icon.Pos + holdOffset, icon.Pos + holdOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
else if (!waiting) else if (!waiting)

View File

@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Cnc.Widgets
{ {
public int Spacing = 10; public int Spacing = 10;
public readonly string ReadyText = "";
public readonly string HoldText = "";
Dictionary<string, Sprite> iconSprites; Dictionary<string, Sprite> iconSprites;
Animation clock; Animation clock;
Dictionary<Rectangle, SupportPowerIcon> Icons = new Dictionary<Rectangle, SupportPowerIcon>(); Dictionary<Rectangle, SupportPowerIcon> Icons = new Dictionary<Rectangle, SupportPowerIcon>();
@@ -36,8 +39,8 @@ namespace OpenRA.Mods.Cnc.Widgets
public override Rectangle EventBounds { get { return eventBounds; } } public override Rectangle EventBounds { get { return eventBounds; } }
readonly WorldRenderer worldRenderer; readonly WorldRenderer worldRenderer;
readonly SupportPowerManager spm; readonly SupportPowerManager spm;
readonly SpriteFont overlayFont; SpriteFont overlayFont;
readonly float2 holdOffset, readyOffset, timeOffset; float2 holdOffset, readyOffset, timeOffset;
[ObjectCreator.UseCtor] [ObjectCreator.UseCtor]
public SupportPowersWidget(World world, WorldRenderer worldRenderer) public SupportPowersWidget(World world, WorldRenderer worldRenderer)
@@ -54,11 +57,6 @@ namespace OpenRA.Mods.Cnc.Widgets
u => Game.modData.SpriteLoader.LoadAllSprites(u)[0]); u => Game.modData.SpriteLoader.LoadAllSprites(u)[0]);
clock = new Animation("clock"); 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 public class SupportPowerIcon
@@ -94,6 +92,11 @@ namespace OpenRA.Mods.Cnc.Widgets
public override void Draw() 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 // Background
foreach (var rect in Icons.Keys) foreach (var rect in Icons.Keys)
WidgetUtils.DrawPanel("panel-black", rect.InflateBy(1,1,1,1)); 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) foreach (var p in Icons.Values)
{ {
if (p.Power.Ready) if (p.Power.Ready)
overlayFont.DrawTextWithContrast("Ready", overlayFont.DrawTextWithContrast(ReadyText,
p.Pos + readyOffset, p.Pos + readyOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
else if (!p.Power.Active) else if (!p.Power.Active)
overlayFont.DrawTextWithContrast("On Hold", overlayFont.DrawTextWithContrast(HoldText,
p.Pos + holdOffset, p.Pos + holdOffset,
Color.White, Color.Black, 1); Color.White, Color.Black, 1);
else else

View File

@@ -26,6 +26,10 @@ namespace OpenRA.Mods.RA.Widgets
public int Columns = 3; public int Columns = 3;
public int Rows = 5; public int Rows = 5;
public string ReadyText = "";
public string HoldText = "";
public string RequiresText = "";
ProductionQueue CurrentQueue; ProductionQueue CurrentQueue;
List<ProductionQueue> VisibleQueues; List<ProductionQueue> VisibleQueues;
@@ -291,8 +295,8 @@ namespace OpenRA.Mods.RA.Widgets
string GetOverlayForItem(ProductionItem item) string GetOverlayForItem(ProductionItem item)
{ {
if (item.Paused) return "ON HOLD"; if (item.Paused) return HoldText;
if (item.Done) return "READY"; if (item.Done) return ReadyText;
return WidgetUtils.FormatTime(item.RemainingTimeActual); return WidgetUtils.FormatTime(item.RemainingTimeActual);
} }
@@ -474,7 +478,7 @@ namespace OpenRA.Mods.RA.Widgets
var prereqs = buildable.Prerequisites var prereqs = buildable.Prerequisites
.Select( a => Description( a ) ); .Select( a => Description( a ) );
Game.Renderer.Fonts["Regular"].DrawText( Game.Renderer.Fonts["Regular"].DrawText(
"Requires {0}".F(prereqs.JoinWith(", ")), "{0} {1}".F(RequiresText, prereqs.JoinWith(", ")),
p.ToInt2(), p.ToInt2(),
Color.White); Color.White);

View File

@@ -20,6 +20,9 @@ namespace OpenRA.Mods.RA.Widgets
{ {
class SupportPowerBinWidget : Widget class SupportPowerBinWidget : Widget
{ {
public string ReadyText = "";
public string HoldText = "";
Dictionary<string, Sprite> spsprites; Dictionary<string, Sprite> spsprites;
Animation clock; Animation clock;
readonly List<Pair<Rectangle, Action<MouseInput>>> buttons = new List<Pair<Rectangle,Action<MouseInput>>>(); readonly List<Pair<Rectangle, Action<MouseInput>>> buttons = new List<Pair<Rectangle,Action<MouseInput>>>();
@@ -148,7 +151,7 @@ namespace OpenRA.Mods.RA.Widgets
WidgetUtils.DrawSHP(clock.Image, drawPos, worldRenderer); 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"]; var font = Game.Renderer.Fonts["TinyBold"];
if (overlay != null) if (overlay != null)
{ {

View File

@@ -87,6 +87,8 @@ Container@PLAYER_WIDGETS:
TooltipContainer:TOOLTIP_CONTAINER TooltipContainer:TOOLTIP_CONTAINER
X:10 X:10
Y:10 Y:10
ReadyText:Ready
HoldText:On Hold
Background@SIDEBAR_BACKGROUND: Background@SIDEBAR_BACKGROUND:
X:WINDOW_RIGHT - 204 X:WINDOW_RIGHT - 204
Y:30 Y:30
@@ -257,6 +259,8 @@ Container@PLAYER_WIDGETS:
X:WINDOW_RIGHT - 204 X:WINDOW_RIGHT - 204
Y:287 Y:287
TooltipContainer:TOOLTIP_CONTAINER TooltipContainer:TOOLTIP_CONTAINER
ReadyText:Ready
HoldText:On Hold
Background@FMVPLAYER: Background@FMVPLAYER:
Width:WINDOW_RIGHT Width:WINDOW_RIGHT
Height:WINDOW_BOTTOM Height:WINDOW_BOTTOM

View File

@@ -53,11 +53,16 @@ Container@INGAME_ROOT:
SupportPowerBin@INGAME_POWERS_BIN: SupportPowerBin@INGAME_POWERS_BIN:
X:0 X:0
Y:25 Y:25
ReadyText: READY
HoldText: ON HOLD
BuildPalette@INGAME_BUILD_PALETTE: BuildPalette@INGAME_BUILD_PALETTE:
X:WINDOW_RIGHT - 250 X:WINDOW_RIGHT - 250
Y:280 Y:280
Width:250 Width:250
Height:500 Height:500
ReadyText: READY
HoldText: ON HOLD
RequiresText: Requires
Button@INGAME_OPTIONS_BUTTON: Button@INGAME_OPTIONS_BUTTON:
X:0 X:0
Y:0 Y:0