mirror of
https://github.com/ppy/osu.git
synced 2025-03-20 07:17:31 +08:00
Merge pull request #2996 from HoutarouOreki/quickEscape
Add quick exit hotkey
This commit is contained in:
commit
afaea9a5fa
@ -50,6 +50,7 @@ namespace osu.Game.Input.Bindings
|
||||
{
|
||||
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 @@ namespace osu.Game.Input.Bindings
|
||||
[Description("Quick retry (hold)")]
|
||||
QuickRetry,
|
||||
|
||||
[Description("Quick exit (Hold)")]
|
||||
QuickExit,
|
||||
|
||||
[Description("Take screenshot")]
|
||||
TakeScreenshot,
|
||||
|
||||
|
28
osu.Game/Screens/Play/HotkeyExitOverlay.cs
Normal file
28
osu.Game/Screens/Play/HotkeyExitOverlay.cs
Normal file
@ -0,0 +1,28 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<GlobalAction>
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -177,6 +177,16 @@ namespace osu.Game.Screens.Play
|
||||
Restart();
|
||||
},
|
||||
},
|
||||
new HotkeyExitOverlay
|
||||
{
|
||||
Action = () =>
|
||||
{
|
||||
if (!this.IsCurrentScreen()) return;
|
||||
|
||||
fadeOut(true);
|
||||
performUserRequestedExit();
|
||||
},
|
||||
},
|
||||
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
|
||||
};
|
||||
|
||||
@ -245,6 +255,11 @@ namespace osu.Game.Screens.Play
|
||||
{
|
||||
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();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user