mirror of
https://github.com/ppy/osu
synced 2025-02-17 19:07:07 +00:00
Merge pull request #29968 from bdach/cache-for-spectate-screen
Use cache for beatmap lookups on spectate screen
This commit is contained in:
commit
b7d8cb2371
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
@ -13,12 +14,11 @@ using osu.Game.Audio;
|
|||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Drawables.Cards;
|
using osu.Game.Beatmaps.Drawables.Cards;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Database;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
using osu.Game.Graphics.UserInterfaceV2;
|
using osu.Game.Graphics.UserInterfaceV2;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
using osu.Game.Online.API;
|
|
||||||
using osu.Game.Online.API.Requests;
|
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Spectator;
|
using osu.Game.Online.Spectator;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
@ -34,7 +34,7 @@ namespace osu.Game.Screens.Play
|
|||||||
public partial class SoloSpectatorScreen : SpectatorScreen, IPreviewTrackOwner
|
public partial class SoloSpectatorScreen : SpectatorScreen, IPreviewTrackOwner
|
||||||
{
|
{
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; } = null!;
|
private BeatmapLookupCache beatmapLookupCache { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private PreviewTrackManager previewTrackManager { get; set; } = null!;
|
private PreviewTrackManager previewTrackManager { get; set; } = null!;
|
||||||
@ -60,7 +60,7 @@ namespace osu.Game.Screens.Play
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private SpectatorGameplayState? immediateSpectatorGameplayState;
|
private SpectatorGameplayState? immediateSpectatorGameplayState;
|
||||||
|
|
||||||
private GetBeatmapSetRequest? onlineBeatmapRequest;
|
private ScheduledDelegate? beatmapFetchCallback;
|
||||||
|
|
||||||
private APIBeatmapSet? beatmapSet;
|
private APIBeatmapSet? beatmapSet;
|
||||||
|
|
||||||
@ -210,7 +210,7 @@ namespace osu.Game.Screens.Play
|
|||||||
private void clearDisplay()
|
private void clearDisplay()
|
||||||
{
|
{
|
||||||
watchButton.Enabled.Value = false;
|
watchButton.Enabled.Value = false;
|
||||||
onlineBeatmapRequest?.Cancel();
|
beatmapFetchCallback?.Cancel();
|
||||||
beatmapPanelContainer.Clear();
|
beatmapPanelContainer.Clear();
|
||||||
previewTrackManager.StopAnyPlaying(this);
|
previewTrackManager.StopAnyPlaying(this);
|
||||||
}
|
}
|
||||||
@ -244,15 +244,17 @@ namespace osu.Game.Screens.Play
|
|||||||
{
|
{
|
||||||
Debug.Assert(state.BeatmapID != null);
|
Debug.Assert(state.BeatmapID != null);
|
||||||
|
|
||||||
onlineBeatmapRequest = new GetBeatmapSetRequest(state.BeatmapID.Value, BeatmapSetLookupType.BeatmapId);
|
beatmapLookupCache.GetBeatmapAsync(state.BeatmapID.Value).ContinueWith(t => beatmapFetchCallback = Schedule(() =>
|
||||||
onlineBeatmapRequest.Success += beatmapSet => Schedule(() =>
|
|
||||||
{
|
{
|
||||||
this.beatmapSet = beatmapSet;
|
var beatmap = t.GetResultSafely();
|
||||||
beatmapPanelContainer.Child = new BeatmapCardNormal(this.beatmapSet, allowExpansion: false);
|
|
||||||
checkForAutomaticDownload();
|
|
||||||
});
|
|
||||||
|
|
||||||
api.Queue(onlineBeatmapRequest);
|
if (beatmap?.BeatmapSet == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
beatmapSet = beatmap.BeatmapSet;
|
||||||
|
beatmapPanelContainer.Child = new BeatmapCardNormal(beatmapSet, allowExpansion: false);
|
||||||
|
checkForAutomaticDownload();
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void checkForAutomaticDownload()
|
private void checkForAutomaticDownload()
|
||||||
|
Loading…
Reference in New Issue
Block a user