From bef15fe6375025990123c1197fe51db8a487be6d Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 2 May 2017 17:45:22 +0900 Subject: [PATCH] Improve organisation of some options and config code. --- osu.Game/Configuration/OsuConfigManager.cs | 69 ++++++++++--------- .../Options/Sections/Audio/MainMenuOptions.cs | 32 +++++++++ .../Overlays/Options/Sections/AudioSection.cs | 2 +- .../Sections/Graphics/MainMenuOptions.cs | 10 --- osu.Game/osu.Game.csproj | 1 + 5 files changed, 72 insertions(+), 42 deletions(-) create mode 100644 osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 30cd31c113..91652e8ef4 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -12,42 +12,61 @@ namespace osu.Game.Configuration { protected override void InitialiseDefaults() { -#pragma warning disable CS0612 // Type or member is obsolete + // UI/selection defaults + + Set(OsuConfig.Ruleset, 0, 0, int.MaxValue); + Set(OsuConfig.BeatmapDetailTab, BeatmapDetailTab.Details); + + // Online settings Set(OsuConfig.Username, string.Empty); Set(OsuConfig.Token, string.Empty); - Set(OsuConfig.Ruleset, 0, 0, int.MaxValue); + Set(OsuConfig.SavePassword, false).ValueChanged += delegate + { + if (Get(OsuConfig.SavePassword)) Set(OsuConfig.SaveUsername, true); + }; + + Set(OsuConfig.SaveUsername, true).ValueChanged += delegate + { + if (!Get(OsuConfig.SaveUsername)) Set(OsuConfig.SavePassword, false); + }; + + // Audio Set(OsuConfig.AudioDevice, string.Empty); - Set(OsuConfig.SavePassword, false); - Set(OsuConfig.SaveUsername, true); - - Set(OsuConfig.MenuCursorSize, 1.0, 0.5f, 2); - Set(OsuConfig.GameplayCursorSize, 1.0, 0.5f, 2); - Set(OsuConfig.DimLevel, 0.3, 0, 1); - - Set(OsuConfig.MouseDisableButtons, false); - Set(OsuConfig.MouseDisableWheel, false); - - Set(OsuConfig.SnakingInSliders, true); - Set(OsuConfig.SnakingOutSliders, true); - - Set(OsuConfig.MenuParallax, true); Set(OsuConfig.MenuVoice, true); Set(OsuConfig.MenuMusic, true); - Set(OsuConfig.BeatmapDetailTab, BeatmapDetailTab.Details); + Set(OsuConfig.AudioOffset, 0, -500.0, 500.0); + + // Input + + Set(OsuConfig.MenuCursorSize, 1.0, 0.5f, 2); + Set(OsuConfig.GameplayCursorSize, 1.0, 0.5f, 2); + + Set(OsuConfig.MouseDisableButtons, false); + Set(OsuConfig.MouseDisableWheel, false); + + // Graphics + + Set(OsuConfig.MenuParallax, true); + + Set(OsuConfig.SnakingInSliders, true); + Set(OsuConfig.SnakingOutSliders, true); + + // Gameplay + + Set(OsuConfig.DimLevel, 0.3, 0, 1); Set(OsuConfig.ShowInterface, true); Set(OsuConfig.KeyOverlay, false); //todo: implement all settings below this line (remove the Disabled set when doing so). - Set(OsuConfig.AudioOffset, 0, -500.0, 500.0); Set(OsuConfig.MouseSpeed, 1.0).Disabled = true; - Set(OsuConfig.BeatmapDirectory, @"Songs").Disabled = true; // TODO: use thi.Disabled = trues + Set(OsuConfig.BeatmapDirectory, @"Songs").Disabled = true; Set(OsuConfig.AllowPublicInvites, true).Disabled = true; Set(OsuConfig.AutoChatHide, true).Disabled = true; Set(OsuConfig.AutomaticDownload, true).Disabled = true; @@ -166,18 +185,6 @@ namespace osu.Game.Configuration Set(OsuConfig.Ticker, false).Disabled = true; Set(OsuConfig.CompatibilityContext, false).Disabled = true; Set(OsuConfig.CanForceOptimusCompatibility, true).Disabled = true; - Set(OsuConfig.ConfineMouse, Get(OsuConfig.ConfineMouseToFullscreen) ? - ConfineMouseMode.Fullscreen : ConfineMouseMode.Never).Disabled = true; - - GetOriginalBindable(OsuConfig.SavePassword).ValueChanged += delegate - { - if (Get(OsuConfig.SavePassword)) Set(OsuConfig.SaveUsername, true); - }; - GetOriginalBindable(OsuConfig.SaveUsername).ValueChanged += delegate - { - if (!Get(OsuConfig.SaveUsername)) Set(OsuConfig.SavePassword, false); - }; -#pragma warning restore CS0612 // Type or member is obsolete } public OsuConfigManager(Storage storage) : base(storage) diff --git a/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs b/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs new file mode 100644 index 0000000000..9de74e1b02 --- /dev/null +++ b/osu.Game/Overlays/Options/Sections/Audio/MainMenuOptions.cs @@ -0,0 +1,32 @@ +// Copyright (c) 2007-2017 ppy Pty Ltd . +// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE + +using osu.Framework.Allocation; +using osu.Game.Configuration; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Overlays.Options.Sections.Audio +{ + public class MainMenuOptions : OptionsSubsection + { + protected override string Header => "Main Menu"; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + Children = new[] + { + new OsuCheckbox + { + LabelText = "Interface voices", + Bindable = config.GetBindable(OsuConfig.MenuVoice) + }, + new OsuCheckbox + { + LabelText = "osu! music theme", + Bindable = config.GetBindable(OsuConfig.MenuMusic) + }, + }; + } + } +} \ No newline at end of file diff --git a/osu.Game/Overlays/Options/Sections/AudioSection.cs b/osu.Game/Overlays/Options/Sections/AudioSection.cs index 3de2bb4901..a9f8265a68 100644 --- a/osu.Game/Overlays/Options/Sections/AudioSection.cs +++ b/osu.Game/Overlays/Options/Sections/AudioSection.cs @@ -1,7 +1,6 @@ // Copyright (c) 2007-2017 ppy Pty Ltd . // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE -using osu.Framework; using osu.Framework.Graphics; using osu.Game.Graphics; using osu.Game.Overlays.Options.Sections.Audio; @@ -20,6 +19,7 @@ namespace osu.Game.Overlays.Options.Sections new AudioDevicesOptions(), new VolumeOptions(), new OffsetOptions(), + new MainMenuOptions(), }; } } diff --git a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs index c5000d8547..13683edb32 100644 --- a/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs +++ b/osu.Game/Overlays/Options/Sections/Graphics/MainMenuOptions.cs @@ -31,16 +31,6 @@ namespace osu.Game.Overlays.Options.Sections.Graphics LabelText = "Menu tips", Bindable = config.GetBindable(OsuConfig.ShowMenuTips) }, - new OsuCheckbox - { - LabelText = "Interface voices", - Bindable = config.GetBindable(OsuConfig.MenuVoice) - }, - new OsuCheckbox - { - LabelText = "osu! music theme", - Bindable = config.GetBindable(OsuConfig.MenuMusic) - }, }; } } diff --git a/osu.Game/osu.Game.csproj b/osu.Game/osu.Game.csproj index 2a1195135a..fb364ccdf5 100644 --- a/osu.Game/osu.Game.csproj +++ b/osu.Game/osu.Game.csproj @@ -78,6 +78,7 @@ +