mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 22:56:36 +09:00
Make apply default methods more explicit in behaviour
This commit is contained in:
@ -11,9 +11,18 @@ namespace osu.Game.Overlays.Settings
|
||||
event Action SettingChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Apply the default values of a setting item, if the setting item specifies a "classic" default via <see cref="SettingsItem{T}.ApplyClassicDefault"/>.
|
||||
/// Whether this setting has a classic default (ie. a different default which better aligns with osu-stable expectations).
|
||||
/// </summary>
|
||||
/// <param name="useClassicDefault">Whether to apply the classic value. If <c>false</c>, the standard default is applied.</param>
|
||||
void ApplyClassicDefault(bool useClassicDefault);
|
||||
bool HasClassicDefault { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Apply the classic default value of the associated setting. Will throw if <see cref="HasClassicDefault"/> is <c>false</c>.
|
||||
/// </summary>
|
||||
void ApplyClassicDefault();
|
||||
|
||||
/// <summary>
|
||||
/// Apply the default value of the associated setting.
|
||||
/// </summary>
|
||||
void ApplyDefault();
|
||||
}
|
||||
}
|
||||
|
@ -107,7 +107,7 @@ namespace osu.Game.Overlays.Settings
|
||||
LabelText.ToString()
|
||||
};
|
||||
|
||||
if (hasClassicDefault)
|
||||
if (HasClassicDefault)
|
||||
keywords.Add(CLASSIC_DEFAULT_SEARCH_TERM);
|
||||
|
||||
return keywords;
|
||||
@ -139,7 +139,8 @@ namespace osu.Game.Overlays.Settings
|
||||
public event Action SettingChanged;
|
||||
|
||||
private T classicDefault;
|
||||
private bool hasClassicDefault;
|
||||
|
||||
public bool HasClassicDefault { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// A "classic" default value for this setting.
|
||||
@ -149,21 +150,20 @@ namespace osu.Game.Overlays.Settings
|
||||
set
|
||||
{
|
||||
classicDefault = value;
|
||||
hasClassicDefault = true;
|
||||
HasClassicDefault = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void ApplyClassicDefault(bool useClassicDefault)
|
||||
public void ApplyClassicDefault()
|
||||
{
|
||||
if (!hasClassicDefault)
|
||||
return;
|
||||
if (!HasClassicDefault)
|
||||
throw new InvalidOperationException($"Cannot apply a classic default to a setting which doesn't have one defined via {nameof(ClassicDefault)}.");
|
||||
|
||||
if (useClassicDefault)
|
||||
Current.Value = classicDefault;
|
||||
else
|
||||
Current.SetDefault();
|
||||
Current.Value = classicDefault;
|
||||
}
|
||||
|
||||
public void ApplyDefault() => Current.SetDefault();
|
||||
|
||||
protected SettingsItem()
|
||||
{
|
||||
RelativeSizeAxes = Axes.X;
|
||||
|
Reference in New Issue
Block a user