mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Pass whole queue in rather than function
This commit is contained in:
parent
27c4f2b06e
commit
2ed28f625a
@ -55,10 +55,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; }
|
||||||
|
|
||||||
private readonly Bindable<WeakReference<BeatmapInfo>> beatmapRestored = new Bindable<WeakReference<BeatmapInfo>>();
|
private readonly Bindable<WeakReference<BeatmapInfo>> beatmapRestored = new Bindable<WeakReference<BeatmapInfo>>();
|
||||||
|
|
||||||
@ -156,8 +155,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))
|
||||||
|
@ -138,7 +138,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
private UserLookupCache userCache;
|
private UserLookupCache userCache;
|
||||||
|
|
||||||
private BeatmapOnlineLookupQueue onlineBeatmapLookupCache;
|
private BeatmapOnlineLookupQueue onlineBeatmapLookupQueue;
|
||||||
|
|
||||||
private FileStore fileStore;
|
private FileStore fileStore;
|
||||||
|
|
||||||
@ -246,9 +246,9 @@ namespace osu.Game
|
|||||||
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, API, contextFactory, Scheduler, Host, () => difficultyCache, LocalConfig));
|
dependencies.Cache(ScoreManager = new ScoreManager(RulesetStore, () => BeatmapManager, Storage, API, contextFactory, Scheduler, Host, () => difficultyCache, LocalConfig));
|
||||||
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Resources, Host, defaultBeatmap));
|
dependencies.Cache(BeatmapManager = new BeatmapManager(Storage, contextFactory, RulesetStore, API, Audio, Resources, Host, defaultBeatmap));
|
||||||
|
|
||||||
onlineBeatmapLookupCache = new BeatmapOnlineLookupQueue(API, Storage);
|
onlineBeatmapLookupQueue = new BeatmapOnlineLookupQueue(API, Storage);
|
||||||
|
|
||||||
BeatmapManager.PopulateOnlineInformation = onlineBeatmapLookupCache.UpdateAsync;
|
BeatmapManager.OnlineLookupQueue = onlineBeatmapLookupQueue;
|
||||||
|
|
||||||
// this should likely be moved to ArchiveModelManager when another case appears where it is necessary
|
// this should likely be moved to ArchiveModelManager when another case appears where it is necessary
|
||||||
// to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to
|
// to have inter-dependent model managers. this could be obtained with an IHasForeign<T> interface to
|
||||||
@ -531,7 +531,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
RulesetStore?.Dispose();
|
RulesetStore?.Dispose();
|
||||||
LocalConfig?.Dispose();
|
LocalConfig?.Dispose();
|
||||||
onlineBeatmapLookupCache?.Dispose();
|
onlineBeatmapLookupQueue?.Dispose();
|
||||||
|
|
||||||
contextFactory?.FlushConnections();
|
contextFactory?.FlushConnections();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user