Fix propagation of selected mods to columns

This commit is contained in:
Bartłomiej Dach
2022-03-28 00:16:10 +02:00
parent 2921a13609
commit cd776d21a6
2 changed files with 64 additions and 21 deletions

View File

@ -167,13 +167,6 @@ namespace osu.Game.Overlays.Mods
}
};
foreach (var column in columnFlow)
{
column.ModStateChanged = (mod, active) => SelectedMods.Value = active
? SelectedMods.Value.Append(mod).ToArray()
: SelectedMods.Value.Except(new[] { mod }).ToArray();
}
columnFlow.Shear = new Vector2(ModPanel.SHEAR_X, 0);
}
@ -182,11 +175,19 @@ namespace osu.Game.Overlays.Mods
base.LoadComplete();
((IBindable<IReadOnlyList<Mod>>)modSettingsArea.SelectedMods).BindTo(SelectedMods);
SelectedMods.BindValueChanged(val =>
{
updateMultiplier();
updateCustomisation(val);
updateSelectionFromBindable();
}, true);
foreach (var column in columnFlow)
{
column.SelectedMods.BindValueChanged(_ => updateBindableFromSelection());
}
customisationVisible.BindValueChanged(_ => updateCustomisationVisualState(), true);
FinishTransforms(true);
@ -239,6 +240,33 @@ namespace osu.Game.Overlays.Mods
mainContent.TransformTo(nameof(Margin), new MarginPadding { Bottom = modAreaHeight }, 800, Easing.InOutCubic);
}
private bool selectionBindableSyncInProgress;
private void updateSelectionFromBindable()
{
if (selectionBindableSyncInProgress)
return;
selectionBindableSyncInProgress = true;
foreach (var column in columnFlow)
column.SelectedMods.Value = SelectedMods.Value.Where(mod => mod.Type == column.ModType).ToArray();
selectionBindableSyncInProgress = false;
}
private void updateBindableFromSelection()
{
if (selectionBindableSyncInProgress)
return;
selectionBindableSyncInProgress = true;
SelectedMods.Value = columnFlow.SelectMany(column => column.SelectedMods.Value).ToArray();
selectionBindableSyncInProgress = false;
}
protected override void PopIn()
{
base.PopIn();