]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add to PDA alert level, shift duration, instructions and ID access. Also fix uknown...
authorDaniil Sikinami <60344369+VigersRay@users.noreply.github.com>
Wed, 17 May 2023 20:35:40 +0000 (23:35 +0300)
committerGitHub <noreply@github.com>
Wed, 17 May 2023 20:35:40 +0000 (14:35 -0600)
* PDA update and fix

* fix alert level

* Fix color level

* Maybe this will look better

* PDA update and fix

* fix alert level

* Fix color level

* Maybe this will look better

* Now threat color is taken in the same way as for emergency lamps

* Minor improvements

* Fix alert level string

* AlertLevelChangedEvent for all PDAs

* StationAlert is also stored in PDAComponent

* Removed IdAccessLevels

* Removed Access from PDAMenu.xaml.cs and Draw time real-time

* AlertLevel updated from AlertLevelChangedEvent

* Removed garbage

* Removed garbage from PDAUpdateState.cs

* Change comp-pda-ui-station-time

* revert rename PDAOwnerInfo to PdaOwnerInfo

* remove not use short names jobs

* "ftl var should be lowercase"

* "ftl var should be lowercase" again

* transfer StationAlert to PDAIdInfoText

* transfer StationAlert to PDAIdInfoText

* Line breaks of parameter/argument lists conventions

* not randomly inline property attributes

* no broadcast AlertLevelChangedEvent

* fix cctualOwnerName

* GridModifiedEvent never called

* add alert-level-unknown-instructions

* UpdateAlertLevel for latejoin

* Add alert-level-unknown

* Revert "GridModifiedEvent never called"

This reverts commit fa7d1620

* remove garbage and fix quite long

Content.Client/PDA/PDAMenu.xaml
Content.Client/PDA/PDAMenu.xaml.cs
Content.Server/AlertLevel/AlertLevelSystem.cs
Content.Server/PDA/PDASystem.cs
Content.Shared/PDA/PDAComponent.cs
Content.Shared/PDA/PDAUpdateState.cs
Resources/Locale/en-US/alert-levels/alert-levels.ftl
Resources/Locale/en-US/pda/pda-component.ftl

index e1c0e706d5d6c8ee4523b27bd2949f983608be66..0b61cde932b6004524b7f8b1d24f6e9eea5b0b8d 100644 (file)
@@ -38,6 +38,9 @@
                                    HorizontalExpand="True" />
                 </BoxContainer>
             </PanelContainer>
+            <RichTextLabel Name="StationAlertLevelLabel" Access="Public" />
+            <RichTextLabel Name="StationTimeLabel" Access="Public" />
+            <RichTextLabel Name="StationAlertLevelInstructions" Access="Public" />
         </BoxContainer>
         <ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True">
             <BoxContainer Orientation="Vertical"
index 98b1e1adaf88d670c2a78a2a1996c44bc7156621..4b80795cc1b7cec6f0a9c7deebc26969265b06ff 100644 (file)
@@ -1,29 +1,38 @@
-using Content.Client.Message;
-using Content.Shared.CartridgeLoader;
+using Content.Client.GameTicking.Managers;
 using Content.Shared.PDA;
-using Robust.Client.AutoGenerated;
+using Robust.Shared.Utility;
+using Content.Shared.CartridgeLoader;
+using Content.Client.Message;
 using Robust.Client.UserInterface;
-using Robust.Client.UserInterface.Controls;
+using Robust.Client.AutoGenerated;
+using Robust.Client.Graphics;
 using Robust.Client.UserInterface.XAML;
