mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 23:42:55 +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.
|
/// Handles general operations related to global beatmap management.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ExcludeFromDynamicCompile]
|
[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 BeatmapModelManager beatmapModelManager;
|
||||||
private readonly WorkingBeatmapCache workingBeatmapCache;
|
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,
|
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)
|
WorkingBeatmap defaultBeatmap = null, bool performOnlineLookups = false)
|
||||||
@ -44,8 +45,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
if (performOnlineLookups)
|
if (performOnlineLookups)
|
||||||
{
|
{
|
||||||
var onlineBeatmapLookupCache = new BeatmapOnlineLookupQueue(api, storage);
|
onlineBetamapLookupQueue = new BeatmapOnlineLookupQueue(api, storage);
|
||||||
beatmapModelManager.PopulateOnlineInformation = onlineBeatmapLookupCache.UpdateAsync;
|
beatmapModelManager.OnlineLookupQueue = onlineBetamapLookupQueue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -308,5 +309,14 @@ namespace osu.Game.Beatmaps
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#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;
|
public IBindable<WeakReference<BeatmapInfo>> BeatmapRestored => beatmapRestored;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// A function which populates online information during the import process.
|
/// An online lookup queue component which handles populating online beatmap metadata.
|
||||||
/// It is run as the final step of import.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public Func<BeatmapSetInfo, CancellationToken, Task> PopulateOnlineInformation;
|
public BeatmapOnlineLookupQueue OnlineLookupQueue { private get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The game working beatmap cache, used to invalidate entries on changes.
|
/// 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);
|
bool hadOnlineBeatmapIDs = beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID > 0);
|
||||||
|
|
||||||
if (PopulateOnlineInformation != null)
|
if (OnlineLookupQueue != null)
|
||||||
await PopulateOnlineInformation(beatmapSet, cancellationToken).ConfigureAwait(false);
|
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.
|
// 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))
|
if (hadOnlineBeatmapIDs && !beatmapSet.Beatmaps.Any(b => b.OnlineBeatmapID > 0))
|
||||||
|
Loading…
Reference in New Issue
Block a user