1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-15 07:22:55 +08:00

Centralise into methods and add assertions for safety

This commit is contained in:
Dean Herbert 2020-11-03 00:45:55 +09:00
parent c3d3856a64
commit d5c95a8b46

View File

@ -37,6 +37,7 @@ using osu.Framework.Input.Bindings;
using osu.Game.Collections;
using osu.Game.Graphics.UserInterface;
using osu.Game.Scoring;
using System.Diagnostics;
namespace osu.Game.Screens.Select
{
@ -519,8 +520,7 @@ namespace osu.Game.Screens.Select
ModSelect.SelectedMods.BindTo(selectedMods);
music.CurrentTrack.Looping = true;
music.TrackChanged += ensureTrackLooping;
beginLooping();
}
private const double logo_transition = 250;
@ -571,8 +571,7 @@ namespace osu.Game.Screens.Select
BeatmapDetails.Refresh();
music.CurrentTrack.Looping = true;
music.TrackChanged += ensureTrackLooping;
beginLooping();
music.ResetTrackAdjustments();
if (Beatmap != null && !Beatmap.Value.BeatmapSetInfo.DeletePending)
@ -598,8 +597,7 @@ namespace osu.Game.Screens.Select
BeatmapOptions.Hide();
music.CurrentTrack.Looping = false;
music.TrackChanged -= ensureTrackLooping;
endLooping();
this.ScaleTo(1.1f, 250, Easing.InSine);
@ -620,12 +618,30 @@ namespace osu.Game.Screens.Select
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()
{
Debug.Assert(isHandlingLooping);
music.CurrentTrack.Looping = isHandlingLooping = false;
music.TrackChanged -= ensureTrackLooping;
}
private void ensureTrackLooping(WorkingBeatmap beatmap, TrackChangeDirection changeDirection)
=> music.CurrentTrack.Looping = true;