diff --git a/osu.Game/Screens/Select/SongSelect.cs b/osu.Game/Screens/Select/SongSelect.cs index a0f20242c2..45485ecebc 100644 --- a/osu.Game/Screens/Select/SongSelect.cs +++ b/osu.Game/Screens/Select/SongSelect.cs @@ -352,39 +352,68 @@ namespace osu.Game.Screens.Select } } - private void addBeatmapSet(BeatmapSetInfo beatmapSet, Framework.Game game, bool select = false) + private BeatmapGroup prepareBeatmapSet(BeatmapSetInfo beatmapSet) { - beatmapSet = database.GetWithChildren(beatmapSet.ID); - beatmapSet.Beatmaps.ForEach(b => - { - database.GetChildren(b); - if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; - }); + database.GetChildren(beatmapSet); + beatmapSet.Beatmaps.ForEach(b => { if (b.Metadata == null) b.Metadata = beatmapSet.Metadata; }); - var group = new BeatmapGroup(beatmapSet, database) + return new BeatmapGroup(beatmapSet, database) { SelectionChanged = selectionChanged, StartRequested = b => raiseSelect() }; + } + + private void addBeatmapSet(BeatmapSetInfo beatmapSet, Framework.Game game, bool select = false) + { + var group = prepareBeatmapSet(beatmapSet); //for the time being, let's completely load the difficulty panels in the background. //this likely won't scale so well, but allows us to completely async the loading flow. Task.WhenAll(group.BeatmapPanels.Select(panel => panel.LoadAsync(game))).ContinueWith(task => Schedule(delegate { - beatmapGroups.Add(group); - - group.State = BeatmapGroupState.Collapsed; - carousel.AddGroup(group); - - filterChanged(false, false); + addGroup(group); if (Beatmap == null || select) - carousel.SelectBeatmap(beatmapSet.Beatmaps.First()); + selectBeatmap(beatmapSet); else - carousel.SelectBeatmap(Beatmap.BeatmapInfo); + selectBeatmap(); })); } + private void addGroup(BeatmapGroup group) + { + beatmapGroups.Add(group); + + group.State = BeatmapGroupState.Collapsed; + carousel.AddGroup(group); + + filterChanged(false, false); + } + + private void selectBeatmap(BeatmapSetInfo beatmapSet = null) + { + carousel.SelectBeatmap(beatmapSet != null ? beatmapSet.Beatmaps.First() : Beatmap.BeatmapInfo); + } + + private void addBeatmapSets(Framework.Game game, CancellationToken token) + { + List groups = new List(); + + foreach (var beatmapSet in database.Query().Where(b => !b.DeletePending)) + { + if (token.IsCancellationRequested) return; + + groups.Add(prepareBeatmapSet(beatmapSet)); + } + + Schedule(() => + { + groups.ForEach(addGroup); + selectBeatmap(Beatmap?.BeatmapSetInfo ?? groups.First().BeatmapSet); + }); + } + private void removeBeatmapSet(BeatmapSetInfo beatmapSet) { var group = beatmapGroups.Find(b => b.BeatmapSet.ID == beatmapSet.ID); @@ -400,15 +429,6 @@ namespace osu.Game.Screens.Select Beatmap = null; } - private void addBeatmapSets(Framework.Game game, CancellationToken token) - { - foreach (var beatmapSet in database.Query().Where(b => !b.DeletePending)) - { - if (token.IsCancellationRequested) return; - addBeatmapSet(beatmapSet, game); - } - } - private void promptDelete() { if (Beatmap != null)