Ahelp / player list changes (#11392)

This commit is contained in:
Leon Friedrich
2022-10-16 10:26:29 +13:00
committed by GitHub
parent bdf48405ec
commit fd5b624a76
7 changed files with 89 additions and 34 deletions

View File

@@ -35,11 +35,11 @@ namespace Content.Client.Administration
foreach (var playerInfo in _system.PlayerList)
{
// Otherwise the entity can not exist yet
var entity = playerInfo.EntityUid;
if (!_entityManager.EntityExists(entity))
if (!_entityManager.EntityExists(playerInfo.EntityUid))
{
continue;
}
var entity = playerInfo.EntityUid.Value;
// if not on the same map, continue
if (_entityManager.GetComponent<TransformComponent>(entity).MapID != _eyeManager.CurrentMap)

View File

@@ -28,7 +28,6 @@ namespace Content.Client.Administration.Systems
InitializeOverlay();
SubscribeNetworkEvent<FullPlayerListEvent>(OnPlayerListChanged);
SubscribeNetworkEvent<PlayerInfoChangedEvent>(OnPlayerInfoChanged);
SubscribeNetworkEvent<RoundRestartCleanupEvent>(OnRoundRestartCleanup);
}
public override void Shutdown()
@@ -37,20 +36,6 @@ namespace Content.Client.Administration.Systems
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 OnPlayerInfoChanged(PlayerInfoChangedEvent ev)
{
if(ev.PlayerInfo == null) return;

View File

@@ -57,7 +57,12 @@ namespace Content.Client.Administration.UI
ChannelSelector.OverrideText += (info, text) =>
{
var sb = new StringBuilder();
sb.Append(info.Connected ? '●' : '○');
if (info.Connected)
sb.Append('●');
else
sb.Append(info.ActiveThisRound ? '○' : '·');
sb.Append(' ');
if (_adminAHelpHelper.TryGetChannel(info.SessionId, out var panel) && panel.Unread > 0)
{
@@ -68,7 +73,7 @@ namespace Content.Client.Administration.UI
sb.Append(' ');
}
if (info.Antag)
if (info.Antag && info.ActiveThisRound)
sb.Append(new Rune(0x1F5E1)); // 🗡
sb.AppendFormat("\"{0}\"", text);
@@ -89,6 +94,23 @@ namespace Content.Client.Administration.UI
if (!bChannelExists)
return -1;
// First, sort by unread. Any chat with unread messages appears first. We just sort based on unread
// status, not number of unread messages, so that more recent unread messages take priority.
var aUnread = ach!.Unread > 0;
var bUnread = bch!.Unread > 0;
if (aUnread != bUnread)
return aUnread ? -1 : 1;
// Next, sort by connection status. Any disconnected players are grouped towards the end.
if (a.Connected != b.Connected)
return a.Connected ? -1 : 1;
// Next, group by whether or not the players have participated in this round.
// The ahelp window shows all players that have connected since server restart, this groups them all towards the bottom.
if (a.ActiveThisRound != b.ActiveThisRound)
return a.ActiveThisRound ? -1 : 1;
// Finally, sort by the most recent message.
return bch!.LastMessage.CompareTo(ach!.LastMessage);
};

View File

@@ -54,9 +54,9 @@ namespace Content.Client.Administration.UI.CustomControls
if (OverrideText != null && args.Button.Children.FirstOrDefault()?.Children?.FirstOrDefault() is Label label)
label.Text = GetText(selectedPlayer);
}
else if (args.Event.Function == EngineKeyFunctions.UseSecondary)
else if (args.Event.Function == EngineKeyFunctions.UseSecondary && selectedPlayer.EntityUid != null)
{
_verbSystem.VerbMenu.OpenVerbMenu(selectedPlayer.EntityUid);
_verbSystem.VerbMenu.OpenVerbMenu(selectedPlayer.EntityUid.Value);
}
}

View File

@@ -227,6 +227,10 @@ namespace Content.Client.Verbs
RaiseNetworkEvent(new RequestServerVerbsEvent(target, verbTypes, adminRequest: force));
}
// Some admin menu interactions will try get verbs for entities that have not yet been sent to the player.
if (!Exists(target))
return new();
return GetLocalVerbs(target, user, verbTypes, force);
}