1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:57:24 +08:00

Merge pull request #24037 from cdwcgt/tournament-beatmapcache

Use beatmap cache to populate beatmap information in tournament client
This commit is contained in:
Dean Herbert 2023-06-26 14:55:05 +09:00 committed by GitHub
commit 719ac75ad2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -9,12 +9,14 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Newtonsoft.Json; using Newtonsoft.Json;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Input; using osu.Framework.Input;
using osu.Framework.IO.Stores; using osu.Framework.IO.Stores;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online; using osu.Game.Online;
using osu.Game.Online.API.Requests; using osu.Game.Online.API.Requests;
@ -35,6 +37,7 @@ namespace osu.Game.Tournament
private TournamentStorage storage; private TournamentStorage storage;
private DependencyContainer dependencies; private DependencyContainer dependencies;
private FileBasedIPC ipc; private FileBasedIPC ipc;
private BeatmapLookupCache beatmapCache;
protected Task BracketLoadTask => bracketLoadTaskCompletionSource.Task; protected Task BracketLoadTask => bracketLoadTaskCompletionSource.Task;
@ -75,6 +78,8 @@ namespace osu.Game.Tournament
Textures.AddTextureSource(new TextureLoaderStore(new StorageBackedResourceStore(storage))); Textures.AddTextureSource(new TextureLoaderStore(new StorageBackedResourceStore(storage)));
dependencies.CacheAs(new StableInfo(storage)); dependencies.CacheAs(new StableInfo(storage));
beatmapCache = dependencies.Get<BeatmapLookupCache>();
} }
protected override void LoadComplete() protected override void LoadComplete()
@ -241,9 +246,7 @@ namespace osu.Game.Tournament
{ {
var b = beatmapsRequiringPopulation[i]; var b = beatmapsRequiringPopulation[i];
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID }); b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetResultSafely() ?? new APIBeatmap());
API.Perform(req);
b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); updateLoadProgressMessage($"Populating round beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
} }
@ -268,9 +271,7 @@ namespace osu.Game.Tournament
{ {
var b = beatmapsRequiringPopulation[i]; var b = beatmapsRequiringPopulation[i];
var req = new GetBeatmapRequest(new APIBeatmap { OnlineID = b.ID }); b.Beatmap = new TournamentBeatmap(beatmapCache.GetBeatmapAsync(b.ID).GetResultSafely() ?? new APIBeatmap());
API.Perform(req);
b.Beatmap = new TournamentBeatmap(req.Response ?? new APIBeatmap());
updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})"); updateLoadProgressMessage($"Populating seeding beatmaps ({i} / {beatmapsRequiringPopulation.Count})");
} }