mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 01:52:55 +08:00
Ensure only run once when not current screen
This commit is contained in:
parent
f9a54dfb1d
commit
6f44f8a1ad
@ -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 @@ namespace osu.Game.Screens.Menu
|
||||
|
||||
private readonly OsuSpriteText title, artist;
|
||||
|
||||
public override bool IsPresent => base.IsPresent || Scheduler.HasPendingTasks;
|
||||
|
||||
public SongTicker()
|
||||
{
|
||||
AutoSizeAxes = Axes.Both;
|
||||
@ -51,19 +53,20 @@ namespace osu.Game.Screens.Menu
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user