Add back immediate deselection flow to ensure user selections can occur without contention

This commit is contained in:
Dean Herbert
2021-02-04 23:44:46 +09:00
parent 794f9e5e93
commit 0750c3cb6a
2 changed files with 9 additions and 3 deletions

View File

@ -158,7 +158,8 @@ namespace osu.Game.Overlays.Mods
/// Deselect one or more mods in this section. /// Deselect one or more mods in this section.
/// </summary> /// </summary>
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be deselected.</param> /// <param name="modTypes">The types of <see cref="Mod"/>s which should be deselected.</param>
public void DeselectTypes(IEnumerable<Type> modTypes) /// <param name="immediate">Whether the deselection should happen immediately. Should only be used when required to ensure correct selection flow.</param>
public void DeselectTypes(IEnumerable<Type> modTypes, bool immediate = false)
{ {
foreach (var button in buttons) foreach (var button in buttons)
{ {
@ -167,10 +168,15 @@ namespace osu.Game.Overlays.Mods
foreach (var type in modTypes) foreach (var type in modTypes)
{ {
if (type.IsInstanceOfType(button.SelectedMod)) if (type.IsInstanceOfType(button.SelectedMod))
{
if (immediate)
button.Deselect();
else
pendingSelectionOperations.Enqueue(button.Deselect); pendingSelectionOperations.Enqueue(button.Deselect);
} }
} }
} }
}
/// <summary> /// <summary>
/// Updates all buttons with the given list of selected mods. /// Updates all buttons with the given list of selected mods.

View File

@ -12,7 +12,7 @@ namespace osu.Game.Overlays.Mods
base.OnModSelected(mod); base.OnModSelected(mod);
foreach (var section in ModSectionsContainer.Children) foreach (var section in ModSectionsContainer.Children)
section.DeselectTypes(mod.IncompatibleMods); section.DeselectTypes(mod.IncompatibleMods, true);
} }
} }
} }