Initialize the font only once and make it configurable.
This commit is contained in:
committed by
Paul Chote
parent
15010f9567
commit
9d179d9a1a
@@ -28,6 +28,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
[Translate]
|
||||
public readonly string HoldText = "";
|
||||
|
||||
public readonly string OverlayFont = "TinyBold";
|
||||
|
||||
public readonly int2 IconSize = new int2(64, 48);
|
||||
public readonly int IconMargin = 10;
|
||||
public readonly int2 IconSpriteOffset = int2.Zero;
|
||||
@@ -107,6 +109,8 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
|
||||
hotkeys = Exts.MakeArray(HotkeyCount,
|
||||
i => modData.Hotkeys[HotkeyPrefix + (i + 1).ToString("D2")]);
|
||||
|
||||
overlayFont = Game.Renderer.Fonts[OverlayFont];
|
||||
}
|
||||
|
||||
public class SupportPowerIcon
|
||||
@@ -191,7 +195,6 @@ namespace OpenRA.Mods.Common.Widgets
|
||||
public override void Draw()
|
||||
{
|
||||
var iconOffset = 0.5f * IconSize.ToFloat2() + IconSpriteOffset;
|
||||
overlayFont = Game.Renderer.Fonts["TinyBold"];
|
||||
|
||||
holdOffset = iconOffset - overlayFont.Measure(HoldText) / 2;
|
||||
readyOffset = iconOffset - overlayFont.Measure(ReadyText) / 2;
|
||||
|
||||
Reference in New Issue
Block a user