From 12b75beeab27f8905d6d3f07b7bbda2cfd859b5e Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Sun, 13 Apr 2025 09:22:36 -0400 Subject: [PATCH] Departmental Economy (#36445) * Cargo Accounts, Request Consoles, and lock boxes * Funding Allocation Computer * final changes * test fix * remove dumb code * ScarKy0 review * first cour * second cour * Update machines.yml * review --------- Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Co-authored-by: Milon --- .../CargoOrderConsoleBoundUserInterface.cs | 33 ++- ...dingAllocationConsoleBoundUserInterface.cs | 35 +++ Content.Client/Cargo/UI/CargoConsoleMenu.xaml | 117 ++++---- .../Cargo/UI/CargoConsoleMenu.xaml.cs | 139 +++++++-- Content.Client/Cargo/UI/CargoOrderRow.xaml | 8 +- Content.Client/Cargo/UI/CargoProductRow.xaml | 6 +- .../Cargo/UI/FundingAllocationMenu.xaml | 29 ++ .../Cargo/UI/FundingAllocationMenu.xaml.cs | 169 +++++++++++ .../Cargo/Components/CargoPalletComponent.cs | 2 - .../Components/CargoPalletConsoleComponent.cs | 6 +- .../Components/StationBankAccountComponent.cs | 19 -- .../StationCargoOrderDatabaseComponent.cs | 12 +- .../Cargo/Systems/CargoSystem.Bounty.cs | 3 +- .../Cargo/Systems/CargoSystem.Funds.cs | 144 +++++++++ .../Cargo/Systems/CargoSystem.Orders.cs | 159 +++++----- .../Cargo/Systems/CargoSystem.Shuttle.cs | 107 ++++--- .../Cargo/Systems/CargoSystem.Telepad.cs | 36 ++- Content.Server/Cargo/Systems/CargoSystem.cs | 41 ++- Content.Server/Delivery/DeliverySystem.cs | 7 +- Content.Server/Stack/StackSystem.cs | 2 +- .../Station/Systems/StationSystem.cs | 4 +- .../Components/CargoGiftsRuleComponent.cs | 6 + .../StationEvents/Events/CargoGiftsRule.cs | 3 +- .../Cargo/BUI/CargoConsoleInterfaceState.cs | 8 +- .../Cargo/Components/BankClientComponent.cs | 25 -- .../Components/CargoOrderConsoleComponent.cs | 100 ++++++- .../FundingAllocationConsoleComponent.cs | 49 ++++ .../Cargo/Components/OverrideSellComponent.cs | 17 ++ .../Components/StationBankAccountComponent.cs | 77 +++++ .../Cargo/Prototypes/CargoAccountPrototype.cs | 39 +++ Content.Shared/Cargo/SharedCargoSystem.cs | 49 +++- .../Locale/en-US/cargo/cargo-accounts.ftl | 17 ++ .../en-US/cargo/cargo-console-component.ftl | 49 +++- .../Catalog/Cargo/cargo_lockbox.yml | 49 ++++ .../Catalog/Fills/Lockers/heads.yml | 6 + .../Prototypes/Catalog/cargo_accounts.yml | 42 +++ .../Entities/Mobs/Player/admin_ghost.yml | 1 - .../Devices/Circuitboards/computer.yml | 78 +++++ .../Entities/Objects/Misc/paper.yml | 2 +- .../Prototypes/Entities/Stations/base.yml | 7 + .../Machines/Computers/computers.yml | 206 ++++++++++++- .../Structures/Storage/Crates/crates.yml | 188 ++++++++++++ .../Prototypes/SoundCollections/machines.yml | 14 + .../Machines/computers.rsi/allocate.png | Bin 0 -> 971 bytes .../Machines/computers.rsi/meta.json | 276 +++++++++++++++++- .../Machines/computers.rsi/request-eng.png | Bin 0 -> 1502 bytes .../Machines/computers.rsi/request-med.png | Bin 0 -> 1448 bytes .../Machines/computers.rsi/request-sci.png | Bin 0 -> 1371 bytes .../Machines/computers.rsi/request-sec.png | Bin 0 -> 1417 bytes .../Machines/computers.rsi/request-srv.png | Bin 0 -> 1511 bytes .../Machines/computers.rsi/transfer.png | Bin 0 -> 1776 bytes .../Storage/Crates/lockbox.rsi/base.png | Bin 0 -> 361 bytes .../Storage/Crates/lockbox.rsi/closed.png | Bin 0 -> 187 bytes .../Storage/Crates/lockbox.rsi/icon.png | Bin 0 -> 370 bytes .../Storage/Crates/lockbox.rsi/locked.png | Bin 0 -> 144 bytes .../Storage/Crates/lockbox.rsi/meta.json | 51 ++++ .../Storage/Crates/lockbox.rsi/open.png | Bin 0 -> 240 bytes .../Crates/lockbox.rsi/overlay-closed.png | Bin 0 -> 155 bytes .../Storage/Crates/lockbox.rsi/overlay.png | Bin 0 -> 144 bytes .../Storage/Crates/lockbox.rsi/sparking.png | Bin 0 -> 221 bytes .../Storage/Crates/lockbox.rsi/unlocked.png | Bin 0 -> 139 bytes .../Storage/Crates/lockbox.rsi/welded.png | Bin 0 -> 274 bytes 62 files changed, 2106 insertions(+), 331 deletions(-) create mode 100644 Content.Client/Cargo/BUI/FundingAllocationConsoleBoundUserInterface.cs create mode 100644 Content.Client/Cargo/UI/FundingAllocationMenu.xaml create mode 100644 Content.Client/Cargo/UI/FundingAllocationMenu.xaml.cs delete mode 100644 Content.Server/Cargo/Components/StationBankAccountComponent.cs create mode 100644 Content.Server/Cargo/Systems/CargoSystem.Funds.cs delete mode 100644 Content.Shared/Cargo/Components/BankClientComponent.cs create mode 100644 Content.Shared/Cargo/Components/FundingAllocationConsoleComponent.cs create mode 100644 Content.Shared/Cargo/Components/OverrideSellComponent.cs create mode 100644 Content.Shared/Cargo/Components/StationBankAccountComponent.cs create mode 100644 Content.Shared/Cargo/Prototypes/CargoAccountPrototype.cs create mode 100644 Resources/Locale/en-US/cargo/cargo-accounts.ftl create mode 100644 Resources/Prototypes/Catalog/Cargo/cargo_lockbox.yml create mode 100644 Resources/Prototypes/Catalog/cargo_accounts.yml create mode 100644 Resources/Prototypes/SoundCollections/machines.yml create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/allocate.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-eng.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-med.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-sci.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-sec.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/request-srv.png create mode 100644 Resources/Textures/Structures/Machines/computers.rsi/transfer.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/base.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/closed.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/icon.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/locked.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/meta.json create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/open.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/overlay-closed.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/overlay.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/sparking.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/unlocked.png create mode 100644 Resources/Textures/Structures/Storage/Crates/lockbox.rsi/welded.png diff --git a/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs b/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs index 0be3ebd97f..52846cefdb 100644 --- a/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs +++ b/Content.Client/Cargo/BUI/CargoOrderConsoleBoundUserInterface.cs @@ -1,6 +1,7 @@ using Content.Shared.Cargo; using Content.Client.Cargo.UI; using Content.Shared.Cargo.BUI; +using Content.Shared.Cargo.Components; using Content.Shared.Cargo.Events; using Content.Shared.Cargo.Prototypes; using Content.Shared.IdentityManagement; @@ -14,6 +15,8 @@ namespace Content.Client.Cargo.BUI { public sealed class CargoOrderConsoleBoundUserInterface : BoundUserInterface { + private readonly SharedCargoSystem _cargoSystem; + [ViewVariables] private CargoConsoleMenu? _menu; @@ -43,6 +46,7 @@ namespace Content.Client.Cargo.BUI public CargoOrderConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) { + _cargoSystem = EntMan.System(); } protected override void Open() @@ -57,7 +61,7 @@ namespace Content.Client.Cargo.BUI string orderRequester; - if (EntMan.TryGetComponent(localPlayer, out var metadata)) + if (EntMan.EntityExists(localPlayer)) orderRequester = Identity.Name(localPlayer.Value, EntMan); else orderRequester = string.Empty; @@ -96,41 +100,54 @@ namespace Content.Client.Cargo.BUI } }; + _menu.OnAccountAction += (account, amount) => + { + SendMessage(new CargoConsoleWithdrawFundsMessage(account, amount)); + }; + + _menu.OnToggleUnboundedLimit += _ => + { + SendMessage(new CargoConsoleToggleLimitMessage()); + }; + _menu.OpenCentered(); } private void Populate(List orders) { - if (_menu == null) return; + if (_menu == null) + return; _menu.PopulateProducts(); _menu.PopulateCategories(); _menu.PopulateOrders(orders); + _menu.PopulateAccountActions(); } protected override void UpdateState(BoundUserInterfaceState state) { base.UpdateState(state); - if (state is not CargoConsoleInterfaceState cState) + if (state is not CargoConsoleInterfaceState cState || !EntMan.TryGetComponent(Owner, out var orderConsole)) return; + var station = EntMan.GetEntity(cState.Station); OrderCapacity = cState.Capacity; OrderCount = cState.Count; - BankBalance = cState.Balance; + BankBalance = _cargoSystem.GetBalanceFromAccount(station, orderConsole.Account); AccountName = cState.Name; + _menu?.UpdateStation(station); Populate(cState.Orders); - _menu?.UpdateCargoCapacity(OrderCount, OrderCapacity); - _menu?.UpdateBankData(AccountName, BankBalance); } protected override void Dispose(bool disposing) { base.Dispose(disposing); - if (!disposing) return; + if (!disposing) + return; _menu?.Dispose(); _orderMenu?.Dispose(); @@ -170,8 +187,6 @@ namespace Content.Client.Cargo.BUI return; SendMessage(new CargoConsoleApproveOrderMessage(row.Order.OrderId)); - // Most of the UI isn't predicted anyway so. - // _menu?.UpdateCargoCapacity(OrderCount + row.Order.Amount, OrderCapacity); } } } diff --git a/Content.Client/Cargo/BUI/FundingAllocationConsoleBoundUserInterface.cs b/Content.Client/Cargo/BUI/FundingAllocationConsoleBoundUserInterface.cs new file mode 100644 index 0000000000..eb65be40d3 --- /dev/null +++ b/Content.Client/Cargo/BUI/FundingAllocationConsoleBoundUserInterface.cs @@ -0,0 +1,35 @@ +using Content.Client.Cargo.UI; +using Content.Shared.Cargo.Components; +using JetBrains.Annotations; +using Robust.Client.UserInterface; + +namespace Content.Client.Cargo.BUI; + +[UsedImplicitly] +public sealed class FundingAllocationConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) +{ + [ViewVariables] + private FundingAllocationMenu? _menu; + + protected override void Open() + { + base.Open(); + + _menu = this.CreateWindow(); + + _menu.OnSavePressed += d => + { + SendMessage(new SetFundingAllocationBuiMessage(d)); + }; + } + + protected override void UpdateState(BoundUserInterfaceState message) + { + base.UpdateState(message); + + if (message is not FundingAllocationConsoleBuiState state) + return; + + _menu?.Update(state); + } +} diff --git a/Content.Client/Cargo/UI/CargoConsoleMenu.xaml b/Content.Client/Cargo/UI/CargoConsoleMenu.xaml index dd7a9f110c..72d8cf7daf 100644 --- a/Content.Client/Cargo/UI/CargoConsoleMenu.xaml +++ b/Content.Client/Cargo/UI/CargoConsoleMenu.xaml @@ -3,66 +3,83 @@ xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" SetSize="600 600" MinSize="600 600"> - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +