From 6dbc75283cdc8261812620bf61c3388f358c3490 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Sat, 15 Apr 2017 05:52:46 +0900 Subject: [PATCH] Re-implement config value. --- osu.Game/Configuration/OsuConfigManager.cs | 2 ++ osu.Game/Modes/RulesetCollection.cs | 3 +++ osu.Game/OsuGame.cs | 8 +++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/osu.Game/Configuration/OsuConfigManager.cs b/osu.Game/Configuration/OsuConfigManager.cs index 2f37717286..8e82406dee 100644 --- a/osu.Game/Configuration/OsuConfigManager.cs +++ b/osu.Game/Configuration/OsuConfigManager.cs @@ -17,6 +17,8 @@ namespace osu.Game.Configuration Set(OsuConfig.Username, string.Empty); Set(OsuConfig.Token, string.Empty); + Set(OsuConfig.Ruleset, 0, 0, int.MaxValue); + Set(OsuConfig.AudioDevice, string.Empty); Set(OsuConfig.SavePassword, false); Set(OsuConfig.SaveUsername, true); diff --git a/osu.Game/Modes/RulesetCollection.cs b/osu.Game/Modes/RulesetCollection.cs index a8cb8f8e26..d699bbfabe 100644 --- a/osu.Game/Modes/RulesetCollection.cs +++ b/osu.Game/Modes/RulesetCollection.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Concurrent; using System.Collections.Generic; +using System.Linq; namespace osu.Game.Modes { @@ -31,6 +32,8 @@ namespace osu.Game.Modes return ruleset; } + public static int GetId(Ruleset ruleset) => available_rulesets.First(kvp => kvp.Value == ruleset).Key; + public static IEnumerable AllRulesets => available_rulesets.Values; } } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 44c1188ab3..3379787d6d 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -58,7 +58,8 @@ namespace osu.Game private VolumeControl volume; - public Bindable Ruleset; + private Bindable configRuleset; + public Bindable Ruleset = new Bindable(); private readonly string[] args; @@ -88,8 +89,9 @@ namespace osu.Game Dependencies.Cache(this); - // Todo: I don't think this'll work, need BindableRuleset - Ruleset = new Bindable(); + configRuleset = LocalConfig.GetBindable(OsuConfig.Ruleset); + Ruleset.Value = RulesetCollection.GetRuleset(configRuleset.Value); + Ruleset.ValueChanged += r => configRuleset.Value = RulesetCollection.GetId(r); } private ScheduledDelegate scoreLoad;