Skip to content

Commit 4c934da

Browse files
authored
Merge pull request ppy#31774 from frenzibyte/carousel-v2-implement-designs
Implement designs for beatmap carousel v2
2 parents df5fe07 + 092d80c commit 4c934da

28 files changed

+2239
-434
lines changed

osu.Game.Tests/Visual/SongSelect/BeatmapCarouselV2TestScene.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using osu.Game.Database;
1818
using osu.Game.Graphics;
1919
using osu.Game.Graphics.Containers;
20+
using osu.Game.Overlays;
2021
using osu.Game.Screens.Select;
2122
using osu.Game.Screens.SelectV2;
2223
using osu.Game.Tests.Beatmaps;
@@ -39,6 +40,9 @@ public abstract partial class BeatmapCarouselV2TestScene : OsuManualInputManager
3940
[Cached(typeof(BeatmapStore))]
4041
private BeatmapStore store;
4142

43+
[Cached]
44+
private readonly OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Aquamarine);
45+
4246
private OsuTextFlowContainer stats = null!;
4347

4448
private int beatmapCount;
@@ -94,7 +98,7 @@ protected void CreateCarousel()
9498
{
9599
Anchor = Anchor.Centre,
96100
Origin = Anchor.Centre,
97-
Width = 500,
101+
Width = 800,
98102
RelativeSizeAxes = Axes.Y,
99103
},
100104
},
@@ -185,6 +189,7 @@ protected void ClickVisiblePanel<T>(int index)
185189
.Where(p => ((ICarouselPanel)p).Item?.IsVisible == true)
186190
.OrderBy(p => p.Y)
187191
.ElementAt(index)
192+
.ChildrenOfType<PanelBase>().Single()
188193
.TriggerClick();
189194
});
190195
}

osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselV2ArtistGrouping.cs

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,42 +28,42 @@ public void SetUpSteps()
2828
[Test]
2929
public void TestOpenCloseGroupWithNoSelectionMouse()
3030
{
31-
AddAssert("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
32-
AddUntilStep("no sets visible", () => Carousel.ChildrenOfType<BeatmapSetPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
31+
AddAssert("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
32+
AddUntilStep("no sets visible", () => Carousel.ChildrenOfType<PanelBeatmapSet>().Count(p => p.Alpha > 0), () => Is.Zero);
3333
CheckNoSelection();
3434

35-
ClickVisiblePanel<GroupPanel>(0);
35+
ClickVisiblePanel<PanelGroup>(0);
3636

37-
AddUntilStep("some sets visible", () => Carousel.ChildrenOfType<BeatmapSetPanel>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
38-
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
37+
AddUntilStep("some sets visible", () => Carousel.ChildrenOfType<PanelBeatmapSet>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
38+
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
3939
CheckNoSelection();
4040

41-
ClickVisiblePanel<GroupPanel>(0);
41+
ClickVisiblePanel<PanelGroup>(0);
4242

43-
AddUntilStep("no sets visible", () => Carousel.ChildrenOfType<BeatmapSetPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
44-
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
43+
AddUntilStep("no sets visible", () => Carousel.ChildrenOfType<PanelBeatmapSet>().Count(p => p.Alpha > 0), () => Is.Zero);
44+
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
4545
CheckNoSelection();
4646
}
4747

4848
[Test]
4949
public void TestOpenCloseGroupWithNoSelectionKeyboard()
5050
{
51-
AddAssert("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
52-
AddUntilStep("no sets visible", () => Carousel.ChildrenOfType<BeatmapSetPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
51+
AddAssert("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
52+
AddUntilStep("no sets visible", () => Carousel.ChildrenOfType<PanelBeatmapSet>().Count(p => p.Alpha > 0), () => Is.Zero);
5353
CheckNoSelection();
5454

5555
SelectNextPanel();
5656
Select();
5757

58-
AddUntilStep("some sets visible", () => Carousel.ChildrenOfType<BeatmapSetPanel>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
59-
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
58+
AddUntilStep("some sets visible", () => Carousel.ChildrenOfType<PanelBeatmapSet>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
59+
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
6060
AddAssert("keyboard selected is expanded", () => GetKeyboardSelectedPanel()?.Expanded.Value, () => Is.True);
6161
CheckNoSelection();
6262

6363
Select();
6464

65-
AddUntilStep("no sets visible", () => Carousel.ChildrenOfType<BeatmapSetPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
66-
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
65+
AddUntilStep("no sets visible", () => Carousel.ChildrenOfType<PanelBeatmapSet>().Count(p => p.Alpha > 0), () => Is.Zero);
66+
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
6767
AddAssert("keyboard selected is collapsed", () => GetKeyboardSelectedPanel()?.Expanded.Value, () => Is.False);
6868
CheckNoSelection();
6969
}
@@ -96,10 +96,10 @@ public void TestCarouselRemembersSelection()
9696
AddUntilStep("drawable selection restored", () => GetSelectedPanel()?.Item?.Model, () => Is.EqualTo(selection));
9797
AddAssert("carousel item is visible", () => GetSelectedPanel()?.Item?.IsVisible, () => Is.True);
9898

99-
ClickVisiblePanel<GroupPanel>(0);
99+
ClickVisiblePanel<PanelGroup>(0);
100100
AddUntilStep("carousel item not visible", GetSelectedPanel, () => Is.Null);
101101

102-
ClickVisiblePanel<GroupPanel>(0);
102+
ClickVisiblePanel<PanelGroup>(0);
103103
AddUntilStep("carousel item is visible", () => GetSelectedPanel()?.Item?.IsVisible, () => Is.True);
104104
}
105105

@@ -137,7 +137,7 @@ public void TestKeyboardSelection()
137137
// open first group
138138
Select();
139139
CheckNoSelection();
140-
AddUntilStep("some beatmaps visible", () => Carousel.ChildrenOfType<BeatmapSetPanel>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
140+
AddUntilStep("some beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmapSet>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
141141

142142
SelectNextPanel();
143143
Select();

osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselV2DifficultyGrouping.cs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -29,32 +29,32 @@ public void SetUpSteps()
2929
[Test]
3030
public void TestOpenCloseGroupWithNoSelectionMouse()
3131
{
32-
AddAssert("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
32+
AddAssert("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
3333
CheckNoSelection();
3434

35-
ClickVisiblePanel<GroupPanel>(0);
36-
AddUntilStep("some beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
35+
ClickVisiblePanel<PanelGroup>(0);
36+
AddUntilStep("some beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
3737
CheckNoSelection();
3838

39-
ClickVisiblePanel<GroupPanel>(0);
40-
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
39+
ClickVisiblePanel<PanelGroup>(0);
40+
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
4141
CheckNoSelection();
4242
}
4343

4444
[Test]
4545
public void TestOpenCloseGroupWithNoSelectionKeyboard()
4646
{
47-
AddAssert("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
47+
AddAssert("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
4848
CheckNoSelection();
4949

5050
SelectNextPanel();
5151
Select();
52-
AddUntilStep("some beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
52+
AddUntilStep("some beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
5353
AddAssert("keyboard selected is expanded", () => GetKeyboardSelectedPanel()?.Expanded.Value, () => Is.True);
5454
CheckNoSelection();
5555

5656
Select();
57-
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.Zero);
57+
AddUntilStep("no beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.Zero);
5858
AddAssert("keyboard selected is collapsed", () => GetKeyboardSelectedPanel()?.Expanded.Value, () => Is.False);
5959
CheckNoSelection();
6060
}
@@ -87,10 +87,10 @@ public void TestCarouselRemembersSelection()
8787
AddUntilStep("drawable selection restored", () => GetSelectedPanel()?.Item?.Model, () => Is.EqualTo(selection));
8888
AddAssert("carousel item is visible", () => GetSelectedPanel()?.Item?.IsVisible, () => Is.True);
8989

90-
ClickVisiblePanel<GroupPanel>(0);
90+
ClickVisiblePanel<PanelGroup>(0);
9191
AddUntilStep("carousel item not visible", GetSelectedPanel, () => Is.Null);
9292

93-
ClickVisiblePanel<GroupPanel>(0);
93+
ClickVisiblePanel<PanelGroup>(0);
9494
AddUntilStep("carousel item is visible", () => GetSelectedPanel()?.Item?.IsVisible, () => Is.True);
9595
}
9696

@@ -120,18 +120,18 @@ public void TestGroupSelectionOnHeaderMouse()
120120
SelectNextGroup();
121121
WaitForGroupSelection(0, 0);
122122

123-
AddAssert("keyboard selected panel is beatmap", GetKeyboardSelectedPanel, Is.TypeOf<BeatmapPanel>);
124-
AddAssert("selected panel is beatmap", GetSelectedPanel, Is.TypeOf<BeatmapPanel>);
123+
AddAssert("keyboard selected panel is beatmap", GetKeyboardSelectedPanel, Is.TypeOf<PanelBeatmap>);
124+
AddAssert("selected panel is beatmap", GetSelectedPanel, Is.TypeOf<PanelBeatmap>);
125125

126-
ClickVisiblePanel<GroupPanel>(0);
127-
AddAssert("keyboard selected panel is group", GetKeyboardSelectedPanel, Is.TypeOf<GroupPanel>);
126+
ClickVisiblePanel<PanelGroup>(0);
127+
AddAssert("keyboard selected panel is group", GetKeyboardSelectedPanel, Is.TypeOf<PanelGroup>);
128128
AddAssert("keyboard selected panel is contracted", () => GetKeyboardSelectedPanel()?.Expanded.Value, () => Is.False);
129129

130-
ClickVisiblePanel<GroupPanel>(0);
131-
AddAssert("keyboard selected panel is group", GetKeyboardSelectedPanel, Is.TypeOf<GroupPanel>);
130+
ClickVisiblePanel<PanelGroup>(0);
131+
AddAssert("keyboard selected panel is group", GetKeyboardSelectedPanel, Is.TypeOf<PanelGroup>);
132132
AddAssert("keyboard selected panel is expanded", () => GetKeyboardSelectedPanel()?.Expanded.Value, () => Is.True);
133133

134-
AddAssert("selected panel is still beatmap", GetSelectedPanel, Is.TypeOf<BeatmapPanel>);
134+
AddAssert("selected panel is still beatmap", GetSelectedPanel, Is.TypeOf<PanelBeatmap>);
135135
}
136136

137137
[Test]
@@ -146,7 +146,7 @@ public void TestKeyboardSelection()
146146
// open first group
147147
Select();
148148
CheckNoSelection();
149-
AddUntilStep("some beatmaps visible", () => Carousel.ChildrenOfType<BeatmapPanel>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
149+
AddUntilStep("some beatmaps visible", () => Carousel.ChildrenOfType<PanelBeatmap>().Count(p => p.Alpha > 0), () => Is.GreaterThan(0));
150150

151151
SelectNextPanel();
152152
Select();
@@ -171,23 +171,23 @@ public void TestKeyboardSelection()
171171
[Test]
172172
public void TestInputHandlingWithinGaps()
173173
{
174-
AddAssert("no beatmaps visible", () => !GetVisiblePanels<BeatmapPanel>().Any());
174+
AddAssert("no beatmaps visible", () => !GetVisiblePanels<PanelBeatmap>().Any());
175175

176176
// Clicks just above the first group panel should not actuate any action.
177-
ClickVisiblePanelWithOffset<GroupPanel>(0, new Vector2(0, -(GroupPanel.HEIGHT / 2 + 1)));
177+
ClickVisiblePanelWithOffset<PanelGroup>(0, new Vector2(0, -(PanelGroup.HEIGHT / 2 + 1)));
178178

179-
AddAssert("no beatmaps visible", () => !GetVisiblePanels<BeatmapPanel>().Any());
179+
AddAssert("no beatmaps visible", () => !GetVisiblePanels<PanelBeatmap>().Any());
180180

181-
ClickVisiblePanelWithOffset<GroupPanel>(0, new Vector2(0, -(GroupPanel.HEIGHT / 2)));
181+
ClickVisiblePanelWithOffset<PanelGroup>(0, new Vector2(0, -(PanelGroup.HEIGHT / 2)));
182182

183-
AddUntilStep("wait for beatmaps visible", () => GetVisiblePanels<BeatmapPanel>().Any());
183+
AddUntilStep("wait for beatmaps visible", () => GetVisiblePanels<PanelBeatmap>().Any());
184184
CheckNoSelection();
185185

186186
// Beatmap panels expand their selection area to cover holes from spacing.
187-
ClickVisiblePanelWithOffset<BeatmapPanel>(0, new Vector2(0, -(CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
187+
ClickVisiblePanelWithOffset<PanelBeatmap>(0, new Vector2(0, -(CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
188188
WaitForGroupSelection(0, 0);
189189

190-
ClickVisiblePanelWithOffset<BeatmapPanel>(1, new Vector2(0, (CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
190+
ClickVisiblePanelWithOffset<PanelBeatmap>(1, new Vector2(0, (CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
191191
WaitForGroupSelection(0, 1);
192192
}
193193
}

osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselV2NoGrouping.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -213,27 +213,27 @@ public void TestInputHandlingWithinGaps()
213213
AddBeatmaps(2, 5);
214214
WaitForDrawablePanels();
215215

216-
AddAssert("no beatmaps visible", () => !GetVisiblePanels<BeatmapPanel>().Any());
216+
AddAssert("no beatmaps visible", () => !GetVisiblePanels<PanelBeatmap>().Any());
217217

218218
// Clicks just above the first group panel should not actuate any action.
219-
ClickVisiblePanelWithOffset<BeatmapSetPanel>(0, new Vector2(0, -(BeatmapSetPanel.HEIGHT / 2 + 1)));
219+
ClickVisiblePanelWithOffset<PanelBeatmapSet>(0, new Vector2(0, -(PanelBeatmapSet.HEIGHT / 2 + 1)));
220220

221-
AddAssert("no beatmaps visible", () => !GetVisiblePanels<BeatmapPanel>().Any());
221+
AddAssert("no beatmaps visible", () => !GetVisiblePanels<PanelBeatmap>().Any());
222222

223-
ClickVisiblePanelWithOffset<BeatmapSetPanel>(0, new Vector2(0, -(BeatmapSetPanel.HEIGHT / 2)));
223+
ClickVisiblePanelWithOffset<PanelBeatmapSet>(0, new Vector2(0, -(PanelBeatmapSet.HEIGHT / 2)));
224224

225-
AddUntilStep("wait for beatmaps visible", () => GetVisiblePanels<BeatmapPanel>().Any());
225+
AddUntilStep("wait for beatmaps visible", () => GetVisiblePanels<PanelBeatmap>().Any());
226226
WaitForSelection(0, 0);
227227

228228
// Beatmap panels expand their selection area to cover holes from spacing.
229-
ClickVisiblePanelWithOffset<BeatmapPanel>(1, new Vector2(0, -(CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
229+
ClickVisiblePanelWithOffset<PanelBeatmap>(1, new Vector2(0, -(CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
230230
WaitForSelection(0, 0);
231231

232232
// Panels with higher depth will handle clicks in the gutters for simplicity.
233-
ClickVisiblePanelWithOffset<BeatmapPanel>(2, new Vector2(0, (CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
233+
ClickVisiblePanelWithOffset<PanelBeatmap>(2, new Vector2(0, (CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
234234
WaitForSelection(0, 2);
235235

236-
ClickVisiblePanelWithOffset<BeatmapPanel>(3, new Vector2(0, (CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
236+
ClickVisiblePanelWithOffset<PanelBeatmap>(3, new Vector2(0, (CarouselItem.DEFAULT_HEIGHT / 2 + 1)));
237237
WaitForSelection(0, 3);
238238
}
239239

osu.Game.Tests/Visual/SongSelect/TestSceneBeatmapCarouselV2Scrolling.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,16 @@ public void TestScrollPositionMaintainedOnAddSecondSelected()
3030
Quad positionBefore = default;
3131

3232
AddStep("select middle beatmap", () => Carousel.CurrentSelection = BeatmapSets.ElementAt(BeatmapSets.Count - 2).Beatmaps.First());
33-
AddStep("scroll to selected item", () => Scroll.ScrollTo(Scroll.ChildrenOfType<BeatmapPanel>().Single(p => p.Selected.Value)));
33+
AddStep("scroll to selected item", () => Scroll.ScrollTo(Scroll.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value)));
3434

3535
WaitForScrolling();
3636

37-
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<BeatmapPanel>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
37+
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<PanelBeatmap>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
3838

3939
RemoveFirstBeatmap();
4040
WaitForSorting();
4141

42-
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<BeatmapPanel>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
42+
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
4343
() => Is.EqualTo(positionBefore));
4444
}
4545

@@ -54,11 +54,11 @@ public void TestScrollPositionMaintainedOnAddLastSelected()
5454

5555
WaitForScrolling();
5656

57-
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<BeatmapPanel>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
57+
AddStep("save selected screen position", () => positionBefore = Carousel.ChildrenOfType<PanelBeatmap>().FirstOrDefault(p => p.Selected.Value)!.ScreenSpaceDrawQuad);
5858

5959
RemoveFirstBeatmap();
6060
WaitForSorting();
61-
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<BeatmapPanel>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
61+
AddAssert("select screen position unchanged", () => Carousel.ChildrenOfType<PanelBeatmap>().Single(p => p.Selected.Value).ScreenSpaceDrawQuad,
6262
() => Is.EqualTo(positionBefore));
6363
}
6464
}

0 commit comments

Comments
 (0)