mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Refactor mod select button initialisation to allow shared usage of deselect button
This commit is contained in:
@ -56,11 +56,32 @@ namespace osu.Game.Overlays.Mods
|
||||
/// </summary>
|
||||
protected virtual bool ShowTotalMultiplier => true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether per-mod customisation controls are visible.
|
||||
/// </summary>
|
||||
protected virtual bool AllowCustomisation => true;
|
||||
|
||||
protected virtual ModColumn CreateModColumn(ModType modType, Key[]? toggleKeys = null) => new ModColumn(modType, false, toggleKeys);
|
||||
|
||||
protected virtual IReadOnlyList<Mod> ComputeNewModsFromSelection(IReadOnlyList<Mod> oldSelection, IReadOnlyList<Mod> newSelection) => newSelection;
|
||||
|
||||
protected virtual IEnumerable<ShearedButton> CreateFooterButtons() => createDefaultFooterButtons();
|
||||
protected virtual IEnumerable<ShearedButton> CreateFooterButtons()
|
||||
{
|
||||
if (AllowCustomisation)
|
||||
{
|
||||
yield return customisationButton = new ShearedToggleButton(BUTTON_WIDTH)
|
||||
{
|
||||
Text = ModSelectOverlayStrings.ModCustomisation,
|
||||
Active = { BindTarget = customisationVisible }
|
||||
};
|
||||
}
|
||||
|
||||
yield return deselectAllButton = new ShearedButton(BUTTON_WIDTH)
|
||||
{
|
||||
Text = CommonStrings.DeselectAll,
|
||||
Action = DeselectAll
|
||||
};
|
||||
}
|
||||
|
||||
private readonly Bindable<Dictionary<ModType, IReadOnlyList<Mod>>> availableMods = new Bindable<Dictionary<ModType, IReadOnlyList<Mod>>>();
|
||||
private readonly Dictionary<ModType, IReadOnlyList<ModState>> localAvailableMods = new Dictionary<ModType, IReadOnlyList<ModState>>();
|
||||
@ -77,6 +98,7 @@ namespace osu.Game.Overlays.Mods
|
||||
private DifficultyMultiplierDisplay? multiplierDisplay;
|
||||
|
||||
private ShearedToggleButton? customisationButton;
|
||||
private ShearedButton? deselectAllButton;
|
||||
|
||||
protected ModSelectOverlay(OverlayColourScheme colourScheme = OverlayColourScheme.Green)
|
||||
: base(colourScheme)
|
||||
@ -201,7 +223,7 @@ namespace osu.Game.Overlays.Mods
|
||||
|
||||
// This is an optimisation to prevent refreshing the available settings controls when it can be
|
||||
// reasonably assumed that the settings panel is never to be displayed (e.g. FreeModSelectOverlay).
|
||||
if (customisationButton != null)
|
||||
if (AllowCustomisation)
|
||||
((IBindable<IReadOnlyList<Mod>>)modSettingsArea.SelectedMods).BindTo(SelectedMods);
|
||||
|
||||
SelectedMods.BindValueChanged(val =>
|
||||
@ -256,21 +278,6 @@ namespace osu.Game.Overlays.Mods
|
||||
};
|
||||
}
|
||||
|
||||
private ShearedButton[] createDefaultFooterButtons()
|
||||
=> new[]
|
||||
{
|
||||
customisationButton = new ShearedToggleButton(BUTTON_WIDTH)
|
||||
{
|
||||
Text = ModSelectOverlayStrings.ModCustomisation,
|
||||
Active = { BindTarget = customisationVisible }
|
||||
},
|
||||
new ShearedButton(BUTTON_WIDTH)
|
||||
{
|
||||
Text = CommonStrings.DeselectAll,
|
||||
Action = DeselectAll
|
||||
}
|
||||
};
|
||||
|
||||
private void createLocalMods()
|
||||
{
|
||||
localAvailableMods.Clear();
|
||||
@ -510,7 +517,7 @@ namespace osu.Game.Overlays.Mods
|
||||
}
|
||||
|
||||
case GlobalAction.DeselectAllMods:
|
||||
DeselectAll();
|
||||
deselectAllButton?.TriggerClick();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user