mirror of https://github.com/ppy/osu
Merge pull request #2996 from HoutarouOreki/quickEscape
Add quick exit hotkey
This commit is contained in:
commit
afaea9a5fa
|
@ -50,6 +50,7 @@ public GlobalActionContainer(OsuGameBase game)
|
||||||
{
|
{
|
||||||
new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene),
|
new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene),
|
||||||
new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry),
|
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.Plus }, GlobalAction.IncreaseScrollSpeed),
|
||||||
new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed),
|
new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed),
|
||||||
};
|
};
|
||||||
|
@ -94,6 +95,9 @@ public enum GlobalAction
|
||||||
[Description("Quick retry (hold)")]
|
[Description("Quick retry (hold)")]
|
||||||
QuickRetry,
|
QuickRetry,
|
||||||
|
|
||||||
|
[Description("Quick exit (Hold)")]
|
||||||
|
QuickExit,
|
||||||
|
|
||||||
[Description("Take screenshot")]
|
[Description("Take screenshot")]
|
||||||
TakeScreenshot,
|
TakeScreenshot,
|
||||||
|
|
||||||
|
|
|
@ -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 @@ private void load(AudioManager audio, IAPIProvider api, OsuConfigManager config)
|
||||||
Restart();
|
Restart();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
new HotkeyExitOverlay
|
||||||
|
{
|
||||||
|
Action = () =>
|
||||||
|
{
|
||||||
|
if (!this.IsCurrentScreen()) return;
|
||||||
|
|
||||||
|
fadeOut(true);
|
||||||
|
performUserRequestedExit();
|
||||||
|
},
|
||||||
|
},
|
||||||
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
|
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -245,6 +255,11 @@ private void performUserRequestedExit()
|
||||||
{
|
{
|
||||||
if (!this.IsCurrentScreen()) return;
|
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();
|
this.Exit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue