mirror of
https://github.com/ppy/osu.git
synced 2025-02-10 13:03:01 +08:00
Transfer flags indicating if settings were changed
This commit is contained in:
parent
9984c80c87
commit
303cc62ee7
@ -59,8 +59,8 @@ namespace osu.Game.Rulesets.Catch.Mods
|
|||||||
{
|
{
|
||||||
base.ApplySettings(difficulty);
|
base.ApplySettings(difficulty);
|
||||||
|
|
||||||
difficulty.CircleSize = CircleSize.Value;
|
ApplySetting(CircleSize, cs => difficulty.CircleSize = cs);
|
||||||
difficulty.ApproachRate = ApproachRate.Value;
|
ApplySetting(ApproachRate, ar => difficulty.ApproachRate = ar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -59,8 +59,8 @@ namespace osu.Game.Rulesets.Osu.Mods
|
|||||||
{
|
{
|
||||||
base.ApplySettings(difficulty);
|
base.ApplySettings(difficulty);
|
||||||
|
|
||||||
difficulty.CircleSize = CircleSize.Value;
|
ApplySetting(CircleSize, cs => difficulty.CircleSize = cs);
|
||||||
difficulty.ApproachRate = ApproachRate.Value;
|
ApplySetting(ApproachRate, ar => difficulty.ApproachRate = ar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -116,18 +116,30 @@ namespace osu.Game.Rulesets.Mods
|
|||||||
|
|
||||||
internal override void CopyAdjustedSetting(IBindable target, object source)
|
internal override void CopyAdjustedSetting(IBindable target, object source)
|
||||||
{
|
{
|
||||||
userChangedSettings[target] = true;
|
// if the value is non-bindable, it's presumably coming from an external source (like the API) - therefore presume it is not default.
|
||||||
|
// if the value is bindable, defer to the source's IsDefault to be able to tell.
|
||||||
|
userChangedSettings[target] = !(source is IBindable bindableSource) || !bindableSource.IsDefault;
|
||||||
base.CopyAdjustedSetting(target, source);
|
base.CopyAdjustedSetting(target, source);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Applies a setting from a configuration bindable using <paramref name="applyFunc"/>, if it has been changed by the user.
|
||||||
|
/// </summary>
|
||||||
|
protected void ApplySetting<T>(BindableNumber<T> setting, Action<T> applyFunc)
|
||||||
|
where T : struct, IComparable<T>, IConvertible, IEquatable<T>
|
||||||
|
{
|
||||||
|
if (userChangedSettings.TryGetValue(setting, out bool userChangedSetting) && userChangedSetting)
|
||||||
|
applyFunc.Invoke(setting.Value);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Apply all custom settings to the provided beatmap.
|
/// Apply all custom settings to the provided beatmap.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="difficulty">The beatmap to have settings applied.</param>
|
/// <param name="difficulty">The beatmap to have settings applied.</param>
|
||||||
protected virtual void ApplySettings(BeatmapDifficulty difficulty)
|
protected virtual void ApplySettings(BeatmapDifficulty difficulty)
|
||||||
{
|
{
|
||||||
difficulty.DrainRate = DrainRate.Value;
|
ApplySetting(DrainRate, dr => difficulty.DrainRate = dr);
|
||||||
difficulty.OverallDifficulty = OverallDifficulty.Value;
|
ApplySetting(OverallDifficulty, od => difficulty.OverallDifficulty = od);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user