chore: only load game font for credits OnOpen

This commit is contained in:
goaaats 2022-06-23 14:05:27 +02:00
parent 5b493b0043
commit c297cd4cd6
No known key found for this signature in database
GPG key ID: 49E2AA8C6A76498B

View file

@ -104,6 +104,7 @@ Truci
Haplo Haplo
Franz Franz
aers aers
philpax
We use these awesome libraries: We use these awesome libraries:
@ -144,10 +145,10 @@ Contribute at: https://github.com/goatsoft/Dalamud
private readonly TextureWrap logoTexture; private readonly TextureWrap logoTexture;
private readonly Stopwatch creditsThrottler; private readonly Stopwatch creditsThrottler;
private readonly GameFontHandle thankYouFont;
private string creditsText; private string creditsText;
private GameFontHandle? thankYouFont;
private const string thankYouText = "Thank you!"; private const string thankYouText = "Thank you!";
/// <summary> /// <summary>
@ -168,9 +169,6 @@ Contribute at: https://github.com/goatsoft/Dalamud
this.PositionCondition = ImGuiCond.Always; this.PositionCondition = ImGuiCond.Always;
this.BgAlpha = 0.8f; this.BgAlpha = 0.8f;
var gfm = Service<GameFontManager>.Get();
this.thankYouFont = gfm.NewFontRef(new GameFontStyle(GameFontFamilyAndSize.TrumpGothic34));
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -183,8 +181,14 @@ Contribute at: https://github.com/goatsoft/Dalamud
this.creditsText = string.Format(CreditsTextTempl, typeof(Dalamud).Assembly.GetName().Version, pluginCredits, Util.GetGitHashClientStructs()); this.creditsText = string.Format(CreditsTextTempl, typeof(Dalamud).Assembly.GetName().Version, pluginCredits, Util.GetGitHashClientStructs());
Service<GameGui>.Get().SetBgm(132); Service<GameGui>.Get().SetBgm(833);
this.creditsThrottler.Restart(); this.creditsThrottler.Restart();
if (this.thankYouFont == null)
{
var gfm = Service<GameFontManager>.Get();
this.thankYouFont = gfm.NewFontRef(new GameFontStyle(GameFontFamilyAndSize.TrumpGothic34));
}
} }
/// <inheritdoc/> /// <inheritdoc/>
@ -244,14 +248,17 @@ Contribute at: https://github.com/goatsoft/Dalamud
ImGuiHelpers.ScaledDummy(0, 40f); ImGuiHelpers.ScaledDummy(0, 40f);
ImGui.PushFont(this.thankYouFont.ImFont); if (this.thankYouFont != null)
var thankYouLenX = ImGui.CalcTextSize(thankYouText).X; {
ImGui.PushFont(this.thankYouFont.ImFont);
var thankYouLenX = ImGui.CalcTextSize(thankYouText).X;
ImGui.Dummy(new Vector2((windowX / 2) - (thankYouLenX / 2), 0f)); ImGui.Dummy(new Vector2((windowX / 2) - (thankYouLenX / 2), 0f));
ImGui.SameLine(); ImGui.SameLine();
ImGui.TextUnformatted(thankYouText); ImGui.TextUnformatted(thankYouText);
ImGui.PopFont(); ImGui.PopFont();
}
ImGuiHelpers.ScaledDummy(0, windowSize.Y + 50f); ImGuiHelpers.ScaledDummy(0, windowSize.Y + 50f);