From f7c9e449d4728ee8362e8139a00a85042ed9017f Mon Sep 17 00:00:00 2001 From: Jorolf Date: Tue, 11 Jul 2017 20:25:24 +0200 Subject: [PATCH] add ruleset settings --- osu.Game.Rulesets.Osu/OsuRuleset.cs | 3 ++ osu.Game.Rulesets.Osu/OsuSettings.cs | 33 +++++++++++++++++++ .../osu.Game.Rulesets.Osu.csproj | 1 + .../Settings/Sections/GameplaySection.cs | 15 +++++++++ .../Sections/Graphics/DetailSettings.cs | 22 ------------- osu.Game/Rulesets/Ruleset.cs | 3 ++ 6 files changed, 55 insertions(+), 22 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/OsuSettings.cs diff --git a/osu.Game.Rulesets.Osu/OsuRuleset.cs b/osu.Game.Rulesets.Osu/OsuRuleset.cs index 63fe6aaa59..8e8e186d40 100644 --- a/osu.Game.Rulesets.Osu/OsuRuleset.cs +++ b/osu.Game.Rulesets.Osu/OsuRuleset.cs @@ -15,6 +15,7 @@ using System.Collections.Generic; using System.Linq; using osu.Game.Rulesets.Osu.Scoring; using osu.Game.Rulesets.Scoring; +using osu.Game.Overlays.Settings; namespace osu.Game.Rulesets.Osu { @@ -119,6 +120,8 @@ namespace osu.Game.Rulesets.Osu public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor(); + public override SettingsSubsection CreateSettings() => new OsuSettings(); + public override int LegacyID => 0; } } diff --git a/osu.Game.Rulesets.Osu/OsuSettings.cs b/osu.Game.Rulesets.Osu/OsuSettings.cs new file mode 100644 index 0000000000..861b7bf73c --- /dev/null +++ b/osu.Game.Rulesets.Osu/OsuSettings.cs @@ -0,0 +1,33 @@ +// 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.Framework.Graphics; +using osu.Game.Configuration; +using osu.Game.Overlays.Settings; + +namespace osu.Game.Rulesets.Osu +{ + public class OsuSettings : SettingsSubsection + { + protected override string Header => "osu"; + + [BackgroundDependencyLoader] + private void load(OsuConfigManager config) + { + Children = new Drawable[] + { + new SettingsCheckbox + { + LabelText = "Snaking in sliders", + Bindable = config.GetBindable(OsuSetting.SnakingInSliders) + }, + new SettingsCheckbox + { + LabelText = "Snaking out sliders", + Bindable = config.GetBindable(OsuSetting.SnakingOutSliders) + }, + }; + } + } +} diff --git a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj index f6f565c502..3f60dfaa25 100644 --- a/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj +++ b/osu.Game.Rulesets.Osu/osu.Game.Rulesets.Osu.csproj @@ -78,6 +78,7 @@ + diff --git a/osu.Game/Overlays/Settings/Sections/GameplaySection.cs b/osu.Game/Overlays/Settings/Sections/GameplaySection.cs index be957912c1..c20519a9b5 100644 --- a/osu.Game/Overlays/Settings/Sections/GameplaySection.cs +++ b/osu.Game/Overlays/Settings/Sections/GameplaySection.cs @@ -1,9 +1,13 @@ // 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.Framework.Graphics; +using osu.Game.Database; using osu.Game.Graphics; using osu.Game.Overlays.Settings.Sections.Gameplay; +using osu.Game.Rulesets; +using System.Linq; namespace osu.Game.Overlays.Settings.Sections { @@ -20,5 +24,16 @@ namespace osu.Game.Overlays.Settings.Sections new SongSelectSettings(), }; } + + [BackgroundDependencyLoader] + private void load(RulesetDatabase rulesets) + { + foreach(Ruleset ruleset in rulesets.AllRulesets.Select(info => info.CreateInstance())) + { + SettingsSubsection section = ruleset.CreateSettings(); + if (section != null) + Add(section); + } + } } } \ No newline at end of file diff --git a/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs index 78eab6ebd8..c068da8129 100644 --- a/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs +++ b/osu.Game/Overlays/Settings/Sections/Graphics/DetailSettings.cs @@ -1,32 +1,10 @@ // 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.Framework.Graphics; -using osu.Game.Configuration; - namespace osu.Game.Overlays.Settings.Sections.Graphics { public class DetailSettings : SettingsSubsection { protected override string Header => "Detail Settings"; - - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - Children = new Drawable[] - { - new SettingsCheckbox - { - LabelText = "Snaking in sliders", - Bindable = config.GetBindable(OsuSetting.SnakingInSliders) - }, - new SettingsCheckbox - { - LabelText = "Snaking out sliders", - Bindable = config.GetBindable(OsuSetting.SnakingOutSliders) - }, - }; - } } } diff --git a/osu.Game/Rulesets/Ruleset.cs b/osu.Game/Rulesets/Ruleset.cs index 286ff331d2..3dbb39d894 100644 --- a/osu.Game/Rulesets/Ruleset.cs +++ b/osu.Game/Rulesets/Ruleset.cs @@ -8,6 +8,7 @@ using osu.Game.Rulesets.UI; using osu.Game.Screens.Play; using System.Collections.Generic; using osu.Game.Rulesets.Scoring; +using osu.Game.Overlays.Settings; namespace osu.Game.Rulesets { @@ -36,6 +37,8 @@ namespace osu.Game.Rulesets public abstract IEnumerable CreateGameplayKeys(); + public virtual SettingsSubsection CreateSettings() => null; + /// /// Do not override this unless you are a legacy mode. ///