1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-13 08:32:57 +08:00

Use extracted ruleset config cache implementation in DI

This commit is contained in:
Bartłomiej Dach 2021-12-23 19:02:10 +01:00
parent 0f65c4e960
commit 5cbaa028eb
No known key found for this signature in database
GPG Key ID: BCECCD4FA41F6497
8 changed files with 14 additions and 11 deletions

View File

@ -4,6 +4,7 @@
using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Game.Rulesets.Mania.UI;
using osu.Game.Tests.Visual;
@ -24,9 +25,9 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
}
[BackgroundDependencyLoader]
private void load(RulesetConfigCache configCache)
private void load(IRulesetConfigCache configCache)
{
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
config.BindWith(ManiaRulesetSetting.ScrollDirection, direction);
}
}

View File

@ -14,6 +14,7 @@ using osu.Game.Rulesets.Mania.Objects;
using osu.Game.Rulesets.Mania.Beatmaps;
using osu.Game.Rulesets.Mania.Configuration;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Rulesets.Mania.Objects.Drawables;
@ -25,7 +26,7 @@ namespace osu.Game.Rulesets.Mania.Tests
public class TestSceneTimingBasedNoteColouring : OsuTestScene
{
[Resolved]
private RulesetConfigCache configCache { get; set; }
private IRulesetConfigCache configCache { get; set; }
private Bindable<bool> configTimingBasedNoteColouring;
@ -48,7 +49,7 @@ namespace osu.Game.Rulesets.Mania.Tests
});
AddStep("retrieve config bindable", () =>
{
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
configTimingBasedNoteColouring = config.GetBindable<bool>(ManiaRulesetSetting.TimingBasedNoteColouring);
});
}

View File

@ -9,6 +9,7 @@ using NUnit.Framework;
using osu.Framework.Allocation;
using osu.Framework.Audio;
using osu.Framework.Bindables;
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics.Containers;
using osu.Framework.Testing;
using osu.Framework.Timing;
@ -46,9 +47,9 @@ namespace osu.Game.Rulesets.Osu.Tests
=> new ClockBackedTestWorkingBeatmap(this.beatmap = beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
[BackgroundDependencyLoader]
private void load(RulesetConfigCache configCache)
private void load(IRulesetConfigCache configCache)
{
var config = (OsuRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance());
var config = (OsuRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
config.BindWith(OsuRulesetSetting.SnakingInSliders, snakingIn);
config.BindWith(OsuRulesetSetting.SnakingOutSliders, snakingOut);
}

View File

@ -72,7 +72,7 @@ namespace osu.Game.Tests.Visual.Navigation
typeof(FileStore),
typeof(ScoreManager),
typeof(BeatmapManager),
typeof(RulesetConfigCache),
typeof(IRulesetConfigCache),
typeof(OsuColour),
typeof(IBindable<WorkingBeatmap>),
typeof(Bindable<WorkingBeatmap>),

View File

@ -268,7 +268,7 @@ namespace osu.Game
dependencies.Cache(scorePerformanceManager);
AddInternal(scorePerformanceManager);
dependencies.Cache(rulesetConfigCache = new RulesetConfigCache(realmFactory, RulesetStore));
dependencies.CacheAs<IRulesetConfigCache>(rulesetConfigCache = new RulesetConfigCache(realmFactory, RulesetStore));
var powerStatus = CreateBatteryInfo();
if (powerStatus != null)

View File

@ -29,7 +29,7 @@ namespace osu.Game.Overlays.Settings
{
dependencies = new DependencyContainer(base.CreateChildDependencies(parent));
Config = dependencies.Get<RulesetConfigCache>().GetConfigFor(ruleset);
Config = dependencies.Get<IRulesetConfigCache>().GetConfigFor(ruleset);
if (Config != null)
dependencies.Cache(Config);

View File

@ -80,7 +80,7 @@ namespace osu.Game.Rulesets.Edit
[BackgroundDependencyLoader]
private void load()
{
Config = Dependencies.Get<RulesetConfigCache>().GetConfigFor(Ruleset);
Config = Dependencies.Get<IRulesetConfigCache>().GetConfigFor(Ruleset);
try
{

View File

@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.UI
CacheAs(ShaderManager = new FallbackShaderManager(ShaderManager, parent.Get<ShaderManager>()));
}
RulesetConfigManager = parent.Get<RulesetConfigCache>().GetConfigFor(ruleset);
RulesetConfigManager = parent.Get<IRulesetConfigCache>().GetConfigFor(ruleset);
if (RulesetConfigManager != null)
Cache(RulesetConfigManager);
}