From 02a54fa428633e1c83a8a60f9e68bc3c75372885 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 May 2025 17:01:13 +0900 Subject: [PATCH] Add context menu container to song select and required tests --- .../SongSelectV2/TestScenePanelBeatmap.cs | 61 ++++---- .../TestScenePanelBeatmapStandalone.cs | 61 ++++---- .../SongSelectV2/TestScenePanelGroup.cs | 121 ++++++++------- .../Visual/SongSelectV2/TestScenePanelSet.cs | 61 ++++---- osu.Game/Screens/SelectV2/SongSelect.cs | 142 +++++++++--------- 5 files changed, 237 insertions(+), 209 deletions(-) diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelBeatmap.cs b/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelBeatmap.cs index c0a77553c2..09f8c68951 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelBeatmap.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelBeatmap.cs @@ -13,6 +13,7 @@ using osu.Framework.Testing; using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Graphics.Carousel; +using osu.Game.Graphics.Cursor; using osu.Game.Online.Leaderboards; using osu.Game.Overlays; using osu.Game.Rulesets.Mania; @@ -87,37 +88,41 @@ namespace osu.Game.Tests.Visual.SongSelectV2 protected override Drawable CreateContent() { - return new FillFlowContainer + return new OsuContextMenuContainer { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Width = 0.5f, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0f, 5f), - Children = new Drawable[] + RelativeSizeAxes = Axes.Both, + Child = new FillFlowContainer { - new PanelBeatmap + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 0.5f, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, 5f), + Children = new Drawable[] { - Item = new CarouselItem(beatmap) - }, - new PanelBeatmap - { - Item = new CarouselItem(beatmap), - KeyboardSelected = { Value = true } - }, - new PanelBeatmap - { - Item = new CarouselItem(beatmap), - Selected = { Value = true } - }, - new PanelBeatmap - { - Item = new CarouselItem(beatmap), - KeyboardSelected = { Value = true }, - Selected = { Value = true } - }, + new PanelBeatmap + { + Item = new CarouselItem(beatmap) + }, + new PanelBeatmap + { + Item = new CarouselItem(beatmap), + KeyboardSelected = { Value = true } + }, + new PanelBeatmap + { + Item = new CarouselItem(beatmap), + Selected = { Value = true } + }, + new PanelBeatmap + { + Item = new CarouselItem(beatmap), + KeyboardSelected = { Value = true }, + Selected = { Value = true } + }, + } } }; } diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelBeatmapStandalone.cs b/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelBeatmapStandalone.cs index 93e495320f..e9361b3d7f 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelBeatmapStandalone.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelBeatmapStandalone.cs @@ -13,6 +13,7 @@ using osu.Framework.Testing; using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Graphics.Carousel; +using osu.Game.Graphics.Cursor; using osu.Game.Online.Leaderboards; using osu.Game.Overlays; using osu.Game.Rulesets.Mania; @@ -87,37 +88,41 @@ namespace osu.Game.Tests.Visual.SongSelectV2 protected override Drawable CreateContent() { - return new FillFlowContainer + return new OsuContextMenuContainer { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Width = 0.5f, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0f, 5f), - Children = new Drawable[] + RelativeSizeAxes = Axes.Both, + Child = new FillFlowContainer { - new PanelBeatmapStandalone + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 0.5f, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, 5f), + Children = new Drawable[] { - Item = new CarouselItem(beatmap) - }, - new PanelBeatmapStandalone - { - Item = new CarouselItem(beatmap), - KeyboardSelected = { Value = true } - }, - new PanelBeatmapStandalone - { - Item = new CarouselItem(beatmap), - Selected = { Value = true } - }, - new PanelBeatmapStandalone - { - Item = new CarouselItem(beatmap), - KeyboardSelected = { Value = true }, - Selected = { Value = true } - }, + new PanelBeatmapStandalone + { + Item = new CarouselItem(beatmap) + }, + new PanelBeatmapStandalone + { + Item = new CarouselItem(beatmap), + KeyboardSelected = { Value = true } + }, + new PanelBeatmapStandalone + { + Item = new CarouselItem(beatmap), + Selected = { Value = true } + }, + new PanelBeatmapStandalone + { + Item = new CarouselItem(beatmap), + KeyboardSelected = { Value = true }, + Selected = { Value = true } + }, + } } }; } diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelGroup.cs b/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelGroup.cs index 2d1b7cd1b2..c8623819b1 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelGroup.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelGroup.cs @@ -8,6 +8,7 @@ using osu.Framework.Graphics.Containers; using osu.Game.Beatmaps; using osu.Game.Overlays; using osu.Game.Graphics.Carousel; +using osu.Game.Graphics.Cursor; using osu.Game.Screens.SelectV2; using osu.Game.Tests.Visual.UserInterface; using osuTK; @@ -43,38 +44,42 @@ namespace osu.Game.Tests.Visual.SongSelectV2 { (typeof(OverlayColourProvider), new OverlayColourProvider(OverlayColourScheme.Aquamarine)) }, - Child = new FillFlowContainer + Child = new OsuContextMenuContainer { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Width = 0.5f, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0f, 5f), - Children = new[] + RelativeSizeAxes = Axes.Both, + Child = new FillFlowContainer { - new PanelGroupStarDifficulty + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 0.5f, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, 5f), + Children = new[] { - Item = new CarouselItem(new GroupDefinition(new StarDifficulty(star, 0), $"{star} Star(s)")) + new PanelGroupStarDifficulty + { + Item = new CarouselItem(new GroupDefinition(new StarDifficulty(star, 0), $"{star} Star(s)")) + }, + new PanelGroupStarDifficulty + { + Item = new CarouselItem(new GroupDefinition(new StarDifficulty(star, 0), $"{star} Star(s)")), + KeyboardSelected = { Value = true }, + }, + new PanelGroupStarDifficulty + { + Item = new CarouselItem(new GroupDefinition(new StarDifficulty(star, 0), $"{star} Star(s)")), + Expanded = { Value = true }, + }, + new PanelGroupStarDifficulty + { + Item = new CarouselItem(new GroupDefinition(new StarDifficulty(star, 0), $"{star} Star(s)")), + Expanded = { Value = true }, + KeyboardSelected = { Value = true }, + }, }, - new PanelGroupStarDifficulty - { - Item = new CarouselItem(new GroupDefinition(new StarDifficulty(star, 0), $"{star} Star(s)")), - KeyboardSelected = { Value = true }, - }, - new PanelGroupStarDifficulty - { - Item = new CarouselItem(new GroupDefinition(new StarDifficulty(star, 0), $"{star} Star(s)")), - Expanded = { Value = true }, - }, - new PanelGroupStarDifficulty - { - Item = new CarouselItem(new GroupDefinition(new StarDifficulty(star, 0), $"{star} Star(s)")), - Expanded = { Value = true }, - KeyboardSelected = { Value = true }, - }, - }, + } } }; }); @@ -83,37 +88,41 @@ namespace osu.Game.Tests.Visual.SongSelectV2 protected override Drawable CreateContent() { - return new FillFlowContainer + return new OsuContextMenuContainer { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Width = 0.5f, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0f, 5f), - Children = new Drawable[] + RelativeSizeAxes = Axes.Both, + Child = new FillFlowContainer { - new PanelGroup + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 0.5f, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, 5f), + Children = new Drawable[] { - Item = new CarouselItem(new GroupDefinition('A', "Group A")) - }, - new PanelGroup - { - Item = new CarouselItem(new GroupDefinition('A', "Group A")), - KeyboardSelected = { Value = true } - }, - new PanelGroup - { - Item = new CarouselItem(new GroupDefinition('A', "Group A")), - Expanded = { Value = true } - }, - new PanelGroup - { - Item = new CarouselItem(new GroupDefinition('A', "Group A")), - KeyboardSelected = { Value = true }, - Expanded = { Value = true } - }, + new PanelGroup + { + Item = new CarouselItem(new GroupDefinition('A', "Group A")) + }, + new PanelGroup + { + Item = new CarouselItem(new GroupDefinition('A', "Group A")), + KeyboardSelected = { Value = true } + }, + new PanelGroup + { + Item = new CarouselItem(new GroupDefinition('A', "Group A")), + Expanded = { Value = true } + }, + new PanelGroup + { + Item = new CarouselItem(new GroupDefinition('A', "Group A")), + KeyboardSelected = { Value = true }, + Expanded = { Value = true } + }, + } } }; } diff --git a/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelSet.cs b/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelSet.cs index 16f6b2cc9c..1723185b1f 100644 --- a/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelSet.cs +++ b/osu.Game.Tests/Visual/SongSelectV2/TestScenePanelSet.cs @@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers; using osu.Framework.Utils; using osu.Game.Beatmaps; using osu.Game.Graphics.Carousel; +using osu.Game.Graphics.Cursor; using osu.Game.Overlays; using osu.Game.Screens.SelectV2; using osu.Game.Tests.Resources; @@ -58,37 +59,41 @@ namespace osu.Game.Tests.Visual.SongSelectV2 protected override Drawable CreateContent() { - return new FillFlowContainer + return new OsuContextMenuContainer { - Anchor = Anchor.Centre, - Origin = Anchor.Centre, - Width = 0.5f, - RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Direction = FillDirection.Vertical, - Spacing = new Vector2(0f, 5f), - Children = new Drawable[] + RelativeSizeAxes = Axes.Both, + Child = new FillFlowContainer { - new PanelBeatmapSet + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + Width = 0.5f, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Direction = FillDirection.Vertical, + Spacing = new Vector2(0f, 5f), + Children = new Drawable[] { - Item = new CarouselItem(beatmapSet) - }, - new PanelBeatmapSet - { - Item = new CarouselItem(beatmapSet), - KeyboardSelected = { Value = true } - }, - new PanelBeatmapSet - { - Item = new CarouselItem(beatmapSet), - Expanded = { Value = true } - }, - new PanelBeatmapSet - { - Item = new CarouselItem(beatmapSet), - KeyboardSelected = { Value = true }, - Expanded = { Value = true } - }, + new PanelBeatmapSet + { + Item = new CarouselItem(beatmapSet) + }, + new PanelBeatmapSet + { + Item = new CarouselItem(beatmapSet), + KeyboardSelected = { Value = true } + }, + new PanelBeatmapSet + { + Item = new CarouselItem(beatmapSet), + Expanded = { Value = true } + }, + new PanelBeatmapSet + { + Item = new CarouselItem(beatmapSet), + KeyboardSelected = { Value = true }, + Expanded = { Value = true } + }, + } } }; } diff --git a/osu.Game/Screens/SelectV2/SongSelect.cs b/osu.Game/Screens/SelectV2/SongSelect.cs index 202b6814df..ac3be511a3 100644 --- a/osu.Game/Screens/SelectV2/SongSelect.cs +++ b/osu.Game/Screens/SelectV2/SongSelect.cs @@ -19,6 +19,7 @@ using osu.Framework.Threading; using osu.Game.Beatmaps; using osu.Game.Collections; using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Cursor; using osu.Game.Input.Bindings; using osu.Game.Overlays; using osu.Game.Overlays.Mods; @@ -109,82 +110,85 @@ namespace osu.Game.Screens.SelectV2 { RelativeSizeAxes = Axes.Both, Padding = new MarginPadding { Bottom = ScreenFooter.HEIGHT }, - Child = new PopoverContainer + Child = new OsuContextMenuContainer { RelativeSizeAxes = Axes.Both, - Children = new Drawable[] + Child = new PopoverContainer { - new GridContainer // used for max width implementation + RelativeSizeAxes = Axes.Both, + Children = new Drawable[] { - RelativeSizeAxes = Axes.Both, - ColumnDimensions = new[] + new GridContainer // used for max width implementation { - new Dimension(GridSizeMode.Relative, 0.5f, maxSize: 850), - new Dimension(), - new Dimension(GridSizeMode.Relative, 0.5f, maxSize: 750), - }, - Content = new[] - { - new[] + RelativeSizeAxes = Axes.Both, + ColumnDimensions = new[] { - wedgesContainer = new FillFlowContainer - { - RelativeSizeAxes = Axes.Both, - Margin = new MarginPadding - { - Top = -CORNER_RADIUS_HIDE_OFFSET, - Left = -CORNER_RADIUS_HIDE_OFFSET - }, - Spacing = new Vector2(0f, 4f), - Direction = FillDirection.Vertical, - Shear = OsuGame.SHEAR, - Children = new Drawable[] - { - new ShearAligningWrapper(titleWedge = new BeatmapTitleWedge()), - new ShearAligningWrapper(detailsArea = new BeatmapDetailsArea()), - }, - }, - Empty(), - new Container - { - RelativeSizeAxes = Axes.Both, - Children = new CompositeDrawable[] - { - new Container - { - RelativeSizeAxes = Axes.Both, - Padding = new MarginPadding - { - Top = FilterControl.HEIGHT_FROM_SCREEN_TOP + 5, - Bottom = 5, - }, - Children = new Drawable[] - { - carousel = new BeatmapCarousel - { - BleedTop = FilterControl.HEIGHT_FROM_SCREEN_TOP + 5, - BleedBottom = ScreenFooter.HEIGHT + 5, - RequestPresentBeatmap = _ => OnStart(), - ChooseRecommendedBeatmap = getRecommendedBeatmap, - NewItemsPresented = newItemsPresented, - RelativeSizeAxes = Axes.Both, - }, - noResultsPlaceholder = new NoResultsPlaceholder(), - } - }, - filterControl = new FilterControl - { - Anchor = Anchor.TopRight, - Origin = Anchor.TopRight, - RelativeSizeAxes = Axes.X, - }, - } - }, + new Dimension(GridSizeMode.Relative, 0.5f, maxSize: 850), + new Dimension(), + new Dimension(GridSizeMode.Relative, 0.5f, maxSize: 750), }, - } - }, - } - }, + Content = new[] + { + new[] + { + wedgesContainer = new FillFlowContainer + { + RelativeSizeAxes = Axes.Both, + Margin = new MarginPadding + { + Top = -CORNER_RADIUS_HIDE_OFFSET, + Left = -CORNER_RADIUS_HIDE_OFFSET + }, + Spacing = new Vector2(0f, 4f), + Direction = FillDirection.Vertical, + Shear = OsuGame.SHEAR, + Children = new Drawable[] + { + new ShearAligningWrapper(titleWedge = new BeatmapTitleWedge()), + new ShearAligningWrapper(detailsArea = new BeatmapDetailsArea()), + }, + }, + Empty(), + new Container + { + RelativeSizeAxes = Axes.Both, + Children = new CompositeDrawable[] + { + new Container + { + RelativeSizeAxes = Axes.Both, + Padding = new MarginPadding + { + Top = FilterControl.HEIGHT_FROM_SCREEN_TOP + 5, + Bottom = 5, + }, + Children = new Drawable[] + { + carousel = new BeatmapCarousel + { + BleedTop = FilterControl.HEIGHT_FROM_SCREEN_TOP + 5, + BleedBottom = ScreenFooter.HEIGHT + 5, + RequestPresentBeatmap = SelectAndStart, + NewItemsPresented = newItemsPresented, + RelativeSizeAxes = Axes.Both, + }, + noResultsPlaceholder = new NoResultsPlaceholder(), + } + }, + filterControl = new FilterControl + { + Anchor = Anchor.TopRight, + Origin = Anchor.TopRight, + RelativeSizeAxes = Axes.X, + }, + } + }, + }, + } + }, + } + }, + } }, new SkinnableContainer(new GlobalSkinnableContainerLookup(GlobalSkinnableContainers.SongSelect)) {