mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 06:42:56 +08:00
Disable "deselect all mods" button if none are selected
This commit is contained in:
parent
a4bd399b0c
commit
a3f2962558
@ -15,11 +15,27 @@ namespace osu.Game.Overlays.Mods
|
|||||||
{
|
{
|
||||||
public class DeselectAllModsButton : ShearedButton, IKeyBindingHandler<GlobalAction>
|
public class DeselectAllModsButton : ShearedButton, IKeyBindingHandler<GlobalAction>
|
||||||
{
|
{
|
||||||
|
private readonly Bindable<IReadOnlyList<Mod>> selectedMods = new Bindable<IReadOnlyList<Mod>>();
|
||||||
|
|
||||||
public DeselectAllModsButton(ModSelectOverlay modSelectOverlay)
|
public DeselectAllModsButton(ModSelectOverlay modSelectOverlay)
|
||||||
: base(ModSelectOverlay.BUTTON_WIDTH)
|
: base(ModSelectOverlay.BUTTON_WIDTH)
|
||||||
{
|
{
|
||||||
Text = CommonStrings.DeselectAll;
|
Text = CommonStrings.DeselectAll;
|
||||||
Action = modSelectOverlay.DeselectAll;
|
Action = modSelectOverlay.DeselectAll;
|
||||||
|
|
||||||
|
selectedMods.BindTo(modSelectOverlay.SelectedMods);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void LoadComplete()
|
||||||
|
{
|
||||||
|
base.LoadComplete();
|
||||||
|
|
||||||
|
selectedMods.BindValueChanged(_ => updateEnabledState(), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateEnabledState()
|
||||||
|
{
|
||||||
|
Enabled.Value = selectedMods.Value.Any();
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
|
||||||
|
Loading…
Reference in New Issue
Block a user