Merge pull request #10660 from peppy/fix-song-select-first-track-looping

Fix looping mode not being set on first track after entering song select
This commit is contained in:
Dan Balasescu 2020-11-04 14:37:27 +09:00 committed by GitHub
commit 98c992004b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 27 additions and 7 deletions

View File

@ -37,6 +37,7 @@
using osu.Game.Collections;
using osu.Game.Graphics.UserInterface;
using osu.Game.Scoring;
using System.Diagnostics;
namespace osu.Game.Screens.Select
{
@ -519,7 +520,7 @@ public override void OnEntering(IScreen last)
ModSelect.SelectedMods.BindTo(selectedMods);
music.TrackChanged += ensureTrackLooping;
beginLooping();
}
private const double logo_transition = 250;
@ -570,8 +571,7 @@ public override void OnResuming(IScreen last)
BeatmapDetails.Refresh();
music.CurrentTrack.Looping = true;
music.TrackChanged += ensureTrackLooping;
beginLooping();
music.ResetTrackAdjustments();
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
@ -597,8 +597,7 @@ public override void OnSuspending(IScreen next)
BeatmapOptions.Hide();
music.CurrentTrack.Looping = false;
music.TrackChanged -= ensureTrackLooping;
endLooping();
this.ScaleTo(1.1f, 250, Easing.InSine);
@ -619,12 +618,33 @@ public override bool OnExiting(IScreen next)
FilterControl.Deactivate();
music.CurrentTrack.Looping = false;
music.TrackChanged -= ensureTrackLooping;
endLooping();
return false;
}
private bool isHandlingLooping;
private void beginLooping()
{
Debug.Assert(!isHandlingLooping);
music.CurrentTrack.Looping = isHandlingLooping = true;
music.TrackChanged += ensureTrackLooping;
}
private void endLooping()
{
// may be called multiple times during screen exit process.
if (!isHandlingLooping)
return;
music.CurrentTrack.Looping = isHandlingLooping = false;
music.TrackChanged -= ensureTrackLooping;
}
private void ensureTrackLooping(WorkingBeatmap beatmap, TrackChangeDirection changeDirection)
=> music.CurrentTrack.Looping = true;