removes a bit of jank from bwoinkwindow
sorta fixes sorting
This commit is contained in:
@@ -24,6 +24,14 @@ namespace Content.Client.Administration
|
||||
}
|
||||
}
|
||||
|
||||
public List<PlayerInfo> GetSortedPlayerList(Comparison<PlayerInfo> comparison)
|
||||
{
|
||||
if (_playerList == null) return new List<PlayerInfo>();
|
||||
var list = _playerList.Values.ToList();
|
||||
list.Sort(comparison);
|
||||
return list;
|
||||
}
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
@@ -36,7 +36,7 @@ namespace Content.Client.Administration
|
||||
LogBwoink(message);
|
||||
// Actual line
|
||||
var window = EnsurePanel(message.ChannelId);
|
||||
window.ReceiveLine($"[color=gray]{message.SentAt.ToShortTimeString()}[/color] {message.Text}");
|
||||
window.ReceiveLine(message);
|
||||
// Play a sound if we didn't send it
|
||||
var localPlayer = _playerManager.LocalPlayer;
|
||||
if (localPlayer?.UserId != message.TrueSender)
|
||||
@@ -62,7 +62,7 @@ namespace Content.Client.Administration
|
||||
_adminWindow.BwoinkArea.AddChild(existingPanel);
|
||||
}
|
||||
|
||||
_adminWindow.Open();
|
||||
if(!_adminWindow.IsOpen) _adminWindow.Open();
|
||||
|
||||
return existingPanel;
|
||||
}
|
||||
|
||||
@@ -54,13 +54,20 @@ namespace Content.Client.Administration.UI
|
||||
li.Text = FormatTabTitle(li, pl);
|
||||
};
|
||||
|
||||
ChannelSelector.SortKey = (PlayerInfo pl) =>
|
||||
ChannelSelector.Comparison = (a, b) =>
|
||||
{
|
||||
if (_bwoinkSystem.TryGetChannel(pl.SessionId, out var ch))
|
||||
{
|
||||
return ch.Unread;
|
||||
}
|
||||
return 0;
|
||||
var aChannelExists = _bwoinkSystem.TryGetChannel(a.SessionId, out var ach);
|
||||
var bChannelExists = _bwoinkSystem.TryGetChannel(b.SessionId, out var bch);
|
||||
if (!aChannelExists && !bChannelExists)
|
||||
return 0;
|
||||
|
||||
if (!aChannelExists)
|
||||
return -1;
|
||||
|
||||
if (!bChannelExists)
|
||||
return 1;
|
||||
|
||||
return bch!.LastMessage.CompareTo(ach!.LastMessage);
|
||||
};
|
||||
|
||||
// ew
|
||||
@@ -152,7 +159,8 @@ namespace Content.Client.Administration.UI
|
||||
public void SwitchToChannel(NetUserId ch)
|
||||
{
|
||||
foreach (var bw in BwoinkArea.Children)
|
||||
bw.Visible = (bw as BwoinkPanel)?.ChannelId == ch;
|
||||
bw.Visible = false;
|
||||
_bwoinkSystem.EnsurePanel(ch).Visible = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
@@ -14,6 +16,7 @@ namespace Content.Client.Administration.UI.CustomControls
|
||||
public readonly NetUserId ChannelId;
|
||||
|
||||
public int Unread { get; private set; } = 0;
|
||||
public DateTime LastMessage { get; private set; }
|
||||
|
||||
public BwoinkPanel(BwoinkSystem bwoinkSys, NetUserId userId)
|
||||
{
|
||||
@@ -37,13 +40,15 @@ namespace Content.Client.Administration.UI.CustomControls
|
||||
SenderLineEdit.Clear();
|
||||
}
|
||||
|
||||
public void ReceiveLine(string text)
|
||||
public void ReceiveLine(SharedBwoinkSystem.BwoinkTextMessage message)
|
||||
{
|
||||
if (!Visible)
|
||||
Unread++;
|
||||
|
||||
var formatted = new FormattedMessage(1);
|
||||
formatted.AddMarkup(text);
|
||||
formatted.AddMarkup($"[color=gray]{message.SentAt.ToShortTimeString()}[/color] {message.Text}");
|
||||
TextOutput.AddMessage(formatted);
|
||||
LastMessage = message.SentAt;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Content.Client.Administration.UI.CustomControls
|
||||
public event Action<PlayerInfo?>? OnSelectionChanged;
|
||||
|
||||
public Action<PlayerInfo, ItemList.Item>? DecoratePlayer;
|
||||
public Func<PlayerInfo, int>? SortKey;
|
||||
public Comparison<PlayerInfo>? Comparison;
|
||||
|
||||
public PlayerListControl()
|
||||
{
|
||||
@@ -59,11 +59,7 @@ namespace Content.Client.Administration.UI.CustomControls
|
||||
{
|
||||
PlayerItemList.Clear();
|
||||
|
||||
IEnumerable<PlayerInfo> iter = _adminSystem.PlayerList;
|
||||
if (SortKey is not null)
|
||||
iter = _adminSystem.PlayerList.OrderByDescending(SortKey);
|
||||
|
||||
foreach (var info in iter)
|
||||
foreach (var info in Comparison == null ? _adminSystem.PlayerList : _adminSystem.GetSortedPlayerList(Comparison))
|
||||
{
|
||||
var displayName = $"{info.CharacterName} ({info.Username})";
|
||||
if (!string.IsNullOrEmpty(FilterLineEdit.Text) &&
|
||||
|
||||
Reference in New Issue
Block a user