Skip to content

Commit f4bb3bc

Browse files
authored
Merge pull request #31802 from frenzibyte/carousel-v2-depth-ordering
Allow ordering certain carousel panels behind others
2 parents d9b370e + 9cc90a5 commit f4bb3bc

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs

+12-2
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ public async Task<IEnumerable<CarouselItem>> Run(IEnumerable<CarouselItem> items
6666
{
6767
starGroup = (int)Math.Floor(b.StarRating);
6868
var groupDefinition = new GroupDefinition($"{starGroup} - {++starGroup} *");
69-
var groupItem = new CarouselItem(groupDefinition) { DrawHeight = GroupPanel.HEIGHT };
69+
70+
var groupItem = new CarouselItem(groupDefinition)
71+
{
72+
DrawHeight = GroupPanel.HEIGHT,
73+
DepthLayer = -2
74+
};
7075

7176
newItems.Add(groupItem);
7277
groupItems[groupDefinition] = new HashSet<CarouselItem> { groupItem };
@@ -95,7 +100,12 @@ public async Task<IEnumerable<CarouselItem>> Run(IEnumerable<CarouselItem> items
95100

96101
if (newBeatmapSet)
97102
{
98-
var setItem = new CarouselItem(beatmap.BeatmapSet!) { DrawHeight = BeatmapSetPanel.HEIGHT };
103+
var setItem = new CarouselItem(beatmap.BeatmapSet!)
104+
{
105+
DrawHeight = BeatmapSetPanel.HEIGHT,
106+
DepthLayer = -1
107+
};
108+
99109
setItems[beatmap.BeatmapSet!] = new HashSet<CarouselItem> { setItem };
100110
newItems.Insert(i, setItem);
101111
i++;

osu.Game/Screens/SelectV2/Carousel.cs

+4-2
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,8 @@ protected override void Update()
548548
updateDisplayedRange(range);
549549
}
550550

551+
double selectedYPos = currentSelection.CarouselItem?.CarouselYPosition ?? 0;
552+
551553
foreach (var panel in scroll.Panels)
552554
{
553555
var c = (ICarouselPanel)panel;
@@ -556,8 +558,8 @@ protected override void Update()
556558
if (c.Item == null)
557559
continue;
558560

559-
double selectedYPos = currentSelection?.CarouselItem?.CarouselYPosition ?? 0;
560-
scroll.Panels.ChangeChildDepth(panel, (float)Math.Abs(c.DrawYPosition - selectedYPos));
561+
float normalisedDepth = (float)(Math.Abs(selectedYPos - c.DrawYPosition) / DrawHeight);
562+
scroll.Panels.ChangeChildDepth(panel, c.Item.DepthLayer + normalisedDepth);
561563

562564
if (c.DrawYPosition != c.Item.CarouselYPosition)
563565
c.DrawYPosition = Interpolation.DampContinuously(c.DrawYPosition, c.Item.CarouselYPosition, 50, Time.Elapsed);

osu.Game/Screens/SelectV2/CarouselItem.cs

+5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,11 @@ public sealed class CarouselItem : IComparable<CarouselItem>
2929
/// </summary>
3030
public float DrawHeight { get; set; } = DEFAULT_HEIGHT;
3131

32+
/// <summary>
33+
/// Defines the display depth relative to other <see cref="CarouselItem"/>s.
34+
/// </summary>
35+
public int DepthLayer { get; set; }
36+
3237
/// <summary>
3338
/// Whether this item is visible or hidden.
3439
/// </summary>

0 commit comments

Comments
 (0)