1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 22:27:25 +08:00

restart correctly when leaving player (without noises)

This commit is contained in:
Unknown 2019-01-31 12:24:47 +01:00
parent e2347ae7bf
commit 8c1f8ee596
2 changed files with 8 additions and 6 deletions

View File

@ -385,6 +385,9 @@ namespace osu.Game.Screens.Play
if ((!AllowPause || HasFailed || !ValidForResume || pauseContainer?.IsPaused != false || RulesetContainer?.HasReplayLoaded != false) && (!pauseContainer?.IsResuming ?? true))
{
// Detaching so seeking in SongSelect while we are fading out doesn't cause noises because we are trying to stay in sync
adjustableClock.ChangeSource(new StopwatchClock());
// In the case of replays, we may have changed the playback rate.
applyRateFromMods();

View File

@ -411,7 +411,7 @@ namespace osu.Game.Screens.Select
}
if (this.IsCurrentScreen())
ensurePlayingSelected(true);
ensurePlayingSelected();
UpdateBeatmap(Beatmap.Value);
}
@ -485,7 +485,7 @@ namespace osu.Game.Screens.Select
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
{
UpdateBeatmap(Beatmap.Value);
ensurePlayingSelected();
ensurePlayingSelected(true);
}
base.OnResuming(last);
@ -575,16 +575,15 @@ namespace osu.Game.Screens.Select
beatmap.Track.Looping = true;
}
private void ensurePlayingSelected(bool preview = false)
private void ensurePlayingSelected(bool restart = false)
{
Track track = Beatmap.Value.Track;
if (!track.IsRunning)
if (!track.IsRunning || restart)
{
// Ensure the track is added to the TrackManager, since it is removed after the player finishes the map.
// Using AddItemToList rather than AddItem so that it doesn't attempt to register adjustment dependencies more than once.
Game.Audio.Track.AddItemToList(track);
if (preview)
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
track.Restart();
}