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:
commit
a86bc344da
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user