Tidy up initialisation code and avoid using DI on inherited class

This commit is contained in:
Dean Herbert 2021-04-19 11:30:55 +09:00
parent 2b6caf9b65
commit dbb8f7f4a9
2 changed files with 9 additions and 7 deletions

View File

@ -577,15 +577,15 @@ protected override void LoadComplete()
dependencies.CacheAs(idleTracker = new GameIdleTracker(6000));
GameIdleTracker sessionIdleTracker = new GameIdleTracker(300_000);
Add(sessionIdleTracker);
sessionIdleTracker.IsIdle.BindValueChanged(e =>
var sessionIdleTracker = new GameIdleTracker(300000);
sessionIdleTracker.IsIdle.BindValueChanged(idle =>
{
if (e.NewValue)
Dependencies.Get<SessionStatics>().ResetValues();
if (idle.NewValue)
SessionStatics.ResetValues();
});
Add(new GameIdleTracker(300000));
AddRange(new Drawable[]
{
new VolumeControlReceptor

View File

@ -61,6 +61,8 @@ public class OsuGameBase : Framework.Game, ICanAcceptFiles
protected OsuConfigManager LocalConfig;
protected SessionStatics SessionStatics { get; private set; }
protected BeatmapManager BeatmapManager;
protected ScoreManager ScoreManager;
@ -289,7 +291,7 @@ List<ScoreInfo> getBeatmapScores(BeatmapSetInfo set)
if (powerStatus != null)
dependencies.CacheAs(powerStatus);
dependencies.Cache(new SessionStatics());
dependencies.Cache(SessionStatics = new SessionStatics());
dependencies.Cache(new OsuColour());
RegisterImportHandler(BeatmapManager);