diff --git a/osu.Game/Overlays/Mods/AssistedSection.cs b/osu.Game/Overlays/Mods/AssistedSection.cs index 08a7b5db6c..86065fb7e7 100644 --- a/osu.Game/Overlays/Mods/AssistedSection.cs +++ b/osu.Game/Overlays/Mods/AssistedSection.cs @@ -1,14 +1,16 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Modes; namespace osu.Game.Overlays.Mods { public class AssistedSection : ModSection { + protected override Key[] ToggleKeys => new Key[] { Key.Z, Key.X, Key.C, Key.V, Key.B, Key.N, Key.M }; + [BackgroundDependencyLoader] private void load(OsuColour colours) { diff --git a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs index 2ae7b06386..62237812c4 100644 --- a/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyIncreaseSection.cs @@ -1,6 +1,7 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE +using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; @@ -8,6 +9,8 @@ namespace osu.Game.Overlays.Mods { public class DifficultyIncreaseSection : ModSection { + protected override Key[] ToggleKeys => new Key[] { Key.A, Key.S, Key.D, Key.F, Key.G, Key.H, Key.J, Key.K, Key.L }; + [BackgroundDependencyLoader] private void load(OsuColour colours) { diff --git a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs index 8f5565b770..f130617701 100644 --- a/osu.Game/Overlays/Mods/DifficultyReductionSection.cs +++ b/osu.Game/Overlays/Mods/DifficultyReductionSection.cs @@ -4,13 +4,13 @@ using OpenTK.Input; using osu.Framework.Allocation; using osu.Game.Graphics; -using osu.Game.Modes; -using osu.Game.Overlays.Mods; -namespace osu.Game +namespace osu.Game.Overlays.Mods { public class DifficultyReductionSection : ModSection { + protected override Key[] ToggleKeys => new Key[] { Key.Q, Key.W, Key.E, Key.R, Key.T, Key.Y, Key.U, Key.I, Key.O, Key.P }; + [BackgroundDependencyLoader] private void load(OsuColour colours) { diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 4c309a4953..594e3c37b4 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -30,7 +30,6 @@ namespace osu.Game.Overlays.Mods private SampleChannel sampleOn, sampleOff; public Action Action; // Passed the selected mod or null if none - public Key ToggleKey; private int _selectedMod = -1; private int selectedMod @@ -235,17 +234,6 @@ namespace osu.Game.Overlays.Mods } } - protected override bool OnKeyDown(Framework.Input.InputState state, KeyDownEventArgs args) - { - if (args.Key == ToggleKey) - { - SelectNext(); - return true; - } - - return base.OnKeyDown(state, args); - } - public ModButton(Mod m) { Direction = FlowDirections.Vertical; diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index d70ed686a2..edac898101 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -2,12 +2,15 @@ // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE using System; +using System.Linq; using System.Collections.Generic; using OpenTK; using OpenTK.Graphics; +using OpenTK.Input; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Primitives; +using osu.Framework.Input; using osu.Game.Graphics.Sprites; using osu.Game.Modes; @@ -26,6 +29,7 @@ namespace osu.Game.Overlays.Mods public FlowContainer ButtonsContainer => buttonsContainer; public Action Action; + protected virtual Key[] ToggleKeys => new Key[] { }; public Mod[] SelectedMods { @@ -119,6 +123,15 @@ namespace osu.Game.Overlays.Mods } } + protected override bool OnKeyDown(InputState state, KeyDownEventArgs args) + { + var index = Array.IndexOf(ToggleKeys, args.Key); + if (index > -1 && index < Buttons.Length) + Buttons[index].SelectNext(); + + return base.OnKeyDown(state, args); + } + public void DeselectAll() { foreach (ModButton button in buttons)