mirror of
https://github.com/ppy/osu.git
synced 2025-02-16 02:23:10 +08:00
Split off "select all mods" button to separate class
This commit is contained in:
parent
a3f2962558
commit
f0303d76e8
@ -242,7 +242,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Select all visible mods in all columns.
|
/// Select all visible mods in all columns.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected void SelectAll()
|
public void SelectAll()
|
||||||
{
|
{
|
||||||
foreach (var column in columnFlow.Columns)
|
foreach (var column in columnFlow.Columns)
|
||||||
column.SelectAll();
|
column.SelectAll();
|
||||||
|
35
osu.Game/Overlays/Mods/SelectAllModsButton.cs
Normal file
35
osu.Game/Overlays/Mods/SelectAllModsButton.cs
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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<PlatformAction>
|
||||||
|
{
|
||||||
|
public SelectAllModsButton(FreeModSelectOverlay modSelectOverlay)
|
||||||
|
: base(ModSelectOverlay.BUTTON_WIDTH)
|
||||||
|
{
|
||||||
|
Text = CommonStrings.SelectAll;
|
||||||
|
Action = modSelectOverlay.SelectAll;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool OnPressed(KeyBindingPressEvent<PlatformAction> e)
|
||||||
|
{
|
||||||
|
if (e.Repeat || e.Action != PlatformAction.SelectAll)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
TriggerClick();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnReleased(KeyBindingReleaseEvent<PlatformAction> e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,18 +6,14 @@ 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;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
using osu.Game.Localisation;
|
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay
|
namespace osu.Game.Screens.OnlinePlay
|
||||||
{
|
{
|
||||||
public class FreeModSelectOverlay : ModSelectOverlay, IKeyBindingHandler<PlatformAction>
|
public class FreeModSelectOverlay : ModSelectOverlay
|
||||||
{
|
{
|
||||||
protected override bool ShowTotalMultiplier => false;
|
protected override bool ShowTotalMultiplier => false;
|
||||||
|
|
||||||
@ -29,8 +25,6 @@ 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)
|
||||||
{
|
{
|
||||||
@ -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 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(
|
||||||
selectAllButton = new ShearedButton(BUTTON_WIDTH)
|
new SelectAllModsButton(this)
|
||||||
{
|
{
|
||||||
Anchor = Anchor.BottomLeft,
|
Anchor = Anchor.BottomLeft,
|
||||||
Origin = 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