Administration: Ahelp tabs (#5965)
This commit is contained in:
@@ -2,14 +2,11 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Administration.Events;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Players;
|
||||
|
||||
namespace Content.Client.Administration.UI.CustomControls
|
||||
{
|
||||
@@ -20,6 +17,9 @@ namespace Content.Client.Administration.UI.CustomControls
|
||||
|
||||
public event Action<PlayerInfo?>? OnSelectionChanged;
|
||||
|
||||
public Action<PlayerInfo, ItemList.Item>? DecoratePlayer;
|
||||
public Func<PlayerInfo, int>? SortKey;
|
||||
|
||||
public PlayerListControl()
|
||||
{
|
||||
_adminSystem = EntitySystem.Get<AdminSystem>();
|
||||
@@ -53,10 +53,17 @@ namespace Content.Client.Administration.UI.CustomControls
|
||||
OnSelectionChanged?.Invoke(null);
|
||||
}
|
||||
|
||||
public void Refresh() => PopulateList();
|
||||
|
||||
private void PopulateList(IReadOnlyList<PlayerInfo> _ = null!)
|
||||
{
|
||||
PlayerItemList.Clear();
|
||||
foreach (var info in _adminSystem.PlayerList)
|
||||
|
||||
IEnumerable<PlayerInfo> iter = _adminSystem.PlayerList;
|
||||
if (SortKey is not null)
|
||||
iter = _adminSystem.PlayerList.OrderByDescending(SortKey);
|
||||
|
||||
foreach (var info in iter)
|
||||
{
|
||||
var displayName = $"{info.CharacterName} ({info.Username})";
|
||||
if (!string.IsNullOrEmpty(FilterLineEdit.Text) &&
|
||||
@@ -65,11 +72,13 @@ namespace Content.Client.Administration.UI.CustomControls
|
||||
continue;
|
||||
}
|
||||
|
||||
PlayerItemList.Add(new ItemList.Item(PlayerItemList)
|
||||
var item = new ItemList.Item(PlayerItemList)
|
||||
{
|
||||
Metadata = info,
|
||||
Text = displayName
|
||||
});
|
||||
};
|
||||
DecoratePlayer?.Invoke(info, item);
|
||||
PlayerItemList.Add(item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user