1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 14:17:26 +08:00

Always reset local user settings when a mod is deselected in ModSelectOverlay

This commit is contained in:
Dean Herbert 2021-02-09 13:44:42 +09:00
parent be379e0e3c
commit 8204d360a8
4 changed files with 21 additions and 1 deletions

View File

@ -69,6 +69,8 @@ namespace osu.Game.Overlays.Mods
Mod newSelection = SelectedMod ?? Mods[0];
newSelection.ResetSettingsToDefaults();
Schedule(() =>
{
if (beforeSelected != Selected)

View File

@ -197,8 +197,10 @@ namespace osu.Game.Overlays.Mods
continue;
var buttonMod = button.Mods[index];
buttonMod.CopyFrom(mod);
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.
buttonMod.CopyFrom(mod);
return;
}

View File

@ -173,5 +173,10 @@ namespace osu.Game.Rulesets.Mods
}
public bool Equals(IMod other) => GetType() == other?.GetType();
/// <summary>
/// Reset all custom settings for this mod back to their defaults.
/// </summary>
public virtual void ResetSettingsToDefaults() => CopyFrom((Mod)Activator.CreateInstance(GetType()));
}
}

View File

@ -141,5 +141,16 @@ namespace osu.Game.Rulesets.Mods
ApplySetting(DrainRate, dr => difficulty.DrainRate = dr);
ApplySetting(OverallDifficulty, od => difficulty.OverallDifficulty = od);
}
public override void ResetSettingsToDefaults()
{
base.ResetSettingsToDefaults();
if (difficulty != null)
{
// base implementation potentially overwrite modified defaults that came from a beatmap selection.
TransferSettings(difficulty);
}
}
}
}