From c21b7c7df994fa6a00a3edf7bc79653035bbaa8c Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 2 May 2024 22:46:42 -0700 Subject: [PATCH] Use `IsLoaded` instead of `Schedule` --- osu.Game/Overlays/NowPlayingOverlay.cs | 35 ++++++++++++++++++++------ 1 file changed, 28 insertions(+), 7 deletions(-) diff --git a/osu.Game/Overlays/NowPlayingOverlay.cs b/osu.Game/Overlays/NowPlayingOverlay.cs index 8f97ce50cc..744d32ff7e 100644 --- a/osu.Game/Overlays/NowPlayingOverlay.cs +++ b/osu.Game/Overlays/NowPlayingOverlay.cs @@ -476,29 +476,35 @@ namespace osu.Game.Overlays private const float initial_move_delay = 1000; private const float pixels_per_second = 50; - private LocalisableString text; private OsuSpriteText mainSpriteText = null!; private OsuSpriteText fillerSpriteText = null!; + private LocalisableString text; + public LocalisableString Text { get => text; set { text = value; - Schedule(updateText); + + if (IsLoaded) + updateText(); } } + private FontUsage font = OsuFont.Default; + public FontUsage Font { - set => Schedule(() => + get => font; + set { - mainSpriteText.Font = value; - fillerSpriteText.Font = value; + font = value; - updateText(); - }); + if (IsLoaded) + updateFontAndText(); + } } public ScrollingTextContainer() @@ -521,6 +527,21 @@ namespace osu.Game.Overlays }; } + protected override void LoadComplete() + { + base.LoadComplete(); + + updateFontAndText(); + } + + private void updateFontAndText() + { + mainSpriteText.Font = font; + fillerSpriteText.Font = font; + + updateText(); + } + private void updateText() { mainSpriteText.Text = text;