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

Добавление баланса в кпк #208

Merged
merged 5 commits into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 10 additions & 5 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");


private int _currentView;

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

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

StationTimeButton.OnPressed += _ =>
{
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
Expand All @@ -126,9 +132,6 @@ public PdaMenu()
_clipboard.SetText(_instructions);
};




HideAllViews();
ToHomeScreen();
}
Expand Down Expand Up @@ -161,7 +164,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 = Loc.GetString("comp-pda-ui-balance", ("balance", state.Balance));
BalanceLabel.SetMarkup(_balance);

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

Expand Down
11 changes: 9 additions & 2 deletions Content.Server/PDA/PdaSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using Content.Server.CartridgeLoader;
using Content.Server.Chat.Managers;
using Content.Server.DeviceNetwork.Components;
using Content.Shared.Bank.Components;
using Content.Server.Instruments;
using Content.Server.Light.EntitySystems;
using Content.Server.PDA.Ringer;
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)
{
if (!Resolve(uid, ref pda, false))
return;
Expand All @@ -165,6 +166,11 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)

var programs = _cartridgeLoader.GetAvailablePrograms(uid, loader);
var id = CompOrNull<IdCardComponent>(pda.ContainedId);
ulong balance = 0;
if (actor_uid != null)
if (TryComp<BankAccountComponent>(actor_uid, out var bank))
balance = (ulong)bank.Balance;

user424242420 marked this conversation as resolved.
Show resolved Hide resolved
var state = new PdaUpdateState(
programs,
GetNetEntity(loader.ActiveProgram),
Expand All @@ -180,6 +186,7 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)
StationAlertLevel = pda.StationAlertLevel,
StationAlertColor = pda.StationAlertColor
},
balance,
pda.StationName,
showUplink,
hasInstrument,
Expand All @@ -193,7 +200,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);
}

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 ulong Balance;
user424242420 marked this conversation as resolved.
Show resolved Hide resolved

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

Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Species/Systems/ReformSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ private void OnZombified(EntityUid uid, ReformComponent comp, ref EntityZombifie
}

public sealed partial class ReformEvent : InstantActionEvent { }

[Serializable, NetSerializable]
public sealed partial class ReformDoAfterEvent : SimpleDoAfterEvent { }

Expand Down
2 changes: 2 additions & 0 deletions Resources/Locale/en-US/pda/pda-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,5 @@ comp-pda-ui-unassigned = Unassigned

pda-notification-message = [font size=12][bold]PDA[/bold] { $header }: [/font]
"{ $message }"

comp-pda-ui-balance = Balance: [color=white]{ $balance }[/color]
user424242420 marked this conversation as resolved.
Show resolved Hide resolved
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/pda/pda-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ comp-pda-ui-unknown = Неизвестно
comp-pda-ui-unassigned = Не назначено
pda-notification-message = [font size=12][bold]КПК[/bold] { $header }: [/font]
"{ $message }"
comp-pda-ui-balance = Баланс: [color=white]{ $balance }[/color]
Loading