From 6cc2e44461ec1c2f90b0cc8f1a2f00245c9233a6 Mon Sep 17 00:00:00 2001 From: Mnemotechnican <69920617+Mnemotechnician@users.noreply.github.com> Date: Fri, 19 Jan 2024 02:15:46 +0300 Subject: [PATCH] tweaks (#888) --- Content.Client/Lobby/LobbyState.cs | 2 +- .../Latejoin/NFLateJoinGui.xaml | 2 +- .../Latejoin/NFLateJoinGui.xaml.cs | 2 +- .../NewFrontierLateJoinJobButton.xaml | 0 .../NewFrontierLateJoinJobButton.xaml.cs | 2 +- .../Latejoin/VesselListControl.xaml | 0 .../Latejoin/VesselListControl.xaml.cs | 30 ++++++++++--------- 7 files changed, 20 insertions(+), 18 deletions(-) rename Content.Client/{NewFrontier => _NF}/Latejoin/NFLateJoinGui.xaml (93%) rename Content.Client/{NewFrontier => _NF}/Latejoin/NFLateJoinGui.xaml.cs (98%) rename Content.Client/{NewFrontier => _NF}/Latejoin/NewFrontierLateJoinJobButton.xaml (100%) rename Content.Client/{NewFrontier => _NF}/Latejoin/NewFrontierLateJoinJobButton.xaml.cs (97%) rename Content.Client/{NewFrontier => _NF}/Latejoin/VesselListControl.xaml (100%) rename Content.Client/{NewFrontier => _NF}/Latejoin/VesselListControl.xaml.cs (74%) diff --git a/Content.Client/Lobby/LobbyState.cs b/Content.Client/Lobby/LobbyState.cs index d70a32f8b57..58a7c4c9df1 100644 --- a/Content.Client/Lobby/LobbyState.cs +++ b/Content.Client/Lobby/LobbyState.cs @@ -1,4 +1,4 @@ -using Content.Client.NewFrontier.Latejoin; +using Content.Client._NF.Latejoin; using Content.Client.Chat.Managers; using Content.Client.GameTicking.Managers; using Content.Client.LateJoin; diff --git a/Content.Client/NewFrontier/Latejoin/NFLateJoinGui.xaml b/Content.Client/_NF/Latejoin/NFLateJoinGui.xaml similarity index 93% rename from Content.Client/NewFrontier/Latejoin/NFLateJoinGui.xaml rename to Content.Client/_NF/Latejoin/NFLateJoinGui.xaml index 062b1588ac1..23752a03117 100644 --- a/Content.Client/NewFrontier/Latejoin/NFLateJoinGui.xaml +++ b/Content.Client/_NF/Latejoin/NFLateJoinGui.xaml @@ -1,6 +1,6 @@ >? _lastJobState; public VesselListControl() { @@ -34,6 +36,12 @@ public VesselListControl() UpdateUi(_gameTicker.JobsAvailable); Comparison = DefaultComparison; + + FilterLineEdit.OnTextChanged += _ => + { + if (_lastJobState != null) + UpdateUi(_lastJobState); + }; } protected override void Dispose(bool disposing) @@ -44,7 +52,8 @@ protected override void Dispose(bool disposing) private int DefaultComparison(NetEntity x, NetEntity y) { - return (int)(_gameTicker.JobsAvailable[x].Values.Sum(a => a ?? 0) - _gameTicker.JobsAvailable[y].Values.Sum(b => b ?? 0)); + // Negated to enforce descending order + return -(int)(_gameTicker.JobsAvailable[x].Values.Sum(a => a ?? 0) - _gameTicker.JobsAvailable[y].Values.Sum(b => b ?? 0)); } public void Sort() @@ -55,27 +64,18 @@ public void Sort() private void UpdateUi(IReadOnlyDictionary> obj) { - var itemsToRemove = new List(); - foreach (var (key, item) in VesselItemList.Select(x => ((NetEntity)x.Metadata!, x))) - { - if (!_gameTicker.StationNames.ContainsKey(key)) - itemsToRemove.Add(item); - } - - foreach (var item in itemsToRemove) - { - VesselItemList.Remove(item); - } + VesselItemList.Clear(); foreach (var (key, name) in _gameTicker.StationNames) { if (VesselItemList.Any(x => ((NetEntity)x.Metadata!) == key)) continue; + var jobsAvailable = _gameTicker.JobsAvailable[key].Values.Sum(a => a ?? 0).ToString(); var item = new ItemList.Item(VesselItemList) { Metadata = key, - Text = name + Text = name + $" ({jobsAvailable})" }; if (!string.IsNullOrEmpty(FilterLineEdit.Text) && @@ -88,5 +88,7 @@ private void UpdateUi(IReadOnlyDictionary> } Sort(); + + _lastJobState = obj; } }