mirror of
https://github.com/ppy/osu.git
synced 2025-02-22 18:12:56 +08:00
make SelectTypes set mods instead of only adding new ones
also made the method actually take types as parameter to make it consistent
This commit is contained in:
parent
95c84ea7fe
commit
a438e45434
@ -114,19 +114,19 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Select one or more mods in this section.
|
/// Select one or more mods in this section and deselects all other ones.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="mods">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 selected.</param>
|
||||||
public void SelectTypes(IEnumerable<Mod> mods)
|
public void SelectTypes(IEnumerable<Type> modTypes)
|
||||||
{
|
{
|
||||||
foreach (var button in buttons)
|
foreach (var button in buttons)
|
||||||
{
|
{
|
||||||
for (int i = 0; i < button.Mods.Length; i++)
|
int i = Array.FindIndex(button.Mods, m => modTypes.Any(t => t.IsInstanceOfType(m)));
|
||||||
{
|
|
||||||
foreach (var mod in mods)
|
if (i >= 0)
|
||||||
if (mod.GetType().IsInstanceOfType(button.Mods[i]))
|
|
||||||
button.SelectAt(i);
|
button.SelectAt(i);
|
||||||
}
|
else
|
||||||
|
button.Deselect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
private void selectedModsChanged(IEnumerable<Mod> obj)
|
private void selectedModsChanged(IEnumerable<Mod> obj)
|
||||||
{
|
{
|
||||||
foreach (ModSection section in ModSectionsContainer.Children)
|
foreach (ModSection section in ModSectionsContainer.Children)
|
||||||
section.SelectTypes(obj);
|
section.SelectTypes(obj.Select(m => m.GetType()).ToList());
|
||||||
|
|
||||||
updateMods();
|
updateMods();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user