1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-14 05:47:20 +08:00

Allow ordering certain carousel panels behind others

This commit is contained in:
Salman Alshamrani 2025-02-05 05:47:34 -05:00
parent ea725e2caf
commit c370c75fe2
3 changed files with 23 additions and 4 deletions

View File

@ -66,7 +66,12 @@ namespace osu.Game.Screens.SelectV2
{
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 };
@ -95,7 +100,12 @@ namespace osu.Game.Screens.SelectV2
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++;

View File

@ -550,6 +550,9 @@ namespace osu.Game.Screens.SelectV2
updateDisplayedRange(range);
}
double selectedYPos = currentSelection?.CarouselItem?.CarouselYPosition ?? 0;
double maximumDistanceFromSelection = scroll.Panels.Select(p => Math.Abs(((ICarouselPanel)p).DrawYPosition - selectedYPos)).DefaultIfEmpty().Max();
foreach (var panel in scroll.Panels)
{
var c = (ICarouselPanel)panel;
@ -558,8 +561,8 @@ namespace osu.Game.Screens.SelectV2
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) / maximumDistanceFromSelection);
scroll.Panels.ChangeChildDepth(panel, normalisedDepth + c.Item.DepthLayer);
if (c.DrawYPosition != c.Item.CarouselYPosition)
c.DrawYPosition = Interpolation.DampContinuously(c.DrawYPosition, c.Item.CarouselYPosition, 50, Time.Elapsed);

View File

@ -29,6 +29,12 @@ namespace osu.Game.Screens.SelectV2
/// </summary>
public float DrawHeight { get; set; } = DEFAULT_HEIGHT;
/// <summary>
/// A number that defines the layer which this <see cref="CarouselItem"/> should be placed on depth-wise.
/// The higher the number, the farther the panel associated with this item is taken to the background.
/// </summary>
public int DepthLayer { get; set; } = 0;
/// <summary>
/// Whether this item is visible or hidden.
/// </summary>