1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-08 03:32:55 +08:00

Merge pull request #31802 from frenzibyte/carousel-v2-depth-ordering

Allow ordering certain carousel panels behind others
This commit is contained in:
Dean Herbert 2025-02-06 17:29:56 +09:00 committed by GitHub
commit f4bb3bc422
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 4 deletions

View File

@ -66,7 +66,12 @@ namespace osu.Game.Screens.SelectV2
{ {
starGroup = (int)Math.Floor(b.StarRating); starGroup = (int)Math.Floor(b.StarRating);
var groupDefinition = new GroupDefinition($"{starGroup} - {++starGroup} *"); 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); newItems.Add(groupItem);
groupItems[groupDefinition] = new HashSet<CarouselItem> { groupItem }; groupItems[groupDefinition] = new HashSet<CarouselItem> { groupItem };
@ -95,7 +100,12 @@ namespace osu.Game.Screens.SelectV2
if (newBeatmapSet) 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 }; setItems[beatmap.BeatmapSet!] = new HashSet<CarouselItem> { setItem };
newItems.Insert(i, setItem); newItems.Insert(i, setItem);
i++; i++;

View File

@ -548,6 +548,8 @@ namespace osu.Game.Screens.SelectV2
updateDisplayedRange(range); updateDisplayedRange(range);
} }
double selectedYPos = currentSelection.CarouselItem?.CarouselYPosition ?? 0;
foreach (var panel in scroll.Panels) foreach (var panel in scroll.Panels)
{ {
var c = (ICarouselPanel)panel; var c = (ICarouselPanel)panel;
@ -556,8 +558,8 @@ namespace osu.Game.Screens.SelectV2
if (c.Item == null) if (c.Item == null)
continue; continue;
double selectedYPos = currentSelection?.CarouselItem?.CarouselYPosition ?? 0; float normalisedDepth = (float)(Math.Abs(selectedYPos - c.DrawYPosition) / DrawHeight);
scroll.Panels.ChangeChildDepth(panel, (float)Math.Abs(c.DrawYPosition - selectedYPos)); scroll.Panels.ChangeChildDepth(panel, c.Item.DepthLayer + normalisedDepth);
if (c.DrawYPosition != c.Item.CarouselYPosition) if (c.DrawYPosition != c.Item.CarouselYPosition)
c.DrawYPosition = Interpolation.DampContinuously(c.DrawYPosition, c.Item.CarouselYPosition, 50, Time.Elapsed); c.DrawYPosition = Interpolation.DampContinuously(c.DrawYPosition, c.Item.CarouselYPosition, 50, Time.Elapsed);

View File

@ -29,6 +29,11 @@ namespace osu.Game.Screens.SelectV2
/// </summary> /// </summary>
public float DrawHeight { get; set; } = DEFAULT_HEIGHT; 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> /// <summary>
/// Whether this item is visible or hidden. /// Whether this item is visible or hidden.
/// </summary> /// </summary>