mirror of
https://github.com/ppy/osu.git
synced 2026-06-06 17:54:29 +08:00
Avoid requiring private variables to set ApplyClassicDefault settings
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
using osu.Game.Localisation;
|
||||
@@ -14,8 +15,6 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
{
|
||||
public partial class OsuSettingsSubsection : RulesetSettingsSubsection
|
||||
{
|
||||
private FormCheckBox snakingOutSliders = null!;
|
||||
|
||||
protected override LocalisableString Header => "osu!";
|
||||
|
||||
public OsuSettingsSubsection(Ruleset ruleset)
|
||||
@@ -35,13 +34,13 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
Caption = RulesetSettingsStrings.SnakingInSliders,
|
||||
Current = config.GetBindable<bool>(OsuRulesetSetting.SnakingInSliders)
|
||||
}),
|
||||
new SettingsItemV2(snakingOutSliders = new FormCheckBox
|
||||
new SettingsItemV2(new FormCheckBox
|
||||
{
|
||||
Caption = RulesetSettingsStrings.SnakingOutSliders,
|
||||
Current = config.GetBindable<bool>(OsuRulesetSetting.SnakingOutSliders)
|
||||
})
|
||||
{
|
||||
ApplyClassicDefault = () => snakingOutSliders.Current.Value = false,
|
||||
ApplyClassicDefault = c => ((IHasCurrentValue<bool>)c).Current.Value = false,
|
||||
},
|
||||
new SettingsItemV2(new FormCheckBox
|
||||
{
|
||||
|
||||
@@ -10,6 +10,7 @@ using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Testing;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics.Containers;
|
||||
@@ -31,7 +32,6 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
private FormSliderBar<float> sliderBar = null!;
|
||||
private FormSliderBar<float> classicSliderBar = null!;
|
||||
|
||||
private SearchContainer searchContainer = null!;
|
||||
|
||||
@@ -173,7 +173,7 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
{
|
||||
ShowRevertToDefaultButton = false
|
||||
},
|
||||
new SettingsItemV2(classicSliderBar = new FormSliderBar<float>
|
||||
new SettingsItemV2(new FormSliderBar<float>
|
||||
{
|
||||
Caption = "Slider with classic default",
|
||||
Current = new BindableFloat
|
||||
@@ -185,7 +185,7 @@ namespace osu.Game.Tests.Visual.Settings
|
||||
},
|
||||
})
|
||||
{
|
||||
ApplyClassicDefault = () => classicSliderBar.Current.Value = 2,
|
||||
ApplyClassicDefault = c => ((IHasCurrentValue<float>)c).Current.Value = 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
@@ -12,8 +13,6 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
public partial class AudioSettings : SettingsSubsection
|
||||
{
|
||||
private FormCheckBox alwaysPlayFirstComboBreak = null!;
|
||||
|
||||
protected override LocalisableString Header => GameplaySettingsStrings.AudioHeader;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@@ -31,13 +30,13 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
Keywords = new[] { @"positional", @"balance" },
|
||||
},
|
||||
new SettingsItemV2(alwaysPlayFirstComboBreak = new FormCheckBox
|
||||
new SettingsItemV2(new FormCheckBox
|
||||
{
|
||||
Caption = GameplaySettingsStrings.AlwaysPlayFirstComboBreak,
|
||||
Current = config.GetBindable<bool>(OsuSetting.AlwaysPlayFirstComboBreak)
|
||||
})
|
||||
{
|
||||
ApplyClassicDefault = () => alwaysPlayFirstComboBreak.Current.Value = false,
|
||||
ApplyClassicDefault = c => ((IHasCurrentValue<bool>)c).Current.Value = false,
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
@@ -13,8 +14,6 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
public partial class GeneralSettings : SettingsSubsection
|
||||
{
|
||||
private FormEnumDropdown<ScoringMode> scoringModeDropdown = null!;
|
||||
|
||||
protected override LocalisableString Header => CommonStrings.General;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@@ -22,14 +21,14 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new SettingsItemV2(scoringModeDropdown = new FormEnumDropdown<ScoringMode>
|
||||
new SettingsItemV2(new FormEnumDropdown<ScoringMode>
|
||||
{
|
||||
Caption = GameplaySettingsStrings.ScoreDisplayMode,
|
||||
Current = config.GetBindable<ScoringMode>(OsuSetting.ScoreDisplayMode),
|
||||
})
|
||||
{
|
||||
Keywords = new[] { "scoring" },
|
||||
ApplyClassicDefault = () => scoringModeDropdown.Current.Value = ScoringMode.Classic,
|
||||
ApplyClassicDefault = c => ((IHasCurrentValue<ScoringMode>)c).Current.Value = ScoringMode.Classic,
|
||||
},
|
||||
new SettingsItemV2(new FormCheckBox
|
||||
{
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
@@ -12,8 +13,6 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
{
|
||||
public partial class HUDSettings : SettingsSubsection
|
||||
{
|
||||
private FormCheckBox showHealthDisplayWhenCantFail = null!;
|
||||
|
||||
protected override LocalisableString Header => GameplaySettingsStrings.HUDHeader;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@@ -57,14 +56,14 @@ namespace osu.Game.Overlays.Settings.Sections.Gameplay
|
||||
Caption = GameplaySettingsStrings.AlwaysShowHoldForMenuButton,
|
||||
Current = config.GetBindable<bool>(OsuSetting.AlwaysShowHoldForMenuButton),
|
||||
}),
|
||||
new SettingsItemV2(showHealthDisplayWhenCantFail = new FormCheckBox
|
||||
new SettingsItemV2(new FormCheckBox
|
||||
{
|
||||
Caption = GameplaySettingsStrings.ShowHealthDisplayWhenCantFail,
|
||||
Current = config.GetBindable<bool>(OsuSetting.ShowHealthDisplayWhenCantFail),
|
||||
})
|
||||
{
|
||||
Keywords = new[] { "hp", "bar" },
|
||||
ApplyClassicDefault = () => showHealthDisplayWhenCantFail.Current.Value = false,
|
||||
ApplyClassicDefault = c => ((IHasCurrentValue<bool>)c).Current.Value = false,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
@@ -12,8 +13,6 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
|
||||
{
|
||||
public partial class GeneralSettings : SettingsSubsection
|
||||
{
|
||||
private FormSliderBar<double> holdToConfirmSlider = null!;
|
||||
|
||||
protected override LocalisableString Header => CommonStrings.General;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@@ -38,7 +37,7 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
|
||||
Caption = UserInterfaceStrings.Parallax,
|
||||
Current = config.GetBindable<bool>(OsuSetting.MenuParallax)
|
||||
}),
|
||||
new SettingsItemV2(holdToConfirmSlider = new FormSliderBar<double>
|
||||
new SettingsItemV2(new FormSliderBar<double>
|
||||
{
|
||||
Caption = UserInterfaceStrings.HoldToConfirmActivationTime,
|
||||
Current = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay),
|
||||
@@ -47,7 +46,7 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
|
||||
})
|
||||
{
|
||||
Keywords = new[] { @"delay" },
|
||||
ApplyClassicDefault = () => holdToConfirmSlider.Current.Value = 0,
|
||||
ApplyClassicDefault = c => ((IHasCurrentValue<double>)c).Current.Value = 0,
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics.UserInterfaceV2;
|
||||
@@ -13,9 +14,6 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
|
||||
{
|
||||
public partial class SongSelectSettings : SettingsSubsection
|
||||
{
|
||||
private FormEnumDropdown<ModSelectHotkeyStyle> modSelectHotkeyStyle = null!;
|
||||
private FormCheckBox modSelectTextSearchStartsActive = null!;
|
||||
|
||||
protected override LocalisableString Header => UserInterfaceStrings.SongSelectHeader;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@@ -36,21 +34,21 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface
|
||||
Caption = UserInterfaceStrings.RandomSelectionAlgorithm,
|
||||
Current = config.GetBindable<RandomSelectAlgorithm>(OsuSetting.RandomSelectAlgorithm),
|
||||
}),
|
||||
new SettingsItemV2(modSelectHotkeyStyle = new FormEnumDropdown<ModSelectHotkeyStyle>
|
||||
new SettingsItemV2(new FormEnumDropdown<ModSelectHotkeyStyle>
|
||||
{
|
||||
Caption = UserInterfaceStrings.ModSelectHotkeyStyle,
|
||||
Current = config.GetBindable<ModSelectHotkeyStyle>(OsuSetting.ModSelectHotkeyStyle),
|
||||
})
|
||||
{
|
||||
ApplyClassicDefault = () => modSelectHotkeyStyle.Current.Value = ModSelectHotkeyStyle.Classic,
|
||||
ApplyClassicDefault = c => ((IHasCurrentValue<ModSelectHotkeyStyle>)c).Current.Value = ModSelectHotkeyStyle.Classic,
|
||||
},
|
||||
new SettingsItemV2(modSelectTextSearchStartsActive = new FormCheckBox
|
||||
new SettingsItemV2(new FormCheckBox
|
||||
{
|
||||
Caption = UserInterfaceStrings.ModSelectTextSearchStartsActive,
|
||||
Current = config.GetBindable<bool>(OsuSetting.ModSelectTextSearchStartsActive),
|
||||
})
|
||||
{
|
||||
ApplyClassicDefault = () => modSelectTextSearchStartsActive.Current.Value = false,
|
||||
ApplyClassicDefault = c => ((IHasCurrentValue<bool>)c).Current.Value = false,
|
||||
},
|
||||
new SettingsItemV2(new FormCheckBox
|
||||
{
|
||||
|
||||
@@ -112,9 +112,9 @@ namespace osu.Game.Overlays.Settings
|
||||
/// If set, this setting is considered as having a "classic" default value,
|
||||
/// and this is the function for overwriting the control with that value.
|
||||
/// </summary>
|
||||
public Action? ApplyClassicDefault { get; set; }
|
||||
public Action<IFormControl>? ApplyClassicDefault { get; set; }
|
||||
|
||||
void ISettingsItem.ApplyClassicDefault() => ApplyClassicDefault?.Invoke();
|
||||
void ISettingsItem.ApplyClassicDefault() => ApplyClassicDefault?.Invoke(Control);
|
||||
|
||||
public void ApplyDefault()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user