mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 14:17:26 +08:00
Merge pull request #17315 from hwabis/queue-list-counter
This commit is contained in:
commit
6fbeea78dd
@ -11,6 +11,8 @@ 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;
|
||||
using osu.Game.Rulesets;
|
||||
@ -129,6 +131,25 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
||||
AddUntilStep("item 1 not in lists", () => !inHistoryList(0) && !inQueueList(0));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestQueueTabCount()
|
||||
{
|
||||
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 +234,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<OsuTabControl<MultiplayerPlaylistDisplayMode>.OsuTabItem>()
|
||||
.Single(t => t.Value == MultiplayerPlaylistDisplayMode.Queue)
|
||||
.ChildrenOfType<OsuSpriteText>().Single().Text == queueTabText;
|
||||
});
|
||||
}
|
||||
|
||||
private void changeDisplayModeStep(MultiplayerPlaylistDisplayMode mode) => AddStep($"change list to {mode}", () => list.DisplayMode.Value = mode);
|
||||
|
||||
private bool inQueueList(int playlistItemId)
|
||||
|
@ -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.UserInterface;
|
||||
using osu.Game.Online.Multiplayer;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
@ -25,6 +24,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
/// </summary>
|
||||
public Action<PlaylistItem> RequestEdit;
|
||||
|
||||
private MultiplayerPlaylistTabControl playlistTabControl;
|
||||
private MultiplayerQueueList queueList;
|
||||
private MultiplayerHistoryList historyList;
|
||||
private bool firstPopulation = true;
|
||||
@ -36,7 +36,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
|
||||
InternalChildren = new Drawable[]
|
||||
{
|
||||
new OsuTabControl<MultiplayerPlaylistDisplayMode>
|
||||
playlistTabControl = new MultiplayerPlaylistTabControl
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Height = tab_control_height,
|
||||
@ -64,6 +64,8 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
playlistTabControl.QueueItems.BindTarget = queueList.Items;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
|
@ -0,0 +1,39 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. 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;
|
||||
using osu.Game.Online.Rooms;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist
|
||||
{
|
||||
public class MultiplayerPlaylistTabControl : OsuTabControl<MultiplayerPlaylistDisplayMode>
|
||||
{
|
||||
public readonly IBindableList<PlaylistItem> QueueItems = new BindableList<PlaylistItem>();
|
||||
|
||||
protected override TabItem<MultiplayerPlaylistDisplayMode> CreateTabItem(MultiplayerPlaylistDisplayMode value)
|
||||
{
|
||||
if (value == MultiplayerPlaylistDisplayMode.Queue)
|
||||
return new QueueTabItem { QueueItems = { BindTarget = QueueItems } };
|
||||
|
||||
return base.CreateTabItem(value);
|
||||
}
|
||||
|
||||
private class QueueTabItem : OsuTabItem
|
||||
{
|
||||
public readonly IBindableList<PlaylistItem> QueueItems = new BindableList<PlaylistItem>();
|
||||
|
||||
public QueueTabItem()
|
||||
: base(MultiplayerPlaylistDisplayMode.Queue)
|
||||
{
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
QueueItems.BindCollectionChanged((_, __) => Text.Text = QueueItems.Count > 0 ? $"Queue ({QueueItems.Count})" : "Queue", true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user