diff --git a/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs b/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs index 56a30f89ac..2382fe6d95 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuSettingsSubsection.cs @@ -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(OsuRulesetSetting.SnakingInSliders) }), - new SettingsItemV2(snakingOutSliders = new FormCheckBox + new SettingsItemV2(new FormCheckBox { Caption = RulesetSettingsStrings.SnakingOutSliders, Current = config.GetBindable(OsuRulesetSetting.SnakingOutSliders) }) { - ApplyClassicDefault = () => snakingOutSliders.Current.Value = false, + ApplyClassicDefault = c => ((IHasCurrentValue)c).Current.Value = false, }, new SettingsItemV2(new FormCheckBox { diff --git a/osu.Game.Tests/Visual/Settings/TestSceneSettingsItemV2.cs b/osu.Game.Tests/Visual/Settings/TestSceneSettingsItemV2.cs index 043eadf370..d460ea0078 100644 --- a/osu.Game.Tests/Visual/Settings/TestSceneSettingsItemV2.cs +++ b/osu.Game.Tests/Visual/Settings/TestSceneSettingsItemV2.cs @@ -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 sliderBar = null!; - private FormSliderBar classicSliderBar = null!; private SearchContainer searchContainer = null!; @@ -173,7 +173,7 @@ namespace osu.Game.Tests.Visual.Settings { ShowRevertToDefaultButton = false }, - new SettingsItemV2(classicSliderBar = new FormSliderBar + new SettingsItemV2(new FormSliderBar { 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)c).Current.Value = 2, }, }, }, diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/AudioSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/AudioSettings.cs index 403b4f2378..e4c64612f5 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/AudioSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/AudioSettings.cs @@ -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(OsuSetting.AlwaysPlayFirstComboBreak) }) { - ApplyClassicDefault = () => alwaysPlayFirstComboBreak.Current.Value = false, + ApplyClassicDefault = c => ((IHasCurrentValue)c).Current.Value = false, } }; } diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs index 34879ffa99..4f402c1cb7 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/GeneralSettings.cs @@ -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 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 + new SettingsItemV2(new FormEnumDropdown { Caption = GameplaySettingsStrings.ScoreDisplayMode, Current = config.GetBindable(OsuSetting.ScoreDisplayMode), }) { Keywords = new[] { "scoring" }, - ApplyClassicDefault = () => scoringModeDropdown.Current.Value = ScoringMode.Classic, + ApplyClassicDefault = c => ((IHasCurrentValue)c).Current.Value = ScoringMode.Classic, }, new SettingsItemV2(new FormCheckBox { diff --git a/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs b/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs index 7c9fad624c..711e10da47 100644 --- a/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Gameplay/HUDSettings.cs @@ -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(OsuSetting.AlwaysShowHoldForMenuButton), }), - new SettingsItemV2(showHealthDisplayWhenCantFail = new FormCheckBox + new SettingsItemV2(new FormCheckBox { Caption = GameplaySettingsStrings.ShowHealthDisplayWhenCantFail, Current = config.GetBindable(OsuSetting.ShowHealthDisplayWhenCantFail), }) { Keywords = new[] { "hp", "bar" }, - ApplyClassicDefault = () => showHealthDisplayWhenCantFail.Current.Value = false, + ApplyClassicDefault = c => ((IHasCurrentValue)c).Current.Value = false, }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs b/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs index 1e8852d4b7..9a894e89fe 100644 --- a/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/UserInterface/GeneralSettings.cs @@ -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 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(OsuSetting.MenuParallax) }), - new SettingsItemV2(holdToConfirmSlider = new FormSliderBar + new SettingsItemV2(new FormSliderBar { Caption = UserInterfaceStrings.HoldToConfirmActivationTime, Current = config.GetBindable(OsuSetting.UIHoldActivationDelay), @@ -47,7 +46,7 @@ namespace osu.Game.Overlays.Settings.Sections.UserInterface }) { Keywords = new[] { @"delay" }, - ApplyClassicDefault = () => holdToConfirmSlider.Current.Value = 0, + ApplyClassicDefault = c => ((IHasCurrentValue)c).Current.Value = 0, }, }; } diff --git a/osu.Game/Overlays/Settings/Sections/UserInterface/SongSelectSettings.cs b/osu.Game/Overlays/Settings/Sections/UserInterface/SongSelectSettings.cs index 4052842de9..83ee3eb09a 100644 --- a/osu.Game/Overlays/Settings/Sections/UserInterface/SongSelectSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/UserInterface/SongSelectSettings.cs @@ -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 = 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(OsuSetting.RandomSelectAlgorithm), }), - new SettingsItemV2(modSelectHotkeyStyle = new FormEnumDropdown + new SettingsItemV2(new FormEnumDropdown { Caption = UserInterfaceStrings.ModSelectHotkeyStyle, Current = config.GetBindable(OsuSetting.ModSelectHotkeyStyle), }) { - ApplyClassicDefault = () => modSelectHotkeyStyle.Current.Value = ModSelectHotkeyStyle.Classic, + ApplyClassicDefault = c => ((IHasCurrentValue)c).Current.Value = ModSelectHotkeyStyle.Classic, }, - new SettingsItemV2(modSelectTextSearchStartsActive = new FormCheckBox + new SettingsItemV2(new FormCheckBox { Caption = UserInterfaceStrings.ModSelectTextSearchStartsActive, Current = config.GetBindable(OsuSetting.ModSelectTextSearchStartsActive), }) { - ApplyClassicDefault = () => modSelectTextSearchStartsActive.Current.Value = false, + ApplyClassicDefault = c => ((IHasCurrentValue)c).Current.Value = false, }, new SettingsItemV2(new FormCheckBox { diff --git a/osu.Game/Overlays/Settings/SettingsItemV2.cs b/osu.Game/Overlays/Settings/SettingsItemV2.cs index 48de6723ea..fea127200a 100644 --- a/osu.Game/Overlays/Settings/SettingsItemV2.cs +++ b/osu.Game/Overlays/Settings/SettingsItemV2.cs @@ -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. /// - public Action? ApplyClassicDefault { get; set; } + public Action? ApplyClassicDefault { get; set; } - void ISettingsItem.ApplyClassicDefault() => ApplyClassicDefault?.Invoke(); + void ISettingsItem.ApplyClassicDefault() => ApplyClassicDefault?.Invoke(Control); public void ApplyDefault() {