From 36d634bdff3fcf17eb65efe853ecb63ef2b061f3 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Wed, 1 Jan 2025 13:47:28 +0000 Subject: [PATCH] shipyard ui cleanup (#1257) * small cleanup * use BankClient for balance updating * pro * fixes fixes fixes * untroll engine --------- Signed-off-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: deltanedas <@deltanedas:kde.org> Co-authored-by: Tad "Taddy" Johnson <120885811+TadJohnson00@users.noreply.github.com> Co-authored-by: Milon Co-authored-by: Milon --- .../Shipyard/UI/ShipyardBoundUserInterface.cs | 23 ++++++++++++++----- .../_DV/Shipyard/UI/ShipyardConsoleMenu.xaml | 1 - .../Shipyard/UI/ShipyardConsoleMenu.xaml.cs | 8 +++---- Content.Client/_DV/Shipyard/UI/VesselRow.xaml | 2 +- .../_DV/Shipyard/UI/VesselRow.xaml.cs | 2 +- .../_DV/Shipyard/ShipyardConsoleSystem.cs | 19 +++++++++------ Content.Server/_DV/Shipyard/ShipyardSystem.cs | 1 - .../Shipyard/SharedShipyardConsoleSystem.cs | 7 +++--- Content.Shared/_DV/Shipyard/ShipyardUi.cs | 18 ++++----------- .../en-US/_DV/shipyard/shipyard-console.ftl | 1 + .../Structures/Machines/computers.yml | 1 + 11 files changed, 44 insertions(+), 39 deletions(-) diff --git a/Content.Client/_DV/Shipyard/UI/ShipyardBoundUserInterface.cs b/Content.Client/_DV/Shipyard/UI/ShipyardBoundUserInterface.cs index 702009cbb1..1b25b17e39 100644 --- a/Content.Client/_DV/Shipyard/UI/ShipyardBoundUserInterface.cs +++ b/Content.Client/_DV/Shipyard/UI/ShipyardBoundUserInterface.cs @@ -1,7 +1,6 @@ using Content.Shared.Access.Systems; using Content.Shared.Shipyard; using Content.Shared.Whitelist; -using Robust.Client.GameObjects; using Robust.Client.Player; using Robust.Shared.Prototypes; @@ -28,10 +27,14 @@ public sealed class ShipyardConsoleBoundUserInterface : BoundUserInterface { base.Open(); - _menu = new ShipyardConsoleMenu(Owner, _proto, EntMan, _player, _access, _whitelist); + if (_menu == null) + { + _menu = new ShipyardConsoleMenu(Owner, _proto, EntMan, _player, _access, _whitelist); + _menu.OnClose += Close; + _menu.OnPurchased += Purchase; + } + _menu.OpenCentered(); - _menu.OnClose += Close; - _menu.OnPurchased += Purchase; } protected override void UpdateState(BoundUserInterfaceState state) @@ -48,8 +51,16 @@ public sealed class ShipyardConsoleBoundUserInterface : BoundUserInterface { base.Dispose(disposing); - if (disposing) - _menu?.Dispose(); + if (!disposing) + return; + + if (_menu == null) + return; + + _menu.OnClose -= Close; + _menu.OnPurchased -= Purchase; + _menu.Close(); + _menu = null; } private void Purchase(string id) diff --git a/Content.Client/_DV/Shipyard/UI/ShipyardConsoleMenu.xaml b/Content.Client/_DV/Shipyard/UI/ShipyardConsoleMenu.xaml index 9eccd45b69..d5c7223f82 100644 --- a/Content.Client/_DV/Shipyard/UI/ShipyardConsoleMenu.xaml +++ b/Content.Client/_DV/Shipyard/UI/ShipyardConsoleMenu.xaml @@ -1,5 +1,4 @@ ? OnPurchased; - private readonly List _vessels = new(); - private readonly List _categories = new(); + private readonly List _vessels = []; + private readonly List _categories = []; public Entity Console; private string? _category; @@ -80,7 +78,7 @@ public sealed partial class ShipyardConsoleMenu : FancyWindow var search = SearchBar.Text.Trim().ToLowerInvariant(); foreach (var vessel in _vessels) { - if (search.Length != 0 && !vessel.Name.ToLowerInvariant().Contains(search)) + if (search.Length != 0 && !vessel.Name.Contains(search, StringComparison.InvariantCultureIgnoreCase)) continue; if (_category != null && !vessel.Categories.Contains(_category)) continue; diff --git a/Content.Client/_DV/Shipyard/UI/VesselRow.xaml b/Content.Client/_DV/Shipyard/UI/VesselRow.xaml index eac2d3a1bd..e01f33e293 100644 --- a/Content.Client/_DV/Shipyard/UI/VesselRow.xaml +++ b/Content.Client/_DV/Shipyard/UI/VesselRow.xaml @@ -3,7 +3,7 @@ HorizontalExpand="True"> -