-using Robust.Shared.Utility;
+using Robust.Client.UserInterface.Controls;
+using Robust.Shared.Timing;
 
 namespace Content.Client.PDA
 {
     [GenerateTypedNameReferences]
     public sealed partial class PDAMenu : PDAWindow
     {
+        [Dependency] private readonly IGameTiming _gameTiming = default!;
+        [Dependency] private readonly IEntitySystemManager _entitySystem = default!;
+        private readonly ClientGameTicker _gameTicker;
+
         public const int HomeView = 0;
         public const int ProgramListView = 1;
         public const int SettingsView = 2;
         public const int ProgramContentView = 3;
 
-        private int _currentView = 0;
+        private int _currentView;
 
         public event Action<EntityUid>? OnProgramItemPressed;
         public event Action<EntityUid>? OnUninstallButtonPressed;
         public event Action<EntityUid>? OnInstallButtonPressed;
         public PDAMenu()
         {
+            IoCManager.InjectDependencies(this);
+            _gameTicker = _entitySystem.GetEntitySystem<ClientGameTicker>();
             RobustXamlLoader.Load(this);
 
             ViewContainer.OnChildAdded += control => control.Visible = false;
@@ -86,22 +95,44 @@ namespace Content.Client.PDA
             if (state.PDAOwnerInfo.ActualOwnerName != null)
             {
                 PdaOwnerLabel.SetMarkup(Loc.GetString("comp-pda-ui-owner",
-                    ("ActualOwnerName", state.PDAOwnerInfo.ActualOwnerName)));
+                    ("actualOwnerName", state.PDAOwnerInfo.ActualOwnerName)));
             }
 
 
             if (state.PDAOwnerInfo.IdOwner != null || state.PDAOwnerInfo.JobTitle != null)
             {
                 IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
-                    ("Owner",state.PDAOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")),
-                    ("JobTitle",state.PDAOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned"))));
+                    ("owner",state.PDAOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")),
+                    ("jobTitle",state.PDAOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned"))));
             }
             else
             {
                 IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui-blank"));
             }
 
-            StationNameLabel.SetMarkup(Loc.GetString("comp-pda-ui-station", ("Station",state.StationName ?? Loc.GetString("comp-pda-ui-unknown"))));
+            StationNameLabel.SetMarkup(Loc.GetString("comp-pda-ui-station",
+                ("station",state.StationName ?? Loc.GetString("comp-pda-ui-unknown"))));
+
+            var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
+
+            StationTimeLabel.SetMarkup(Loc.GetString("comp-pda-ui-station-time",
+                ("time", stationTime.ToString("hh\\:mm\\:ss"))));
+
+            var alertLevel = state.PDAOwnerInfo.StationAlertLevel;
+            var alertColor = state.PDAOwnerInfo.StationAlertColor;
+            var alertLevelKey = alertLevel != null ? $"alert-level-{alertLevel}" : "alert-level-unknown";
+
+            StationAlertLevelLabel.SetMarkup(Loc.GetString(
+                "comp-pda-ui-station-alert-level",
+                ("color", alertColor),
+                ("level", Loc.GetString(alertLevelKey))
+            ));
+
+            StationAlertLevelInstructions.SetMarkup(Loc.GetString(
+                "comp-pda-ui-station-alert-level-instructions",
+                ("instructions", Loc.GetString($"{alertLevelKey}-instructions")))
+            );
+
             AddressLabel.Text = state.Address?.ToUpper() ?? " - ";
 
             EjectIdButton.IsActive = state.PDAOwnerInfo.IdOwner != null || state.PDAOwnerInfo.JobTitle != null;
@@ -249,5 +280,15 @@ namespace Content.Client.PDA
                 view.Visible = false;
             }
         }
+
+        protected override void Draw(DrawingHandleScreen handle)
+        {
+            base.Draw(handle);
+
+            var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
+
+            StationTimeLabel.SetMarkup(Loc.GetString("comp-pda-ui-station-time",
+                ("time", stationTime.ToString("hh\\:mm\\:ss"))));
+        }
     }
 }
index c0c0f6fd204c489364de06269b2d67a48b90984e..1c3339414671021cb202ac3e9511d1dc722683a9 100644 (file)
@@ -1,9 +1,8 @@
 using System.Linq;
-using Content.Server.Chat;
 using Content.Server.Chat.Systems;
 using Content.Server.Station.Systems;
+using Content.Shared.PDA;
 using Robust.Shared.Audio;
-using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
 
 namespace Content.Server.AlertLevel;
@@ -189,6 +188,12 @@ public sealed class AlertLevelSystem : EntitySystem
         }
 
         RaiseLocalEvent(new AlertLevelChangedEvent(station, level));
+
+        var pdas = EntityQueryEnumerator<PDAComponent>();
+        while (pdas.MoveNext(out var ent, out var comp))
+        {
+            RaiseLocalEvent(ent,new AlertLevelChangedEvent(station, level));
+        }
     }
 }
 
index 6c4d63b54af65572852b6b59adca44d4a9a688d1..c38f95d5bdb26cca23999440417a3dcc71334246 100644 (file)
@@ -1,20 +1,16 @@
+using Content.Server.AlertLevel;
 using Content.Server.CartridgeLoader;
 using Content.Server.DeviceNetwork.Components;
 using Content.Server.Instruments;
-using Content.Server.Light.Components;
 using Content.Server.Light.EntitySystems;
 using Content.Server.Light.Events;
 using Content.Server.PDA.Ringer;
 using Content.Server.Station.Systems;
 using Content.Server.Store.Components;
 using Content.Server.Store.Systems;
-using Content.Server.UserInterface;
 using Content.Shared.PDA;
 using Robust.Server.GameObjects;
 using Robust.Shared.Containers;
-using Robust.Shared.Map;
-using Content.Server.Mind.Components;
-using Content.Server.Traitor;
 using Content.Shared.Light.Component;
 
 namespace Content.Server.PDA
