Administration: Ahelp tabs (#5965)

This commit is contained in:
E F R
2022-01-03 00:54:44 +00:00
committed by GitHub
parent a3f21e9603
commit df9aecb6a0
14 changed files with 291 additions and 57 deletions

View File

@@ -0,0 +1,7 @@
<BoxContainer
xmlns="https://spacestation14.io"
Orientation="Vertical"
HorizontalExpand="true">
<OutputPanel Name="TextOutput" VerticalExpand="true" />
<HistoryLineEdit Name="SenderLineEdit" />
</BoxContainer>

View File

@@ -0,0 +1,49 @@
#nullable enable
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Network;
using Robust.Shared.Utility;
namespace Content.Client.Administration.UI.CustomControls
{
[GenerateTypedNameReferences]
public partial class BwoinkPanel : BoxContainer
{
private readonly BwoinkSystem _bwoinkSystem;
public readonly NetUserId ChannelId;
public int Unread { get; private set; } = 0;
public BwoinkPanel(BwoinkSystem bwoinkSys, NetUserId userId)
{
RobustXamlLoader.Load(this);
_bwoinkSystem = bwoinkSys;
ChannelId = userId;
OnVisibilityChanged += c =>
{
if (c.Visible)
Unread = 0;
};
SenderLineEdit.OnTextEntered += Input_OnTextEntered;
}
private void Input_OnTextEntered(LineEdit.LineEditEventArgs args)
{
if (!string.IsNullOrWhiteSpace(args.Text))
_bwoinkSystem.Send(ChannelId, args.Text);
SenderLineEdit.Clear();
}
public void ReceiveLine(string text)
{
if (!Visible)
Unread++;
var formatted = new FormattedMessage(1);
formatted.AddMarkup(text);
TextOutput.AddMessage(formatted);
}
}
}

View File

@@ -6,6 +6,7 @@
HorizontalExpand="True"
PlaceHolder="{Loc Filter}"/>
<ItemList Name="PlayerItemList"
Access="Public"
SelectMode="Single"
VerticalExpand="True"
HorizontalExpand="True"

View File

@@ -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);
}
}
}