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"> - + - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +