Cache offsets in ProductionPaletteWidget
At least those that never change.
This commit is contained in:
@@ -113,7 +113,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
readonly WorldRenderer worldRenderer;
|
readonly WorldRenderer worldRenderer;
|
||||||
|
|
||||||
SpriteFont overlayFont, symbolFont;
|
SpriteFont overlayFont, symbolFont;
|
||||||
float2 holdOffset, readyOffset, timeOffset, queuedOffset, infiniteOffset;
|
float2 iconOffset, holdOffset, readyOffset, timeOffset, queuedOffset, infiniteOffset;
|
||||||
|
|
||||||
[CustomLintableHotkeyNames]
|
[CustomLintableHotkeyNames]
|
||||||
public static IEnumerable<string> LinterHotkeyNames(MiniYamlNode widgetNode, Action<string> emitError, Action<string> emitWarning)
|
public static IEnumerable<string> LinterHotkeyNames(MiniYamlNode widgetNode, Action<string> emitError, Action<string> emitWarning)
|
||||||
@@ -162,6 +162,16 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
overlayFont = Game.Renderer.Fonts[OverlayFont];
|
overlayFont = Game.Renderer.Fonts[OverlayFont];
|
||||||
Game.Renderer.Fonts.TryGetValue(SymbolsFont, out symbolFont);
|
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;
|
||||||
|
else
|
||||||
|
infiniteOffset = queuedOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void ScrollDown()
|
public void ScrollDown()
|
||||||
@@ -463,17 +473,7 @@ namespace OpenRA.Mods.Common.Widgets
|
|||||||
|
|
||||||
public override void Draw()
|
public override void Draw()
|
||||||
{
|
{
|
||||||
var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;
|
|
||||||
|
|
||||||
timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0, World.Timestep)) / 2;
|
timeOffset = iconOffset - overlayFont.Measure(WidgetUtils.FormatTime(0, World.Timestep)) / 2;
|
||||||
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;
|
|
||||||
else
|
|
||||||
infiniteOffset = queuedOffset;
|
|
||||||
|
|
||||||
if (CurrentQueue == null)
|
if (CurrentQueue == null)
|
||||||
return;
|
return;
|
||||||
|
|||||||
Reference in New Issue
Block a user