From 8f2cd0e8c55178b75315c912d1c4eeb25e1d5f08 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 2 Nov 2020 15:01:30 +0900 Subject: [PATCH] Add matching requestedByUser parameter to Play method --- osu.Game/Overlays/MusicController.cs | 13 ++++++++++--- osu.Game/Screens/Select/SongSelect.cs | 3 ++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/osu.Game/Overlays/MusicController.cs b/osu.Game/Overlays/MusicController.cs index eafbeebbc9..d78f387b30 100644 --- a/osu.Game/Overlays/MusicController.cs +++ b/osu.Game/Overlays/MusicController.cs @@ -166,10 +166,17 @@ public void EnsurePlayingSomething() /// /// Start playing the current track (if not already playing). /// + /// Whether to restart the track from the beginning. + /// + /// Whether the request to play was issued by the user rather than internally. + /// Specifying true will ensure that other methods like + /// will resume music playback going forward. + /// /// Whether the operation was successful. - public bool Play(bool restart = false) + public bool Play(bool restart = false, bool requestedByUser = false) { - IsUserPaused = false; + if (requestedByUser) + IsUserPaused = false; if (restart) CurrentTrack.Restart(); @@ -203,7 +210,7 @@ public bool TogglePause() if (CurrentTrack.IsRunning) Stop(true); else - Play(); + Play(requestedByUser: true); return true; } diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index a85e1869be..0473efd404 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -579,7 +579,8 @@ public override void OnResuming(IScreen last) updateComponentFromBeatmap(Beatmap.Value); // restart playback on returning to song select, regardless. - music.Play(); + // not sure this should be a permanent thing (we may want to leave a user pause paused even on returning) + music.Play(requestedByUser: true); } this.FadeIn(250);