Better Service dependency handling (#1535)

This commit is contained in:
srkizer 2023-11-29 06:20:16 +09:00 committed by GitHub
parent fcebd15077
commit b66be84b93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 415 additions and 197 deletions

View file

@ -67,7 +67,7 @@ internal sealed class ChangelogWindow : Window, IDisposable
// If we are going to show a changelog, make sure we have the font ready, otherwise it will hitch
if (WarrantsChangelog())
this.MakeFont();
Service<GameFontManager>.GetAsync().ContinueWith(t => this.MakeFont(t.Result));
}
private enum State
@ -98,7 +98,7 @@ internal sealed class ChangelogWindow : Window, IDisposable
Service<DalamudInterface>.Get().SetCreditsDarkeningAnimation(true);
this.tsmWindow.AllowDrawing = false;
this.MakeFont();
this.MakeFont(Service<GameFontManager>.Get());
this.state = State.WindowFadeIn;
this.windowFade.Reset();
@ -379,12 +379,6 @@ internal sealed class ChangelogWindow : Window, IDisposable
this.logoTexture.Dispose();
}
private void MakeFont()
{
if (this.bannerFont == null)
{
var gfm = Service<GameFontManager>.Get();
this.bannerFont = gfm.NewFontRef(new GameFontStyle(GameFontFamilyAndSize.MiedingerMid18));
}
}
private void MakeFont(GameFontManager gfm) =>
this.bannerFont ??= gfm.NewFontRef(new GameFontStyle(GameFontFamilyAndSize.MiedingerMid18));
}