1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-30 07:19:54 +08:00

Merge pull request #33335 from bdach/song-select-v2-single-items-arent-shown

This commit is contained in:
Dean Herbert
2025-05-30 19:29:15 +09:00
committed by GitHub
Unverified
2 changed files with 21 additions and 2 deletions
@@ -6,9 +6,11 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using NUnit.Framework;
using osu.Framework.Testing;
using osu.Framework.Utils;
using osu.Game.Beatmaps;
using osu.Game.Screens.Select.Filter;
using osu.Game.Screens.SelectV2;
using osu.Game.Tests.Resources;
namespace osu.Game.Tests.Visual.SongSelectV2
@@ -116,5 +118,16 @@ namespace osu.Game.Tests.Visual.SongSelectV2
AddStep("add all beatmaps", () => BeatmapSets.AddRange(generated));
}
[Test]
public void TestSingleItemDisplayed()
{
CreateCarousel();
RemoveAllBeatmaps();
SortAndGroupBy(SortMode.Difficulty, GroupMode.None);
AddBeatmaps(1, fixedDifficultiesPerSet: 1);
AddUntilStep("single item is shown", () => this.ChildrenOfType<PanelBeatmapStandalone>().Count(), () => Is.EqualTo(1));
}
}
}
+8 -2
View File
@@ -747,6 +747,9 @@ namespace osu.Game.Graphics.Carousel
{
Debug.Assert(carouselItems != null);
if (carouselItems.Count == 0)
return DisplayRange.EMPTY;
// Find index range of all items that should be on-screen
carouselBoundsItem.CarouselYPosition = visibleUpperBound - DistanceOffscreenToPreload;
int firstIndex = carouselItems.BinarySearch(carouselBoundsItem);
@@ -766,7 +769,7 @@ namespace osu.Game.Graphics.Carousel
{
Debug.Assert(carouselItems != null);
List<CarouselItem> toDisplay = range.Last - range.First == 0
List<CarouselItem> toDisplay = range == DisplayRange.EMPTY
? new List<CarouselItem>()
: carouselItems.GetRange(range.First, range.Last - range.First + 1);
@@ -885,7 +888,10 @@ namespace osu.Game.Graphics.Carousel
/// <param name="Index">The index of the selection as of the last run of <see cref="Carousel{T}.refreshAfterSelection"/>. May be null if selection is not present as an item, or if <see cref="Carousel{T}.refreshAfterSelection"/> has not been run yet.</param>
private record Selection(object? Model = null, CarouselItem? CarouselItem = null, double? YPosition = null, int? Index = null);
private record DisplayRange(int First, int Last);
private record DisplayRange(int First, int Last)
{
public static readonly DisplayRange EMPTY = new DisplayRange(-1, -1);
}
/// <summary>
/// Implementation of scroll container which handles very large vertical lists by internally using <c>double</c> precision