1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 07:42:57 +08:00

Use IsLoaded instead of Schedule

This commit is contained in:
Joseph Madamba 2024-05-02 22:46:42 -07:00
parent c15a685071
commit c21b7c7df9

View File

@ -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;