Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change mapping delete key to shift+delete to allow binding delete key #2375

Merged
merged 8 commits into from May 14, 2018
27 changes: 18 additions & 9 deletions osu.Game/Overlays/KeyBinding/KeyBindingRow.cs
Expand Up @@ -12,6 +12,7 @@
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Input;
using OpenTK.Graphics;
Expand Down Expand Up @@ -43,7 +44,7 @@ public bool MatchingFilter
}

private OsuSpriteText text;
private OsuSpriteText pressAKey;
private OsuTextFlowContainer pressAKey;

private FillFlowContainer<KeyButton> buttons;

Expand Down Expand Up @@ -95,10 +96,11 @@ private void load(OsuColour colours, KeyBindingStore store)
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight
},
pressAKey = new OsuSpriteText
pressAKey = new OsuTextFlowContainer
{
Text = "Press a key to change binding, DEL to delete, ESC to cancel.",
Y = height,
Text = "Press a key to change binding, Shift+Delete to delete, Escape to cancel.",
RelativeSizeAxes = Axes.X,
AutoSizeAxes = Axes.Y,
Margin = new MarginPadding(padding),
Alpha = 0,
Colour = colours.YellowDark
Expand Down Expand Up @@ -204,9 +206,16 @@ protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
finalise();
return true;
case Key.Delete:
bindTarget.UpdateKeyCombination(InputKey.None);
finalise();
return true;
{
if (state.Keyboard.ShiftPressed)
{
bindTarget.UpdateKeyCombination(InputKey.None);
finalise();
return true;
}

break;
}
}

bindTarget.UpdateKeyCombination(KeyCombination.FromInputState(state));
Expand Down Expand Up @@ -261,7 +270,7 @@ private void finalise()
GetContainingInputManager().ChangeFocus(null);

pressAKey.FadeOut(300, Easing.OutQuint);
pressAKey.Padding = new MarginPadding { Bottom = -pressAKey.DrawHeight };
pressAKey.Padding = new MarginPadding { Top = height, Bottom = -pressAKey.DrawHeight };
}

protected override void OnFocus(InputState state)
Expand All @@ -270,7 +279,7 @@ protected override void OnFocus(InputState state)
AutoSizeEasing = Easing.OutQuint;

pressAKey.FadeIn(300, Easing.OutQuint);
pressAKey.Padding = new MarginPadding();
pressAKey.Padding = new MarginPadding { Top = height };

updateBindTarget();
base.OnFocus(state);
Expand Down