1
0
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:
Bartłomiej Dach 2022-05-25 22:12:09 +02:00
parent a4bd399b0c
commit a3f2962558
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497

View File

@ -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)