Skip to content

Commit

Permalink
PDA Bank Data (#1432)
Browse files Browse the repository at this point in the history
* Bank data

* Data

* Update Content.Client/PDA/PdaMenu.xaml.cs

Co-authored-by: whatston3 <[email protected]>

---------

Co-authored-by: Checkraze <[email protected]>
Co-authored-by: whatston3 <[email protected]>
  • Loading branch information
3 people authored Jun 6, 2024
1 parent 2e94949 commit 6347758
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Content.Client/PDA/PdaMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@
<ContainerButton Name="StationAlertLevelInstructionsButton">
<RichTextLabel Name="StationAlertLevelInstructions" Access="Public"/>
</ContainerButton>
<ContainerButton Name="BalanceButton">
<RichTextLabel Name="BalanceLabel" Access="Public"/>
</ContainerButton>
</BoxContainer>
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True">
<BoxContainer Orientation="Vertical"
Expand Down
12 changes: 10 additions & 2 deletions Content.Client/PDA/PdaMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ public sealed partial class PdaMenu : PdaWindow
private string _stationName = Loc.GetString("comp-pda-ui-unknown");
private string _alertLevel = Loc.GetString("comp-pda-ui-unknown");
private string _instructions = Loc.GetString("comp-pda-ui-unknown");


private string _balance = Loc.GetString("comp-pda-ui-unknown"); // Frontier

private int _currentView;

Expand Down Expand Up @@ -115,6 +116,11 @@ public PdaMenu()
_clipboard.SetText(_alertLevel);
};

BalanceButton.OnPressed += _ => // Frontier
{
_clipboard.SetText(_balance);
};

StationTimeButton.OnPressed += _ =>
{
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
Expand Down Expand Up @@ -161,7 +167,9 @@ public void UpdateState(PdaUpdateState state)
_stationName = state.StationName ?? Loc.GetString("comp-pda-ui-unknown");
StationNameLabel.SetMarkup(Loc.GetString("comp-pda-ui-station",
("station", _stationName)));


_balance = state.Balance.ToString(); // Frontier
BalanceLabel.SetMarkup(Loc.GetString("comp-pda-ui-balance", ("balance", _balance))); // Frontier

var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);

Expand Down
9 changes: 7 additions & 2 deletions Content.Server/PDA/PdaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Robust.Shared.Utility;
using Content.Shared.Bank.Components; // Frontier

namespace Content.Server.PDA
{
Expand Down Expand Up @@ -142,7 +143,7 @@ private void OnNotification(Entity<PdaComponent> ent, ref CartridgeLoaderNotific
/// <summary>
/// Send new UI state to clients, call if you modify something like uplink.
/// </summary>
public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)
public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null, EntityUid? actor_uid = null) // Frontier
{
if (!Resolve(uid, ref pda, false))
return;
Expand All @@ -165,6 +166,9 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)

var programs = _cartridgeLoader.GetAvailablePrograms(uid, loader);
var id = CompOrNull<IdCardComponent>(pda.ContainedId);
var balance = 0; // frontier
if (actor_uid != null && TryComp<BankAccountComponent>(actor_uid, out var account)) // frontier
balance = account.Balance; // frontier
var state = new PdaUpdateState(
programs,
GetNetEntity(loader.ActiveProgram),
Expand All @@ -180,6 +184,7 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)
StationAlertLevel = pda.StationAlertLevel,
StationAlertColor = pda.StationAlertColor
},
balance, // Frontier
pda.StationName,
showUplink,
hasInstrument,
Expand All @@ -193,7 +198,7 @@ private void OnPdaOpen(Entity<PdaComponent> ent, ref BoundUIOpenedEvent args)
if (!PdaUiKey.Key.Equals(args.UiKey))
return;

UpdatePdaUi(ent.Owner, ent.Comp);
UpdatePdaUi(ent.Owner, ent.Comp, args.Actor); // Frontier
}

private void OnUiMessage(EntityUid uid, PdaComponent pda, PdaRequestUpdateInterfaceMessage msg)
Expand Down
3 changes: 3 additions & 0 deletions Content.Shared/PDA/PdaUpdateState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public sealed class PdaUpdateState : CartridgeLoaderUiState // WTF is this. what
public bool HasUplink;
public bool CanPlayMusic;
public string? Address;
public int Balance; // Frontier

public PdaUpdateState(
List<NetEntity> programs,
Expand All @@ -26,6 +27,7 @@ public PdaUpdateState(
bool hasPai,
bool hasBook,
PdaIdInfoText pdaOwnerInfo,
int balance, // Frontier
string? stationName,
bool hasUplink = false,
bool canPlayMusic = false,
Expand All @@ -41,6 +43,7 @@ public PdaUpdateState(
CanPlayMusic = canPlayMusic;
StationName = stationName;
Address = address;
Balance = balance; // Frontier
}
}

Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/en-US/_NF/pda/pda-component.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comp-pda-ui-balance = Balance: [color=white]{ $balance }[/color]

0 comments on commit 6347758

Please sign in to comment.