From 9d179d9a1a0132fcdc2807320acb3d6163ebd07e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthias=20Mail=C3=A4nder?= Date: Sun, 9 Aug 2020 13:50:14 +0200 Subject: [PATCH] Initialize the font only once and make it configurable. --- OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs index 20aed21a1f..4ab921e23f 100644 --- a/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs +++ b/OpenRA.Mods.Common/Widgets/SupportPowersWidget.cs @@ -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;