Avoid performing eager selection constantly on adding ranges of new children

This commit is contained in:
Dean Herbert 2020-10-12 15:36:26 +09:00
parent 0a978c6131
commit f3b24b9bb5
2 changed files with 10 additions and 1 deletions

View File

@ -95,7 +95,7 @@ private void loadBeatmapSets(IEnumerable<BeatmapSetInfo> beatmapSets)
{
CarouselRoot newRoot = new CarouselRoot(this);
beatmapSets.Select(createCarouselSet).Where(g => g != null).ForEach(newRoot.AddChild);
newRoot.AddChildren(beatmapSets.Select(createCarouselSet).Where(g => g != null));
root = newRoot;
if (selectedBeatmapSet != null && !beatmapSets.Contains(selectedBeatmapSet.BeatmapSet))

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Screens.Select.Carousel
@ -54,6 +55,14 @@ public override void RemoveChild(CarouselItem i)
updateSelectedIndex();
}
public void AddChildren(IEnumerable<CarouselItem> items)
{
foreach (var i in items)
base.AddChild(i);
attemptSelection();
}
public override void AddChild(CarouselItem i)
{
base.AddChild(i);