diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs index 2a2df777f7..aa36bde030 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapLeaderboard.cs @@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.SongSelect dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory)); dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get(), Resources, dependencies.Get(), Beatmap.Default)); - dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, null, ContextFactory, Scheduler)); + dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, ContextFactory, Scheduler)); return dependencies; } diff --git a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs index 7353e47229..9f0f4a6b8b 100644 --- a/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs +++ b/osu.Game.Tests/Visual/UserInterface/TestSceneDeleteLocalScore.cs @@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual.UserInterface dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory)); dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get(), Resources, dependencies.Get(), Beatmap.Default)); - dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, null, ContextFactory, Scheduler)); + dependencies.Cache(scoreManager = new ScoreManager(rulesetStore, () => beatmapManager, LocalStorage, ContextFactory, Scheduler)); beatmapInfo = beatmapManager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).Result.Value.Beatmaps[0]; diff --git a/osu.Game/Online/ScoreDownloadTracker.cs b/osu.Game/Online/ScoreDownloadTracker.cs index 32307fc50e..e09cc7c9cd 100644 --- a/osu.Game/Online/ScoreDownloadTracker.cs +++ b/osu.Game/Online/ScoreDownloadTracker.cs @@ -15,6 +15,9 @@ namespace osu.Game.Online [Resolved(CanBeNull = true)] protected ScoreManager? Manager { get; private set; } + [Resolved(CanBeNull = true)] + protected ScoreModelDownloader? Downloader { get; private set; } + private ArchiveDownloadRequest? attachedRequest; public ScoreDownloadTracker(ScoreInfo trackedItem) @@ -25,7 +28,7 @@ namespace osu.Game.Online [BackgroundDependencyLoader(true)] private void load() { - if (Manager == null) + if (Manager == null || Downloader == null) return; // Used to interact with manager classes that don't support interface types. Will eventually be replaced. @@ -38,10 +41,10 @@ namespace osu.Game.Online if (Manager.IsAvailableLocally(scoreInfo)) UpdateState(DownloadState.LocallyAvailable); else - attachDownload(Manager.GetExistingDownload(scoreInfo)); + attachDownload(Downloader.GetExistingDownload(scoreInfo)); - Manager.DownloadBegan += downloadBegan; - Manager.DownloadFailed += downloadFailed; + Downloader.DownloadBegan += downloadBegan; + Downloader.DownloadFailed += downloadFailed; Manager.ItemUpdated += itemUpdated; Manager.ItemRemoved += itemRemoved; } @@ -119,10 +122,14 @@ namespace osu.Game.Online base.Dispose(isDisposing); attachDownload(null); + if (Downloader != null) + { + Downloader.DownloadBegan -= downloadBegan; + Downloader.DownloadFailed -= downloadFailed; + } + if (Manager != null) { - Manager.DownloadBegan -= downloadBegan; - Manager.DownloadFailed -= downloadFailed; Manager.ItemUpdated -= itemUpdated; Manager.ItemRemoved -= itemRemoved; } diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index 1060724680..aa9bdac756 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -657,6 +657,8 @@ namespace osu.Game BeatmapManager.PostImport = items => PresentBeatmap(items.First().Value); BeatmapDownloader.PostNotification = n => Notifications.Post(n); + ScoreDownloader.PostNotification = n => Notifications.Post(n); + ScoreManager.PostNotification = n => Notifications.Post(n); ScoreManager.PostImport = items => PresentScore(items.First().Value); diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index a64d9ac01a..c0594231df 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -100,6 +100,8 @@ namespace osu.Game protected ScoreManager ScoreManager { get; private set; } + protected ScoreModelDownloader ScoreDownloader { get; private set; } + protected SkinManager SkinManager { get; private set; } protected RulesetStore RulesetStore { get; private set; } @@ -234,10 +236,12 @@ namespace osu.Game dependencies.Cache(fileStore = new FileStore(contextFactory, Storage)); // ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup() - dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, API, contextFactory, Scheduler, Host, () => difficultyCache, LocalConfig)); + dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, contextFactory, Scheduler, Host, () => difficultyCache, LocalConfig)); dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Resources, Host, defaultBeatmap, performOnlineLookups: true)); dependencies.Cache(BeatmapDownloader = new BeatmapModelDownloader(BeatmapManager, API, Host)); + dependencies.Cache(ScoreDownloader = new ScoreModelDownloader(ScoreManager, API, Host)); + // the following realm components are not actively used yet, but initialised and kept up to date for initial testing. realmRulesetStore = new RealmRulesetStore(realmFactory, Storage); diff --git a/osu.Game/Scoring/ScoreManager.cs b/osu.Game/Scoring/ScoreManager.cs index abc0bfdda7..8d9733669c 100644 --- a/osu.Game/Scoring/ScoreManager.cs +++ b/osu.Game/Scoring/ScoreManager.cs @@ -17,7 +17,6 @@ using osu.Game.Configuration; using osu.Game.Database; using osu.Game.IO; using osu.Game.IO.Archives; -using osu.Game.Online.API; using osu.Game.Overlays.Notifications; using osu.Game.Rulesets; using osu.Game.Rulesets.Judgements; @@ -25,15 +24,14 @@ using osu.Game.Rulesets.Scoring; namespace osu.Game.Scoring { - public class ScoreManager : IModelManager, IModelImporter, IModelDownloader + public class ScoreManager : IModelManager, IModelImporter { private readonly Scheduler scheduler; private readonly Func difficulties; private readonly OsuConfigManager configManager; private readonly ScoreModelManager scoreModelManager; - private readonly ScoreModelDownloader scoreModelDownloader; - public ScoreManager(RulesetStore rulesets, Func beatmaps, Storage storage, IAPIProvider api, IDatabaseContextFactory contextFactory, Scheduler scheduler, + public ScoreManager(RulesetStore rulesets, Func beatmaps, Storage storage, IDatabaseContextFactory contextFactory, Scheduler scheduler, IIpcHost importHost = null, Func difficulties = null, OsuConfigManager configManager = null) { this.scheduler = scheduler; @@ -41,7 +39,6 @@ namespace osu.Game.Scoring this.configManager = configManager; scoreModelManager = new ScoreModelManager(rulesets, beatmaps, storage, contextFactory, importHost); - scoreModelDownloader = new ScoreModelDownloader(scoreModelManager, api, importHost); } public Score GetScore(ScoreInfo score) => scoreModelManager.GetScore(score); @@ -240,11 +237,7 @@ namespace osu.Game.Scoring public Action PostNotification { - set - { - scoreModelManager.PostNotification = value; - scoreModelDownloader.PostNotification = value; - } + set => scoreModelManager.PostNotification = value; } #endregion @@ -342,30 +335,6 @@ namespace osu.Game.Scoring #endregion - #region Implementation of IModelDownloader - - public event Action> DownloadBegan - { - add => scoreModelDownloader.DownloadBegan += value; - remove => scoreModelDownloader.DownloadBegan -= value; - } - - public event Action> DownloadFailed - { - add => scoreModelDownloader.DownloadFailed += value; - remove => scoreModelDownloader.DownloadFailed -= value; - } - - public bool Download(IScoreInfo model, bool minimiseDownloadSize) => - scoreModelDownloader.Download(model, minimiseDownloadSize); - - public ArchiveDownloadRequest GetExistingDownload(IScoreInfo model) - { - return scoreModelDownloader.GetExistingDownload(model); - } - - #endregion - #region Implementation of IPresentImports public Action>> PostImport diff --git a/osu.Game/Screens/Ranking/ReplayDownloadButton.cs b/osu.Game/Screens/Ranking/ReplayDownloadButton.cs index 66b3c973f5..6a74fdaf75 100644 --- a/osu.Game/Screens/Ranking/ReplayDownloadButton.cs +++ b/osu.Game/Screens/Ranking/ReplayDownloadButton.cs @@ -45,7 +45,7 @@ namespace osu.Game.Screens.Ranking } [BackgroundDependencyLoader(true)] - private void load(OsuGame game, ScoreManager scores) + private void load(OsuGame game, ScoreModelDownloader scores) { InternalChild = shakeContainer = new ShakeContainer { @@ -65,7 +65,7 @@ namespace osu.Game.Screens.Ranking break; case DownloadState.NotDownloaded: - scores.Download(Score.Value, false); + scores.Download(Score.Value); break; case DownloadState.Importing: