mirror of
https://github.com/ppy/osu.git
synced 2025-01-26 18:03:11 +08:00
Move ruleset dependency caching to CreateLocalDependencies
In some cases we may want to refer to the cached configmanager dependency from subclasses. This prevents injection errors when doing so.
This commit is contained in:
parent
f4fbf27d42
commit
be01dbae3a
@ -13,7 +13,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Configuration;
|
||||
using osu.Framework.Graphics.Cursor;
|
||||
using osu.Framework.Input;
|
||||
@ -86,11 +85,13 @@ namespace osu.Game.Rulesets.UI
|
||||
Cursor = CreateCursor();
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load([CanBeNull] OnScreenDisplay onScreenDisplay, [CanBeNull] SettingsStore settings)
|
||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||
{
|
||||
this.onScreenDisplay = onScreenDisplay;
|
||||
var dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
||||
|
||||
onScreenDisplay = dependencies.Get<OnScreenDisplay>();
|
||||
|
||||
var settings = dependencies.Get<SettingsStore>();
|
||||
if (settings != null)
|
||||
{
|
||||
rulesetConfig = Ruleset.CreateConfig(settings);
|
||||
@ -101,13 +102,10 @@ namespace osu.Game.Rulesets.UI
|
||||
onScreenDisplay?.BeginTracking(this, rulesetConfig);
|
||||
}
|
||||
}
|
||||
|
||||
return dependencies;
|
||||
}
|
||||
|
||||
private DependencyContainer dependencies;
|
||||
|
||||
protected override IReadOnlyDependencyContainer CreateLocalDependencies(IReadOnlyDependencyContainer parent)
|
||||
=> dependencies = new DependencyContainer(base.CreateLocalDependencies(parent));
|
||||
|
||||
public abstract ScoreProcessor CreateScoreProcessor();
|
||||
|
||||
/// <summary>
|
||||
|
Loading…
Reference in New Issue
Block a user