mirror of https://github.com/ppy/osu
Expose and use test ruleset config cache in test scenes
This commit is contained in:
parent
8094b502cb
commit
c429c74d89
|
@ -25,9 +25,9 @@ public TestSceneEditor()
|
|||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IRulesetConfigCache configCache)
|
||||
private void load()
|
||||
{
|
||||
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
|
||||
var config = (ManiaRulesetConfigManager)RulesetConfigs.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
|
||||
config.BindWith(ManiaRulesetSetting.ScrollDirection, direction);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
using System.Linq;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
|
@ -25,9 +24,6 @@ namespace osu.Game.Rulesets.Mania.Tests
|
|||
[TestFixture]
|
||||
public class TestSceneTimingBasedNoteColouring : OsuTestScene
|
||||
{
|
||||
[Resolved]
|
||||
private IRulesetConfigCache configCache { get; set; }
|
||||
|
||||
private Bindable<bool> configTimingBasedNoteColouring;
|
||||
|
||||
private ManualClock clock;
|
||||
|
@ -49,7 +45,7 @@ public void SetUpSteps()
|
|||
});
|
||||
AddStep("retrieve config bindable", () =>
|
||||
{
|
||||
var config = (ManiaRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
|
||||
var config = (ManiaRulesetConfigManager)RulesetConfigs.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
|
||||
configTimingBasedNoteColouring = config.GetBindable<bool>(ManiaRulesetSetting.TimingBasedNoteColouring);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -47,9 +47,9 @@ protected override WorkingBeatmap CreateWorkingBeatmap(IBeatmap beatmap, Storybo
|
|||
=> new ClockBackedTestWorkingBeatmap(this.beatmap = beatmap, storyboard, new FramedClock(new ManualClock { Rate = 1 }), audioManager);
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(IRulesetConfigCache configCache)
|
||||
private void load()
|
||||
{
|
||||
var config = (OsuRulesetConfigManager)configCache.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
|
||||
var config = (OsuRulesetConfigManager)RulesetConfigs.GetConfigFor(Ruleset.Value.CreateInstance()).AsNonNull();
|
||||
config.BindWith(OsuRulesetSetting.SnakingInSliders, snakingIn);
|
||||
config.BindWith(OsuRulesetSetting.SnakingOutSliders, snakingOut);
|
||||
}
|
||||
|
|
|
@ -95,6 +95,16 @@ protected IAPIProvider API
|
|||
/// </remarks>
|
||||
protected Storage LocalStorage => localStorage.Value;
|
||||
|
||||
/// <summary>
|
||||
/// A cache for ruleset configurations to be used in this test scene.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This <see cref="IRulesetConfigCache"/> instance is provided to the children of this test scene via DI.
|
||||
/// It is only exposed so that test scenes themselves can access the ruleset config cache in a safe manner
|
||||
/// (<see cref="OsuTestScene"/>s cannot use DI themselves, as they will end up accessing the real cached instance from <see cref="OsuGameBase"/>).
|
||||
/// </remarks>
|
||||
protected IRulesetConfigCache RulesetConfigs { get; private set; }
|
||||
|
||||
private Lazy<Storage> localStorage;
|
||||
|
||||
private Storage headlessHostStorage;
|
||||
|
@ -124,7 +134,7 @@ protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnl
|
|||
// as well as problems due to the implementation details of the "real" implementation (the configs only being available at `LoadComplete()`),
|
||||
// cache a test implementation of the ruleset config cache over the "real" one.
|
||||
var isolatedBaseDependencies = new DependencyContainer(baseDependencies);
|
||||
isolatedBaseDependencies.CacheAs<IRulesetConfigCache>(new TestRulesetConfigCache());
|
||||
isolatedBaseDependencies.CacheAs(RulesetConfigs = new TestRulesetConfigCache());
|
||||
baseDependencies = isolatedBaseDependencies;
|
||||
|
||||
var providedRuleset = CreateRuleset();
|
||||
|
|
Loading…
Reference in New Issue