From 6f44f8a1ad0a64a142043ea97eb806836519df76 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 24 Jan 2020 16:27:49 +0900 Subject: [PATCH] Ensure only run once when not current screen --- osu.Game/Screens/Menu/SongTicker.cs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/osu.Game/Screens/Menu/SongTicker.cs b/osu.Game/Screens/Menu/SongTicker.cs index c3569b7ccb..4323d639c4 100644 --- a/osu.Game/Screens/Menu/SongTicker.cs +++ b/osu.Game/Screens/Menu/SongTicker.cs @@ -1,4 +1,4 @@ -// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. using osu.Framework.Allocation; @@ -22,6 +22,8 @@ public class SongTicker : Container private readonly OsuSpriteText title, artist; + public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks; + public SongTicker() { AutoSizeAxes = Axes.Both; @@ -51,19 +53,20 @@ public SongTicker() protected override void LoadComplete() { base.LoadComplete(); - beatmap.BindValueChanged(onBeatmapChanged); + + beatmap.BindValueChanged(_ => Scheduler.AddOnce(show), true); } - private void onBeatmapChanged(ValueChangedEvent working) + private void show() { var metadata = beatmap.Value.Metadata; - var metadata = working.NewValue.Metadata; - title.Text = new LocalisedString((metadata.TitleUnicode, metadata.Title)); artist.Text = new LocalisedString((metadata.ArtistUnicode, metadata.Artist)); - this.FadeIn(fade_duration, Easing.OutQuint).Delay(4000).Then().FadeOut(fade_duration, Easing.OutQuint); + this.FadeInFromZero(fade_duration) + .Delay(4000) + .Then().FadeOut(fade_duration); } } }