Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow ordering certain carousel panels behind others #31802

Merged
merged 2 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,12 @@ public async Task<IEnumerable<CarouselItem>> Run(IEnumerable<CarouselItem> items
{
starGroup = (int)Math.Floor(b.StarRating);
var groupDefinition = new GroupDefinition($"{starGroup} - {++starGroup} *");
var groupItem = new CarouselItem(groupDefinition) { DrawHeight = GroupPanel.HEIGHT };

var groupItem = new CarouselItem(groupDefinition)
{
DrawHeight = GroupPanel.HEIGHT,
DepthLayer = -2
};

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

if (newBeatmapSet)
{
var setItem = new CarouselItem(beatmap.BeatmapSet!) { DrawHeight = BeatmapSetPanel.HEIGHT };
var setItem = new CarouselItem(beatmap.BeatmapSet!)
{
DrawHeight = BeatmapSetPanel.HEIGHT,
DepthLayer = -1
};

setItems[beatmap.BeatmapSet!] = new HashSet<CarouselItem> { setItem };
newItems.Insert(i, setItem);
i++;
Expand Down
6 changes: 4 additions & 2 deletions osu.Game/Screens/SelectV2/Carousel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,8 @@ protected override void Update()
updateDisplayedRange(range);
}

double selectedYPos = currentSelection.CarouselItem?.CarouselYPosition ?? 0;

foreach (var panel in scroll.Panels)
{
var c = (ICarouselPanel)panel;
Expand All @@ -558,8 +560,8 @@ protected override void Update()
if (c.Item == null)
continue;

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

if (c.DrawYPosition != c.Item.CarouselYPosition)
c.DrawYPosition = Interpolation.DampContinuously(c.DrawYPosition, c.Item.CarouselYPosition, 50, Time.Elapsed);
Expand Down
5 changes: 5 additions & 0 deletions osu.Game/Screens/SelectV2/CarouselItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ public sealed class CarouselItem : IComparable<CarouselItem>
/// </summary>
public float DrawHeight { get; set; } = DEFAULT_HEIGHT;

/// <summary>
/// Defines the display depth relative to other <see cref="CarouselItem"/>s.
/// </summary>
public int DepthLayer { get; set; }

/// <summary>
/// Whether this item is visible or hidden.
/// </summary>
Expand Down
Loading