1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 16:32:54 +08:00

Fix externally changed settings from being reset when ModSelectOverlay is initialised

This commit is contained in:
Dean Herbert 2021-02-10 15:12:29 +09:00
parent 75bc9f607e
commit a39263423c
2 changed files with 15 additions and 6 deletions

View File

@ -46,8 +46,9 @@ namespace osu.Game.Overlays.Mods
/// Change the selected mod index of this button.
/// </summary>
/// <param name="newIndex">The new index.</param>
/// <param name="resetSettings">Whether any settings applied to the mod should be reset on selection.</param>
/// <returns>Whether the selection changed.</returns>
private bool changeSelectedIndex(int newIndex)
private bool changeSelectedIndex(int newIndex, bool resetSettings = true)
{
if (newIndex == selectedIndex) return false;
@ -69,6 +70,7 @@ namespace osu.Game.Overlays.Mods
Mod newSelection = SelectedMod ?? Mods[0];
if (resetSettings)
newSelection.ResetSettingsToDefaults();
Schedule(() =>
@ -211,11 +213,17 @@ namespace osu.Game.Overlays.Mods
Deselect();
}
public bool SelectAt(int index)
/// <summary>
/// Select the mod at the provided index.
/// </summary>
/// <param name="index">The index to select.</param>
/// <param name="resetSettings">Whether any settings applied to the mod should be reset on selection.</param>
/// <returns>Whether the selection changed.</returns>
public bool SelectAt(int index, bool resetSettings = true)
{
if (!Mods[index].HasImplementation) return false;
changeSelectedIndex(index);
changeSelectedIndex(index, resetSettings);
return true;
}

View File

@ -197,9 +197,10 @@ namespace osu.Game.Overlays.Mods
continue;
var buttonMod = button.Mods[index];
button.SelectAt(index);
// the selection above will reset settings to defaults, but as this is an external change we want to copy the new settings across.
button.SelectAt(index, false);
// as this is likely coming from an external change, ensure the settings of the mod are in sync.
buttonMod.CopyFrom(mod);
return;
}