mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:12:54 +08:00
Allow selecting all mods at free mod select using ctrl
+a
This commit is contained in:
parent
8a01050168
commit
b6575c216b
@ -7,6 +7,7 @@ using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Input;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays.Mods;
|
||||
@ -55,6 +56,18 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddAssert("customisation area not expanded", () => this.ChildrenOfType<ModSettingsArea>().Single().Height == 0);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectDeselectAllViaKeyboard()
|
||||
{
|
||||
createFreeModSelect();
|
||||
|
||||
AddStep("press ctrl+a", () => InputManager.Keys(PlatformAction.SelectAll));
|
||||
AddUntilStep("all mods selected", assertAllAvailableModsSelected);
|
||||
|
||||
AddStep("press backspace", () => InputManager.Key(Key.BackSpace));
|
||||
AddUntilStep("all mods deselected", () => !freeModSelectOverlay.SelectedMods.Value.Any());
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSelectDeselectAll()
|
||||
{
|
||||
|
@ -425,10 +425,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
AddStep("select DT + HD", () => SelectedMods.Value = new Mod[] { new OsuModDoubleTime(), new OsuModHidden() });
|
||||
AddAssert("DT + HD selected", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => panel.Active.Value) == 2);
|
||||
|
||||
AddStep("press backspace", () =>
|
||||
{
|
||||
InputManager.Key(Key.BackSpace);
|
||||
});
|
||||
AddStep("press backspace", () => InputManager.Key(Key.BackSpace));
|
||||
AddUntilStep("all mods deselected", () => !SelectedMods.Value.Any());
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,9 @@ 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;
|
||||
@ -14,7 +17,7 @@ using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
public class FreeModSelectOverlay : ModSelectOverlay
|
||||
public class FreeModSelectOverlay : ModSelectOverlay, IKeyBindingHandler<PlatformAction>
|
||||
{
|
||||
protected override bool ShowTotalMultiplier => false;
|
||||
|
||||
@ -26,6 +29,8 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
set => base.IsValidMod = m => m.UserPlayable && value.Invoke(m);
|
||||
}
|
||||
|
||||
private ShearedButton selectAllButton;
|
||||
|
||||
public FreeModSelectOverlay()
|
||||
: base(OverlayColourScheme.Plum)
|
||||
{
|
||||
@ -35,12 +40,31 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
protected override ModColumn CreateModColumn(ModType modType, Key[] toggleKeys = null) => new ModColumn(modType, true, toggleKeys);
|
||||
|
||||
protected override IEnumerable<ShearedButton> CreateFooterButtons() => base.CreateFooterButtons().Prepend(
|
||||
new ShearedButton(BUTTON_WIDTH)
|
||||
selectAllButton = new ShearedButton(BUTTON_WIDTH)
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Text = CommonStrings.SelectAll,
|
||||
Action = SelectAll
|
||||
});
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)
|
||||
{
|
||||
if (e.Repeat)
|
||||
return false;
|
||||
|
||||
switch (e.Action)
|
||||
{
|
||||
case PlatformAction.SelectAll:
|
||||
selectAllButton.TriggerClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void OnReleased(KeyBindingReleaseEvent<PlatformAction> e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user