Moved key press select mods to ModSection

This commit is contained in:
DrabWeb
2017-03-02 01:24:32 -04:00
parent 1eee587c18
commit 37ed1b3d09
5 changed files with 22 additions and 16 deletions

View File

@ -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<Mod> 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)