diff --git a/osu.Game/Input/Bindings/GlobalActionContainer.cs b/osu.Game/Input/Bindings/GlobalActionContainer.cs index b21deff509..f4419cc6d0 100644 --- a/osu.Game/Input/Bindings/GlobalActionContainer.cs +++ b/osu.Game/Input/Bindings/GlobalActionContainer.cs @@ -49,6 +49,7 @@ namespace osu.Game.Input.Bindings { new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene), new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry), + new KeyBinding(new[] { InputKey.Alt, InputKey.Tilde }, GlobalAction.QuickExit), new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed), new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed), }; @@ -83,6 +84,8 @@ namespace osu.Game.Input.Bindings SkipCutscene, [Description("Quick Retry (Hold)")] QuickRetry, + [Description("Quick Exit (Hold)")] + QuickExit, [Description("Take screenshot")] TakeScreenshot, diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index b406bda411..84fcede6b5 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -71,6 +71,7 @@ namespace osu.Game.Screens.Play private APIAccess api; private SampleChannel sampleRestart; + private SampleChannel sampleExit; protected ScoreProcessor ScoreProcessor; protected RulesetContainer RulesetContainer; @@ -93,6 +94,7 @@ namespace osu.Game.Screens.Play return; sampleRestart = audio.Sample.Get(@"Gameplay/restart"); + sampleExit = audio.Sample.Get(@"UI/screen-back"); mouseWheelDisabled = config.GetBindable(OsuSetting.MouseDisableWheel); userAudioOffset = config.GetBindable(OsuSetting.AudioOffset); @@ -224,6 +226,17 @@ namespace osu.Game.Screens.Play RulesetContainer?.Hide(); Restart(); }, + }, + new QuickExit + { + Action = () => + { + if (!IsCurrentScreen) return; + + sampleExit?.Play(); + ValidForResume = false; + Exit(); + } } }; diff --git a/osu.Game/Screens/Play/QuickExit.cs b/osu.Game/Screens/Play/QuickExit.cs new file mode 100644 index 0000000000..611b02c543 --- /dev/null +++ b/osu.Game/Screens/Play/QuickExit.cs @@ -0,0 +1,28 @@ +// Copyright (c) 2007-2018 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCEusing System; + +using osu.Framework.Input.Bindings; +using osu.Game.Input.Bindings; +using osu.Game.Overlays; + +namespace osu.Game.Screens.Play +{ + public class QuickExit : 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; + } + } +}