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 IconMargin = int2.Zero;
|
||||||
public readonly int2 IconSpriteOffset = 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 ClickSound = ChromeMetrics.Get<string>("ClickSound");
|
||||||
public readonly string ClickDisabledSound = ChromeMetrics.Get<string>("ClickDisabledSound");
|
public readonly string ClickDisabledSound = ChromeMetrics.Get<string>("ClickDisabledSound");
|
||||||
public readonly string TooltipContainer;
|
public readonly string TooltipContainer;
|
||||||
@@ -119,7 +122,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
readonly WorldRenderer worldRenderer;
|
readonly WorldRenderer worldRenderer;
|
||||||
|
|
||||||
SpriteFont overlayFont, symbolFont;
|
SpriteFont overlayFont, symbolFont;
|
||||||
float2 iconOffset, holdOffset, readyOffset, timeOffset, queuedOffset, infiniteOffset;
|
float2 iconOffset, holdOffset, readyOffset, timeOffset, infiniteOffset;
|
||||||
|
|
||||||
Player cachedQueueOwner;
|
Player cachedQueueOwner;
|
||||||
IProductionIconOverlay[] pios;
|
IProductionIconOverlay[] pios;
|
||||||
@@ -172,14 +175,13 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
Game.Renderer.Fonts.TryGetValue(SymbolsFont, out symbolFont);
|
Game.Renderer.Fonts.TryGetValue(SymbolsFont, out symbolFont);
|
||||||
|
|
||||||
iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;
|
iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;
|
||||||
queuedOffset = new float2(4, 2);
|
|
||||||
holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2;
|
holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2;
|
||||||
readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2;
|
readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2;
|
||||||
|
|
||||||
if (ChromeMetrics.TryGet("InfiniteOffset", out infiniteOffset))
|
if (ChromeMetrics.TryGet("InfiniteOffset", out infiniteOffset))
|
||||||
infiniteOffset += queuedOffset;
|
infiniteOffset += QueuedOffset;
|
||||||
else
|
else
|
||||||
infiniteOffset = queuedOffset;
|
infiniteOffset = QueuedOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScrollDown()
|
public void ScrollDown()
|
||||||
@@ -578,12 +580,24 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
icon.Pos + infiniteOffset,
|
icon.Pos + infiniteOffset,
|
||||||
TextColor, Color.Black, 1);
|
TextColor, Color.Black, 1);
|
||||||
else if (total > 1 || waiting)
|
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(),
|
overlayFont.DrawTextWithContrast(total.ToString(),
|
||||||
icon.Pos + queuedOffset,
|
icon.Pos + pos,
|
||||||
TextColor, Color.Black, 1);
|
TextColor, Color.Black, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override string GetCursor(int2 pos)
|
public override string GetCursor(int2 pos)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user