mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 14:25:05 +08:00
Fix behavioural regression by splitting methods out
This commit is contained in:
parent
44fdb5b82e
commit
1760cc2427
@ -134,9 +134,31 @@ namespace osu.Game.Overlays
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures music is playing, no matter what, unless the user has explicitly paused.
|
||||
/// This means that if the current beatmap has a virtual track (see <see cref="TrackVirtual"/>) a new beatmap will be selected.
|
||||
/// </summary>
|
||||
public void EnsurePlayingSomething()
|
||||
{
|
||||
if (IsUserPaused) return;
|
||||
|
||||
var track = current?.Track;
|
||||
|
||||
if (track == null || track is TrackVirtual)
|
||||
{
|
||||
if (beatmap.Disabled)
|
||||
return;
|
||||
|
||||
next();
|
||||
}
|
||||
else if (!IsPlaying)
|
||||
{
|
||||
Play();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start playing the current track (if not already playing).
|
||||
/// Will select the next valid track if the current track is null or <see cref="TrackVirtual"/>.
|
||||
/// </summary>
|
||||
/// <returns>Whether the operation was successful.</returns>
|
||||
public bool Play(bool restart = false)
|
||||
@ -145,14 +167,8 @@ namespace osu.Game.Overlays
|
||||
|
||||
IsUserPaused = false;
|
||||
|
||||
if (track == null || track is TrackVirtual)
|
||||
{
|
||||
if (beatmap.Disabled)
|
||||
return false;
|
||||
|
||||
next();
|
||||
return true;
|
||||
}
|
||||
if (track == null)
|
||||
return false;
|
||||
|
||||
if (restart)
|
||||
track.Restart();
|
||||
|
@ -260,8 +260,7 @@ namespace osu.Game.Screens.Menu
|
||||
// we may have consumed our preloaded instance, so let's make another.
|
||||
preloadSongSelect();
|
||||
|
||||
if (music?.IsUserPaused == false)
|
||||
music.Play();
|
||||
music.EnsurePlayingSomething();
|
||||
}
|
||||
|
||||
public override bool OnExiting(IScreen next)
|
||||
|
@ -126,8 +126,7 @@ namespace osu.Game.Screens.Multi.Lounge
|
||||
if (selectedRoom.Value?.RoomID.Value == null)
|
||||
selectedRoom.Value = new Room();
|
||||
|
||||
if (music?.IsUserPaused == false)
|
||||
music.Play();
|
||||
music.EnsurePlayingSomething();
|
||||
|
||||
onReturning();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user