From 722f34b7fe4c265cf6ee89187f1e7c8c01569a83 Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Sun, 26 May 2024 05:42:56 +0100 Subject: [PATCH 1/5] small cleanup --- .../DeltaV/Shipyard/UI/ShipyardBoundUserInterface.cs | 11 ++++++++--- .../DeltaV/Shipyard/SharedShipyardConsoleSystem.cs | 4 ++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/Content.Client/DeltaV/Shipyard/UI/ShipyardBoundUserInterface.cs b/Content.Client/DeltaV/Shipyard/UI/ShipyardBoundUserInterface.cs index 4a3def491e3..c093de9373b 100644 --- a/Content.Client/DeltaV/Shipyard/UI/ShipyardBoundUserInterface.cs +++ b/Content.Client/DeltaV/Shipyard/UI/ShipyardBoundUserInterface.cs @@ -25,10 +25,14 @@ protected override void Open() { base.Open(); - _menu = new ShipyardConsoleMenu(Owner, _proto, EntMan, _player, _access); + if (_menu == null) + { + _menu = new ShipyardConsoleMenu(Owner, _proto, EntMan, _player, _access); + _menu.OnClose += Close; + _menu.OnPurchased += Purchase; + } + _menu.OpenCentered(); - _menu.OnClose += Close; - _menu.OnPurchased += Purchase; } protected override void UpdateState(BoundUserInterfaceState state) @@ -45,6 +49,7 @@ protected override void Dispose(bool disposing) { base.Dispose(disposing); + _menu?.Close(); if (disposing) _menu?.Dispose(); } diff --git a/Content.Shared/DeltaV/Shipyard/SharedShipyardConsoleSystem.cs b/Content.Shared/DeltaV/Shipyard/SharedShipyardConsoleSystem.cs index ea35bb92eec..88feb137050 100644 --- a/Content.Shared/DeltaV/Shipyard/SharedShipyardConsoleSystem.cs +++ b/Content.Shared/DeltaV/Shipyard/SharedShipyardConsoleSystem.cs @@ -12,8 +12,8 @@ namespace Content.Shared.Shipyard; /// public abstract class SharedShipyardConsoleSystem : EntitySystem { - [Dependency] protected readonly AccessReaderSystem _access = default!; - [Dependency] protected readonly IPrototypeManager _proto = default!; + [Dependency] private readonly AccessReaderSystem _access = default!; + [Dependency] private readonly IPrototypeManager _proto = default!; [Dependency] protected readonly SharedAudioSystem Audio = default!; [Dependency] protected readonly SharedPopupSystem Popup = default!; From 279d0367bd4ab552ea3e229033180c29ec88011e Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Sun, 26 May 2024 05:43:12 +0100 Subject: [PATCH 2/5] use BankClient for balance updating --- .../DeltaV/Shipyard/ShipyardConsoleSystem.cs | 12 +++++++++--- .../Entities/Structures/Machines/computers.yml | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs b/Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs index 15e473f740a..3f19050ae6c 100644 --- a/Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs +++ b/Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs @@ -2,6 +2,7 @@ using Content.Server.Cargo.Systems; using Content.Server.Radio.EntitySystems; using Content.Server.Station.Systems; +using Content.Shared.Cargo.Components; using Content.Shared.Shipyard; using Content.Shared.Shipyard.Prototypes; using Robust.Server.GameObjects; @@ -24,6 +25,7 @@ public override void Initialize() { base.Initialize(); + SubscribeLocalEvent(OnBalanceUpdated); Subs.BuiEvents(ShipyardConsoleUiKey.Key, subs => { subs.Event(OnOpened); @@ -58,10 +60,14 @@ protected override void TryPurchase(Entity ent, Entity var message = Loc.GetString("shipyard-console-docking", ("vessel", vessel.Name.ToString())); _radio.SendRadioMessage(ent, message, ent.Comp.Channel, ent); Audio.PlayPvs(ent.Comp.ConfirmSound, ent); + } + + private void OnBalanceUpdated(Entity ent, ref BankBalanceUpdatedEvent args) + { + if (!_ui.IsUiOpen(ent.Owner, ShipyardUiConsole.Key)) + return; - // TODO: make the ui updating more robust, make pr upstream to have UpdateBankAccount support things that arent ordering consoles - // TODO: then have shipyard have that component and update the ui when it changes balance - UpdateUI(ent, bank.Comp.Balance); + UpdateUI(ent, args.Balance); } private void OnOpened(Entity ent, ref BoundUIOpenedEvent args) diff --git a/Resources/Prototypes/DeltaV/Entities/Structures/Machines/computers.yml b/Resources/Prototypes/DeltaV/Entities/Structures/Machines/computers.yml index 7d23abb0137..13826430d9b 100644 --- a/Resources/Prototypes/DeltaV/Entities/Structures/Machines/computers.yml +++ b/Resources/Prototypes/DeltaV/Entities/Structures/Machines/computers.yml @@ -5,6 +5,7 @@ description: Used to purchase and sell shuttles components: - type: ShipyardConsole + - type: BankClient - type: AccessReader access: [[ Captain ]] - type: ActivatableUI From ebca45e3d7c0e50aa5adc2b074ad6ef382bfc83a Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Fri, 20 Sep 2024 13:46:08 +0100 Subject: [PATCH 3/5] pro --- Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs b/Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs index 00916575d2b..f52a5e16f81 100644 --- a/Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs +++ b/Content.Server/DeltaV/Shipyard/ShipyardConsoleSystem.cs @@ -70,7 +70,7 @@ protected override void TryPurchase(Entity ent, Entity private void OnBalanceUpdated(Entity ent, ref BankBalanceUpdatedEvent args) { - if (!_ui.IsUiOpen(ent.Owner, ShipyardUiConsole.Key)) + if (!_ui.IsUiOpen(ent.Owner, ShipyardConsoleUiKey.Key)) return; UpdateUI(ent, args.Balance); From 8e9dc43bd63c9f4a57e8328800a13158335bf926 Mon Sep 17 00:00:00 2001 From: Milon Date: Mon, 4 Nov 2024 22:10:33 +0100 Subject: [PATCH 4/5] fixes fixes fixes --- .../Shipyard/UI/ShipyardBoundUserInterface.cs | 14 ++++++++++---- .../Shipyard/UI/ShipyardConsoleMenu.xaml | 1 - .../Shipyard/UI/ShipyardConsoleMenu.xaml.cs | 8 +++----- .../DeltaV/Shipyard/UI/VesselRow.xaml | 2 +- .../DeltaV/Shipyard/UI/VesselRow.xaml.cs | 2 +- .../DeltaV/Shipyard/ShipyardConsoleSystem.cs | 7 +++---- .../DeltaV/Shipyard/ShipyardSystem.cs | 1 - .../Shipyard/SharedShipyardConsoleSystem.cs | 3 ++- Content.Shared/DeltaV/Shipyard/ShipyardUi.cs | 18 ++++-------------- .../en-US/deltav/shipyard/shipyard-console.ftl | 1 + 10 files changed, 25 insertions(+), 32 deletions(-) diff --git a/Content.Client/DeltaV/Shipyard/UI/ShipyardBoundUserInterface.cs b/Content.Client/DeltaV/Shipyard/UI/ShipyardBoundUserInterface.cs index d44e1b1d31e..c68a7eb67d2 100644 --- a/Content.Client/DeltaV/Shipyard/UI/ShipyardBoundUserInterface.cs +++ b/Content.Client/DeltaV/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; @@ -52,9 +51,16 @@ protected override void Dispose(bool disposing) { base.Dispose(disposing); - _menu?.Close(); - 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/DeltaV/Shipyard/UI/ShipyardConsoleMenu.xaml b/Content.Client/DeltaV/Shipyard/UI/ShipyardConsoleMenu.xaml index 9eccd45b698..d5c7223f820 100644 --- a/Content.Client/DeltaV/Shipyard/UI/ShipyardConsoleMenu.xaml +++ b/Content.Client/DeltaV/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 @@ private void PopulateProducts() 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/DeltaV/Shipyard/UI/VesselRow.xaml b/Content.Client/DeltaV/Shipyard/UI/VesselRow.xaml index eac2d3a1bde..e01f33e2939 100644 --- a/Content.Client/DeltaV/Shipyard/UI/VesselRow.xaml +++ b/Content.Client/DeltaV/Shipyard/UI/VesselRow.xaml @@ -3,7 +3,7 @@ HorizontalExpand="True"> -