From 1760cc242730fb1998135a79bd74586f63fc79f1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 10 Jul 2020 18:03:56 +0900 Subject: [PATCH] Fix behavioural regression by splitting methods out --- osu.Game/Overlays/MusicController.cs | 34 ++++++++++++++----- osu.Game/Screens/Menu/MainMenu.cs | 3 +- .../Screens/Multi/Lounge/LoungeSubScreen.cs | 3 +- 3 files changed, 27 insertions(+), 13 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index 63e828a782..09f2a66b47 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -134,9 +134,31 @@ namespace osu.Game.Overlays }); } + /// + /// 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 ) a new beatmap will be selected. + /// + 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(); + } + } + /// /// Start playing the current track (if not already playing). - /// Will select the next valid track if the current track is null or . /// /// Whether the operation was successful. 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(); diff --git a/osu.Game/Screens/Menu/MainMenu.cs b/osu.Game/Screens/Menu/MainMenu.cs index 41e2564141..57252d557e 100644 --- a/osu.Game/Screens/Menu/MainMenu.cs +++ b/osu.Game/Screens/Menu/MainMenu.cs @@ -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) diff --git a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs index e2ffb21153..ff7d56a95b 100644 --- a/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs +++ b/osu.Game/Screens/Multi/Lounge/LoungeSubScreen.cs @@ -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(); }