diff --git a/Content.Client/Bank/BUI/BankATMMenuBoundUserInterface.cs b/Content.Client/Bank/BUI/BankATMMenuBoundUserInterface.cs new file mode 100644 index 00000000000000..455388fd4ef3d5 --- /dev/null +++ b/Content.Client/Bank/BUI/BankATMMenuBoundUserInterface.cs @@ -0,0 +1,58 @@ +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 BankATMMenuBoundUserInterface : BoundUserInterface +{ + private BankATMMenu? _menu; + + public BankATMMenuBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) {} + + protected override void Open() + { + base.Open(); + + _menu = new BankATMMenu(); + _menu.WithdrawRequest += OnWithdraw; + _menu.DepositRequest += OnDeposit; + _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)); + } + + private void OnDeposit() + { + SendMessage(new BankDepositMessage()); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (state is not BankATMMenuInterfaceState bankState) + return; + + _menu?.SetEnabled(bankState.Enabled); + _menu?.SetBalance(bankState.Balance); + _menu?.SetDeposit(bankState.Deposit); + } +} diff --git a/Content.Client/Bank/BUI/StationBankATMMenuBoundUserInterface.cs b/Content.Client/Bank/BUI/StationBankATMMenuBoundUserInterface.cs new file mode 100644 index 00000000000000..028e5db36e6ef2 --- /dev/null +++ b/Content.Client/Bank/BUI/StationBankATMMenuBoundUserInterface.cs @@ -0,0 +1,63 @@ +using Content.Client.Bank.UI; +using Content.Shared.Bank.BUI; +using Content.Shared.Bank.Events; +using Robust.Client.GameObjects; +using Content.Shared.Access.Systems; + +namespace Content.Client.Cargo.BUI; + +public sealed class StationBankATMMenuBoundUserInterface : BoundUserInterface +{ + private StationBankATMMenu? _menu; + + public StationBankATMMenuBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) {} + + protected override void Open() + { + base.Open(); + + _menu = new StationBankATMMenu(); + _menu.WithdrawRequest += OnWithdraw; + _menu.DepositRequest += OnDeposit; + _menu.OnClose += Close; + _menu.PopulateReasons(); + _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 StationBankWithdrawMessage(amount, _menu.Reason, _menu.Description)); + } + + private void OnDeposit() + { + if (_menu?.Amount is not int amount) + return; + + SendMessage(new StationBankDepositMessage(amount, _menu.Reason, _menu.Description)); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (state is not StationBankATMMenuInterfaceState bankState) + return; + + _menu?.SetEnabled(bankState.Enabled); + _menu?.SetBalance(bankState.Balance); + _menu?.SetDeposit(bankState.Deposit); + } +} diff --git a/Content.Client/Bank/BUI/WithdrawlBankATMMenuBoundUserInterface.cs b/Content.Client/Bank/BUI/WithdrawlBankATMMenuBoundUserInterface.cs new file mode 100644 index 00000000000000..e59c5325861a7f --- /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(EntityUid 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/BankATMMenu.xaml b/Content.Client/Bank/UI/BankATMMenu.xaml new file mode 100644 index 00000000000000..ff91ed98a8f4f2 --- /dev/null +++ b/Content.Client/Bank/UI/BankATMMenu.xaml @@ -0,0 +1,26 @@ + + + + + +