Bring back SettingsStore to avoid changing ruleset API for now

Also fixes some remaining test failures due to locally constructed
rulesets that are not being tracked by the game.
This commit is contained in:
Dean Herbert
2021-09-15 16:08:31 +09:00
parent c36a67d06e
commit 520e550764
11 changed files with 95 additions and 69 deletions

View File

@ -4,6 +4,7 @@
using System;
using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Rulesets.Configuration;
@ -30,13 +31,15 @@ namespace osu.Game.Rulesets
{
base.LoadComplete();
var settingsStore = new SettingsStore(realmFactory);
// let's keep things simple for now and just retrieve all the required configs at startup..
foreach (var ruleset in rulesets.AvailableRulesets)
{
if (ruleset.ID == null)
continue;
configCache[ruleset.ID.Value] = ruleset.CreateInstance().CreateConfig(realmFactory);
configCache[ruleset.ID.Value] = ruleset.CreateInstance().CreateConfig(settingsStore);
}
}
@ -52,7 +55,9 @@ namespace osu.Game.Rulesets
return null;
if (!configCache.TryGetValue(ruleset.RulesetInfo.ID.Value, out var config))
return ruleset.CreateConfig(realmFactory);
// any ruleset request which wasn't initialised on startup should not be stored to realm.
// this should only be used by tests.
return ruleset.CreateConfig(null);
return config;
}