From c297cd4cd63cfe56570787f5d3cdf8033a728715 Mon Sep 17 00:00:00 2001 From: goaaats Date: Thu, 23 Jun 2022 14:05:27 +0200 Subject: [PATCH] chore: only load game font for credits OnOpen --- .../Internal/Windows/CreditsWindow.cs | 29 ++++++++++++------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/CreditsWindow.cs b/Dalamud/Interface/Internal/Windows/CreditsWindow.cs index 43860a548..112c0ccb8 100644 --- a/Dalamud/Interface/Internal/Windows/CreditsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/CreditsWindow.cs @@ -104,6 +104,7 @@ Truci Haplo Franz aers +philpax We use these awesome libraries: @@ -144,10 +145,10 @@ Contribute at: https://github.com/goatsoft/Dalamud private readonly TextureWrap logoTexture; private readonly Stopwatch creditsThrottler; - private readonly GameFontHandle thankYouFont; private string creditsText; + private GameFontHandle? thankYouFont; private const string thankYouText = "Thank you!"; /// @@ -168,9 +169,6 @@ Contribute at: https://github.com/goatsoft/Dalamud this.PositionCondition = ImGuiCond.Always; this.BgAlpha = 0.8f; - - var gfm = Service.Get(); - this.thankYouFont = gfm.NewFontRef(new GameFontStyle(GameFontFamilyAndSize.TrumpGothic34)); } /// @@ -183,8 +181,14 @@ Contribute at: https://github.com/goatsoft/Dalamud this.creditsText = string.Format(CreditsTextTempl, typeof(Dalamud).Assembly.GetName().Version, pluginCredits, Util.GetGitHashClientStructs()); - Service.Get().SetBgm(132); + Service.Get().SetBgm(833); this.creditsThrottler.Restart(); + + if (this.thankYouFont == null) + { + var gfm = Service.Get(); + this.thankYouFont = gfm.NewFontRef(new GameFontStyle(GameFontFamilyAndSize.TrumpGothic34)); + } } /// @@ -244,14 +248,17 @@ Contribute at: https://github.com/goatsoft/Dalamud ImGuiHelpers.ScaledDummy(0, 40f); - ImGui.PushFont(this.thankYouFont.ImFont); - var thankYouLenX = ImGui.CalcTextSize(thankYouText).X; + if (this.thankYouFont != null) + { + ImGui.PushFont(this.thankYouFont.ImFont); + var thankYouLenX = ImGui.CalcTextSize(thankYouText).X; - ImGui.Dummy(new Vector2((windowX / 2) - (thankYouLenX / 2), 0f)); - ImGui.SameLine(); - ImGui.TextUnformatted(thankYouText); + ImGui.Dummy(new Vector2((windowX / 2) - (thankYouLenX / 2), 0f)); + ImGui.SameLine(); + ImGui.TextUnformatted(thankYouText); - ImGui.PopFont(); + ImGui.PopFont(); + } ImGuiHelpers.ScaledDummy(0, windowSize.Y + 50f);