mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 15:12:57 +08:00
Copy selected mods properties into overlay's buttons
This commit is contained in:
parent
b4df2d6d43
commit
2ce9599957
@ -127,18 +127,28 @@ namespace osu.Game.Overlays.Mods
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Select one or more mods in this section and deselects all other ones.
|
/// Updates all buttons with the given list of selected mods.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="modTypes">The types of <see cref="Mod"/>s which should be selected.</param>
|
/// <param name="newSelectedMods">The types of <see cref="Mod"/>s to select.</param>
|
||||||
public void SelectTypes(IEnumerable<Type> modTypes)
|
public void UpdateSelectedMods(IReadOnlyList<Mod> newSelectedMods)
|
||||||
{
|
{
|
||||||
foreach (var button in buttons)
|
foreach (var button in buttons)
|
||||||
{
|
{
|
||||||
int i = Array.FindIndex(button.Mods, m => modTypes.Any(t => t == m.GetType()));
|
int index = -1;
|
||||||
|
|
||||||
if (i >= 0)
|
foreach (var mod in newSelectedMods)
|
||||||
button.SelectAt(i);
|
{
|
||||||
else
|
index = Array.FindIndex(button.Mods, m1 => mod.GetType() == m1.GetType());
|
||||||
|
if (index < 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
var buttonMod = button.Mods[index];
|
||||||
|
buttonMod.CopyFrom(mod);
|
||||||
|
button.SelectAt(index);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (index < 0)
|
||||||
button.Deselect();
|
button.Deselect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -409,7 +409,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
private void selectedModsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
private void selectedModsChanged(ValueChangedEvent<IReadOnlyList<Mod>> mods)
|
||||||
{
|
{
|
||||||
foreach (var section in ModSectionsContainer.Children)
|
foreach (var section in ModSectionsContainer.Children)
|
||||||
section.SelectTypes(mods.NewValue.Select(m => m.GetType()).ToList());
|
section.UpdateSelectedMods(mods.NewValue);
|
||||||
|
|
||||||
updateMods();
|
updateMods();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user