@@ -35,6 +31,7 @@ namespace Content.Server.PDA
 
             SubscribeLocalEvent<PDAComponent, LightToggleEvent>(OnLightToggle);
             SubscribeLocalEvent<PDAComponent, GridModifiedEvent>(OnGridChanged);
+            SubscribeLocalEvent<PDAComponent, AlertLevelChangedEvent>(OnAlertLevelChanged);
         }
 
         protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
@@ -44,6 +41,7 @@ namespace Content.Server.PDA
             if (!TryComp(uid, out ServerUserInterfaceComponent? uiComponent))
                 return;
 
+            UpdateAlertLevel(uid, pda);
             UpdateStationName(uid, pda);
 
             if (_ui.TryGetUi(uid, PDAUiKey.Key, out var ui, uiComponent))
@@ -89,7 +87,9 @@ namespace Content.Server.PDA
             {
                 ActualOwnerName = pda.OwnerName,
                 IdOwner = pda.ContainedID?.FullName,
-                JobTitle = pda.ContainedID?.JobTitle
+                JobTitle = pda.ContainedID?.JobTitle,
+                StationAlertLevel = pda.StationAlertLevel,
+                StationAlertColor = pda.StationAlertColor
             };
 
             if (!_ui.TryGetUi(uid, PDAUiKey.Key, out var ui))
@@ -99,7 +99,20 @@ namespace Content.Server.PDA
             var hasInstrument = HasComp<InstrumentComponent>(uid);
             var showUplink = HasComp<StoreComponent>(uid) && IsUnlocked(uid);
 
-            var state = new PDAUpdateState(pda.FlashlightOn, pda.PenSlot.HasItem, ownerInfo, pda.StationName, showUplink, hasInstrument, address);
+            UpdateStationName(uid, pda);
+            UpdateAlertLevel(uid, pda);
+            // TODO: Update the level and name of the station with each call to UpdatePdaUi is only needed for latejoin players.
+            // TODO: If someone can implement changing the level and name of the station when changing the PDA grid, this can be removed.
+
+            var state = new PDAUpdateState(
+                pda.FlashlightOn,
+                pda.PenSlot.HasItem,
+                ownerInfo,
+                pda.StationName,
+                showUplink,
+                hasInstrument,
+                address);
+
             _cartridgeLoader?.UpdateUiState(uid, state);
         }
 
@@ -160,6 +173,23 @@ namespace Content.Server.PDA
             pda.StationName = station is null ? null : Name(station.Value);
         }
 
+        private void OnAlertLevelChanged(EntityUid uid, PDAComponent pda, AlertLevelChangedEvent args)
+        {
+            UpdateAlertLevel(uid, pda);
+            UpdatePdaUi(uid, pda);
+        }
+
+        private void UpdateAlertLevel(EntityUid uid, PDAComponent pda)
+        {
+            var station = _station.GetOwningStation(uid);
+            if (!TryComp(station, out AlertLevelComponent? alertComp) ||
+                alertComp.AlertLevels == null)
+                return;
+            pda.StationAlertLevel = alertComp.CurrentLevel;
+            if (alertComp.AlertLevels.Levels.TryGetValue(alertComp.CurrentLevel, out var details))
+                pda.StationAlertColor = details.Color;
+        }
+
         private string? GetDeviceNetAddress(EntityUid uid)
         {
             string? address = null;
index 1cc1832e85aac8e16ffb61ae555af841599376e4..7a319b77a1a0ea188445a6bf0c8133f4659c85b1 100644 (file)
@@ -1,7 +1,7 @@
-using Content.Shared.Access.Components;
-using Content.Shared.Containers.ItemSlots;
 using Robust.Shared.Prototypes;
 using Robust.Shared.GameStates;
+using Content.Shared.Access.Components;
+using Content.Shared.Containers.ItemSlots;
 using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
 
 namespace Content.Shared.PDA
@@ -35,5 +35,7 @@ namespace Content.Shared.PDA
 
         [ViewVariables] public string? OwnerName;
         [ViewVariables] public string? StationName;
+        [ViewVariables] public string? StationAlertLevel;
+        [ViewVariables] public Color StationAlertColor = Color.White;
     }
 }
index 339f18d725af78bcef2aa6404ab97b4dc38ab61b..20002e277e6dc47a948931d1dcbb483114fd49d1 100644 (file)
@@ -15,7 +15,9 @@ namespace Content.Shared.PDA
         public bool CanPlayMusic;
         public string? Address;
 
