mirror of
https://github.com/osukey/osukey.git
synced 2025-08-02 22:26:41 +09:00
Cache ruleset dependencies if the scene tests ruleset-specific components
This commit is contained in:
@ -20,6 +20,8 @@ using osu.Game.Database;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Testing;
|
||||
using osu.Game.Rulesets.UI;
|
||||
using osu.Game.Screens;
|
||||
using osu.Game.Storyboards;
|
||||
using osu.Game.Tests.Beatmaps;
|
||||
@ -36,6 +38,8 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected new OsuScreenDependencies Dependencies { get; private set; }
|
||||
|
||||
private DrawableRulesetDependencies rulesetDependencies;
|
||||
|
||||
private Lazy<Storage> localStorage;
|
||||
protected Storage LocalStorage => localStorage.Value;
|
||||
|
||||
@ -64,7 +68,12 @@ namespace osu.Game.Tests.Visual
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
Dependencies = new OsuScreenDependencies(false, base.CreateChildDependencies(parent));
|
||||
var baseDependencies = base.CreateChildDependencies(parent);
|
||||
|
||||
if (this is IRulesetTestScene rts)
|
||||
baseDependencies = rulesetDependencies = new DrawableRulesetDependencies(rts.CreateRuleset(), baseDependencies);
|
||||
|
||||
Dependencies = new OsuScreenDependencies(false, baseDependencies);
|
||||
|
||||
Beatmap = Dependencies.Beatmap;
|
||||
Beatmap.SetDefault();
|
||||
@ -142,6 +151,8 @@ namespace osu.Game.Tests.Visual
|
||||
{
|
||||
base.Dispose(isDisposing);
|
||||
|
||||
rulesetDependencies?.Dispose();
|
||||
|
||||
if (Beatmap?.Value.TrackLoaded == true)
|
||||
Beatmap.Value.Track.Stop();
|
||||
|
||||
|
Reference in New Issue
Block a user