Add keyboard shortcuts to actuate mod select buttons (#4841)

Add keyboard shortcuts to actuate mod select buttons

Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert 2019-06-07 15:53:42 +09:00 committed by GitHub
commit 046df743be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 29 additions and 0 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using osuTK;
using osuTK.Input;
using osuTK.Graphics;
using osu.Framework.Allocation;
using osu.Framework.Extensions.Color4Extensions;
@ -23,6 +24,7 @@
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays.Mods.Sections;
using osu.Game.Screens;
using osu.Framework.Input.Events;
namespace osu.Game.Overlays.Mods
{
@ -33,6 +35,7 @@ public class ModSelectOverlay : WaveOverlayContainer
protected Color4 LowMultiplierColour, HighMultiplierColour;
protected readonly TriangleButton DeselectAllButton;
protected readonly TriangleButton CloseButton;
protected readonly OsuSpriteText MultiplierLabel, UnrankedLabel;
private readonly FillFlowContainer footerContainer;
@ -192,6 +195,22 @@ private void modButtonPressed(Mod selectedMod)
refreshSelectedMods();
}
protected override bool OnKeyDown(KeyDownEvent e)
{
switch (e.Key)
{
case Key.Number1:
DeselectAllButton.Click();
return true;
case Key.Number2:
CloseButton.Click();
return true;
}
return base.OnKeyDown(e);
}
private void refreshSelectedMods() => SelectedMods.Value = ModSectionsContainer.Children.SelectMany(s => s.SelectedMods).ToArray();
public ModSelectOverlay()
@ -364,6 +383,16 @@ public ModSelectOverlay()
Right = 20
}
},
CloseButton = new TriangleButton
{
Width = 180,
Text = "Close",
Action = Hide,
Margin = new MarginPadding
{
Right = 20
}
},
new OsuSpriteText
{
Text = @"Score Multiplier:",