diff --git a/Content.Client/State/LobbyState.cs b/Content.Client/State/LobbyState.cs index d3f756a0c8..6f04765caa 100644 --- a/Content.Client/State/LobbyState.cs +++ b/Content.Client/State/LobbyState.cs @@ -1,6 +1,4 @@ -using System; -using System.Linq; -using Content.Client.Interfaces; +using Content.Client.Interfaces; using Content.Client.Interfaces.Chat; using Content.Client.UserInterface; using Content.Shared.Input; @@ -18,6 +16,8 @@ using Robust.Shared.Localization; using Robust.Shared.Prototypes; using Robust.Shared.Timing; using Robust.Shared.ViewVariables; +using System; +using System.Linq; using static Content.Shared.SharedGameTicker; namespace Content.Client.State @@ -211,12 +211,11 @@ namespace Content.Client.State private void UpdatePlayerList() { - _lobby.OnlinePlayerItemList.Clear(); - _lobby.PlayerReadyList.Clear(); + _lobby.OnlinePlayerList.Clear(); foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name)) { - _lobby.OnlinePlayerItemList.AddItem(session.Name); + var readyState = ""; // Don't show ready state if we're ingame @@ -236,7 +235,7 @@ namespace Content.Client.State _ => "", }; } - _lobby.PlayerReadyList.AddItem(readyState, null, false); + _lobby.OnlinePlayerList.AddItem(session.Name, readyState); } } diff --git a/Content.Client/UserInterface/LobbyGui.cs b/Content.Client/UserInterface/LobbyGui.cs index 2f8caf3574..9c2ec94a34 100644 --- a/Content.Client/UserInterface/LobbyGui.cs +++ b/Content.Client/UserInterface/LobbyGui.cs @@ -9,6 +9,8 @@ using Robust.Client.UserInterface.Controls; using Robust.Shared.Interfaces.GameObjects; using Robust.Shared.Localization; using Robust.Shared.Maths; +using System; +using System.Collections.Generic; namespace Content.Client.UserInterface { @@ -21,8 +23,7 @@ namespace Content.Client.UserInterface public Button CreditsButton { get; } public Button LeaveButton { get; } public ChatBox Chat { get; } - public ItemList OnlinePlayerItemList { get; } - public ItemList PlayerReadyList { get; } + public LobbyPlayerList OnlinePlayerList { get; } public ServerInfo ServerInfo { get; } public LobbyCharacterPreviewPanel CharacterPreview { get; } @@ -226,17 +227,11 @@ namespace Content.Client.UserInterface CustomMinimumSize = (50,50), Children = { - (OnlinePlayerItemList = new ItemList + (OnlinePlayerList = new LobbyPlayerList { SizeFlagsVertical = SizeFlags.FillExpand, SizeFlagsHorizontal = SizeFlags.FillExpand, - }), - (PlayerReadyList = new ItemList - { - SizeFlagsVertical = SizeFlags.FillExpand, - SizeFlagsHorizontal = SizeFlags.FillExpand, - SizeFlagsStretchRatio = 0.2f - }), + }) } } } @@ -262,4 +257,82 @@ namespace Content.Client.UserInterface } } } + + public class LobbyPlayerList : Control + { + private ScrollContainer _scroll; + private VBoxContainer _vBox; + + public LobbyPlayerList() + { + var panel = new PanelContainer() + { + PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#202028") }, + }; + _vBox = new VBoxContainer(); + _scroll = new ScrollContainer(); + _scroll.AddChild(_vBox); + panel.AddChild(_scroll); + AddChild(panel); + } + + // Adds a row + public void AddItem(string name, string status) + { + var hbox = new HBoxContainer + { + SizeFlagsHorizontal = SizeFlags.FillExpand, + }; + + // Player Name + hbox.AddChild(new PanelContainer() + { + PanelOverride = new StyleBoxFlat + { + BackgroundColor = Color.FromHex("#373744"), + ContentMarginBottomOverride = 2, + ContentMarginLeftOverride = 4, + ContentMarginRightOverride = 4, + ContentMarginTopOverride = 2 + }, + Children = + { + new Label + { + Text = name + } + }, + SizeFlagsHorizontal = SizeFlags.FillExpand + }); + // Status + hbox.AddChild(new PanelContainer() + { + PanelOverride = new StyleBoxFlat + { + BackgroundColor = Color.FromHex("#373744"), + ContentMarginBottomOverride = 2, + ContentMarginLeftOverride = 4, + ContentMarginRightOverride = 4, + ContentMarginTopOverride = 2 + }, + Children = + { + new Label + { + Text = status + } + }, + SizeFlagsHorizontal = SizeFlags.FillExpand, + SizeFlagsStretchRatio = 0.2f, + }); + + _vBox.AddChild(hbox); + } + + // Deletes all rows + public void Clear() + { + _vBox.RemoveAllChildren(); + } + } }