diff --git a/osu.Game/Overlays/Mods/ModSelectOverlay.cs b/osu.Game/Overlays/Mods/ModSelectOverlay.cs index ea7f969450..d8355a4dea 100644 --- a/osu.Game/Overlays/Mods/ModSelectOverlay.cs +++ b/osu.Game/Overlays/Mods/ModSelectOverlay.cs @@ -242,7 +242,7 @@ namespace osu.Game.Overlays.Mods /// /// Select all visible mods in all columns. /// - protected void SelectAll() + public void SelectAll() { foreach (var column in columnFlow.Columns) column.SelectAll(); diff --git a/osu.Game/Overlays/Mods/SelectAllModsButton.cs b/osu.Game/Overlays/Mods/SelectAllModsButton.cs new file mode 100644 index 0000000000..b9d6bf9633 --- /dev/null +++ b/osu.Game/Overlays/Mods/SelectAllModsButton.cs @@ -0,0 +1,35 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Input; +using osu.Framework.Input.Bindings; +using osu.Framework.Input.Events; +using osu.Game.Graphics.UserInterface; +using osu.Game.Localisation; +using osu.Game.Screens.OnlinePlay; + +namespace osu.Game.Overlays.Mods +{ + public class SelectAllModsButton : ShearedButton, IKeyBindingHandler + { + public SelectAllModsButton(FreeModSelectOverlay modSelectOverlay) + : base(ModSelectOverlay.BUTTON_WIDTH) + { + Text = CommonStrings.SelectAll; + Action = modSelectOverlay.SelectAll; + } + + public bool OnPressed(KeyBindingPressEvent e) + { + if (e.Repeat || e.Action != PlatformAction.SelectAll) + return false; + + TriggerClick(); + return true; + } + + public void OnReleased(KeyBindingReleaseEvent e) + { + } + } +} diff --git a/osu.Game/Screens/OnlinePlay/FreeModSelectOverlay.cs b/osu.Game/Screens/OnlinePlay/FreeModSelectOverlay.cs index f494f9799a..7c9184cc0f 100644 --- a/osu.Game/Screens/OnlinePlay/FreeModSelectOverlay.cs +++ b/osu.Game/Screens/OnlinePlay/FreeModSelectOverlay.cs @@ -6,18 +6,14 @@ using osu.Game.Overlays; using System.Collections.Generic; using System.Linq; using osu.Framework.Graphics; -using osu.Framework.Input; -using osu.Framework.Input.Bindings; -using osu.Framework.Input.Events; using osu.Game.Graphics.UserInterface; using osu.Game.Overlays.Mods; using osu.Game.Rulesets.Mods; using osuTK.Input; -using osu.Game.Localisation; namespace osu.Game.Screens.OnlinePlay { - public class FreeModSelectOverlay : ModSelectOverlay, IKeyBindingHandler + public class FreeModSelectOverlay : ModSelectOverlay { protected override bool ShowTotalMultiplier => false; @@ -29,8 +25,6 @@ namespace osu.Game.Screens.OnlinePlay set => base.IsValidMod = m => m.UserPlayable && value.Invoke(m); } - private ShearedButton selectAllButton; - public FreeModSelectOverlay() : base(OverlayColourScheme.Plum) { @@ -40,31 +34,10 @@ namespace osu.Game.Screens.OnlinePlay protected override ModColumn CreateModColumn(ModType modType, Key[] toggleKeys = null) => new ModColumn(modType, true, toggleKeys); protected override IEnumerable CreateFooterButtons() => base.CreateFooterButtons().Prepend( - selectAllButton = new ShearedButton(BUTTON_WIDTH) + new SelectAllModsButton(this) { Anchor = Anchor.BottomLeft, Origin = Anchor.BottomLeft, - Text = CommonStrings.SelectAll, - Action = SelectAll }); - - public bool OnPressed(KeyBindingPressEvent e) - { - if (e.Repeat) - return false; - - switch (e.Action) - { - case PlatformAction.SelectAll: - selectAllButton.TriggerClick(); - return true; - } - - return false; - } - - public void OnReleased(KeyBindingReleaseEvent e) - { - } } }