mirror of
https://github.com/ppy/osu.git
synced 2025-03-05 11:43:01 +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.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Input;
|
||||||
using osu.Framework.Testing;
|
using osu.Framework.Testing;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Mods;
|
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);
|
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]
|
[Test]
|
||||||
public void TestSelectDeselectAll()
|
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() });
|
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);
|
AddAssert("DT + HD selected", () => modSelectOverlay.ChildrenOfType<ModPanel>().Count(panel => panel.Active.Value) == 2);
|
||||||
|
|
||||||
AddStep("press backspace", () =>
|
AddStep("press backspace", () => InputManager.Key(Key.BackSpace));
|
||||||
{
|
|
||||||
InputManager.Key(Key.BackSpace);
|
|
||||||
});
|
|
||||||
AddUntilStep("all mods deselected", () => !SelectedMods.Value.Any());
|
AddUntilStep("all mods deselected", () => !SelectedMods.Value.Any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@ using osu.Game.Overlays;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
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.Graphics.UserInterface;
|
||||||
using osu.Game.Overlays.Mods;
|
using osu.Game.Overlays.Mods;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
@ -14,7 +17,7 @@ using osu.Game.Localisation;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay
|
namespace osu.Game.Screens.OnlinePlay
|
||||||
{
|
{
|
||||||
public class FreeModSelectOverlay : ModSelectOverlay
|
public class FreeModSelectOverlay : ModSelectOverlay, IKeyBindingHandler<PlatformAction>
|
||||||
{
|
{
|
||||||
protected override bool ShowTotalMultiplier => false;
|
protected override bool ShowTotalMultiplier => false;
|
||||||
|
|
||||||
@ -26,6 +29,8 @@ namespace osu.Game.Screens.OnlinePlay
|
|||||||
set => base.IsValidMod = m => m.UserPlayable && value.Invoke(m);
|
set => base.IsValidMod = m => m.UserPlayable && value.Invoke(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ShearedButton selectAllButton;
|
||||||
|
|
||||||
public FreeModSelectOverlay()
|
public FreeModSelectOverlay()
|
||||||
: base(OverlayColourScheme.Plum)
|
: 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 ModColumn CreateModColumn(ModType modType, Key[] toggleKeys = null) => new ModColumn(modType, true, toggleKeys);
|
||||||
|
|
||||||
protected override IEnumerable<ShearedButton> CreateFooterButtons() => base.CreateFooterButtons().Prepend(
|
protected override IEnumerable<ShearedButton> CreateFooterButtons() => base.CreateFooterButtons().Prepend(
|
||||||
new ShearedButton(BUTTON_WIDTH)
|
selectAllButton = new ShearedButton(BUTTON_WIDTH)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = Anchor.BottomLeft,
|
Origin = Anchor.BottomLeft,
|
||||||
Text = CommonStrings.SelectAll,
|
Text = CommonStrings.SelectAll,
|
||||||
Action = 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