Keep PlayerTab entries until the end of the round (#5910)
This commit is contained in:
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Events;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
@@ -36,6 +37,7 @@ namespace Content.Client.Administration
|
||||
SubscribeNetworkEvent<FullPlayerListEvent>(OnPlayerListChanged);
|
||||
SubscribeNetworkEvent<PlayerInfoChangedEvent>(OnPlayerInfoChanged);
|
||||
SubscribeNetworkEvent<PlayerInfoRemovalMessage>(OnPlayerInfoRemoval);
|
||||
SubscribeNetworkEvent<RoundRestartCleanupEvent>(OnRoundRestartCleanup);
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
@@ -44,11 +46,27 @@ namespace Content.Client.Administration
|
||||
ShutdownOverlay();
|
||||
}
|
||||
|
||||
private void OnRoundRestartCleanup(RoundRestartCleanupEvent msg, EntitySessionEventArgs args)
|
||||
{
|
||||
if (_playerList == null)
|
||||
return;
|
||||
|
||||
foreach (var (id, playerInfo) in _playerList.ToArray())
|
||||
{
|
||||
if (playerInfo.Connected)
|
||||
continue;
|
||||
_playerList.Remove(id);
|
||||
}
|
||||
PlayerListChanged?.Invoke(_playerList.Values.ToList());
|
||||
}
|
||||
|
||||
private void OnPlayerInfoRemoval(PlayerInfoRemovalMessage ev)
|
||||
{
|
||||
if (_playerList == null) _playerList = new();
|
||||
|
||||
_playerList.Remove(ev.NetUserId);
|
||||
var playerInfo = _playerList[ev.NetUserId];
|
||||
_playerList[ev.NetUserId] = new PlayerInfo(playerInfo.Username, playerInfo.CharacterName, playerInfo.Antag,
|
||||
playerInfo.EntityUid, playerInfo.SessionId, false);
|
||||
PlayerListChanged?.Invoke(_playerList.Values.ToList());
|
||||
}
|
||||
|
||||
|
||||
@@ -52,7 +52,8 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab
|
||||
PlayerList.AddChild(new PlayerTabEntry("Username",
|
||||
"Character",
|
||||
"Antagonist",
|
||||
new StyleBoxFlat(altColor)));
|
||||
new StyleBoxFlat(altColor),
|
||||
true));
|
||||
PlayerList.AddChild(new HSeparator());
|
||||
|
||||
var useAltColor = false;
|
||||
@@ -61,7 +62,8 @@ namespace Content.Client.Administration.UI.Tabs.PlayerTab
|
||||
var entry = new PlayerTabEntry(player.Username,
|
||||
player.CharacterName,
|
||||
player.Antag ? "YES" : "NO",
|
||||
new StyleBoxFlat(useAltColor ? altColor : defaultColor));
|
||||
new StyleBoxFlat(useAltColor ? altColor : defaultColor),
|
||||
player.Connected);
|
||||
entry.PlayerUid = player.EntityUid;
|
||||
entry.OnPressed += args => OnEntryPressed?.Invoke(args);
|
||||
PlayerList.AddChild(entry);
|
||||
|
||||
@@ -11,11 +11,13 @@ public partial class PlayerTabEntry : ContainerButton
|
||||
{
|
||||
public EntityUid? PlayerUid;
|
||||
|
||||
public PlayerTabEntry(string username, string character, string antagonist, StyleBox styleBox)
|
||||
public PlayerTabEntry(string username, string character, string antagonist, StyleBox styleBox, bool connected)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
UsernameLabel.Text = username;
|
||||
if (!connected)
|
||||
UsernameLabel.StyleClasses.Add("Disabled");
|
||||
CharacterLabel.Text = character;
|
||||
AntagonistLabel.Text = antagonist;
|
||||
BackgroundColorPanel.PanelOverride = styleBox;
|
||||
|
||||
@@ -130,7 +130,7 @@ namespace Content.Server.Administration
|
||||
|
||||
var antag = session.ContentData()?.Mind?.AllRoles.Any(r => r.Antagonist) ?? false;
|
||||
|
||||
return new PlayerInfo(name, username, antag, session.AttachedEntity.GetValueOrDefault(), session.UserId);
|
||||
return new PlayerInfo(name, username, antag, session.AttachedEntity.GetValueOrDefault(), session.UserId, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,5 +6,5 @@ using Robust.Shared.Serialization;
|
||||
namespace Content.Shared.Administration
|
||||
{
|
||||
[Serializable, NetSerializable]
|
||||
public record PlayerInfo(string Username, string CharacterName, bool Antag, EntityUid EntityUid, NetUserId SessionId);
|
||||
public record PlayerInfo(string Username, string CharacterName, bool Antag, EntityUid EntityUid, NetUserId SessionId, bool Connected);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user