-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
85 changed files
with
2,047 additions
and
54 deletions.
There are no files selected for viewing
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,7 @@ | ||
namespace Content.Client.ADT.Economy; | ||
|
||
public enum ATMVisualLayers : byte | ||
{ | ||
Base, | ||
BaseUnshaded | ||
} |
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,42 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace Content.Client.ADT.Economy.UI; | ||
|
||
|
||
[UsedImplicitly] | ||
public sealed class ATMBui : BoundUserInterface | ||
{ | ||
private AtmWindow _window; | ||
|
||
public ATMBui(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
_window = new AtmWindow(); | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
_window.OnClose += Close; | ||
_window.OnWithdrawAttempt += SendMessage; | ||
|
||
if (State != null) | ||
{ | ||
UpdateState(State); | ||
} | ||
|
||
_window.OpenCentered(); | ||
|
||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
_window?.UpdateState(state); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
_window?.Close(); | ||
base.Dispose(disposing); | ||
} | ||
} |
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,20 @@ | ||
<DefaultWindow xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
Title="ATM" | ||
SetSize="400 220" | ||
Resizable="False"> | ||
|
||
<BoxContainer Name="AuthorizationPage" HorizontalExpand="True" VerticalExpand="True"> | ||
<BoxContainer HorizontalAlignment="Center" HorizontalExpand="True" VerticalAlignment="Center" Orientation="Vertical" MinSize="325 160"> | ||
<Label Text="Nanotrasen ATM"/> | ||
<Label Name="BalanceLabel" Visible="False"/> | ||
<controls:HighDivider Name="Divider" Visible="False"/> | ||
<Label Name="StatusLabel"/> | ||
<SliderIntInput Name="WithdrawSlider"/> | ||
<BoxContainer HorizontalExpand="True" VerticalExpand="True" VerticalAlignment="Bottom" Orientation="Horizontal"> | ||
<LineEdit Name="PinLineEdit" HorizontalExpand="True" PlaceHolder="{Loc 'atm-ui-enter-pin'}"/> | ||
<Button Name="WithdrawButton" Text="{Loc 'store-ui-default-withdraw-text'}"/> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</BoxContainer> | ||
</DefaultWindow> |
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,92 @@ | ||
using System.Text.RegularExpressions; | ||
using Content.Shared.ADT.Economy; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.CustomControls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.ADT.Economy.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class AtmWindow : DefaultWindow | ||
{ | ||
public Action<ATMRequestWithdrawMessage>? OnWithdrawAttempt; | ||
|
||
private readonly string _pinPattern = "[^0-9]"; | ||
public AtmWindow() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
IoCManager.InjectDependencies(this); | ||
|
||
|
||
WithdrawButton.OnButtonDown += args => | ||
{ | ||
if(PinLineEdit.Text.Length != 4) return; | ||
OnWithdrawAttempt?.Invoke(new ATMRequestWithdrawMessage(WithdrawSlider.Value, int.Parse((string) PinLineEdit.Text))); | ||
}; | ||
|
||
PinLineEdit.OnTextChanged += _ => | ||
{ | ||
ValidatePin(); | ||
}; | ||
} | ||
|
||
public void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
if(state is not ATMBuiState cast) return; | ||
|
||
if (!cast.HasCard) | ||
{ | ||
StatusLabel.Text = cast.InfoMessage; | ||
BalanceLabel.Visible = false; | ||
Divider.Visible = false; | ||
StatusLabel.Visible = true; | ||
WithdrawSlider.Visible = false; | ||
PinLineEdit.Visible = false; | ||
WithdrawButton.Visible = false; | ||
return; | ||
} | ||
|
||
StatusLabel.Text = cast.InfoMessage; | ||
|
||
BalanceLabel.Text = Loc.GetString("atm-ui-balance", ("balance", cast.AccountBalance)); | ||
BalanceLabel.Visible = true; | ||
|
||
if (cast.AccountBalance > 0) | ||
{ | ||
Divider.Visible = true; | ||
StatusLabel.Visible = true; | ||
WithdrawSlider.Visible = true; | ||
PinLineEdit.Visible = true; | ||
WithdrawButton.Visible = true; | ||
|
||
WithdrawSlider.MaxValue = cast.AccountBalance; | ||
WithdrawSlider.Value = Math.Min((int) WithdrawSlider.Value, cast.AccountBalance); | ||
return; | ||
} | ||
|
||
Divider.Visible = false; | ||
StatusLabel.Visible = false; | ||
WithdrawSlider.Visible = false; | ||
PinLineEdit.Visible = false; | ||
WithdrawButton.Visible = false; | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
WithdrawButton.Disabled = PinLineEdit.Text.Length != 4; | ||
} | ||
|
||
private void ValidatePin() | ||
{ | ||
var pinText = Regex.Replace(PinLineEdit.Text, _pinPattern, string.Empty); | ||
|
||
if (pinText.Length > 4) | ||
{ | ||
pinText = pinText[..4]; | ||
} | ||
|
||
PinLineEdit.Text = pinText; | ||
} | ||
} |
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,33 @@ | ||
using Content.Client.UserInterface.Fragments; | ||
using Content.Shared.ADT.Economy; | ||
using Content.Shared.CartridgeLoader; | ||
using JetBrains.Annotations; | ||
using Robust.Client.UserInterface; | ||
|
||
namespace Content.Client.ADT.Economy.UI; | ||
|
||
[UsedImplicitly] | ||
public sealed partial class BankUi : UIFragment | ||
{ | ||
private BankUiFragment? _fragment; | ||
|
||
public override Control GetUIFragmentRoot() | ||
{ | ||
return _fragment!; | ||
} | ||
|
||
public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner) | ||
{ | ||
_fragment = new BankUiFragment(); | ||
|
||
_fragment.OnLinkAttempt += message => userInterface.SendMessage(new CartridgeUiMessage(message)); | ||
} | ||
|
||
public override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
if (state is not BankCartridgeUiState bankState) | ||
return; | ||
|
||
_fragment?.UpdateState(bankState); | ||
} | ||
} |
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,30 @@ | ||
<ui1:BankUiFragment xmlns="https://spacestation14.io" | ||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls" | ||
xmlns:ui1="clr-namespace:Content.Client.ADT.Economy.UI"> | ||
|
||
<PanelContainer StyleClasses="BackgroundDark"></PanelContainer> | ||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" VerticalExpand="True" Margin="8"> | ||
<BoxContainer Name="LinkedAccount" Orientation="Vertical" Visible="False"> | ||
<RichTextLabel Name="LinkedAccountNumberLabel" /> | ||
<RichTextLabel Name="LinkedAccountNameLabel" /> | ||
<RichTextLabel Name="LinkedAccountBalanceLabel" /> | ||
</BoxContainer> | ||
<RichTextLabel Name="NoLinkedAccountLabel" Visible="False" /> | ||
<controls:StripeBack> | ||
<Button Name="AccountLinkButton" HorizontalExpand="True" HorizontalAlignment="Center" | ||
Text="{Loc 'bank-program-ui-link-account'}" /> | ||
<BoxContainer Name="AccountLink" Orientation="Vertical" Visible="False" HorizontalExpand="True" | ||
Margin="0 5 0 5"> | ||
<RichTextLabel Name="AccountLinkMessageLabel" /> | ||
<GridContainer HorizontalExpand="True" Columns="2" Rows="2"> | ||
<LineEdit Name="AccountLineEdit" HorizontalExpand="True" | ||
PlaceHolder="{Loc 'bank-program-ui-account-number'}" /> | ||
<Button Name="LinkConfirmButton" Text="{Loc 'bank-program-ui-link-confirm'}" /> | ||
<LineEdit Name="PinLineEdit" HorizontalExpand="True" PlaceHolder="PIN" /> | ||
<Button Name="LinkCancelButton" Text="{Loc 'bank-program-ui-link-cancel'}" /> | ||
</GridContainer> | ||
</BoxContainer> | ||
</controls:StripeBack> | ||
<RichTextLabel Name="AccountLinkResultLabel" Visible="False" /> | ||
</BoxContainer> | ||
</ui1:BankUiFragment> |
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,108 @@ | ||
using System.Text.RegularExpressions; | ||
using Content.Client.Message; | ||
using Content.Shared.ADT.Economy; | ||
using Robust.Client.AutoGenerated; | ||
using Robust.Client.UserInterface.Controls; | ||
using Robust.Client.UserInterface.XAML; | ||
using Robust.Shared.Timing; | ||
|
||
namespace Content.Client.ADT.Economy.UI; | ||
|
||
[GenerateTypedNameReferences] | ||
public sealed partial class BankUiFragment : BoxContainer | ||
{ | ||
public Action<BankAccountLinkMessage>? OnLinkAttempt; | ||
|
||
private bool _accountLinkActive; | ||
|
||
private readonly string _lineEditPattern = "[^0-9]"; | ||
|
||
public BankUiFragment() | ||
{ | ||
RobustXamlLoader.Load(this); | ||
|
||
AccountLinkButton.OnPressed += _ => | ||
{ | ||
_accountLinkActive = true; | ||
AccountLinkResultLabel.Visible = false; | ||
UpdateAccountLinkUi(); | ||
}; | ||
|
||
LinkCancelButton.OnPressed += _ => | ||
{ | ||
_accountLinkActive = false; | ||
UpdateAccountLinkUi(); | ||
}; | ||
|
||
PinLineEdit.OnTextChanged += _ => | ||
{ | ||
ValidateLineEdit(PinLineEdit, 4); | ||
}; | ||
|
||
AccountLineEdit.OnTextChanged += _ => | ||
{ | ||
ValidateLineEdit(AccountLineEdit, 6); | ||
}; | ||
|
||
LinkConfirmButton.OnPressed += _ => | ||
{ | ||
if (PinLineEdit.Text.Length != 4 || AccountLineEdit.Text.Length != 6) | ||
return; | ||
|
||
var accountId = int.Parse((string) AccountLineEdit.Text); | ||
var pin = int.Parse((string) PinLineEdit.Text); | ||
AccountLinkResultLabel.Visible = true; | ||
_accountLinkActive = false; | ||
OnLinkAttempt?.Invoke(new BankAccountLinkMessage(accountId, pin)); | ||
}; | ||
} | ||
|
||
public void UpdateState(BankCartridgeUiState state) | ||
{ | ||
var accountLinked = state.AccountId != null; | ||
|
||
RichTextLabelExt.SetMarkup(AccountLinkMessageLabel, state.AccountLinkMessage); | ||
RichTextLabelExt.SetMarkup(AccountLinkResultLabel, state.AccountLinkResult); | ||
|
||
LinkedAccount.Visible = accountLinked; | ||
NoLinkedAccountLabel.Visible = !accountLinked; | ||
|
||
if (accountLinked) | ||
{ | ||
RichTextLabelExt.SetMarkup(LinkedAccountNumberLabel, Loc.GetString("bank-program-ui-account-number-text", | ||
("account", state.AccountId!.Value))); | ||
RichTextLabelExt.SetMarkup(LinkedAccountNameLabel, Loc.GetString("bank-program-ui-account-owner-text", | ||
("owner", state.OwnerName))); | ||
RichTextLabelExt.SetMarkup(LinkedAccountBalanceLabel, Loc.GetString("atm-ui-balance", ("balance", state.Balance))); | ||
UpdateAccountLinkUi(); | ||
return; | ||
} | ||
|
||
RichTextLabelExt.SetMarkup(NoLinkedAccountLabel, Loc.GetString("bank-program-ui-no-account")); | ||
UpdateAccountLinkUi(); | ||
} | ||
|
||
private void UpdateAccountLinkUi() | ||
{ | ||
AccountLinkButton.Visible = !_accountLinkActive; | ||
AccountLink.Visible = _accountLinkActive; | ||
} | ||
|
||
protected override void FrameUpdate(FrameEventArgs args) | ||
{ | ||
base.FrameUpdate(args); | ||
LinkConfirmButton.Disabled = PinLineEdit.Text.Length != 4 || AccountLineEdit.Text.Length != 6; | ||
} | ||
|
||
private void ValidateLineEdit(LineEdit lineEdit, int length) | ||
{ | ||
var text = Regex.Replace(lineEdit.Text, _lineEditPattern, string.Empty); | ||
|
||
if (text.Length > length) | ||
{ | ||
text = text[..length]; | ||
} | ||
|
||
lineEdit.Text = text; | ||
} | ||
} |
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,40 @@ | ||
using JetBrains.Annotations; | ||
|
||
namespace Content.Client.ADT.Economy.UI; | ||
|
||
[UsedImplicitly] | ||
public sealed class EftposBui : BoundUserInterface | ||
{ | ||
private readonly EftposWindow _window; | ||
|
||
public EftposBui(EntityUid owner, Enum uiKey) : base(owner, uiKey) | ||
{ | ||
_window = new EftposWindow(); | ||
} | ||
|
||
protected override void Open() | ||
{ | ||
base.Open(); | ||
_window.OnClose += Close; | ||
_window.OnCardButtonPressed += SendMessage; | ||
|
||
if (State != null) | ||
{ | ||
UpdateState(State); | ||
} | ||
|
||
_window.OpenCentered(); | ||
} | ||
|
||
protected override void UpdateState(BoundUserInterfaceState state) | ||
{ | ||
base.UpdateState(state); | ||
_window.UpdateState(state); | ||
} | ||
|
||
protected override void Dispose(bool disposing) | ||
{ | ||
_window.Close(); | ||
base.Dispose(disposing); | ||
} | ||
} |
Oops, something went wrong.