diff --git a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs index d3ae3a19ea..8e4e2ac257 100644 --- a/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs +++ b/osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarousel.cs @@ -427,7 +427,7 @@ namespace osu.Game.Tests.Visual.SongSelect for (int i = 0; i < 3; i++) { - var set = createTestBeatmapSet(i, 3); + var set = createTestBeatmapSet(i); set.Beatmaps[0].StarDifficulty = 3 - i; set.Beatmaps[2].StarDifficulty = 6 + i; sets.Add(set); @@ -822,7 +822,7 @@ namespace osu.Game.Tests.Visual.SongSelect AddAssert("Selection is visible", selectedBeatmapVisible); } - private BeatmapSetInfo createTestBeatmapSet(int id, int minimumDifficulties = 1) + private BeatmapSetInfo createTestBeatmapSet(int id, bool randomDifficultyCount = false) { return new BeatmapSetInfo { @@ -836,7 +836,7 @@ namespace osu.Game.Tests.Visual.SongSelect Title = $"test set #{id}!", AuthorString = string.Concat(Enumerable.Repeat((char)('z' - Math.Min(25, id - 1)), 5)) }, - Beatmaps = getBeatmaps(RNG.Next(minimumDifficulties, 20)).ToList() + Beatmaps = getBeatmaps(randomDifficultyCount ? RNG.Next(1, 20) : 3).ToList() }; } @@ -846,14 +846,22 @@ namespace osu.Game.Tests.Visual.SongSelect for (int i = 0; i < count; i++) { + float diff = (float)i / count * 10; + + string version = "Normal"; + if (diff > 6.6) + version = "Insane"; + else if (diff > 3.3) + version = "Hard"; + yield return new BeatmapInfo { OnlineBeatmapID = id++ * 10, - Version = "Normal", - StarDifficulty = RNG.NextSingle() * 10, + Version = version, + StarDifficulty = diff, BaseDifficulty = new BeatmapDifficulty { - OverallDifficulty = RNG.NextSingle() * 10, + OverallDifficulty = diff, } }; } @@ -899,7 +907,22 @@ namespace osu.Game.Tests.Visual.SongSelect { public bool PendingFilterTask => PendingFilter != null; - public IEnumerable Items => InternalChildren.OfType(); + public IEnumerable Items + { + get + { + foreach (var item in ScrollableContent) + { + yield return item; + + if (item is DrawableCarouselBeatmapSet set) + { + foreach (var difficulty in set.ChildItems) + yield return difficulty; + } + } + } + } protected override IEnumerable GetLoadableBeatmaps() => Enumerable.Empty(); } diff --git a/osu.Game/Screens/Select/BeatmapCarousel.cs b/osu.Game/Screens/Select/BeatmapCarousel.cs index bcdbc53e26..b6ca6a242d 100644 --- a/osu.Game/Screens/Select/BeatmapCarousel.cs +++ b/osu.Game/Screens/Select/BeatmapCarousel.cs @@ -101,7 +101,7 @@ namespace osu.Game.Screens.Select if (selectedBeatmapSet != null && !beatmapSets.Contains(selectedBeatmapSet.BeatmapSet)) selectedBeatmapSet = null; - scrollableContent.Clear(false); + ScrollableContent.Clear(false); itemsCache.Invalidate(); scrollPositionCache.Invalidate(); @@ -121,7 +121,7 @@ namespace osu.Game.Screens.Select private readonly Cached itemsCache = new Cached(); private readonly Cached scrollPositionCache = new Cached(); - private readonly Container scrollableContent; + protected readonly Container ScrollableContent; public Bindable RightClickScrollingEnabled = new Bindable(); @@ -151,7 +151,7 @@ namespace osu.Game.Screens.Select Children = new Drawable[] { setPool, - scrollableContent = new Container + ScrollableContent = new Container { RelativeSizeAxes = Axes.X, } @@ -595,7 +595,7 @@ namespace osu.Game.Screens.Select var toDisplay = visibleItems.GetRange(displayedRange.first, displayedRange.last - displayedRange.first); - foreach (var panel in scrollableContent.Children) + foreach (var panel in ScrollableContent.Children) { if (toDisplay.Remove(panel.Item)) { @@ -622,7 +622,7 @@ namespace osu.Game.Screens.Select panel.Depth = item.CarouselYPosition; panel.Y = item.CarouselYPosition; - scrollableContent.Add(panel); + ScrollableContent.Add(panel); } } @@ -630,7 +630,7 @@ namespace osu.Game.Screens.Select // This is common if a selected/collapsed state has changed. if (revalidateItems) { - foreach (DrawableCarouselItem panel in scrollableContent.Children) + foreach (DrawableCarouselItem panel in ScrollableContent.Children) { panel.MoveToY(panel.Item.CarouselYPosition, 800, Easing.OutQuint); } @@ -638,7 +638,7 @@ namespace osu.Game.Screens.Select // Update externally controlled state of currently visible items (e.g. x-offset and opacity). // This is a per-frame update on all drawable panels. - foreach (DrawableCarouselItem item in scrollableContent.Children) + foreach (DrawableCarouselItem item in ScrollableContent.Children) { updateItem(item); @@ -786,7 +786,7 @@ namespace osu.Game.Screens.Select } currentY += visibleHalfHeight; - scrollableContent.Height = currentY; + ScrollableContent.Height = currentY; if (BeatmapSetsLoaded && (selectedBeatmapSet == null || selectedBeatmap == null || selectedBeatmapSet.State.Value != CarouselItemState.Selected)) { @@ -841,7 +841,7 @@ namespace osu.Game.Screens.Select /// For nested items, the parent of the item to be updated. private void updateItem(DrawableCarouselItem item, DrawableCarouselItem parent = null) { - Vector2 posInScroll = scrollableContent.ToLocalSpace(item.Header.ScreenSpaceDrawQuad.Centre); + Vector2 posInScroll = ScrollableContent.ToLocalSpace(item.Header.ScreenSpaceDrawQuad.Centre); float itemDrawY = posInScroll.Y - visibleUpperBound; float dist = Math.Abs(1f - itemDrawY / visibleHalfHeight);