From 33572c5cc8ddd225e0d2e77d9f4341dc568529ed Mon Sep 17 00:00:00 2001 From: Paul Date: Mon, 3 Jan 2022 04:14:10 +0100 Subject: [PATCH] submodule update & fixes the ahelpwindow further --- Content.Client/Administration/AdminSystem.cs | 8 -------- .../Administration/UI/BwoinkWindow.xaml.cs | 7 ++++--- .../UI/CustomControls/BwoinkPanel.xaml.cs | 7 ++++--- .../CustomControls/PlayerListControl.xaml.cs | 18 ++++++++++++++++-- RobustToolbox | 2 +- 5 files changed, 25 insertions(+), 17 deletions(-) diff --git a/Content.Client/Administration/AdminSystem.cs b/Content.Client/Administration/AdminSystem.cs index b9ae77f754..3b4b0a9240 100644 --- a/Content.Client/Administration/AdminSystem.cs +++ b/Content.Client/Administration/AdminSystem.cs @@ -24,14 +24,6 @@ namespace Content.Client.Administration } } - public List GetSortedPlayerList(Comparison comparison) - { - if (_playerList == null) return new List(); - var list = _playerList.Values.ToList(); - list.Sort(comparison); - return list; - } - public override void Initialize() { base.Initialize(); diff --git a/Content.Client/Administration/UI/BwoinkWindow.xaml.cs b/Content.Client/Administration/UI/BwoinkWindow.xaml.cs index ababb5e8c3..36a9847c8a 100644 --- a/Content.Client/Administration/UI/BwoinkWindow.xaml.cs +++ b/Content.Client/Administration/UI/BwoinkWindow.xaml.cs @@ -62,10 +62,10 @@ namespace Content.Client.Administration.UI return 0; if (!aChannelExists) - return -1; + return 1; if (!bChannelExists) - return 1; + return -1; return bch!.LastMessage.CompareTo(ach!.LastMessage); }; @@ -103,7 +103,8 @@ namespace Content.Client.Administration.UI var open = IsOpen; Open(); - ChannelSelector.Refresh(); + ChannelSelector.RefreshDecorators(); + ChannelSelector.Sort(); if (!open) { diff --git a/Content.Client/Administration/UI/CustomControls/BwoinkPanel.xaml.cs b/Content.Client/Administration/UI/CustomControls/BwoinkPanel.xaml.cs index 86540a3f27..3135389af4 100644 --- a/Content.Client/Administration/UI/CustomControls/BwoinkPanel.xaml.cs +++ b/Content.Client/Administration/UI/CustomControls/BwoinkPanel.xaml.cs @@ -16,7 +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 DateTime LastMessage { get; private set; } = DateTime.MinValue; public BwoinkPanel(BwoinkSystem bwoinkSys, NetUserId userId) { @@ -34,9 +34,10 @@ namespace Content.Client.Administration.UI.CustomControls private void Input_OnTextEntered(LineEdit.LineEditEventArgs args) { - if (!string.IsNullOrWhiteSpace(args.Text)) - _bwoinkSystem.Send(ChannelId, args.Text); + if (string.IsNullOrWhiteSpace(args.Text)) + return; + _bwoinkSystem.Send(ChannelId, args.Text); SenderLineEdit.Clear(); } diff --git a/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs b/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs index 48b0ca65a7..68863a386d 100644 --- a/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs +++ b/Content.Client/Administration/UI/CustomControls/PlayerListControl.xaml.cs @@ -53,13 +53,25 @@ namespace Content.Client.Administration.UI.CustomControls OnSelectionChanged?.Invoke(null); } - public void Refresh() => PopulateList(); + 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 _ = null!) { PlayerItemList.Clear(); - foreach (var info in Comparison == null ? _adminSystem.PlayerList : _adminSystem.GetSortedPlayerList(Comparison)) + foreach (var info in _adminSystem.PlayerList) { var displayName = $"{info.CharacterName} ({info.Username})"; if (!string.IsNullOrEmpty(FilterLineEdit.Text) && @@ -76,6 +88,8 @@ namespace Content.Client.Administration.UI.CustomControls DecoratePlayer?.Invoke(info, item); PlayerItemList.Add(item); } + + Sort(); } } } diff --git a/RobustToolbox b/RobustToolbox index 579b21716d..f49a29cfb3 160000 --- a/RobustToolbox +++ b/RobustToolbox @@ -1 +1 @@ -Subproject commit 579b21716da3b239893ebe9ef9608c1201177fd0 +Subproject commit f49a29cfb3db2cb8474b514507f7cc6b1fc66370