diff --git a/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs b/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs index a52d3fa216..792fa90c4e 100644 --- a/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs +++ b/osu.Game/Screens/SelectV2/PanelBeatmapSet.cs @@ -14,6 +14,7 @@ using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.UserInterface; using osu.Framework.Localisation; +using osu.Framework.Threading; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Collections; @@ -38,6 +39,7 @@ namespace osu.Game.Screens.SelectV2 private Box chevronBackground = null!; private PanelSetBackground setBackground = null!; + private ScheduledDelegate? scheduledBackgroundRetrieval; private OsuSpriteText titleText = null!; private OsuSpriteText artistText = null!; @@ -191,7 +193,7 @@ namespace osu.Game.Screens.SelectV2 var beatmapSet = groupedBeatmapSet.BeatmapSet; // Choice of background image matches BSS implementation (always uses the lowest `beatmap_id` from the set). - setBackground.Beatmap = beatmaps.GetWorkingBeatmap(beatmapSet.Beatmaps.MinBy(b => b.OnlineID)); + scheduledBackgroundRetrieval = Scheduler.AddDelayed(s => setBackground.Beatmap = beatmaps.GetWorkingBeatmap(s.Beatmaps.MinBy(b => b.OnlineID)), beatmapSet, 50); titleText.Text = new RomanisableString(beatmapSet.Metadata.TitleUnicode, beatmapSet.Metadata.Title); artistText.Text = new RomanisableString(beatmapSet.Metadata.ArtistUnicode, beatmapSet.Metadata.Artist); @@ -204,6 +206,8 @@ namespace osu.Game.Screens.SelectV2 { base.FreeAfterUse(); + scheduledBackgroundRetrieval?.Cancel(); + scheduledBackgroundRetrieval = null; setBackground.Beatmap = null; updateButton.BeatmapSet = null; difficultiesDisplay.BeatmapSet = null; diff --git a/osu.Game/Screens/SelectV2/PanelBeatmapStandalone.cs b/osu.Game/Screens/SelectV2/PanelBeatmapStandalone.cs index 4ac05c0308..53ade139e2 100644 --- a/osu.Game/Screens/SelectV2/PanelBeatmapStandalone.cs +++ b/osu.Game/Screens/SelectV2/PanelBeatmapStandalone.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.UserInterface; using osu.Framework.Localisation; +using osu.Framework.Threading; using osu.Game.Beatmaps; using osu.Game.Beatmaps.Drawables; using osu.Game.Graphics; @@ -55,6 +56,7 @@ namespace osu.Game.Screens.SelectV2 private CancellationTokenSource? starDifficultyCancellationSource; private PanelSetBackground beatmapBackground = null!; + private ScheduledDelegate? scheduledBackgroundRetrieval; private OsuSpriteText titleText = null!; private OsuSpriteText artistText = null!; @@ -222,7 +224,7 @@ namespace osu.Game.Screens.SelectV2 var beatmapSet = beatmap.BeatmapSet!; - beatmapBackground.Beatmap = beatmaps.GetWorkingBeatmap(beatmap); + scheduledBackgroundRetrieval = Scheduler.AddDelayed(b => beatmapBackground.Beatmap = beatmaps.GetWorkingBeatmap(b), beatmap, 50); titleText.Text = new RomanisableString(beatmapSet.Metadata.TitleUnicode, beatmapSet.Metadata.Title); artistText.Text = new RomanisableString(beatmapSet.Metadata.ArtistUnicode, beatmapSet.Metadata.Artist); @@ -244,6 +246,8 @@ namespace osu.Game.Screens.SelectV2 { base.FreeAfterUse(); + scheduledBackgroundRetrieval?.Cancel(); + scheduledBackgroundRetrieval = null; beatmapBackground.Beatmap = null; updateButton.BeatmapSet = null; localRank.Beatmap = null; diff --git a/osu.Game/Screens/SelectV2/PanelSetBackground.cs b/osu.Game/Screens/SelectV2/PanelSetBackground.cs index 1b49f48ea6..7f15a23b9a 100644 --- a/osu.Game/Screens/SelectV2/PanelSetBackground.cs +++ b/osu.Game/Screens/SelectV2/PanelSetBackground.cs @@ -149,7 +149,7 @@ namespace osu.Game.Screens.SelectV2 // - By using a slightly customised formula to decide when to start the load, we can coerce the loading of backgrounds into an order that // prioritises panels which are closest to the centre of the screen. Basically, we want to load backgrounds "outwards" from the visual // centre to give the user the best experience possible. - float timeUpdatingBeforeLoad = 50 + Math.Abs(containingSsdq.Centre.Y - ScreenSpaceDrawQuad.Centre.Y) / containingSsdq.Height * 100; + float timeUpdatingBeforeLoad = Math.Abs(containingSsdq.Centre.Y - ScreenSpaceDrawQuad.Centre.Y) / containingSsdq.Height * 100; timeSinceUnpool += Time.Elapsed;