From c370c75fe2793dd379b4f4b8983fd3a35da17511 Mon Sep 17 00:00:00 2001 From: Salman Alshamrani Date: Wed, 5 Feb 2025 05:47:34 -0500 Subject: [PATCH 1/2] Allow ordering certain carousel panels behind others --- .../SelectV2/BeatmapCarouselFilterGrouping.cs | 14 ++++++++++++-- osu.Game/Screens/SelectV2/Carousel.cs | 7 +++++-- osu.Game/Screens/SelectV2/CarouselItem.cs | 6 ++++++ 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs b/osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs index e4160cc0fa..55cb5fa5f9 100644 --- a/osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs +++ b/osu.Game/Screens/SelectV2/BeatmapCarouselFilterGrouping.cs @@ -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 { 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 { setItem }; newItems.Insert(i, setItem); i++; diff --git a/osu.Game/Screens/SelectV2/Carousel.cs b/osu.Game/Screens/SelectV2/Carousel.cs index 608ef207d9..5dc8d80476 100644 --- a/osu.Game/Screens/SelectV2/Carousel.cs +++ b/osu.Game/Screens/SelectV2/Carousel.cs @@ -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); diff --git a/osu.Game/Screens/SelectV2/CarouselItem.cs b/osu.Game/Screens/SelectV2/CarouselItem.cs index 32be33e99a..e497c3890c 100644 --- a/osu.Game/Screens/SelectV2/CarouselItem.cs +++ b/osu.Game/Screens/SelectV2/CarouselItem.cs @@ -29,6 +29,12 @@ namespace osu.Game.Screens.SelectV2 /// public float DrawHeight { get; set; } = DEFAULT_HEIGHT; + /// + /// A number that defines the layer which this should be placed on depth-wise. + /// The higher the number, the farther the panel associated with this item is taken to the background. + /// + public int DepthLayer { get; set; } = 0; + /// /// Whether this item is visible or hidden. /// From 9cc90a51df7aa2a0043690ff873ed836741993b0 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Thu, 6 Feb 2025 13:32:11 +0900 Subject: [PATCH 2/2] Adjust xmldoc and avoid LINQ overheads --- osu.Game/Screens/SelectV2/Carousel.cs | 7 +++---- osu.Game/Screens/SelectV2/CarouselItem.cs | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/osu.Game/Screens/SelectV2/Carousel.cs b/osu.Game/Screens/SelectV2/Carousel.cs index 5dc8d80476..07d9c988f5 100644 --- a/osu.Game/Screens/SelectV2/Carousel.cs +++ b/osu.Game/Screens/SelectV2/Carousel.cs @@ -550,8 +550,7 @@ 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(); + double selectedYPos = currentSelection.CarouselItem?.CarouselYPosition ?? 0; foreach (var panel in scroll.Panels) { @@ -561,8 +560,8 @@ namespace osu.Game.Screens.SelectV2 if (c.Item == null) continue; - float normalisedDepth = (float)(Math.Abs(selectedYPos - c.DrawYPosition) / maximumDistanceFromSelection); - scroll.Panels.ChangeChildDepth(panel, normalisedDepth + c.Item.DepthLayer); + 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); diff --git a/osu.Game/Screens/SelectV2/CarouselItem.cs b/osu.Game/Screens/SelectV2/CarouselItem.cs index e497c3890c..0ac8180028 100644 --- a/osu.Game/Screens/SelectV2/CarouselItem.cs +++ b/osu.Game/Screens/SelectV2/CarouselItem.cs @@ -30,10 +30,9 @@ namespace osu.Game.Screens.SelectV2 public float DrawHeight { get; set; } = DEFAULT_HEIGHT; /// - /// A number that defines the layer which this should be placed on depth-wise. - /// The higher the number, the farther the panel associated with this item is taken to the background. + /// Defines the display depth relative to other s. /// - public int DepthLayer { get; set; } = 0; + public int DepthLayer { get; set; } /// /// Whether this item is visible or hidden.