Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Commit

Permalink
missing files from bank
Browse files Browse the repository at this point in the history
  • Loading branch information
Peptide90 committed Feb 22, 2024
1 parent a22c0ae commit 30c1c5f
Show file tree
Hide file tree
Showing 35 changed files with 1,808 additions and 118 deletions.
58 changes: 58 additions & 0 deletions Content.Client/Bank/BUI/BankATMMenuBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
63 changes: 63 additions & 0 deletions Content.Client/Bank/BUI/StationBankATMMenuBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -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);
}
}
51 changes: 51 additions & 0 deletions Content.Client/Bank/BUI/WithdrawlBankATMMenuBoundUserInterface.cs
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(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);
}
}
26 changes: 26 additions & 0 deletions Content.Client/Bank/UI/BankATMMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<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 176"
MinSize="300 176">
<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 Orientation="Horizontal">
<Label Text="{Loc 'bank-atm-menu-deposit-label'}"
StyleClasses="LabelKeyText" />
<Label Name="DepositLabel"
Text="{Loc 'bank-atm-menu-no-deposit'}" />
</BoxContainer>
<Button Name="DepositButton"
Text="{Loc 'bank-atm-menu-deposit-button'}"/>
<TextureButton VerticalExpand="True" />
</BoxContainer>
</controls:FancyWindow>
56 changes: 56 additions & 0 deletions Content.Client/Bank/UI/BankATMMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
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 BankATMMenu : FancyWindow
{
public Action? WithdrawRequest;
public Action? DepositRequest;
public int Amount;
public BankATMMenu()
{
RobustXamlLoader.Load(this);
WithdrawButton.OnPressed += OnWithdrawPressed;
DepositButton.OnPressed += OnDepositPressed;
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 SetDeposit(int amount)
{
DepositButton.Disabled = amount <= 0;
DepositLabel.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 OnDepositPressed(BaseButton.ButtonEventArgs obj)
{
DepositRequest?.Invoke();
}

private void OnAmountChanged(LineEdit.LineEditEventArgs args)
{
if (int.TryParse(args.Text, out var amount))
{
Amount = amount;
}
}
}
45 changes: 45 additions & 0 deletions Content.Client/Bank/UI/StationBankATMMenu.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<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="480 230"
MinSize="360 230">
<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>
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'bank-atm-menu-amount-label'}"
StyleClasses="LabelKeyText"
MinSize="100 0" />
<LineEdit Name="WithdrawEdit" SetSize="120 30" HorizontalAlignment="Right"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'bank-atm-reason-label'}"
StyleClasses="LabelKeyText"
MinSize="100 0" />
<OptionButton Name="Reasons"
HorizontalExpand="True"/>
</BoxContainer>
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'bank-atm-description-label'}"
StyleClasses="LabelKeyText"
MinSize="100 0" />
<LineEdit Name="AmountDescription" MinSize="120 0" HorizontalExpand="True"/>
</BoxContainer>
<Button Name="WithdrawButton"
Text="{Loc 'bank-atm-menu-withdraw-button'}"/>
<TextureButton VerticalExpand="True" />
<BoxContainer Orientation="Horizontal">
<Label Text="{Loc 'bank-atm-menu-deposit-label'}"
StyleClasses="LabelKeyText" />
<Label Name="DepositLabel"
Text="{Loc 'bank-atm-menu-no-deposit'}" />
</BoxContainer>
<Button Name="DepositButton"
Text="{Loc 'bank-atm-menu-deposit-button'}"/>
<TextureButton VerticalExpand="True" />
</BoxContainer>
</controls:FancyWindow>
Loading

0 comments on commit 30c1c5f

Please sign in to comment.