Make the lobby player list include the ready indicator and not hack it together (#1860)

* Started new Lobby

* -Proper styling
-Use a scrollcontainer :smilethink:

* Too lazy to add a stylerule, too young to optimize css

* Fix typo

Co-authored-by: DrSmugleaf <DrSmugleaf@users.noreply.github.com>
This commit is contained in:
Exp
2020-08-24 12:11:53 +02:00
committed by GitHub
parent 99e0f2019d
commit 769a371be6
2 changed files with 89 additions and 17 deletions

View File

@@ -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);
}
}

View File

@@ -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();
}
}
}