customisable Ready/Hold text for CnC mod
make those strings also translatable
This commit is contained in:
@@ -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<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()
|
||||
@@ -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)
|
||||
|
||||
@@ -23,6 +23,9 @@ namespace OpenRA.Mods.Cnc.Widgets
|
||||
{
|
||||
public int Spacing = 10;
|
||||
|
||||
public readonly string ReadyText = "";
|
||||
public readonly string HoldText = "";
|
||||
|
||||
Dictionary<string, Sprite> iconSprites;
|
||||
Animation clock;
|
||||
Dictionary<Rectangle, SupportPowerIcon> Icons = new Dictionary<Rectangle, SupportPowerIcon>();
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user