Merge pull request #2996 from HoutarouOreki/quickEscape

Add quick exit hotkey
This commit is contained in:
Dean Herbert 2019-06-24 19:02:42 +09:00 committed by GitHub
commit afaea9a5fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 0 deletions

View File

@ -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,

View 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;
}
}
}

View File

@ -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();
}