Add to PDA alert level, shift duration, instructions and ID access. Also fix uknown station name. (#15220)

* 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
This commit is contained in:
Daniil Sikinami
2023-05-17 23:35:40 +03:00
committed by GitHub
parent 5da40f0d88
commit 7ca7272a80
8 changed files with 128 additions and 26 deletions

View File

@@ -38,6 +38,9 @@
HorizontalExpand="True" /> HorizontalExpand="True" />
</BoxContainer> </BoxContainer>
</PanelContainer> </PanelContainer>
<RichTextLabel Name="StationAlertLevelLabel" Access="Public" />
<RichTextLabel Name="StationTimeLabel" Access="Public" />
<RichTextLabel Name="StationAlertLevelInstructions" Access="Public" />
</BoxContainer> </BoxContainer>
<ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True"> <ScrollContainer HorizontalExpand="True" VerticalExpand="True" HScrollEnabled="True">
<BoxContainer Orientation="Vertical" <BoxContainer Orientation="Vertical"

View File

@@ -1,29 +1,38 @@
using Content.Client.Message; using Content.Client.GameTicking.Managers;
using Content.Shared.CartridgeLoader;
using Content.Shared.PDA; using Content.Shared.PDA;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Utility; using Robust.Shared.Utility;
using Content.Shared.CartridgeLoader;
using Content.Client.Message;
using Robust.Client.UserInterface;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.UserInterface.XAML;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
namespace Content.Client.PDA namespace Content.Client.PDA
{ {
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
public sealed partial class PDAMenu : PDAWindow 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 HomeView = 0;
public const int ProgramListView = 1; public const int ProgramListView = 1;
public const int SettingsView = 2; public const int SettingsView = 2;
public const int ProgramContentView = 3; public const int ProgramContentView = 3;
private int _currentView = 0; private int _currentView;
public event Action<EntityUid>? OnProgramItemPressed; public event Action<EntityUid>? OnProgramItemPressed;
public event Action<EntityUid>? OnUninstallButtonPressed; public event Action<EntityUid>? OnUninstallButtonPressed;
public event Action<EntityUid>? OnInstallButtonPressed; public event Action<EntityUid>? OnInstallButtonPressed;
public PDAMenu() public PDAMenu()
{ {
IoCManager.InjectDependencies(this);
_gameTicker = _entitySystem.GetEntitySystem<ClientGameTicker>();
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
ViewContainer.OnChildAdded += control => control.Visible = false; ViewContainer.OnChildAdded += control => control.Visible = false;
@@ -86,22 +95,44 @@ namespace Content.Client.PDA
if (state.PDAOwnerInfo.ActualOwnerName != null) if (state.PDAOwnerInfo.ActualOwnerName != null)
{ {
PdaOwnerLabel.SetMarkup(Loc.GetString("comp-pda-ui-owner", 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) if (state.PDAOwnerInfo.IdOwner != null || state.PDAOwnerInfo.JobTitle != null)
{ {
IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui", IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui",
("Owner",state.PDAOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")), ("owner",state.PDAOwnerInfo.IdOwner ?? Loc.GetString("comp-pda-ui-unknown")),
("JobTitle",state.PDAOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned")))); ("jobTitle",state.PDAOwnerInfo.JobTitle ?? Loc.GetString("comp-pda-ui-unassigned"))));
} }
else else
{ {
IdInfoLabel.SetMarkup(Loc.GetString("comp-pda-ui-blank")); 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() ?? " - "; AddressLabel.Text = state.Address?.ToUpper() ?? " - ";
EjectIdButton.IsActive = state.PDAOwnerInfo.IdOwner != null || state.PDAOwnerInfo.JobTitle != null; EjectIdButton.IsActive = state.PDAOwnerInfo.IdOwner != null || state.PDAOwnerInfo.JobTitle != null;
@@ -249,5 +280,15 @@ namespace Content.Client.PDA
view.Visible = false; 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"))));
}
} }
} }

View File

@@ -1,9 +1,8 @@
using System.Linq; using System.Linq;
using Content.Server.Chat;
using Content.Server.Chat.Systems; using Content.Server.Chat.Systems;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
using Content.Shared.PDA;
using Robust.Shared.Audio; using Robust.Shared.Audio;
using Robust.Shared.Player;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Server.AlertLevel; namespace Content.Server.AlertLevel;
@@ -189,6 +188,12 @@ public sealed class AlertLevelSystem : EntitySystem
} }
RaiseLocalEvent(new AlertLevelChangedEvent(station, level)); RaiseLocalEvent(new AlertLevelChangedEvent(station, level));
var pdas = EntityQueryEnumerator<PDAComponent>();
while (pdas.MoveNext(out var ent, out var comp))
{
RaiseLocalEvent(ent,new AlertLevelChangedEvent(station, level));
}
} }
} }

View File

@@ -1,20 +1,16 @@
using Content.Server.AlertLevel;
using Content.Server.CartridgeLoader; using Content.Server.CartridgeLoader;
using Content.Server.DeviceNetwork.Components; using Content.Server.DeviceNetwork.Components;
using Content.Server.Instruments; using Content.Server.Instruments;
using Content.Server.Light.Components;
using Content.Server.Light.EntitySystems; using Content.Server.Light.EntitySystems;
using Content.Server.Light.Events; using Content.Server.Light.Events;
using Content.Server.PDA.Ringer; using Content.Server.PDA.Ringer;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
using Content.Server.Store.Components; using Content.Server.Store.Components;
using Content.Server.Store.Systems; using Content.Server.Store.Systems;
using Content.Server.UserInterface;
using Content.Shared.PDA; using Content.Shared.PDA;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
using Robust.Shared.Containers; using Robust.Shared.Containers;
using Robust.Shared.Map;
using Content.Server.Mind.Components;
using Content.Server.Traitor;
using Content.Shared.Light.Component; using Content.Shared.Light.Component;
namespace Content.Server.PDA namespace Content.Server.PDA
@@ -35,6 +31,7 @@ namespace Content.Server.PDA
SubscribeLocalEvent<PDAComponent, LightToggleEvent>(OnLightToggle); SubscribeLocalEvent<PDAComponent, LightToggleEvent>(OnLightToggle);
SubscribeLocalEvent<PDAComponent, GridModifiedEvent>(OnGridChanged); SubscribeLocalEvent<PDAComponent, GridModifiedEvent>(OnGridChanged);
SubscribeLocalEvent<PDAComponent, AlertLevelChangedEvent>(OnAlertLevelChanged);
} }
protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args) protected override void OnComponentInit(EntityUid uid, PDAComponent pda, ComponentInit args)
@@ -44,6 +41,7 @@ namespace Content.Server.PDA
if (!TryComp(uid, out ServerUserInterfaceComponent? uiComponent)) if (!TryComp(uid, out ServerUserInterfaceComponent? uiComponent))
return; return;
UpdateAlertLevel(uid, pda);
UpdateStationName(uid, pda); UpdateStationName(uid, pda);
if (_ui.TryGetUi(uid, PDAUiKey.Key, out var ui, uiComponent)) if (_ui.TryGetUi(uid, PDAUiKey.Key, out var ui, uiComponent))
@@ -89,7 +87,9 @@ namespace Content.Server.PDA
{ {
ActualOwnerName = pda.OwnerName, ActualOwnerName = pda.OwnerName,
IdOwner = pda.ContainedID?.FullName, 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)) if (!_ui.TryGetUi(uid, PDAUiKey.Key, out var ui))
@@ -99,7 +99,20 @@ namespace Content.Server.PDA
var hasInstrument = HasComp<InstrumentComponent>(uid); var hasInstrument = HasComp<InstrumentComponent>(uid);
var showUplink = HasComp<StoreComponent>(uid) && IsUnlocked(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); _cartridgeLoader?.UpdateUiState(uid, state);
} }
@@ -160,6 +173,23 @@ namespace Content.Server.PDA
pda.StationName = station is null ? null : Name(station.Value); 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) private string? GetDeviceNetAddress(EntityUid uid)
{ {
string? address = null; string? address = null;

View File

@@ -1,7 +1,7 @@
using Content.Shared.Access.Components;
using Content.Shared.Containers.ItemSlots;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.GameStates; using Robust.Shared.GameStates;
using Content.Shared.Access.Components;
using Content.Shared.Containers.ItemSlots;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
namespace Content.Shared.PDA namespace Content.Shared.PDA
@@ -35,5 +35,7 @@ namespace Content.Shared.PDA
[ViewVariables] public string? OwnerName; [ViewVariables] public string? OwnerName;
[ViewVariables] public string? StationName; [ViewVariables] public string? StationName;
[ViewVariables] public string? StationAlertLevel;
[ViewVariables] public Color StationAlertColor = Color.White;
} }
} }

View File

@@ -15,7 +15,9 @@ namespace Content.Shared.PDA
public bool CanPlayMusic; public bool CanPlayMusic;
public string? Address; 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; FlashlightEnabled = flashlightEnabled;
HasPen = hasPen; HasPen = hasPen;
@@ -33,5 +35,7 @@ namespace Content.Shared.PDA
public string? ActualOwnerName; public string? ActualOwnerName;
public string? IdOwner; public string? IdOwner;
public string? JobTitle; public string? JobTitle;
public string? StationAlertLevel;
public Color StationAlertColor;
} }
} }

View File

@@ -1,25 +1,36 @@
alert-level-announcement = Attention! Station alert level is now {$name}! {$announcement} 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 = Green
alert-level-green-announcement = It is now safe to return to your workplaces. 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 = 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-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 = 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-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 = 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-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 = 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-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 = 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-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 = 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-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 = Epsilon
alert-level-epsilon-announcement = Central Command has ordered the Epsilon security level on the station. Consider all contracts terminated. 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.

View File

@@ -2,11 +2,11 @@
### UI ### UI
# For the PDA screen # 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-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 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-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 comp-pda-ui-eject-id-button = Eject ID