* Adds three new smites, headstand, locker stuff, and reptilian species swap. * Localize all the smites. * save work * More smites... * Final tweaks. * oops * !PLEH * Adds disarm prone and improved hand removal options. * fix chances. * take out the trash. * Add some admin TRICKS instead of more smites. * oop * Implements the admin test arena and associated trick. * Tricks for granting/revoking access. * e * mfw * Implement quick dialogs, for when you don't want to spend 20 minutes writing a simple dialog prompt. * Forgot the rejuv icon. * E * docs * augh * Add rename/redescribe buttons. * Adds objects menu, implements a couple tricks for stations. * 1984 * Adds a trick for effectively infinite power. * fixes some icon uggo. * a * HALT! * Pause/unpause buttons. * Forgor the textures. * they broke every bone in their body. * i added more * more battery actions, touch up battery icon. * Address reviews.
96 lines
3.1 KiB
C#
96 lines
3.1 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Content.Client.Administration.Systems;
|
|
using Content.Shared.Administration;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
|
|
namespace Content.Client.Administration.UI.CustomControls
|
|
{
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class PlayerListControl : BoxContainer
|
|
{
|
|
private readonly AdminSystem _adminSystem;
|
|
|
|
public event Action<PlayerInfo?>? OnSelectionChanged;
|
|
|
|
public Action<PlayerInfo, ItemList.Item>? DecoratePlayer;
|
|
public Comparison<PlayerInfo>? Comparison;
|
|
|
|
public PlayerListControl()
|
|
{
|
|
_adminSystem = EntitySystem.Get<AdminSystem>();
|
|
IoCManager.InjectDependencies(this);
|
|
RobustXamlLoader.Load(this);
|
|
// Fill the Option data
|
|
PopulateList();
|
|
PlayerItemList.OnItemSelected += PlayerItemListOnOnItemSelected;
|
|
PlayerItemList.OnItemDeselected += PlayerItemListOnOnItemDeselected;
|
|
FilterLineEdit.OnTextChanged += FilterLineEditOnOnTextEntered;
|
|
_adminSystem.PlayerListChanged += PopulateList;
|
|
|
|
}
|
|
|
|
private void FilterLineEditOnOnTextEntered(LineEdit.LineEditEventArgs obj)
|
|
{
|
|
PopulateList();
|
|
}
|
|
|
|
private void PlayerItemListOnOnItemSelected(ItemList.ItemListSelectedEventArgs obj)
|
|
{
|
|
var selectedPlayer = (PlayerInfo) obj.ItemList[obj.ItemIndex].Metadata!;
|
|
OnSelectionChanged?.Invoke(selectedPlayer);
|
|
}
|
|
|
|
private void PlayerItemListOnOnItemDeselected(ItemList.ItemListDeselectedEventArgs obj)
|
|
{
|
|
OnSelectionChanged?.Invoke(null);
|
|
}
|
|
|
|
public void RefreshDecorators()
|
|
{
|
|
foreach (var item in PlayerItemList)
|
|
{
|
|
DecoratePlayer?.Invoke((PlayerInfo) item.Metadata!, item);
|
|
}
|
|
}
|
|
|
|
public void Sort()
|
|
{
|
|
if(Comparison != null)
|
|
PlayerItemList.Sort((a, b) => Comparison((PlayerInfo) a.Metadata!, (PlayerInfo) b.Metadata!));
|
|
}
|
|
|
|
private void PopulateList(IReadOnlyList<PlayerInfo> _ = null!)
|
|
{
|
|
PlayerItemList.Clear();
|
|
|
|
foreach (var info in _adminSystem.PlayerList)
|
|
{
|
|
var displayName = $"{info.CharacterName} ({info.Username})";
|
|
if (info.IdentityName != info.CharacterName)
|
|
displayName += $" [{info.IdentityName}]";
|
|
if (!string.IsNullOrEmpty(FilterLineEdit.Text) &&
|
|
!displayName.ToLowerInvariant().Contains(FilterLineEdit.Text.Trim().ToLowerInvariant()))
|
|
{
|
|
continue;
|
|
}
|
|
|
|
var item = new ItemList.Item(PlayerItemList)
|
|
{
|
|
Metadata = info,
|
|
Text = displayName
|
|
};
|
|
DecoratePlayer?.Invoke(info, item);
|
|
PlayerItemList.Add(item);
|
|
}
|
|
|
|
Sort();
|
|
}
|
|
}
|
|
}
|