diff --git a/osu.Game/Overlays/Mods/ModButton.cs b/osu.Game/Overlays/Mods/ModButton.cs index 90ed89a1ea..c41000af15 100644 --- a/osu.Game/Overlays/Mods/ModButton.cs +++ b/osu.Game/Overlays/Mods/ModButton.cs @@ -48,32 +48,27 @@ namespace osu.Game.Overlays.Mods /// /// Change the selected mod index of this button. /// - /// The new index + /// 1 for forwards, -1 for backwards. + public void SelectNext(int direction) + { + int start = selectedIndex + direction; + // wrap around if we are at an extremity. + if (start >= Mods.Length) + start = -1; + else if (start < -1) + start = Mods.Length - 1; - public void SelectPrevious() => changeSelectedIndex(selectedIndex - 1); + for (int i = start; i < Mods.Length && i >= 0; i += direction) + { + if (Mods[i].HasImplementation) + { + changeSelectedIndex(i); + return; + } + } + + Deselect(); + } public void Deselect() => changeSelectedIndex(-1); diff --git a/osu.Game/Overlays/Mods/ModSection.cs b/osu.Game/Overlays/Mods/ModSection.cs index ba183abc3f..50310d1b27 100644 --- a/osu.Game/Overlays/Mods/ModSection.cs +++ b/osu.Game/Overlays/Mods/ModSection.cs @@ -83,7 +83,7 @@ namespace osu.Game.Overlays.Mods { var index = Array.IndexOf(ToggleKeys, args.Key); if (index > -1 && index < buttons.Length) - buttons[index].SelectNext(); + buttons[index].SelectNext(state.Keyboard.ShiftPressed ? -1 : 1); return base.OnKeyDown(state, args); }