Allow user choice of the quick retry hotkey

This commit is contained in:
Dean Herbert 2018-01-23 13:05:07 +09:00
parent 4f360eac56
commit f823650b10
2 changed files with 16 additions and 19 deletions

View File

@ -37,7 +37,8 @@ namespace osu.Game.Input.Bindings
public IEnumerable<KeyBinding> InGameKeyBindings => new[] public IEnumerable<KeyBinding> InGameKeyBindings => new[]
{ {
new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene) new KeyBinding(InputKey.Space, GlobalAction.SkipCutscene),
new KeyBinding(InputKey.Tilde, GlobalAction.QuickRetry)
}; };
protected override IEnumerable<Drawable> KeyBindingInputQueue => protected override IEnumerable<Drawable> KeyBindingInputQueue =>
@ -65,6 +66,8 @@ namespace osu.Game.Input.Bindings
// In-Game Keybindings // In-Game Keybindings
[Description("Skip Cutscene")] [Description("Skip Cutscene")]
SkipCutscene SkipCutscene,
[Description("Quick Retry (Hold)")]
QuickRetry,
} }
} }

View File

@ -8,11 +8,13 @@ using System;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
using OpenTK.Graphics; using OpenTK.Graphics;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
public class HotkeyRetryOverlay : Container public class HotkeyRetryOverlay : Container, IKeyBindingHandler<GlobalAction>
{ {
public Action Action; 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;
overlay.FadeIn(activate_delay, Easing.Out);
return true;
}
return base.OnKeyDown(state, args);
} }
protected override bool OnKeyUp(InputState state, KeyUpEventArgs args) public bool OnReleased(GlobalAction action)
{ {
if (args.Key == Key.Tilde && !fired) if (action != GlobalAction.QuickRetry) return false;
{
overlay.FadeOut(fadeout_delay, Easing.Out);
return true;
}
return base.OnKeyUp(state, args); overlay.FadeOut(fadeout_delay, Easing.Out);
return true;
} }
protected override void Update() protected override void Update()