-
Notifications
You must be signed in to change notification settings - Fork 523
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #29 from LankLTE/withdrawlatm
Withdraw-only ATM
- Loading branch information
Showing
6 changed files
with
236 additions
and
138 deletions.
There are no files selected for viewing
51 changes: 51 additions & 0 deletions
51
Content.Client/Bank/BUI/WithdrawlBankATMMenuBoundUserInterface.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<controls:FancyWindow xmlns="https://spacestation14.io" | ||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
SetSize="300 120" | ||
MinSize="300 120"> | ||
<BoxContainer Margin="10 2 10 2" Orientation="Vertical"> | ||
<BoxContainer Orientation="Horizontal"> | ||
<Label Text="{Loc 'bank-atm-menu-balance-label'}" | ||
StyleClasses="LabelKeyText" /> | ||
<Label Name="BalanceLabel" | ||
Text="{Loc 'bank-atm-menu-no-bank'}" /> | ||
</BoxContainer> | ||
<LineEdit Name="WithdrawEdit" MinSize="80 0" /> | ||
<Button Name="WithdrawButton" | ||
Text="{Loc 'bank-atm-menu-withdraw-button'}"/> | ||
</BoxContainer> | ||
</controls:FancyWindow> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.