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

Commit

Permalink
Добавление баланса в кпк
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Rubinov committed May 22, 2024
1 parent 1b9e378 commit c8ad794
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 6 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
13 changes: 10 additions & 3 deletions Content.Client/PDA/PdaMenu.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ 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-balance", ("balance", 0));

private int _currentView;

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

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

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




HideAllViews();
Expand Down Expand Up @@ -161,7 +166,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
12 changes: 10 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,12 @@ 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;
}
}
var state = new PdaUpdateState(
programs,
GetNetEntity(loader.ActiveProgram),
Expand All @@ -180,6 +187,7 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)
StationAlertLevel = pda.StationAlertLevel,
StationAlertColor = pda.StationAlertColor
},
balance,
pda.StationName,
showUplink,
hasInstrument,
Expand All @@ -193,7 +201,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;

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]
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]

0 comments on commit c8ad794

Please sign in to comment.