Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@frenzibyte
Copy link
Member

Prerequisite for implementing design. Difficulty panels should have positive spacing / gaps between them, while set/group panels should overlap, matching stable.

Before:

CleanShot 2025-02-05 at 05 22 25
CleanShot 2025-02-05 at 05 22 35

After:
CleanShot 2025-02-05 at 05 21 45
CleanShot 2025-02-05 at 05 21 13

@frenzibyte frenzibyte added area:song-select type/cosmetic Only affects the game visually. Doesn't affect things working or not working. labels Feb 5, 2025
@frenzibyte frenzibyte requested a review from peppy February 5, 2025 10:23
var inputRectangle = DrawRectangle;

// Cover a gap introduced by the spacing between a BeatmapSetPanel and a BeatmapPanel either below/above it.
inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
Copy link
Member

@peppy peppy Feb 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pretty sure this is wrong? If there's two set panels next to each other this is going to give the "closer" one extra input lenience.

osu.Game.Tests.2025-02-06.at.08.40.19.mp4

I'm not sure how much it matters, but it's worth pointing out.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

99% sure you just don't need this at all? the inflation should only be on beatmap panels?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, to achieve complete evenness, beatmap panels extend input rectangle by half the spacing, so if you have a beatmap panel on top of a beatmap set panel, there'll be extra gap towards the beatmap set panel which has to be handled somehow.

Other options could be making beatmap panels somehow aware of the panel above/below it and adjust the inflation accordingly, or get rid of this completely and add handle click at gaps in BeatmapCarousel and make it determine the panel closest to its Y position (may work much better than this).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's how the alternative approach of handling this at a higher level would look like:

diff
diff --git a/osu.Game/Screens/SelectV2/BeatmapPanel.cs b/osu.Game/Screens/SelectV2/BeatmapPanel.cs
index 2fe509402b..3edfd4203b 100644
--- a/osu.Game/Screens/SelectV2/BeatmapPanel.cs
+++ b/osu.Game/Screens/SelectV2/BeatmapPanel.cs
@@ -24,16 +24,6 @@ public partial class BeatmapPanel : PoolableDrawable, ICarouselPanel
         private Box activationFlash = null!;
         private OsuSpriteText text = null!;
 
-        public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
-        {
-            var inputRectangle = DrawRectangle;
-
-            // Cover the gaps introduced by the spacing between BeatmapPanels.
-            inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
-
-            return inputRectangle.Contains(ToLocalSpace(screenSpacePos));
-        }
-
         [BackgroundDependencyLoader]
         private void load()
         {
diff --git a/osu.Game/Screens/SelectV2/BeatmapSetPanel.cs b/osu.Game/Screens/SelectV2/BeatmapSetPanel.cs
index 85d5cc097d..79ffe0f68a 100644
--- a/osu.Game/Screens/SelectV2/BeatmapSetPanel.cs
+++ b/osu.Game/Screens/SelectV2/BeatmapSetPanel.cs
@@ -27,16 +27,6 @@ public partial class BeatmapSetPanel : PoolableDrawable, ICarouselPanel
         private OsuSpriteText text = null!;
         private Box box = null!;
 
-        public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
-        {
-            var inputRectangle = DrawRectangle;
-
-            // Cover a gap introduced by the spacing between a BeatmapSetPanel and a BeatmapPanel either below/above it.
-            inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
-
-            return inputRectangle.Contains(ToLocalSpace(screenSpacePos));
-        }
-
         [BackgroundDependencyLoader]
         private void load()
         {
diff --git a/osu.Game/Screens/SelectV2/Carousel.cs b/osu.Game/Screens/SelectV2/Carousel.cs
index 5e0fa29684..8ce2b00482 100644
--- a/osu.Game/Screens/SelectV2/Carousel.cs
+++ b/osu.Game/Screens/SelectV2/Carousel.cs
@@ -426,6 +426,26 @@ private void traverseGroupSelection(int direction)
             } while (newIndex != originalIndex);
         }
 
+        protected override bool OnClick(ClickEvent e)
+        {
+            if (Parent == null)
+                return false;
+
+            var closestPanel = scroll.Panels.MinBy(p => Math.Min(
+                Math.Abs(p.ScreenSpaceDrawQuad.TopLeft.Y - e.ScreenSpaceMousePosition.Y),
+                Math.Abs(p.ScreenSpaceDrawQuad.BottomLeft.Y - e.ScreenSpaceMousePosition.Y)));
+
+            if (closestPanel == null)
+                return false;
+
+            var closestPanelCentre = closestPanel.ScreenSpaceDrawQuad.Centre;
+            if (!closestPanel.ReceivePositionalInputAt(new Vector2(e.ScreenSpaceMousePosition.X, closestPanelCentre.Y)))
+                return false;
+
+            closestPanel.TriggerClick();
+            return base.OnClick(e);
+        }
+
         #endregion
 
         #region Selection handling
diff --git a/osu.Game/Screens/SelectV2/GroupPanel.cs b/osu.Game/Screens/SelectV2/GroupPanel.cs
index df930a3111..7ed256ca6a 100644
--- a/osu.Game/Screens/SelectV2/GroupPanel.cs
+++ b/osu.Game/Screens/SelectV2/GroupPanel.cs
@@ -28,16 +28,6 @@ public partial class GroupPanel : PoolableDrawable, ICarouselPanel
 
         private Box box = null!;
 
-        public override bool ReceivePositionalInputAt(Vector2 screenSpacePos)
-        {
-            var inputRectangle = DrawRectangle;
-
-            // Cover a gap introduced by the spacing between a GroupPanel and a BeatmapPanel either below/above it.
-            inputRectangle = inputRectangle.Inflate(new MarginPadding { Vertical = BeatmapCarousel.SPACING / 2f });
-
-            return inputRectangle.Contains(ToLocalSpace(screenSpacePos));
-        }
-
         [BackgroundDependencyLoader]
         private void load()
         {

It sacrifices hover state between gaps but I would argue it doesn't even make sense to show anything hovered within gaps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like the alternative. Definitely need hover states to match.

I'm just going to turn a blind eye for now and mention it's not perfect inline. Can be fixed if someone has the time and energy later.

Copy link
Member

@peppy peppy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented.

@peppy peppy self-requested a review February 7, 2025 05:30
@peppy
Copy link
Member

peppy commented Feb 7, 2025

In order to simplify things, I've removed the inflation from group and set panels. This was objectively wrong and not something I can get behind merging, as a user could be clicking on what visually looks like one group and have the click arrive incorrectly at another due to the inflation.

Instead, I've only inflated the difficulty panels. As you mentioned, this will mean that the gaps between difficulties are non-equal, but I don't see this as an issue – at least not a blocker like the aforementioned visual discrepancy.

@frenzibyte Please check the changes and see if you can agree to this direction.

Copy link
Member Author

@frenzibyte frenzibyte left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sacrificing evenness to fix over-inflation in group/set panels sounds fair. Changes look good to me.

@peppy peppy merged commit 177ca4f into ppy:master Feb 7, 2025
7 of 10 checks passed
@frenzibyte frenzibyte deleted the carousel-v2-spacing branch February 7, 2025 08:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:song-select size/L type/cosmetic Only affects the game visually. Doesn't affect things working or not working.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants