diff --git a/Content.Client/Administration/AdminSystem.cs b/Content.Client/Administration/AdminSystem.cs index 198ca6c6f4..ce74adc4ae 100644 --- a/Content.Client/Administration/AdminSystem.cs +++ b/Content.Client/Administration/AdminSystem.cs @@ -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(OnPlayerListChanged); SubscribeNetworkEvent(OnPlayerInfoChanged); SubscribeNetworkEvent(OnPlayerInfoRemoval); + SubscribeNetworkEvent(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()); } diff --git a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs index 3c77c5b5fe..3dd0818cf0 100644 --- a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTab.xaml.cs @@ -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); diff --git a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs index c333bc9609..d6d773388d 100644 --- a/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs +++ b/Content.Client/Administration/UI/Tabs/PlayerTab/PlayerTabEntry.xaml.cs @@ -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; diff --git a/Content.Server/Administration/AdminSystem.cs b/Content.Server/Administration/AdminSystem.cs index d2d234e389..60f0d7fecd 100644 --- a/Content.Server/Administration/AdminSystem.cs +++ b/Content.Server/Administration/AdminSystem.cs @@ -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); } } } diff --git a/Content.Shared/Administration/PlayerInfo.cs b/Content.Shared/Administration/PlayerInfo.cs index 77942fd6dd..ab201dc829 100644 --- a/Content.Shared/Administration/PlayerInfo.cs +++ b/Content.Shared/Administration/PlayerInfo.cs @@ -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); }