use BeatmapCache for populate beatmap information

This commit is contained in:
cdwcgt 2023-06-25 22:42:02 +09:00
parent 35d2c0f4cf
commit 14e26d2a85
No known key found for this signature in database
GPG Key ID: 144396D01095C3A2
1 changed files with 6 additions and 6 deletions

View File

@ -15,6 +15,7 @@
using osu.Framework.IO.Stores;
using osu.Framework.Logging;
using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Online;
using osu.Game.Online.API.Requests;
@ -35,6 +36,7 @@ public partial class TournamentGameBase : OsuGameBase
private TournamentStorage storage;
private DependencyContainer dependencies;
private FileBasedIPC ipc;
private BeatmapLookupCache beatmapCache;
protected Task BracketLoadTask => bracketLoadTaskCompletionSource.Task;
@ -75,6 +77,8 @@ private void load(Storage baseStorage)
Textures.AddTextureSource(new TextureLoaderStore(new StorageBackedResourceStore(storage)));
dependencies.CacheAs(new StableInfo(storage));
beatmapCache = dependencies.Get<BeatmapLookupCache>();
}
protected override void LoadComplete()
@ -241,9 +245,7 @@ private bool addRoundBeatmaps()
{
var b = beatmapsRequiringPopulation[i];
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
API.Perform(req);
b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetAwaiter().GetResult() ?? new APIBeatmap());
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
}
@ -268,9 +270,7 @@ private bool addSeedingBeatmaps()
{
var b = beatmapsRequiringPopulation[i];
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID });
API.Perform(req);
b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetAwaiter().GetResult() ?? new APIBeatmap());
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
}