From c2e7ff7e3e2dd645f46b90851307e7f3ed72dd6d Mon Sep 17 00:00:00 2001 From: hwabis Date: Fri, 18 Mar 2022 01:37:53 -0400 Subject: [PATCH 01/12] display count of listQueue --- .../Match/Playlist/MultiplayerPlaylist.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs index eeafebfec0..edd6cf93e9 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs @@ -7,6 +7,8 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; +using osu.Game.Graphics; +using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; @@ -29,6 +31,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist private MultiplayerHistoryList historyList; private bool firstPopulation = true; + private OsuSpriteText queueListCount; + [BackgroundDependencyLoader] private void load() { @@ -42,6 +46,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist Height = tab_control_height, Current = { BindTarget = DisplayMode } }, + queueListCount = new OsuSpriteText + { + Font = OsuFont.Default.With(weight: FontWeight.Bold), + Anchor = Anchor.TopCentre, + Origin = Anchor.TopCentre, + }, new Container { RelativeSizeAxes = Axes.Both, @@ -70,6 +80,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist { base.LoadComplete(); DisplayMode.BindValueChanged(onDisplayModeChanged, true); + queueList.Items.BindCollectionChanged( + (_, __) => queueListCount.Text = queueList.Items.Count.ToString(), true); } private void onDisplayModeChanged(ValueChangedEvent mode) From faa36c78e5c2c0fc80bd25ba12c82f1213fefeb2 Mon Sep 17 00:00:00 2001 From: hwabis Date: Fri, 18 Mar 2022 12:55:00 -0400 Subject: [PATCH 02/12] put count and tabs into new fillflowcontainer --- .../Match/Playlist/MultiplayerPlaylist.cs | 34 ++++++++++++++----- 1 file changed, 25 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs index edd6cf93e9..2b59452ff1 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs @@ -12,6 +12,7 @@ using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; +using osuTK; namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist { @@ -34,23 +35,38 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist private OsuSpriteText queueListCount; [BackgroundDependencyLoader] - private void load() + private void load(OsuColour osuColour) { const float tab_control_height = 25; InternalChildren = new Drawable[] { - new OsuTabControl + new FillFlowContainer { - RelativeSizeAxes = Axes.X, - Height = tab_control_height, - Current = { BindTarget = DisplayMode } - }, - queueListCount = new OsuSpriteText - { - Font = OsuFont.Default.With(weight: FontWeight.Bold), Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, + Direction = FillDirection.Horizontal, + RelativeSizeAxes = Axes.X, + AutoSizeAxes = Axes.Y, + Spacing = new Vector2(OsuTabControl.HORIZONTAL_SPACING, 0), + Children = new Drawable[] + { + queueListCount = new OsuSpriteText + { + Font = OsuFont.Default.With(weight: FontWeight.Bold), + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Colour = osuColour.Yellow, + }, + new OsuTabControl + { + RelativeSizeAxes = Axes.X, + Height = tab_control_height, + Anchor = Anchor.CentreLeft, + Origin = Anchor.CentreLeft, + Current = { BindTarget = DisplayMode }, + }, + } }, new Container { From d9b2a29c6d6d90fc568afff257652779f1e401e1 Mon Sep 17 00:00:00 2001 From: hwabis Date: Fri, 18 Mar 2022 20:02:26 -0400 Subject: [PATCH 03/12] (not working yet) add MultiplayerPlaylistTabControl, "Queue ({count})" --- .../Match/Playlist/MultiplayerPlaylist.cs | 36 ++++--------------- .../Playlist/MultiplayerPlaylistTabControl.cs | 34 ++++++++++++++++++ 2 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs index 2b59452ff1..c65ff1bd00 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs @@ -8,11 +8,8 @@ using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; using osu.Game.Graphics; -using osu.Game.Graphics.Sprites; -using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; -using osuTK; namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist { @@ -32,41 +29,20 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist private MultiplayerHistoryList historyList; private bool firstPopulation = true; - private OsuSpriteText queueListCount; + private MultiplayerPlaylistTabControl playlistTabControl; [BackgroundDependencyLoader] - private void load(OsuColour osuColour) + private void load() { const float tab_control_height = 25; InternalChildren = new Drawable[] { - new FillFlowContainer + playlistTabControl = new MultiplayerPlaylistTabControl { - Anchor = Anchor.TopCentre, - Origin = Anchor.TopCentre, - Direction = FillDirection.Horizontal, RelativeSizeAxes = Axes.X, - AutoSizeAxes = Axes.Y, - Spacing = new Vector2(OsuTabControl.HORIZONTAL_SPACING, 0), - Children = new Drawable[] - { - queueListCount = new OsuSpriteText - { - Font = OsuFont.Default.With(weight: FontWeight.Bold), - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Colour = osuColour.Yellow, - }, - new OsuTabControl - { - RelativeSizeAxes = Axes.X, - Height = tab_control_height, - Anchor = Anchor.CentreLeft, - Origin = Anchor.CentreLeft, - Current = { BindTarget = DisplayMode }, - }, - } + Height = tab_control_height, + Current = { BindTarget = DisplayMode }, }, new Container { @@ -97,7 +73,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist base.LoadComplete(); DisplayMode.BindValueChanged(onDisplayModeChanged, true); queueList.Items.BindCollectionChanged( - (_, __) => queueListCount.Text = queueList.Items.Count.ToString(), true); + (_, __) => playlistTabControl.queueListCount = queueList.Items.Count, true); } private void onDisplayModeChanged(ValueChangedEvent mode) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs new file mode 100644 index 0000000000..f6a5bfed41 --- /dev/null +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs @@ -0,0 +1,34 @@ +// Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. +// See the LICENCE file in the repository root for full licence text. + +using osu.Framework.Graphics.UserInterface; +using osu.Game.Graphics.UserInterface; + +namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist +{ + public class MultiplayerPlaylistTabControl : OsuTabControl + { + public int queueListCount; + + public MultiplayerPlaylistTabControl() + { + queueListCount = 0; + } + + protected override TabItem CreateTabItem(MultiplayerPlaylistDisplayMode value) + { + if (value == MultiplayerPlaylistDisplayMode.Queue) + return new QueueTabItem(value, queueListCount); + return new OsuTabItem(value); + } + + private class QueueTabItem : OsuTabItem + { + public QueueTabItem(MultiplayerPlaylistDisplayMode value, int count) + : base(value) + { + Text.Text += " (" + count + ")"; + } + } + } +} From 5e5fbc496ed25fd66029305c1665e0d23bb59759 Mon Sep 17 00:00:00 2001 From: hwabis Date: Fri, 18 Mar 2022 20:32:37 -0400 Subject: [PATCH 04/12] (still not working) try bindables instead of int --- .../Match/Playlist/MultiplayerPlaylist.cs | 2 +- .../Match/Playlist/MultiplayerPlaylistTabControl.cs | 12 ++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs index c65ff1bd00..a1feda9000 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs @@ -73,7 +73,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist base.LoadComplete(); DisplayMode.BindValueChanged(onDisplayModeChanged, true); queueList.Items.BindCollectionChanged( - (_, __) => playlistTabControl.queueListCount = queueList.Items.Count, true); + (_, __) => playlistTabControl.queueListCount.Value = queueList.Items.Count, true); } private void onDisplayModeChanged(ValueChangedEvent mode) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs index f6a5bfed41..a459ec6f80 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs @@ -1,6 +1,7 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Bindables; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; @@ -8,11 +9,10 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist { public class MultiplayerPlaylistTabControl : OsuTabControl { - public int queueListCount; + public Bindable queueListCount = new Bindable(0); public MultiplayerPlaylistTabControl() { - queueListCount = 0; } protected override TabItem CreateTabItem(MultiplayerPlaylistDisplayMode value) @@ -24,10 +24,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist private class QueueTabItem : OsuTabItem { - public QueueTabItem(MultiplayerPlaylistDisplayMode value, int count) + private Bindable count; + + public QueueTabItem(MultiplayerPlaylistDisplayMode value, Bindable queueListCount) : base(value) { - Text.Text += " (" + count + ")"; + count = new Bindable(); + count.BindTo(queueListCount); + Text.Text += " (" + count.Value + ")"; } } } From 5a5629eb5a50b6d5d4987167ff564403d49835eb Mon Sep 17 00:00:00 2001 From: hwabis Date: Fri, 18 Mar 2022 20:47:45 -0400 Subject: [PATCH 05/12] (works now) use BindValueChanged to set the Queue text --- .../Match/Playlist/MultiplayerPlaylistTabControl.cs | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs index a459ec6f80..f0a51eb5e1 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs @@ -24,14 +24,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist private class QueueTabItem : OsuTabItem { - private Bindable count; - public QueueTabItem(MultiplayerPlaylistDisplayMode value, Bindable queueListCount) : base(value) { - count = new Bindable(); - count.BindTo(queueListCount); - Text.Text += " (" + count.Value + ")"; + queueListCount.BindValueChanged( + _ => Text.Text = "Queue (" + queueListCount.Value + ")", true); } } } From 5d16519a822db2eda9d8759b0a27046bbe77e891 Mon Sep 17 00:00:00 2001 From: hwabis Date: Fri, 18 Mar 2022 23:41:55 -0400 Subject: [PATCH 06/12] make code prettier --- .../Multiplayer/Match/Playlist/MultiplayerPlaylist.cs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs index a1feda9000..3269257260 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs @@ -7,7 +7,6 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Game.Graphics; using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; @@ -25,12 +24,11 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist /// public Action RequestEdit; + private MultiplayerPlaylistTabControl playlistTabControl; private MultiplayerQueueList queueList; private MultiplayerHistoryList historyList; private bool firstPopulation = true; - private MultiplayerPlaylistTabControl playlistTabControl; - [BackgroundDependencyLoader] private void load() { @@ -42,7 +40,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist { RelativeSizeAxes = Axes.X, Height = tab_control_height, - Current = { BindTarget = DisplayMode }, + Current = { BindTarget = DisplayMode } }, new Container { From ef823d58a7e790d370a9e184405eedbc30f5025d Mon Sep 17 00:00:00 2001 From: hwabis Date: Sat, 19 Mar 2022 13:05:35 -0400 Subject: [PATCH 07/12] address frenzibyte review (refactor bindable flow, clean up CI stuff) --- .../Match/Playlist/MultiplayerPlaylist.cs | 3 +- .../Playlist/MultiplayerPlaylistTabControl.cs | 31 ++++++++++++------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs index 3269257260..77076bd1cc 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs @@ -70,8 +70,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist { base.LoadComplete(); DisplayMode.BindValueChanged(onDisplayModeChanged, true); - queueList.Items.BindCollectionChanged( - (_, __) => playlistTabControl.queueListCount.Value = queueList.Items.Count, true); + playlistTabControl.QueueItems.BindTarget = queueList.Items; } private void onDisplayModeChanged(ValueChangedEvent mode) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs index f0a51eb5e1..882a96c877 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs @@ -4,31 +4,40 @@ using osu.Framework.Bindables; using osu.Framework.Graphics.UserInterface; using osu.Game.Graphics.UserInterface; +using osu.Game.Online.Rooms; namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist { public class MultiplayerPlaylistTabControl : OsuTabControl { - public Bindable queueListCount = new Bindable(0); - - public MultiplayerPlaylistTabControl() - { - } + public readonly IBindableList QueueItems = new BindableList(); protected override TabItem CreateTabItem(MultiplayerPlaylistDisplayMode value) { if (value == MultiplayerPlaylistDisplayMode.Queue) - return new QueueTabItem(value, queueListCount); - return new OsuTabItem(value); + return new QueueTabItem { QueueItems = { BindTarget = QueueItems } }; + + return base.CreateTabItem(value); } private class QueueTabItem : OsuTabItem { - public QueueTabItem(MultiplayerPlaylistDisplayMode value, Bindable queueListCount) - : base(value) + public readonly IBindableList QueueItems = new BindableList(); + + public QueueTabItem() + : base(MultiplayerPlaylistDisplayMode.Queue) { - queueListCount.BindValueChanged( - _ => Text.Text = "Queue (" + queueListCount.Value + ")", true); + } + + protected override void LoadComplete() + { + base.LoadComplete(); + QueueItems.BindCollectionChanged((_,__) => + { + Text.Text = $"Queue"; + if (QueueItems.Count != 0) + Text.Text += $" ({QueueItems.Count})"; + }, true); } } } From 7529d6fc0078197d0f58e1c5fa0dc6cd3855a921 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 20 Mar 2022 06:23:42 +0300 Subject: [PATCH 08/12] Bind queue items during playlist initialization Along with where the other bindables are bound together (only bind, not listening). --- .../Multiplayer/Match/Playlist/MultiplayerPlaylist.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs index 77076bd1cc..879a21e7c1 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs @@ -64,13 +64,14 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist } } }; + + playlistTabControl.QueueItems.BindTarget = queueList.Items; } protected override void LoadComplete() { base.LoadComplete(); DisplayMode.BindValueChanged(onDisplayModeChanged, true); - playlistTabControl.QueueItems.BindTarget = queueList.Items; } private void onDisplayModeChanged(ValueChangedEvent mode) From e1d22e58bfbd03c6d8c198460711860ae1c23fb1 Mon Sep 17 00:00:00 2001 From: Salman Ahmed Date: Sun, 20 Mar 2022 06:25:07 +0300 Subject: [PATCH 09/12] Simplify queue count text logic --- .../Match/Playlist/MultiplayerPlaylistTabControl.cs | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs index 882a96c877..583a05839f 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylistTabControl.cs @@ -32,12 +32,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist protected override void LoadComplete() { base.LoadComplete(); - QueueItems.BindCollectionChanged((_,__) => - { - Text.Text = $"Queue"; - if (QueueItems.Count != 0) - Text.Text += $" ({QueueItems.Count})"; - }, true); + QueueItems.BindCollectionChanged((_, __) => Text.Text = QueueItems.Count > 0 ? $"Queue ({QueueItems.Count})" : "Queue", true); } } } From 8fbdd068951bf1f213f396aaa57fe51498a7c194 Mon Sep 17 00:00:00 2001 From: hwabis Date: Sun, 20 Mar 2022 16:24:41 -0400 Subject: [PATCH 10/12] add queue tab count test --- .../TestSceneMultiplayerPlaylist.cs | 31 +++++++++++++++++++ .../Graphics/UserInterface/OsuTabControl.cs | 2 +- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs index 6b5b45b73e..af17458649 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Game.Beatmaps; +using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; using osu.Game.Rulesets; @@ -129,6 +130,25 @@ namespace osu.Game.Tests.Visual.Multiplayer AddUntilStep("item 1 not in lists", () => !inHistoryList(0) && !inQueueList(0)); } + [Test] + public void TestTabQueueListCount() + { + assertQueueTabCount(1); + + addItemStep(); + assertQueueTabCount(2); + + addItemStep(); + assertQueueTabCount(3); + + AddStep("finish current item", () => MultiplayerClient.FinishCurrentItem().WaitSafely()); + assertQueueTabCount(2); + + AddStep("leave room", () => RoomManager.PartRoom()); + AddUntilStep("wait for room part", () => !RoomJoined); + assertQueueTabCount(0); + } + [Ignore("Expired items are initially removed from the room.")] [Test] public void TestJoinRoomWithMixedItemsAddedInCorrectLists() @@ -213,6 +233,17 @@ namespace osu.Game.Tests.Visual.Multiplayer }); } + private void assertQueueTabCount(int count) + { + string queueTabText = count > 0 ? $"Queue ({count})" : "Queue"; + AddUntilStep($"Queue tab shows \"{queueTabText}\"", () => + { + return this.ChildrenOfType.OsuTabItem>() + .First() + .Text.Text.Equals(queueTabText); + }); + } + private void changeDisplayModeStep(MultiplayerPlaylistDisplayMode mode) => AddStep($"change list to {mode}", () => list.DisplayMode.Value = mode); private bool inQueueList(int playlistItemId) diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index 3572ea5c31..ab03669207 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -98,7 +98,7 @@ namespace osu.Game.Graphics.UserInterface public class OsuTabItem : TabItem, IHasAccentColour { - protected readonly SpriteText Text; + public readonly SpriteText Text; protected readonly Box Bar; private Color4 accentColour; From 63b668638462a9e92af2b1a1bb1d150ed540b6e3 Mon Sep 17 00:00:00 2001 From: hwabis Date: Sun, 20 Mar 2022 16:28:05 -0400 Subject: [PATCH 11/12] make test name clearer --- .../Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs index af17458649..15b626ceeb 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs @@ -131,7 +131,7 @@ namespace osu.Game.Tests.Visual.Multiplayer } [Test] - public void TestTabQueueListCount() + public void TestQueueTabCount() { assertQueueTabCount(1); From 06136b2247c81868cb69ad3497fb681cc4e0e89d Mon Sep 17 00:00:00 2001 From: hwabis Date: Sun, 20 Mar 2022 21:37:02 -0400 Subject: [PATCH 12/12] Revert OsuTabItem Text to protected, update tab count test --- .../Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs | 5 +++-- osu.Game/Graphics/UserInterface/OsuTabControl.cs | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs index 15b626ceeb..cbd8b472b8 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs @@ -11,6 +11,7 @@ using osu.Framework.Graphics; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Game.Beatmaps; +using osu.Game.Graphics.Sprites; using osu.Game.Graphics.UserInterface; using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; @@ -239,8 +240,8 @@ namespace osu.Game.Tests.Visual.Multiplayer AddUntilStep($"Queue tab shows \"{queueTabText}\"", () => { return this.ChildrenOfType.OsuTabItem>() - .First() - .Text.Text.Equals(queueTabText); + .Single(t => t.Value == MultiplayerPlaylistDisplayMode.Queue) + .ChildrenOfType().Single().Text == queueTabText; }); } diff --git a/osu.Game/Graphics/UserInterface/OsuTabControl.cs b/osu.Game/Graphics/UserInterface/OsuTabControl.cs index ab03669207..3572ea5c31 100644 --- a/osu.Game/Graphics/UserInterface/OsuTabControl.cs +++ b/osu.Game/Graphics/UserInterface/OsuTabControl.cs @@ -98,7 +98,7 @@ namespace osu.Game.Graphics.UserInterface public class OsuTabItem : TabItem, IHasAccentColour { - public readonly SpriteText Text; + protected readonly SpriteText Text; protected readonly Box Bar; private Color4 accentColour;