mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 16:02:58 +08:00
Split off "deselect all mods" button to separate class
This commit is contained in:
parent
4f8b6b52ba
commit
a4bd399b0c
38
osu.Game/Overlays/Mods/DeselectAllModsButton.cs
Normal file
38
osu.Game/Overlays/Mods/DeselectAllModsButton.cs
Normal file
@ -0,0 +1,38 @@
|
||||
// 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 System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Input.Bindings;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Input.Bindings;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
|
||||
namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public class DeselectAllModsButton : ShearedButton, IKeyBindingHandler<GlobalAction>
|
||||
{
|
||||
public DeselectAllModsButton(ModSelectOverlay modSelectOverlay)
|
||||
: base(ModSelectOverlay.BUTTON_WIDTH)
|
||||
{
|
||||
Text = CommonStrings.DeselectAll;
|
||||
Action = modSelectOverlay.DeselectAll;
|
||||
}
|
||||
|
||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||
{
|
||||
if (e.Repeat || e.Action != GlobalAction.DeselectAllMods)
|
||||
return false;
|
||||
|
||||
TriggerClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Mods
|
||||
{
|
||||
public abstract class ModSelectOverlay : ShearedOverlayContainer, ISamplePlaybackDisabler
|
||||
{
|
||||
protected const int BUTTON_WIDTH = 200;
|
||||
public const int BUTTON_WIDTH = 200;
|
||||
|
||||
[Cached]
|
||||
public Bindable<IReadOnlyList<Mod>> SelectedMods { get; private set; } = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
|
||||
@ -76,11 +76,7 @@ namespace osu.Game.Overlays.Mods
|
||||
};
|
||||
}
|
||||
|
||||
yield return deselectAllButton = new ShearedButton(BUTTON_WIDTH)
|
||||
{
|
||||
Text = CommonStrings.DeselectAll,
|
||||
Action = DeselectAll
|
||||
};
|
||||
yield return new DeselectAllModsButton(this);
|
||||
}
|
||||
|
||||
private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
|
||||
@ -98,7 +94,6 @@ namespace osu.Game.Overlays.Mods
|
||||
private DifficultyMultiplierDisplay? multiplierDisplay;
|
||||
|
||||
private ShearedToggleButton? customisationButton;
|
||||
private ShearedButton? deselectAllButton;
|
||||
|
||||
protected ModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Green)
|
||||
: base(colourScheme)
|
||||
@ -256,7 +251,7 @@ namespace osu.Game.Overlays.Mods
|
||||
/// <summary>
|
||||
/// Deselect all visible mods in all columns.
|
||||
/// </summary>
|
||||
protected void DeselectAll()
|
||||
public void DeselectAll()
|
||||
{
|
||||
foreach (var column in columnFlow.Columns)
|
||||
column.DeselectAll();
|
||||
@ -514,10 +509,6 @@ namespace osu.Game.Overlays.Mods
|
||||
hideOverlay(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
case GlobalAction.DeselectAllMods:
|
||||
deselectAllButton?.TriggerClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnPressed(e);
|
||||
|
Loading…
Reference in New Issue
Block a user