1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:18:22 +08:00

Convert function weirdness to property + bool

This commit is contained in:
Dean Herbert 2022-04-26 15:06:27 +09:00
parent 5d0842ac44
commit b41e273086
7 changed files with 23 additions and 18 deletions

View File

@ -33,7 +33,7 @@ namespace osu.Game.Rulesets.Osu.UI
},
new SettingsCheckbox
{
GetClassicDefault = () => false,
ClassicDefault = false,
LabelText = "Snaking out sliders",
Current = config.GetBindable<bool>(OsuRulesetSetting.SnakingOutSliders)
},

View File

@ -28,7 +28,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
},
new SettingsCheckbox
{
GetClassicDefault = () => false,
ClassicDefault = false,
LabelText = GameplaySettingsStrings.AlwaysPlayFirstComboBreak,
Current = config.GetBindable<bool>(OsuSetting.AlwaysPlayFirstComboBreak)
}

View File

@ -21,7 +21,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
{
new SettingsEnumDropdown<ScoringMode>
{
GetClassicDefault = () => ScoringMode.Classic,
ClassicDefault = ScoringMode.Classic,
LabelText = GameplaySettingsStrings.ScoreDisplayMode,
Current = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode),
Keywords = new[] { "scoring" }

View File

@ -30,7 +30,7 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
},
new SettingsCheckbox
{
GetClassicDefault = () => false,
ClassicDefault = false,
LabelText = GameplaySettingsStrings.ShowHealthDisplayWhenCantFail,
Current = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail),
Keywords = new[] { "hp", "bar" }

View File

@ -37,7 +37,7 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
},
new SettingsSlider<double, TimeSlider>
{
GetClassicDefault = () => 0,
ClassicDefault = 0,
LabelText = UserInterfaceStrings.HoldToConfirmActivationTime,
Current = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay),
Keywords = new[] { @"delay" },

View File

@ -32,7 +32,7 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
{
new SettingsCheckbox
{
GetClassicDefault = () => true,
ClassicDefault = true,
LabelText = UserInterfaceStrings.RightMouseScroll,
Current = config.GetBindable<bool>(OsuSetting.SongSelectRightMouseScroll),
},

View File

@ -107,10 +107,8 @@ namespace osu.Game.Overlays.Settings
LabelText.ToString()
};
if (GetClassicDefault != null)
{
if (hasClassicDefault)
keywords.Add(CLASSIC_DEFAULT_SEARCH_TERM);
}
return keywords;
}
@ -126,20 +124,27 @@ namespace osu.Game.Overlays.Settings
public event Action SettingChanged;
private T classicDefault;
private bool hasClassicDefault;
/// <summary>
/// An action which when invoked will apply a classic default value to this setting.
/// A "classic" default value for this setting.
/// </summary>
public Func<T> GetClassicDefault { get; set; }
public T ClassicDefault
{
set
{
classicDefault = value;
hasClassicDefault = true;
}
}
public void ApplyClassicDefault(bool useClassicDefault)
{
if (GetClassicDefault != null)
{
if (useClassicDefault)
Current.Value = GetClassicDefault();
else
Current.SetDefault();
}
if (hasClassicDefault && useClassicDefault)
Current.Value = classicDefault;
else
Current.SetDefault();
}
protected SettingsItem()