1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 05:47:50 +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:
FreezyLemon 2018-03-14 12:33:08 +01:00
parent 95c84ea7fe
commit a438e45434
2 changed files with 10 additions and 10 deletions

View File

@ -114,19 +114,19 @@ namespace osu.Game.Overlays.Mods
}
/// <summary>
/// Select one or more mods in this section.
/// Select one or more mods in this section and deselects all other ones.
/// </summary>
/// <param name="mods">The types of <see cref="Mod"/>s which should be deselected.</param>
public void SelectTypes(IEnumerable<Mod> mods)
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be selected.</param>
public void SelectTypes(IEnumerable<Type> modTypes)
{
foreach (var button in buttons)
{
for (int i = 0; i < button.Mods.Length; i++)
{
foreach (var mod in mods)
if (mod.GetType().IsInstanceOfType(button.Mods[i]))
button.SelectAt(i);
}
int i = Array.FindIndex(button.Mods, m => modTypes.Any(t => t.IsInstanceOfType(m)));
if (i >= 0)
button.SelectAt(i);
else
button.Deselect();
}
}

View File

@ -76,7 +76,7 @@ namespace osu.Game.Overlays.Mods
private void selectedModsChanged(IEnumerable<Mod> obj)
{
foreach (ModSection section in ModSectionsContainer.Children)
section.SelectTypes(obj);
section.SelectTypes(obj.Select(m => m.GetType()).ToList());
updateMods();
}