1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 16:52:54 +08:00

Fix behavioural regression by splitting methods out

This commit is contained in:
Dean Herbert 2020-07-10 18:03:56 +09:00
parent 44fdb5b82e
commit 1760cc2427
3 changed files with 27 additions and 13 deletions

View File

@ -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,15 +167,9 @@ namespace osu.Game.Overlays
IsUserPaused = false;
if (track == null || track is TrackVirtual)
{
if (beatmap.Disabled)
if (track == null)
return false;
next();
return true;
}
if (restart)
track.Restart();
else if (!IsPlaying)

View File

@ -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)

View File

@ -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();
}