1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:03:22 +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)] [Resolved(canBeNull: true)]
private OnScreenDisplay onScreenDisplay { get; set; } private OnScreenDisplay onScreenDisplay { get; set; }
[Resolved]
private OsuGame game { get; set; }
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e) public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{ {
if (e.Repeat) if (e.Repeat)
return false; return false;
if (beatmap.Disabled)
return false;
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.MusicPlay: 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) // 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; bool wasPlaying = musicController.IsPlaying;
@ -49,11 +52,17 @@ namespace osu.Game.Overlays.Music
return true; return true;
case GlobalAction.MusicNext: case GlobalAction.MusicNext:
if (beatmap.Disabled)
return false;
musicController.NextTrack(() => onScreenDisplay?.Display(new MusicActionToast(GlobalActionKeyBindingStrings.MusicNext, e.Action))); musicController.NextTrack(() => onScreenDisplay?.Display(new MusicActionToast(GlobalActionKeyBindingStrings.MusicNext, e.Action)));
return true; return true;
case GlobalAction.MusicPrev: case GlobalAction.MusicPrev:
if (beatmap.Disabled)
return false;
musicController.PreviousTrack(res => musicController.PreviousTrack(res =>
{ {
switch (res) switch (res)