Ensure only run once when not current screen

This commit is contained in:
Dean Herbert 2020-01-24 16:27:49 +09:00
parent f9a54dfb1d
commit 6f44f8a1ad
1 changed files with 9 additions and 6 deletions

View File

@ -1,4 +1,4 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<WorkingBeatmap> 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);
}
}
}