mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 00:42:55 +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>
|
||||
{
|
||||
private readonly Bindable<IReadOnlyList<Mod>> selectedMods = new Bindable<IReadOnlyList<Mod>>();
|
||||
|
||||
public DeselectAllModsButton(ModSelectOverlay modSelectOverlay)
|
||||
: base(ModSelectOverlay.BUTTON_WIDTH)
|
||||
{
|
||||
Text = CommonStrings.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)
|
||||
|
Loading…
Reference in New Issue
Block a user