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),
Scale = new Vector2(HEIGHT / ModSwitchSmall.DEFAULT_SIZE)
};
Action = select;
}
public ModPanel(Mod mod)
@ -57,6 +59,20 @@ namespace osu.Game.Overlays.Mods
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
private void updateFilterState()

View File

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

View File

@ -24,6 +24,13 @@ namespace osu.Game.Overlays.Mods
/// </summary>
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>
/// Whether the mod is currently filtered out due to not matching imposed criteria.
/// </summary>