From c8ad7949a757954e3d4d91288f8761a209874a0b Mon Sep 17 00:00:00 2001 From: Ivan Rubinov Date: Wed, 22 May 2024 20:46:49 +0300 Subject: [PATCH 1/5] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=B1=D0=B0=D0=BB=D0=B0=D0=BD=D1=81=D0=B0?= =?UTF-8?q?=20=D0=B2=20=D0=BA=D0=BF=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/PDA/PdaMenu.xaml | 3 +++ Content.Client/PDA/PdaMenu.xaml.cs | 13 ++++++++++--- Content.Server/PDA/PdaSystem.cs | 12 ++++++++++-- Content.Shared/PDA/PdaUpdateState.cs | 3 +++ Content.Shared/Species/Systems/ReformSystem.cs | 2 +- Resources/Locale/en-US/pda/pda-component.ftl | 2 ++ Resources/Locale/ru-RU/pda/pda-component.ftl | 1 + 7 files changed, 30 insertions(+), 6 deletions(-) diff --git a/Content.Client/PDA/PdaMenu.xaml b/Content.Client/PDA/PdaMenu.xaml index cc4a384343a..8f9a297afc2 100644 --- a/Content.Client/PDA/PdaMenu.xaml +++ b/Content.Client/PDA/PdaMenu.xaml @@ -47,6 +47,9 @@ + + + + { + _clipboard.SetText(_balance); + }; + StationTimeButton.OnPressed += _ => { var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan); @@ -126,7 +131,7 @@ public PdaMenu() _clipboard.SetText(_instructions); }; - + HideAllViews(); @@ -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); diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index b91f2522b20..33a0eb9fc97 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -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; @@ -142,7 +143,7 @@ private void OnNotification(Entity ent, ref CartridgeLoaderNotific /// /// Send new UI state to clients, call if you modify something like uplink. /// - 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; @@ -165,6 +166,12 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null) var programs = _cartridgeLoader.GetAvailablePrograms(uid, loader); var id = CompOrNull(pda.ContainedId); + ulong balance = 0; + if (actor_uid != null){ + if (TryComp(actor_uid, out var bank)) { + balance = (ulong)bank.Balance; + } + } var state = new PdaUpdateState( programs, GetNetEntity(loader.ActiveProgram), @@ -180,6 +187,7 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null) StationAlertLevel = pda.StationAlertLevel, StationAlertColor = pda.StationAlertColor }, + balance, pda.StationName, showUplink, hasInstrument, @@ -193,7 +201,7 @@ private void OnPdaOpen(Entity 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) diff --git a/Content.Shared/PDA/PdaUpdateState.cs b/Content.Shared/PDA/PdaUpdateState.cs index 4b0c8ccba5b..d3f406f5095 100644 --- a/Content.Shared/PDA/PdaUpdateState.cs +++ b/Content.Shared/PDA/PdaUpdateState.cs @@ -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 programs, @@ -26,6 +27,7 @@ public PdaUpdateState( bool hasPai, bool hasBook, PdaIdInfoText pdaOwnerInfo, + ulong balance, string? stationName, bool hasUplink = false, bool canPlayMusic = false, @@ -41,6 +43,7 @@ public PdaUpdateState( CanPlayMusic = canPlayMusic; StationName = stationName; Address = address; + Balance = balance; } } diff --git a/Content.Shared/Species/Systems/ReformSystem.cs b/Content.Shared/Species/Systems/ReformSystem.cs index b7f32b41bd1..d5c735ab2a8 100644 --- a/Content.Shared/Species/Systems/ReformSystem.cs +++ b/Content.Shared/Species/Systems/ReformSystem.cs @@ -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 { } diff --git a/Resources/Locale/en-US/pda/pda-component.ftl b/Resources/Locale/en-US/pda/pda-component.ftl index 7f17102c5f0..b38ac9bb218 100644 --- a/Resources/Locale/en-US/pda/pda-component.ftl +++ b/Resources/Locale/en-US/pda/pda-component.ftl @@ -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] diff --git a/Resources/Locale/ru-RU/pda/pda-component.ftl b/Resources/Locale/ru-RU/pda/pda-component.ftl index a0549ca97d7..43656ee32a1 100644 --- a/Resources/Locale/ru-RU/pda/pda-component.ftl +++ b/Resources/Locale/ru-RU/pda/pda-component.ftl @@ -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] From 33761ab50c2ea14452a15e422578326405bc5136 Mon Sep 17 00:00:00 2001 From: Ivan Rubinov Date: Wed, 22 May 2024 21:12:39 +0300 Subject: [PATCH 2/5] =?UTF-8?q?=D1=80=D0=B5=D0=BA=D0=B2=D0=B5=D1=81=D1=82?= =?UTF-8?q?=D1=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/PDA/PdaMenu.xaml.cs | 6 ++---- Content.Server/PDA/PdaSystem.cs | 7 +++---- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/Content.Client/PDA/PdaMenu.xaml.cs b/Content.Client/PDA/PdaMenu.xaml.cs index 2ba4a8a588e..e6c4b82a918 100644 --- a/Content.Client/PDA/PdaMenu.xaml.cs +++ b/Content.Client/PDA/PdaMenu.xaml.cs @@ -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-balance", ("balance", 0)); + private string _balance = 0; + private int _currentView; @@ -131,9 +132,6 @@ public PdaMenu() _clipboard.SetText(_instructions); }; - - - HideAllViews(); ToHomeScreen(); } diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index 33a0eb9fc97..9bb1c250b6c 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -167,11 +167,10 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null, EntityUid? acto var programs = _cartridgeLoader.GetAvailablePrograms(uid, loader); var id = CompOrNull(pda.ContainedId); ulong balance = 0; - if (actor_uid != null){ - if (TryComp(actor_uid, out var bank)) { + if (actor_uid != null) + if (TryComp(actor_uid, out var bank)) balance = (ulong)bank.Balance; - } - } + var state = new PdaUpdateState( programs, GetNetEntity(loader.ActiveProgram), From f4af735d6403ffbbe5e75f8bb316885607b50fa6 Mon Sep 17 00:00:00 2001 From: Ivan Rubinov Date: Wed, 22 May 2024 21:25:38 +0300 Subject: [PATCH 3/5] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/PDA/PdaMenu.xaml.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Client/PDA/PdaMenu.xaml.cs b/Content.Client/PDA/PdaMenu.xaml.cs index e6c4b82a918..c87b05b2d91 100644 --- a/Content.Client/PDA/PdaMenu.xaml.cs +++ b/Content.Client/PDA/PdaMenu.xaml.cs @@ -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 = 0; + private string _balance = Loc.GetString("comp-pda-ui-unknown"); private int _currentView; From 0467d1ec5240357962b4a988dc7f42df3b13d806 Mon Sep 17 00:00:00 2001 From: user424242420 <142989209+user424242420@users.noreply.github.com> Date: Thu, 23 May 2024 13:07:21 +0300 Subject: [PATCH 4/5] fiz --- Content.Server/PDA/PdaSystem.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index 9bb1c250b6c..edb99b35ec4 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -168,8 +168,8 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null, EntityUid? acto var id = CompOrNull(pda.ContainedId); ulong balance = 0; if (actor_uid != null) - if (TryComp(actor_uid, out var bank)) - balance = (ulong)bank.Balance; + if (TryComp(actor_uid, out var account)) + balance = account.Balance; var state = new PdaUpdateState( programs, From 6cd7d9dc1a03c958ea55953c14562ce8e8cad0f7 Mon Sep 17 00:00:00 2001 From: user424242420 <142989209+user424242420@users.noreply.github.com> Date: Thu, 23 May 2024 13:52:19 +0300 Subject: [PATCH 5/5] fix --- Content.Server/PDA/PdaSystem.cs | 5 ++--- Content.Shared/PDA/PdaUpdateState.cs | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index edb99b35ec4..047d671c9a2 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -166,9 +166,8 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null, EntityUid? acto var programs = _cartridgeLoader.GetAvailablePrograms(uid, loader); var id = CompOrNull(pda.ContainedId); - ulong balance = 0; - if (actor_uid != null) - if (TryComp(actor_uid, out var account)) + var balance = 0; + if (actor_uid != null && TryComp(actor_uid, out var account)) balance = account.Balance; var state = new PdaUpdateState( diff --git a/Content.Shared/PDA/PdaUpdateState.cs b/Content.Shared/PDA/PdaUpdateState.cs index d3f406f5095..840f8c5ac1c 100644 --- a/Content.Shared/PDA/PdaUpdateState.cs +++ b/Content.Shared/PDA/PdaUpdateState.cs @@ -17,7 +17,7 @@ public sealed class PdaUpdateState : CartridgeLoaderUiState // WTF is this. what public bool HasUplink; public bool CanPlayMusic; public string? Address; - public ulong Balance; + public int Balance; public PdaUpdateState( List programs, @@ -27,7 +27,7 @@ public PdaUpdateState( bool hasPai, bool hasBook, PdaIdInfoText pdaOwnerInfo, - ulong balance, + int balance, string? stationName, bool hasUplink = false, bool canPlayMusic = false,