mirror of
https://github.com/osukey/osukey.git
synced 2025-07-01 16:29:58 +09:00
Move score download logic out of ScoreManager
This commit is contained in:
@ -42,7 +42,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
|
|
||||||
dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory));
|
dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory));
|
||||||
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), 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;
|
return dependencies;
|
||||||
}
|
}
|
||||||
|
@ -83,7 +83,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory));
|
dependencies.Cache(rulesetStore = new RulesetStore(ContextFactory));
|
||||||
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), Beatmap.Default));
|
dependencies.Cache(beatmapManager = new BeatmapManager(LocalStorage, ContextFactory, rulesetStore, null, dependencies.Get<AudioManager>(), Resources, dependencies.Get<GameHost>(), 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];
|
beatmapInfo = beatmapManager.Import(new ImportTask(TestResources.GetQuickTestBeatmapForImport())).Result.Value.Beatmaps[0];
|
||||||
|
|
||||||
|
@ -15,6 +15,9 @@ namespace osu.Game.Online
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
protected ScoreManager? Manager { get; private set; }
|
protected ScoreManager? Manager { get; private set; }
|
||||||
|
|
||||||
|
[Resolved(CanBeNull = true)]
|
||||||
|
protected ScoreModelDownloader? Downloader { get; private set; }
|
||||||
|
|
||||||
private ArchiveDownloadRequest<IScoreInfo>? attachedRequest;
|
private ArchiveDownloadRequest<IScoreInfo>? attachedRequest;
|
||||||
|
|
||||||
public ScoreDownloadTracker(ScoreInfo trackedItem)
|
public ScoreDownloadTracker(ScoreInfo trackedItem)
|
||||||
@ -25,7 +28,7 @@ namespace osu.Game.Online
|
|||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
if (Manager == null)
|
if (Manager == null || Downloader == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Used to interact with manager classes that don't support interface types. Will eventually be replaced.
|
// 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))
|
if (Manager.IsAvailableLocally(scoreInfo))
|
||||||
UpdateState(DownloadState.LocallyAvailable);
|
UpdateState(DownloadState.LocallyAvailable);
|
||||||
else
|
else
|
||||||
attachDownload(Manager.GetExistingDownload(scoreInfo));
|
attachDownload(Downloader.GetExistingDownload(scoreInfo));
|
||||||
|
|
||||||
Manager.DownloadBegan += downloadBegan;
|
Downloader.DownloadBegan += downloadBegan;
|
||||||
Manager.DownloadFailed += downloadFailed;
|
Downloader.DownloadFailed += downloadFailed;
|
||||||
Manager.ItemUpdated += itemUpdated;
|
Manager.ItemUpdated += itemUpdated;
|
||||||
Manager.ItemRemoved += itemRemoved;
|
Manager.ItemRemoved += itemRemoved;
|
||||||
}
|
}
|
||||||
@ -119,10 +122,14 @@ namespace osu.Game.Online
|
|||||||
base.Dispose(isDisposing);
|
base.Dispose(isDisposing);
|
||||||
attachDownload(null);
|
attachDownload(null);
|
||||||
|
|
||||||
|
if (Downloader != null)
|
||||||
|
{
|
||||||
|
Downloader.DownloadBegan -= downloadBegan;
|
||||||
|
Downloader.DownloadFailed -= downloadFailed;
|
||||||
|
}
|
||||||
|
|
||||||
if (Manager != null)
|
if (Manager != null)
|
||||||
{
|
{
|
||||||
Manager.DownloadBegan -= downloadBegan;
|
|
||||||
Manager.DownloadFailed -= downloadFailed;
|
|
||||||
Manager.ItemUpdated -= itemUpdated;
|
Manager.ItemUpdated -= itemUpdated;
|
||||||
Manager.ItemRemoved -= itemRemoved;
|
Manager.ItemRemoved -= itemRemoved;
|
||||||
}
|
}
|
||||||
|
@ -657,6 +657,8 @@ namespace osu.Game
|
|||||||
BeatmapManager.PostImport = items => PresentBeatmap(items.First().Value);
|
BeatmapManager.PostImport = items => PresentBeatmap(items.First().Value);
|
||||||
|
|
||||||
BeatmapDownloader.PostNotification = n => Notifications.Post(n);
|
BeatmapDownloader.PostNotification = n => Notifications.Post(n);
|
||||||
|
ScoreDownloader.PostNotification = n => Notifications.Post(n);
|
||||||
|
|
||||||
ScoreManager.PostNotification = n => Notifications.Post(n);
|
ScoreManager.PostNotification = n => Notifications.Post(n);
|
||||||
ScoreManager.PostImport = items => PresentScore(items.First().Value);
|
ScoreManager.PostImport = items => PresentScore(items.First().Value);
|
||||||
|
|
||||||
|
@ -100,6 +100,8 @@ namespace osu.Game
|
|||||||
|
|
||||||
protected ScoreManager ScoreManager { get; private set; }
|
protected ScoreManager ScoreManager { get; private set; }
|
||||||
|
|
||||||
|
protected ScoreModelDownloader ScoreDownloader { get; private set; }
|
||||||
|
|
||||||
protected SkinManager SkinManager { get; private set; }
|
protected SkinManager SkinManager { get; private set; }
|
||||||
|
|
||||||
protected RulesetStore RulesetStore { get; private set; }
|
protected RulesetStore RulesetStore { get; private set; }
|
||||||
@ -234,10 +236,12 @@ namespace osu.Game
|
|||||||
dependencies.Cache(fileStore = new FileStore(contextFactory, Storage));
|
dependencies.Cache(fileStore = new FileStore(contextFactory, Storage));
|
||||||
|
|
||||||
// ordering is important here to ensure foreign keys rules are not broken in ModelStore.Cleanup()
|
// 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(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Resources, Host, defaultBeatmap, performOnlineLookups: true));
|
||||||
|
|
||||||
dependencies.Cache(BeatmapDownloader = new BeatmapModelDownloader(BeatmapManager, API, Host));
|
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.
|
// the following realm components are not actively used yet, but initialised and kept up to date for initial testing.
|
||||||
realmRulesetStore = new RealmRulesetStore(realmFactory, Storage);
|
realmRulesetStore = new RealmRulesetStore(realmFactory, Storage);
|
||||||
|
|
||||||
|
@ -17,7 +17,6 @@ using osu.Game.Configuration;
|
|||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
using osu.Game.IO;
|
using osu.Game.IO;
|
||||||
using osu.Game.IO.Archives;
|
using osu.Game.IO.Archives;
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Game.Overlays.Notifications;
|
using osu.Game.Overlays.Notifications;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
using osu.Game.Rulesets.Judgements;
|
using osu.Game.Rulesets.Judgements;
|
||||||
@ -25,15 +24,14 @@ using osu.Game.Rulesets.Scoring;
|
|||||||
|
|
||||||
namespace osu.Game.Scoring
|
namespace osu.Game.Scoring
|
||||||
{
|
{
|
||||||
public class ScoreManager : IModelManager<ScoreInfo>, IModelImporter<ScoreInfo>, IModelDownloader<IScoreInfo>
|
public class ScoreManager : IModelManager<ScoreInfo>, IModelImporter<ScoreInfo>
|
||||||
{
|
{
|
||||||
private readonly Scheduler scheduler;
|
private readonly Scheduler scheduler;
|
||||||
private readonly Func<BeatmapDifficultyCache> difficulties;
|
private readonly Func<BeatmapDifficultyCache> difficulties;
|
||||||
private readonly OsuConfigManager configManager;
|
private readonly OsuConfigManager configManager;
|
||||||
private readonly ScoreModelManager scoreModelManager;
|
private readonly ScoreModelManager scoreModelManager;
|
||||||
private readonly ScoreModelDownloader scoreModelDownloader;
|
|
||||||
|
|
||||||
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, IAPIProvider api, IDatabaseContextFactory contextFactory, Scheduler scheduler,
|
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, IDatabaseContextFactory contextFactory, Scheduler scheduler,
|
||||||
IIpcHost importHost = null, Func<BeatmapDifficultyCache> difficulties = null, OsuConfigManager configManager = null)
|
IIpcHost importHost = null, Func<BeatmapDifficultyCache> difficulties = null, OsuConfigManager configManager = null)
|
||||||
{
|
{
|
||||||
this.scheduler = scheduler;
|
this.scheduler = scheduler;
|
||||||
@ -41,7 +39,6 @@ namespace osu.Game.Scoring
|
|||||||
this.configManager = configManager;
|
this.configManager = configManager;
|
||||||
|
|
||||||
scoreModelManager = new ScoreModelManager(rulesets, beatmaps, storage, contextFactory, importHost);
|
scoreModelManager = new ScoreModelManager(rulesets, beatmaps, storage, contextFactory, importHost);
|
||||||
scoreModelDownloader = new ScoreModelDownloader(scoreModelManager, api, importHost);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Score GetScore(ScoreInfo score) => scoreModelManager.GetScore(score);
|
public Score GetScore(ScoreInfo score) => scoreModelManager.GetScore(score);
|
||||||
@ -240,11 +237,7 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
public Action<Notification> PostNotification
|
public Action<Notification> PostNotification
|
||||||
{
|
{
|
||||||
set
|
set => scoreModelManager.PostNotification = value;
|
||||||
{
|
|
||||||
scoreModelManager.PostNotification = value;
|
|
||||||
scoreModelDownloader.PostNotification = value;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@ -342,30 +335,6 @@ namespace osu.Game.Scoring
|
|||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Implementation of IModelDownloader<IScoreInfo>
|
|
||||||
|
|
||||||
public event Action<ArchiveDownloadRequest<IScoreInfo>> DownloadBegan
|
|
||||||
{
|
|
||||||
add => scoreModelDownloader.DownloadBegan += value;
|
|
||||||
remove => scoreModelDownloader.DownloadBegan -= value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public event Action<ArchiveDownloadRequest<IScoreInfo>> DownloadFailed
|
|
||||||
{
|
|
||||||
add => scoreModelDownloader.DownloadFailed += value;
|
|
||||||
remove => scoreModelDownloader.DownloadFailed -= value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool Download(IScoreInfo model, bool minimiseDownloadSize) =>
|
|
||||||
scoreModelDownloader.Download(model, minimiseDownloadSize);
|
|
||||||
|
|
||||||
public ArchiveDownloadRequest<IScoreInfo> GetExistingDownload(IScoreInfo model)
|
|
||||||
{
|
|
||||||
return scoreModelDownloader.GetExistingDownload(model);
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Implementation of IPresentImports<ScoreInfo>
|
#region Implementation of IPresentImports<ScoreInfo>
|
||||||
|
|
||||||
public Action<IEnumerable<ILive<ScoreInfo>>> PostImport
|
public Action<IEnumerable<ILive<ScoreInfo>>> PostImport
|
||||||
|
@ -45,7 +45,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(OsuGame game, ScoreManager scores)
|
private void load(OsuGame game, ScoreModelDownloader scores)
|
||||||
{
|
{
|
||||||
InternalChild = shakeContainer = new ShakeContainer
|
InternalChild = shakeContainer = new ShakeContainer
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ namespace osu.Game.Screens.Ranking
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case DownloadState.NotDownloaded:
|
case DownloadState.NotDownloaded:
|
||||||
scores.Download(Score.Value, false);
|
scores.Download(Score.Value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DownloadState.Importing:
|
case DownloadState.Importing:
|
||||||
|
Reference in New Issue
Block a user