ProductionPaletteWidget: offset and align for queued count is now customizable
This commit is contained in:
committed by
Matthias Mailänder
parent
6bedc4697b
commit
e64c0a35c5
@@ -48,6 +48,9 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public readonly int2 IconMargin = int2.Zero;
|
||||
public readonly int2 IconSpriteOffset = int2.Zero;
|
||||
|
||||
public readonly float2 QueuedOffset = new float2(4, 2);
|
||||
public readonly TextAlign QueuedTextAlign = TextAlign.Left;
|
||||
|
||||
public readonly string ClickSound = ChromeMetrics.Get<string>("ClickSound");
|
||||
public readonly string ClickDisabledSound = ChromeMetrics.Get<string>("ClickDisabledSound");
|
||||
public readonly string TooltipContainer;
|
||||
@@ -119,7 +122,7 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
readonly WorldRenderer worldRenderer;
|
||||
|
||||
SpriteFont overlayFont, symbolFont;
|
||||
float2 iconOffset, holdOffset, readyOffset, timeOffset, queuedOffset, infiniteOffset;
|
||||
float2 iconOffset, holdOffset, readyOffset, timeOffset, infiniteOffset;
|
||||
|
||||
Player cachedQueueOwner;
|
||||
IProductionIconOverlay[] pios;
|
||||
@@ -172,14 +175,13 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
Game.Renderer.Fonts.TryGetValue(SymbolsFont, out symbolFont);
|
||||
|
||||
iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;
|
||||
queuedOffset = new float2(4, 2);
|
||||
holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2;
|
||||
readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2;
|
||||
|
||||
if (ChromeMetrics.TryGet("InfiniteOffset", out infiniteOffset))
|
||||
infiniteOffset += queuedOffset;
|
||||
infiniteOffset += QueuedOffset;
|
||||
else
|
||||
infiniteOffset = queuedOffset;
|
||||
infiniteOffset = QueuedOffset;
|
||||
}
|
||||
|
||||
public void ScrollDown()
|
||||
@@ -578,9 +580,21 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
icon.Pos + infiniteOffset,
|
||||
TextColor, Color.Black, 1);
|
||||
else if (total > 1 || waiting)
|
||||
{
|
||||
var pos = QueuedOffset;
|
||||
if (QueuedTextAlign != TextAlign.Left)
|
||||
{
|
||||
var size = overlayFont.Measure(total.ToString());
|
||||
|
||||
pos = QueuedTextAlign == TextAlign.Center ?
|
||||
new float2(QueuedOffset.X - size.X / 2, QueuedOffset.Y) :
|
||||
new float2(QueuedOffset.X - size.X, QueuedOffset.Y);
|
||||
}
|
||||
|
||||
overlayFont.DrawTextWithContrast(total.ToString(),
|
||||
icon.Pos + queuedOffset,
|
||||
icon.Pos + pos,
|
||||
TextColor, Color.Black, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user