-        public PDAUpdateState(bool flashlightEnabled, bool hasPen, PDAIdInfoText pdaOwnerInfo, string? stationName, bool hasUplink = false, bool canPlayMusic = false, string? address = null)
+        public PDAUpdateState(bool flashlightEnabled, bool hasPen, PDAIdInfoText pdaOwnerInfo,
+            string? stationName, bool hasUplink = false,
+            bool canPlayMusic = false, string? address = null)
         {
             FlashlightEnabled = flashlightEnabled;
             HasPen = hasPen;
@@ -33,5 +35,7 @@ namespace Content.Shared.PDA
         public string? ActualOwnerName;
         public string? IdOwner;
         public string? JobTitle;
+        public string? StationAlertLevel;
+        public Color StationAlertColor;
     }
 }
index 29a1f66419d855e1f541626c2b2da0f62fd7c10c..9476a95a2099767f3f0cfd6cc793f95a1e48b59f 100644 (file)
@@ -1,25 +1,36 @@
 alert-level-announcement = Attention! Station alert level is now {$name}! {$announcement}
 
+alert-level-unknown = Unknown.
+alert-level-unknown-instructions = Unknown.
+
 alert-level-green = Green
 alert-level-green-announcement = It is now safe to return to your workplaces.
+alert-level-green-instructions = Do your job.
 
 alert-level-blue = Blue
 alert-level-blue-announcement = There is a confirmed threat to the station. Security should perform random checks. Crewmembers are advised to be vigilant and report suspicious activity to security.
+alert-level-blue-instructions = Crewmembers are advised to be vigilant and report suspicious activity to security.
 
 alert-level-red = Red
 alert-level-red-announcement = There is an immediate threat to the station. Security should prepare to use lethal force if necessary. Crewmembers should find a safe place to shelter in, and are advised to follow any present authorities.
+alert-level-red-instructions = Crewmembers should find a safe place to shelter in, and are advised to follow any present authorities.
 
 alert-level-violet = Violet
 alert-level-violet-announcement = There is a viral threat on the station. Medical staff are advised to isolate crewmembers with any symptoms. Crewmembers are advised to distance themselves from others and perform safety measures to prevent further spread.
+alert-level-violet-instructions = Crewmembers are advised to distance themselves from others and perform safety measures to prevent further spread.
 
 alert-level-yellow = Yellow
 alert-level-yellow-announcement = There is a structural or atmospheric threat within the station. Engineering staff are advised to immediately respond and perform safety measures. Crewmembers are advised to stay away from the threat, and stay in their workplaces if necessary.
+alert-level-yellow-instructions = Crewmembers are advised to stay away from the threat, and stay in their workplaces if necessary.
 
 alert-level-gamma = Gamma
 alert-level-gamma-announcement = Central Command has ordered the Gamma security level on the station. Security is to have weapons equipped at all times, and all civilians are to immediately seek their nearest head for transportation to a secure location.
+alert-level-gamma-instructions = All civilians are to immediately seek their nearest head for transportation to a secure location.
 
 alert-level-delta = Delta
 alert-level-delta-announcement = The station is currently under threat of imminent destruction. Crewmembers are advised to listen to heads of staff for more information.
+alert-level-delta-instructions = Crewmembers are advised to listen to heads of staff for more information.
 
 alert-level-epsilon = Epsilon
 alert-level-epsilon-announcement = Central Command has ordered the Epsilon security level on the station. Consider all contracts terminated.
+alert-level-epsilon-instructions = Consider all contracts terminated.
index 1eb1f829d80ee072a20915c4ac5106ed0c0203e4..551ff29e5526190d0dc8800365d235c0f76565a3 100644 (file)
@@ -2,11 +2,11 @@
 ### UI
 
 # For the PDA screen
-comp-pda-ui = ID: [color=white]{$Owner}[/color], [color=yellow]{$JobTitle}[/color]
+comp-pda-ui = ID: [color=white]{$owner}[/color], [color=yellow]{$jobTitle}[/color]
 
 comp-pda-ui-blank = ID:
 
-comp-pda-ui-owner = Owner: [color=white]{$ActualOwnerName}[/color]
+comp-pda-ui-owner = Owner: [color=white]{$actualOwnerName}[/color]
 
 comp-pda-io-program-list-button = Programs
 
@@ -24,7 +24,13 @@ pda-bound-user-interface-lock-uplink-description = Prevent anyone from accessing
 
 comp-pda-ui-menu-title = PDA
 
-comp-pda-ui-station = Station: [color=white]{$Station}[/color]
+comp-pda-ui-station = Station: [color=white]{$station}[/color]
+
+comp-pda-ui-station-alert-level = Alert Level: [color={ $color }]{ $level }[/color]
+
+comp-pda-ui-station-alert-level-instructions = Instructions: [color=white]{ $instructions }[/color]
+
+comp-pda-ui-station-time = Shift duration: [color=white]{ $time }[/color]
 
 comp-pda-ui-eject-id-button = Eject ID