diff --git a/osu.Game.Tests/Visual/Playlists/TestScenePlaylistTray.cs b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistTray.cs new file mode 100644 index 0000000000..5efb859157 --- /dev/null +++ b/osu.Game.Tests/Visual/Playlists/TestScenePlaylistTray.cs @@ -0,0 +1,38 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.Linq; +using NUnit.Framework; +using osu.Framework.Graphics; +using osu.Game.Online.Rooms; +using osu.Game.Screens.OnlinePlay.Playlists; +using osu.Game.Tests.Visual.OnlinePlay; + +namespace osu.Game.Tests.Visual.Playlists +{ + public partial class TestScenePlaylistTray : OnlinePlayTestScene + { + private Room room = null!; + private PlaylistsSongSelectV2.PlaylistTray tray = null!; + + public override void SetUpSteps() + { + base.SetUpSteps(); + + AddStep("add tray", () => Child = tray = new PlaylistsSongSelectV2.PlaylistTray(room = new Room()) + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre + }); + } + + [Test] + public void TestAddItem() + { + AddStep("add playlist item", () => + { + room.Playlist = room.Playlist.Append(new PlaylistItem(CreateAPIBeatmap())).ToArray(); + }); + } + } +} diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.PlaylistTray.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.PlaylistTray.cs new file mode 100644 index 0000000000..f2c210b33b --- /dev/null +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.PlaylistTray.cs @@ -0,0 +1,128 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using System.ComponentModel; +using System.Linq; +using osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Shapes; +using osu.Game.Graphics; +using osu.Game.Graphics.Containers; +using osu.Game.Graphics.Sprites; +using osu.Game.Online.Rooms; +using osuTK; +using osuTK.Graphics; + +namespace osu.Game.Screens.OnlinePlay.Playlists +{ + public partial class PlaylistsSongSelectV2 + { + public partial class PlaylistTray : CompositeDrawable + { + private readonly Room room; + + private OsuScrollContainer scroll = null!; + private FillFlowContainer flow = null!; + + public PlaylistTray(Room room) + { + this.room = room; + + Size = new Vector2(400, 75); + } + + [BackgroundDependencyLoader] + private void load() + { + Masking = true; + CornerRadius = 20; + + InternalChildren = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = Color4.Black, + Alpha = 0.9f + }, + new GridContainer + { + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + RelativeSizeAxes = Axes.X, + Height = DrawableRoomPlaylistItem.HEIGHT, + Padding = new MarginPadding { Horizontal = 20 }, + ColumnDimensions = new[] + { + new Dimension(GridSizeMode.AutoSize), + new Dimension() + }, + Content = new[] + { + new Drawable[] + { + new OsuSpriteText + { + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Text = "Playlist", + Font = OsuFont.Default.With(size: 20) + }, + scroll = new OsuScrollContainer(Direction.Horizontal) + { + RelativeSizeAxes = Axes.Both, + Margin = new MarginPadding { Left = 10 }, + ScrollbarVisible = false, + Child = flow = new FillFlowContainer + { + RelativeSizeAxes = Axes.Y, + AutoSizeAxes = Axes.X, + Direction = FillDirection.Horizontal + } + } + }, + } + } + }; + } + + protected override void LoadComplete() + { + base.LoadComplete(); + + room.PropertyChanged += onRoomPropertyChanged; + updateRoomPlaylist(); + } + + private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e) + { + if (e.PropertyName == nameof(Room.Playlist)) + updateRoomPlaylist(); + } + + private void updateRoomPlaylist() + { + if (room.Playlist.Count > 0) + { + flow.Add(new DrawableRoomPlaylistItem(room.Playlist[^1], loadImmediately: true) + { + RelativeSizeAxes = Axes.None, + Width = 250, + AllowReordering = false, + }); + } + + scroll.ScrollToStart(animated: false); + + this.FadeIn(200); + ScheduleAfterChildren(() => scroll.ScrollToEnd()); + this.Delay(1000).FadeOut(200); + } + + // Disallow the user from interacting with the scrolling elements. + public override bool PropagatePositionalInputSubTree => false; + public override bool PropagateNonPositionalInputSubTree => false; + } + } +} diff --git a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.cs b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.cs index ea5fc1536c..2ceecf6985 100644 --- a/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.cs +++ b/osu.Game/Screens/OnlinePlay/Playlists/PlaylistsSongSelectV2.cs @@ -61,10 +61,23 @@ namespace osu.Game.Screens.OnlinePlay.Playlists [BackgroundDependencyLoader] private void load() { - AddInternal(freeModSelect = new FreeModSelectOverlay + AddRangeInternal(new Drawable[] { - SelectedMods = { BindTarget = freeMods }, - IsValidMod = isValidAllowedMod, + freeModSelect = new FreeModSelectOverlay + { + SelectedMods = { BindTarget = freeMods }, + IsValidMod = isValidAllowedMod, + }, + new PlaylistTray(room) + { + Anchor = Anchor.BottomRight, + Origin = Anchor.BottomRight, + Margin = new MarginPadding + { + Bottom = ScreenFooterButton.HEIGHT, + Right = OsuGame.SCREEN_EDGE_MARGIN + } + } }); } @@ -195,8 +208,6 @@ namespace osu.Game.Screens.OnlinePlay.Playlists buttons.Single(i => i is FooterButtonMods).TooltipText = MultiplayerMatchStrings.RequiredModsButtonTooltip; - buttons.Insert(0, new FooterButtonPlaylistV2(room)); - buttons.InsertRange(buttons.FindIndex(b => b is FooterButtonMods) + 1, [ new FooterButtonFreeModsV2(freeModSelect)