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