mirror of https://github.com/ppy/osu
Always reset local user settings when a mod is deselected in ModSelectOverlay
This commit is contained in:
parent
be379e0e3c
commit
8204d360a8
|
@ -69,6 +69,8 @@ private bool changeSelectedIndex(int newIndex)
|
|||
|
||||
Mod newSelection = SelectedMod ?? Mods[0];
|
||||
|
||||
newSelection.ResetSettingsToDefaults();
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
if (beforeSelected != Selected)
|
||||
|
|
|
@ -197,8 +197,10 @@ private void updateButtonSelection(ModButton button, IReadOnlyList<Mod> newSelec
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,5 +173,10 @@ internal virtual void CopyAdjustedSetting(IBindable target, object source)
|
|||
}
|
||||
|
||||
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()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -141,5 +141,16 @@ protected virtual void ApplySettings(BeatmapDifficulty difficulty)
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue