diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index 97f4a9771f..904aa9c8c0 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -50,6 +50,7 @@ public GlobalActionContainer(OsuGameBase game) { new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene), new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry), + new KeyBinding(new[] { InputKey.Control, InputKey.Tilde }, GlobalAction.QuickExit), new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed), new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed), }; @@ -94,6 +95,9 @@ public enum GlobalAction [Description("Quick retry (hold)")] QuickRetry, + [Description("Quick exit (Hold)")] + QuickExit, + [Description("Take screenshot")] TakeScreenshot, diff --git a/osu.Game/Screens/Play/HotkeyExitOverlay.cs b/osu.Game/Screens/Play/HotkeyExitOverlay.cs new file mode 100644 index 0000000000..c18aecda55 --- /dev/null +++ b/osu.Game/Screens/Play/HotkeyExitOverlay.cs @@ -0,0 +1,28 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Input.Bindings; +using osu.Game.Input.Bindings; +using osu.Game.Overlays; + +namespace osu.Game.Screens.Play +{ + public class HotkeyExitOverlay : HoldToConfirmOverlay, IKeyBindingHandler + { + public bool OnPressed(GlobalAction action) + { + if (action != GlobalAction.QuickExit) return false; + + BeginConfirm(); + return true; + } + + public bool OnReleased(GlobalAction action) + { + if (action != GlobalAction.QuickExit) return false; + + AbortConfirm(); + return true; + } + } +} diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index c3e351a0ca..c3a9ffdaba 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -177,6 +177,16 @@ private void load(AudioManager audio, IAPIProvider api, OsuConfigManager config) Restart(); }, }, + new HotkeyExitOverlay + { + Action = () => + { + if (!this.IsCurrentScreen()) return; + + fadeOut(true); + performUserRequestedExit(); + }, + }, failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, } }; @@ -245,6 +255,11 @@ private void performUserRequestedExit() { if (!this.IsCurrentScreen()) return; + // if a restart has been requested, cancel any pending completion (user has shown intent to restart). + onCompletionEvent = null; + + ValidForResume = false; + this.Exit(); }