1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 06:42:54 +08:00

Consume new method in existing usages (and remove some unnecessary set/unset code)

This commit is contained in:
Dean Herbert 2021-02-18 15:01:11 +09:00
parent dfedea9ea2
commit 421cdb6650
3 changed files with 10 additions and 15 deletions

View File

@ -179,14 +179,15 @@ namespace osu.Game.Screens.Menu
base.OnEntering(last);
buttons.FadeInFromZero(500);
var metadata = Beatmap.Value.Metadata;
if (last is IntroScreen && musicController.TrackLoaded)
{
if (!musicController.CurrentTrack.IsRunning)
var track = musicController.CurrentTrack;
// presume the track is the current beatmap's track. not sure how correct this assumption is but it has worked until now.
if (!track.IsRunning)
{
musicController.CurrentTrack.Seek(metadata.PreviewTime != -1 ? metadata.PreviewTime : 0.4f * musicController.CurrentTrack.Length);
musicController.CurrentTrack.Start();
Beatmap.Value.PrepareTrackForPreviewLooping();
track.Restart();
}
}

View File

@ -173,9 +173,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
if (track != null)
{
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
track.Looping = true;
Beatmap.Value.PrepareTrackForPreviewLooping();
music?.EnsurePlayingSomething();
}
}
@ -185,10 +183,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
var track = Beatmap?.Value?.Track;
if (track != null)
{
track.Looping = false;
track.RestartPoint = 0;
}
}
}
}

View File

@ -648,8 +648,9 @@ namespace osu.Game.Screens.Select
{
Debug.Assert(!isHandlingLooping);
music.CurrentTrack.Looping = isHandlingLooping = true;
isHandlingLooping = true;
ensureTrackLooping(Beatmap.Value, TrackChangeDirection.None);
music.TrackChanged += ensureTrackLooping;
}
@ -665,7 +666,7 @@ namespace osu.Game.Screens.Select
}
private void ensureTrackLooping(WorkingBeatmap beatmap, TrackChangeDirection changeDirection)
=> music.CurrentTrack.Looping = true;
=> beatmap.PrepareTrackForPreviewLooping();
public override bool OnBackButton()
{
@ -719,8 +720,6 @@ namespace osu.Game.Screens.Select
bool isNewTrack = !lastTrack.TryGetTarget(out var last) || last != track;
track.RestartPoint = Beatmap.Value.Metadata.PreviewTime;
if (!track.IsRunning && (music.UserPauseRequested != true || isNewTrack))
music.Play(true);