From 83500383dc9c07dfbf7667ed039c56dc7beb5f04 Mon Sep 17 00:00:00 2001 From: LankLTE Date: Wed, 12 Jul 2023 15:24:14 -0700 Subject: [PATCH] withdrawals --- .../WithdrawlBankATMMenuBoundUserInterface.cs | 51 ++++ Content.Client/Bank/UI/WithdrawBankATMMenu.cs | 44 ++++ .../Bank/UI/WithdrawBankATMMenu.xaml | 17 ++ Content.Shared/_NF/Bank/SharedBankSystem.cs | 3 +- Resources/Maps/Shuttles/skipper.yml | 246 ++++++++---------- .../_NF/Entities/Structures/machines.yml | 13 + 6 files changed, 237 insertions(+), 137 deletions(-) create mode 100644 Content.Client/Bank/BUI/WithdrawlBankATMMenuBoundUserInterface.cs create mode 100644 Content.Client/Bank/UI/WithdrawBankATMMenu.cs create mode 100644 Content.Client/Bank/UI/WithdrawBankATMMenu.xaml diff --git a/Content.Client/Bank/BUI/WithdrawlBankATMMenuBoundUserInterface.cs b/Content.Client/Bank/BUI/WithdrawlBankATMMenuBoundUserInterface.cs new file mode 100644 index 00000000000..35e91b934e7 --- /dev/null +++ b/Content.Client/Bank/BUI/WithdrawlBankATMMenuBoundUserInterface.cs @@ -0,0 +1,51 @@ +using Content.Client.Bank.UI; +using Content.Shared.Bank.BUI; +using Content.Shared.Bank.Events; +using Robust.Client.GameObjects; + +namespace Content.Client.Cargo.BUI; + +public sealed class WithdrawBankATMMenuBoundUserInterface : BoundUserInterface +{ + private WithdrawBankATMMenu? _menu; + + public WithdrawBankATMMenuBoundUserInterface(ClientUserInterfaceComponent owner, Enum uiKey) : base(owner, uiKey) {} + + protected override void Open() + { + base.Open(); + + _menu = new WithdrawBankATMMenu(); + _menu.WithdrawRequest += OnWithdraw; + _menu.OnClose += Close; + _menu.OpenCentered(); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (disposing) + { + _menu?.Dispose(); + } + } + + private void OnWithdraw() + { + if (_menu?.Amount is not int amount) + return; + + SendMessage(new BankWithdrawMessage(amount)); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (state is not BankATMMenuInterfaceState bankState) + return; + + _menu?.SetEnabled(bankState.Enabled); + _menu?.SetBalance(bankState.Balance); + } +} diff --git a/Content.Client/Bank/UI/WithdrawBankATMMenu.cs b/Content.Client/Bank/UI/WithdrawBankATMMenu.cs new file mode 100644 index 00000000000..1811e5d1992 --- /dev/null +++ b/Content.Client/Bank/UI/WithdrawBankATMMenu.cs @@ -0,0 +1,44 @@ +using Content.Client.UserInterface.Controls; +using Robust.Client.AutoGenerated; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.XAML; + +namespace Content.Client.Bank.UI; + +[GenerateTypedNameReferences] +public sealed partial class WithdrawBankATMMenu : FancyWindow +{ + public Action? WithdrawRequest; + public Action? DepositRequest; + public int Amount; + public WithdrawBankATMMenu() + { + RobustXamlLoader.Load(this); + WithdrawButton.OnPressed += OnWithdrawPressed; + Title = Loc.GetString("bank-atm-menu-title"); + WithdrawEdit.OnTextChanged += OnAmountChanged; + } + + public void SetBalance(int amount) + { + BalanceLabel.Text = Loc.GetString("cargo-console-menu-points-amount", ("amount", amount.ToString())); + } + + public void SetEnabled(bool enabled) + { + WithdrawButton.Disabled = !enabled; + } + + private void OnWithdrawPressed(BaseButton.ButtonEventArgs obj) + { + WithdrawRequest?.Invoke(); + } + + private void OnAmountChanged(LineEdit.LineEditEventArgs args) + { + if (int.TryParse(args.Text, out var amount)) + { + Amount = amount; + } + } +} diff --git a/Content.Client/Bank/UI/WithdrawBankATMMenu.xaml b/Content.Client/Bank/UI/WithdrawBankATMMenu.xaml new file mode 100644 index 00000000000..ffa0bf38c8d --- /dev/null +++ b/Content.Client/Bank/UI/WithdrawBankATMMenu.xaml @@ -0,0 +1,17 @@ + + + + + +