1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 08:12:55 +08:00

Only open mod customisation panel on explicit selection of single mod

This commit is contained in:
Bartłomiej Dach 2022-08-15 19:40:05 +02:00
parent f0ad31b650
commit 10daac6752
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
3 changed files with 33 additions and 9 deletions

View File

@ -37,6 +37,8 @@ namespace osu.Game.Overlays.Mods
Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0), Shear = new Vector2(-ShearedOverlayContainer.SHEAR, 0),
Scale = new Vector2(HEIGHT / ModSwitchSmall.DEFAULT_SIZE) Scale = new Vector2(HEIGHT / ModSwitchSmall.DEFAULT_SIZE)
}; };
Action = select;
} }
public ModPanel(Mod mod) public ModPanel(Mod mod)
@ -57,6 +59,20 @@ namespace osu.Game.Overlays.Mods
Filtered.BindValueChanged(_ => updateFilterState(), true); Filtered.BindValueChanged(_ => updateFilterState(), true);
} }
private void select()
{
if (!Active.Value)
{
modState.RequiresConfiguration = Mod.RequiresConfiguration;
Active.Value = true;
}
else
{
modState.RequiresConfiguration = false;
Active.Value = false;
}
}
#region Filtering support #region Filtering support
private void updateFilterState() private void updateFilterState()

View File

@ -247,8 +247,8 @@ namespace osu.Game.Overlays.Mods
modSettingChangeTracker?.Dispose(); modSettingChangeTracker?.Dispose();
updateMultiplier(); updateMultiplier();
updateCustomisation(val);
updateFromExternalSelection(); updateFromExternalSelection();
updateCustomisation();
if (AllowCustomisation) if (AllowCustomisation)
{ {
@ -356,25 +356,26 @@ namespace osu.Game.Overlays.Mods
multiplierDisplay.Current.Value = multiplier; multiplierDisplay.Current.Value = multiplier;
} }
private void updateCustomisation(ValueChangedEvent<IReadOnlyList<Mod>> valueChangedEvent) private void updateCustomisation()
{ {
if (CustomisationButton == null) if (CustomisationButton == null)
return; return;
bool anyCustomisableMod = false; bool anyCustomisableModActive = false;
bool anyModWithRequiredCustomisationAdded = false; bool anyModRequiresCustomisation = false;
foreach (var mod in SelectedMods.Value) foreach (var modState in allAvailableMods)
{ {
anyCustomisableMod |= mod.GetSettingsSourceProperties().Any(); anyCustomisableModActive |= modState.Active.Value && modState.Mod.GetSettingsSourceProperties().Any();
anyModWithRequiredCustomisationAdded |= valueChangedEvent.OldValue.All(m => m.GetType() != mod.GetType()) && mod.RequiresConfiguration; anyModRequiresCustomisation |= modState.RequiresConfiguration;
modState.RequiresConfiguration = false;
} }
if (anyCustomisableMod) if (anyCustomisableModActive)
{ {
customisationVisible.Disabled = false; customisationVisible.Disabled = false;
if (anyModWithRequiredCustomisationAdded && !customisationVisible.Value) if (anyModRequiresCustomisation && !customisationVisible.Value)
customisationVisible.Value = true; customisationVisible.Value = true;
} }
else else

View File

@ -24,6 +24,13 @@ namespace osu.Game.Overlays.Mods
/// </summary> /// </summary>
public BindableBool Active { get; } = new BindableBool(); public BindableBool Active { get; } = new BindableBool();
/// <summary>
/// Whether the mod requires further customisation.
/// This flag is read by the <see cref="ModSelectOverlay"/> to determine if the customisation panel should be opened after a mod change
/// and cleared after reading.
/// </summary>
public bool RequiresConfiguration { get; set; }
/// <summary> /// <summary>
/// Whether the mod is currently filtered out due to not matching imposed criteria. /// Whether the mod is currently filtered out due to not matching imposed criteria.
/// </summary> /// </summary>