1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Merge pull request #16977 from peppy/pause-at-results

Allow pausing audio via hotkey at multiplayer lobby and results screen
This commit is contained in:
Dan Balasescu 2022-02-25 19:13:06 +09:00 committed by GitHub
commit a86bc344da
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -30,17 +30,20 @@ namespace osu.Game.Overlays.Music
[Resolved(canBeNull: true)]
private OnScreenDisplay onScreenDisplay { get; set; }
[Resolved]
private OsuGame game { get; set; }
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (e.Repeat)
return false;
if (beatmap.Disabled)
return false;
switch (e.Action)
{
case GlobalAction.MusicPlay:
if (game.LocalUserPlaying.Value)
return false;
// use previous state as TogglePause may not update the track's state immediately (state update is run on the audio thread see https://github.com/ppy/osu/issues/9880#issuecomment-674668842)
bool wasPlaying = musicController.IsPlaying;
@ -49,11 +52,17 @@ namespace osu.Game.Overlays.Music
return true;
case GlobalAction.MusicNext:
if (beatmap.Disabled)
return false;
musicController.NextTrack(() => onScreenDisplay?.Display(new MusicActionToast(GlobalActionKeyBindingStrings.MusicNext, e.Action)));
return true;
case GlobalAction.MusicPrev:
if (beatmap.Disabled)
return false;
musicController.PreviousTrack(res =>
{
switch (res)