mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 20:33:11 +08:00
Pass online lookup queue in as a whole, rather than function
This commit is contained in:
parent
fd13142a15
commit
428c7830d9
@ -29,10 +29,11 @@ namespace osu.Game.Beatmaps
|
||||
/// Handles general operations related to global beatmap management.
|
||||
/// </summary>
|
||||
[ExcludeFromDynamicCompile]
|
||||
public class BeatmapManager : IModelDownloader<BeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, ICanAcceptFiles, IWorkingBeatmapCache
|
||||
public class BeatmapManager : IModelDownloader<BeatmapSetInfo>, IModelManager<BeatmapSetInfo>, IModelFileManager<BeatmapSetInfo, BeatmapSetFileInfo>, ICanAcceptFiles, IWorkingBeatmapCache, IDisposable
|
||||
{
|
||||
private readonly BeatmapModelManager beatmapModelManager;
|
||||
private readonly WorkingBeatmapCache workingBeatmapCache;
|
||||
private readonly BeatmapOnlineLookupQueue onlineBetamapLookupQueue;
|
||||
|
||||
public BeatmapManager(Storage storage, IDatabaseContextFactory contextFactory, RulesetStore rulesets, IAPIProvider api, [NotNull] AudioManager audioManager, IResourceStore<byte[]> resources, GameHost host = null,
|
||||
WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false)
|
||||
@ -44,8 +45,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
if (performOnlineLookups)
|
||||
{
|
||||
var onlineBeatmapLookupCache = new BeatmapOnlineLookupQueue(api, storage);
|
||||
beatmapModelManager.PopulateOnlineInformation = onlineBeatmapLookupCache.UpdateAsync;
|
||||
onlineBetamapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
|
||||
beatmapModelManager.OnlineLookupQueue = onlineBetamapLookupQueue;
|
||||
}
|
||||
}
|
||||
|
||||
@ -308,5 +309,14 @@ namespace osu.Game.Beatmaps
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Implementation of IDisposable
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
onlineBetamapLookupQueue?.Dispose();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -49,10 +49,9 @@ namespace osu.Game.Beatmaps
|
||||
public IBindable<WeakReference<BeatmapInfo>> BeatmapRestored => beatmapRestored;
|
||||
|
||||
/// <summary>
|
||||
/// A function which populates online information during the import process.
|
||||
/// It is run as the final step of import.
|
||||
/// An online lookup queue component which handles populating online beatmap metadata.
|
||||
/// </summary>
|
||||
public Func<BeatmapSetInfo, CancellationToken, Task> PopulateOnlineInformation;
|
||||
public BeatmapOnlineLookupQueue OnlineLookupQueue { private get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The game working beatmap cache, used to invalidate entries on changes.
|
||||
@ -107,8 +106,8 @@ namespace osu.Game.Beatmaps
|
||||
|
||||
bool hadOnlineBeatmapIDs = beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID > 0);
|
||||
|
||||
if (PopulateOnlineInformation != null)
|
||||
await PopulateOnlineInformation(beatmapSet, cancellationToken).ConfigureAwait(false);
|
||||
if (OnlineLookupQueue != null)
|
||||
await OnlineLookupQueue.UpdateAsync(beatmapSet, cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// ensure at least one beatmap was able to retrieve or keep an online ID, else drop the set ID.
|
||||
if (hadOnlineBeatmapIDs && !beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID > 0))
|
||||
|
Loading…
Reference in New Issue
Block a user