From f823650b10691fb348b29d56bb7a1a5566abe7b1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 23 Jan 2018 13:05:07 +0900 Subject: [PATCH] Allow user choice of the quick retry hotkey --- .../Bindings/GlobalKeyBindingInputManager.cs | 7 +++-- osu.Game/Screens/Play/HotkeyRetryOverlay.cs | 28 ++++++++----------- 2 files changed, 16 insertions(+), 19 deletions(-) diff --git a/osu.Game/Input/Bindings/GlobalKeyBindingInputManager.cs b/osu.Game/Input/Bindings/GlobalKeyBindingInputManager.cs index f5e54775fb..dcebe939d4 100644 --- a/osu.Game/Input/Bindings/GlobalKeyBindingInputManager.cs +++ b/osu.Game/Input/Bindings/GlobalKeyBindingInputManager.cs @@ -37,7 +37,8 @@ namespace osu.Game.Input.Bindings public IEnumerable InGameKeyBindings => new[] { - new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene) + new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene), + new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry) }; protected override IEnumerable KeyBindingInputQueue => @@ -65,6 +66,8 @@ namespace osu.Game.Input.Bindings // In-Game Keybindings [Description("Skip Cutscene")] - SkipCutscene + SkipCutscene, + [Description("Quick Retry (Hold)")] + QuickRetry, } } diff --git a/osu.Game/Screens/Play/HotkeyRetryOverlay.cs b/osu.Game/Screens/Play/HotkeyRetryOverlay.cs index 06db1d9df1..fcea15f7b0 100644 --- a/osu.Game/Screens/Play/HotkeyRetryOverlay.cs +++ b/osu.Game/Screens/Play/HotkeyRetryOverlay.cs @@ -8,11 +8,13 @@ using System; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics; using osu.Framework.Graphics.Shapes; +using osu.Framework.Input.Bindings; +using osu.Game.Input.Bindings; using OpenTK.Graphics; namespace osu.Game.Screens.Play { - public class HotkeyRetryOverlay : Container + public class HotkeyRetryOverlay : Container, IKeyBindingHandler { public Action Action; @@ -40,28 +42,20 @@ namespace osu.Game.Screens.Play }; } - protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + public bool OnPressed(GlobalAction action) { - if (args.Repeat) return false; + if (action != GlobalAction.QuickRetry) return false; - if (args.Key == Key.Tilde) - { - overlay.FadeIn(activate_delay, Easing.Out); - return true; - } - - return base.OnKeyDown(state, args); + overlay.FadeIn(activate_delay, Easing.Out); + return true; } - protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) + public bool OnReleased(GlobalAction action) { - if (args.Key == Key.Tilde && !fired) - { - overlay.FadeOut(fadeout_delay, Easing.Out); - return true; - } + if (action != GlobalAction.QuickRetry) return false; - return base.OnKeyUp(state, args); + overlay.FadeOut(fadeout_delay, Easing.Out); + return true; } protected override void Update()