diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs index 3117db8900..b21dbbd462 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneMultiplayerPlaylist.cs @@ -6,7 +6,6 @@ using NUnit.Framework; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Graphics; -using osu.Framework.Graphics.Containers; using osu.Framework.Platform; using osu.Framework.Testing; using osu.Game.Beatmaps; @@ -14,7 +13,6 @@ using osu.Game.Online.Multiplayer; using osu.Game.Online.Rooms; using osu.Game.Rulesets; using osu.Game.Screens.OnlinePlay; -using osu.Game.Screens.OnlinePlay.Multiplayer; using osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist; using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Resources; @@ -219,84 +217,5 @@ namespace osu.Game.Tests.Visual.Multiplayer .ChildrenOfType() .Any(i => i.Item.ID == playlistItemId); } - - public class MultiplayerPlaylist : MultiplayerRoomComposite - { - private MultiplayerQueueList queueList; - private MultiplayerHistoryList historyList; - private bool firstPopulation = true; - - [BackgroundDependencyLoader] - private void load() - { - InternalChild = new GridContainer - { - RelativeSizeAxes = Axes.Both, - Content = new[] - { - new Drawable[] - { - queueList = new MultiplayerQueueList - { - RelativeSizeAxes = Axes.Both - }, - historyList = new MultiplayerHistoryList - { - RelativeSizeAxes = Axes.Both - } - } - } - }; - } - - protected override void OnRoomUpdated() - { - base.OnRoomUpdated(); - - if (Room == null) - { - historyList.Items.Clear(); - queueList.Items.Clear(); - firstPopulation = true; - return; - } - - if (firstPopulation) - { - foreach (var item in Room.Playlist) - PlaylistItemAdded(item); - - firstPopulation = false; - } - } - - protected override void PlaylistItemAdded(MultiplayerPlaylistItem item) - { - base.PlaylistItemAdded(item); - - var apiItem = Playlist.Single(i => i.ID == item.ID); - - if (item.Expired) - historyList.Items.Add(apiItem); - else - queueList.Items.Add(apiItem); - } - - protected override void PlaylistItemRemoved(long item) - { - base.PlaylistItemRemoved(item); - - queueList.Items.RemoveAll(i => i.ID == item); - historyList.Items.RemoveAll(i => i.ID == item); - } - - protected override void PlaylistItemChanged(MultiplayerPlaylistItem item) - { - base.PlaylistItemChanged(item); - - PlaylistItemRemoved(item.ID); - PlaylistItemAdded(item); - } - } } } diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs new file mode 100644 index 0000000000..f853333b08 --- /dev/null +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/Match/Playlist/MultiplayerPlaylist.cs @@ -0,0 +1,90 @@ +// 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 osu.Framework.Allocation; +using osu.Framework.Graphics; +using osu.Framework.Graphics.Containers; +using osu.Game.Online.Rooms; + +namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match.Playlist +{ + public class MultiplayerPlaylist : MultiplayerRoomComposite + { + private MultiplayerQueueList queueList; + private MultiplayerHistoryList historyList; + private bool firstPopulation = true; + + [BackgroundDependencyLoader] + private void load() + { + InternalChild = new GridContainer + { + RelativeSizeAxes = Axes.Both, + Content = new[] + { + new Drawable[] + { + queueList = new MultiplayerQueueList + { + RelativeSizeAxes = Axes.Both + }, + historyList = new MultiplayerHistoryList + { + RelativeSizeAxes = Axes.Both + } + } + } + }; + } + + protected override void OnRoomUpdated() + { + base.OnRoomUpdated(); + + if (Room == null) + { + historyList.Items.Clear(); + queueList.Items.Clear(); + firstPopulation = true; + return; + } + + if (firstPopulation) + { + foreach (var item in Room.Playlist) + PlaylistItemAdded(item); + + firstPopulation = false; + } + } + + protected override void PlaylistItemAdded(MultiplayerPlaylistItem item) + { + base.PlaylistItemAdded(item); + + var apiItem = Playlist.Single(i => i.ID == item.ID); + + if (item.Expired) + historyList.Items.Add(apiItem); + else + queueList.Items.Add(apiItem); + } + + protected override void PlaylistItemRemoved(long item) + { + base.PlaylistItemRemoved(item); + + queueList.Items.RemoveAll(i => i.ID == item); + historyList.Items.RemoveAll(i => i.ID == item); + } + + protected override void PlaylistItemChanged(MultiplayerPlaylistItem item) + { + base.PlaylistItemChanged(item); + + PlaylistItemRemoved(item.ID); + PlaylistItemAdded(item); + } + } +}