mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:33:20 +08:00
Convert function weirdness to property + bool
This commit is contained in:
parent
5d0842ac44
commit
b41e273086
@ -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)
|
||||
},
|
||||
|
@ -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)
|
||||
}
|
||||
|
@ -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" }
|
||||
|
@ -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" }
|
||||
|
@ -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" },
|
||||
|
@ -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),
|
||||
},
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user