diff --git a/Content.Client/PDA/PdaMenu.xaml b/Content.Client/PDA/PdaMenu.xaml index 8f9a297afc2..e372dc521b6 100644 --- a/Content.Client/PDA/PdaMenu.xaml +++ b/Content.Client/PDA/PdaMenu.xaml @@ -44,6 +44,9 @@ + + + diff --git a/Content.Client/PDA/PdaMenu.xaml.cs b/Content.Client/PDA/PdaMenu.xaml.cs index c87b05b2d91..e3e871f0f3b 100644 --- a/Content.Client/PDA/PdaMenu.xaml.cs +++ b/Content.Client/PDA/PdaMenu.xaml.cs @@ -25,12 +25,14 @@ public sealed partial class PdaMenu : PdaWindow public const int SettingsView = 2; public const int ProgramContentView = 3; + private TimeSpan shuttleEvacTimeSpan; private string _pdaOwner = Loc.GetString("comp-pda-ui-unknown"); private string _owner = Loc.GetString("comp-pda-ui-unknown"); private string _jobTitle = Loc.GetString("comp-pda-ui-unassigned"); private string _stationName = Loc.GetString("comp-pda-ui-unknown"); private string _alertLevel = Loc.GetString("comp-pda-ui-unknown"); + private string _timeLeftShuttle = Loc.GetString("comp-pda-ui-unknown"); private string _instructions = Loc.GetString("comp-pda-ui-unknown"); private string _balance = Loc.GetString("comp-pda-ui-unknown"); @@ -116,6 +118,11 @@ public PdaMenu() _clipboard.SetText(_alertLevel); }; + ShuttleLeftTimeButton.OnPressed += _ => + { + _clipboard.SetText(_timeLeftShuttle); + }; + BalanceButton.OnPressed += _ => { _clipboard.SetText(_balance); @@ -165,14 +172,25 @@ public void UpdateState(PdaUpdateState state) StationNameLabel.SetMarkup(Loc.GetString("comp-pda-ui-station", ("station", _stationName))); - _balance = Loc.GetString("comp-pda-ui-balance", ("balance", state.Balance)); - BalanceLabel.SetMarkup(_balance); + if (state.Balance is not null) + { + _balance = Loc.GetString("comp-pda-ui-balance", ("balance", state.Balance.Value)); + BalanceLabel.SetMarkup(_balance); + } var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan); StationTimeLabel.SetMarkup(Loc.GetString("comp-pda-ui-station-time", ("time", stationTime.ToString("hh\\:mm\\:ss")))); + shuttleEvacTimeSpan = state.EvacShuttleTime ?? TimeSpan.Zero; + var shuttleEvacTime = shuttleEvacTimeSpan - _gameTiming.CurTime; + if (state.EvacShuttleTime is not null) + _timeLeftShuttle = Loc.GetString("comp-pda-ui-left-time", + ("time", shuttleEvacTime.ToString("hh\\:mm\\:ss"))); + + ShuttleLeftTimeLabel.SetMarkup(_timeLeftShuttle); + var alertLevel = state.PdaOwnerInfo.StationAlertLevel; var alertColor = state.PdaOwnerInfo.StationAlertColor; var alertLevelKey = alertLevel != null ? $"alert-level-{alertLevel}" : "alert-level-unknown"; @@ -346,6 +364,12 @@ protected override void Draw(DrawingHandleScreen handle) StationTimeLabel.SetMarkup(Loc.GetString("comp-pda-ui-station-time", ("time", stationTime.ToString("hh\\:mm\\:ss")))); + + var shuttleEvacTime = shuttleEvacTimeSpan - _gameTiming.CurTime; + _timeLeftShuttle = Loc.GetString("comp-pda-ui-left-time", + ("time", shuttleEvacTime.TotalSeconds <= 0 ? Loc.GetString("comp-pda-ui-unknown") : shuttleEvacTime.ToString("hh\\:mm\\:ss"))); + + ShuttleLeftTimeLabel.SetMarkup(_timeLeftShuttle); } } } diff --git a/Content.Server/PDA/PdaSystem.cs b/Content.Server/PDA/PdaSystem.cs index 047d671c9a2..ef86bdfbc19 100644 --- a/Content.Server/PDA/PdaSystem.cs +++ b/Content.Server/PDA/PdaSystem.cs @@ -7,6 +7,9 @@ using Content.Server.Light.EntitySystems; using Content.Server.PDA.Ringer; using Content.Server.Station.Systems; +using Content.Server.RoundEnd; +using Content.Server.Shuttles.Components; +using Content.Server.Shuttles.Systems; using Content.Server.Store.Components; using Content.Server.Store.Systems; using Content.Shared.Access.Components; @@ -21,20 +24,25 @@ using Robust.Shared.Containers; using Robust.Shared.Player; using Robust.Shared.Utility; +using Content.Shared.CCVar; +using Robust.Shared.Configuration; namespace Content.Server.PDA { public sealed class PdaSystem : SharedPdaSystem { + [Dependency] private readonly RoundEndSystem _roundEndSystem = default!; [Dependency] private readonly CartridgeLoaderSystem _cartridgeLoader = default!; [Dependency] private readonly InstrumentSystem _instrument = default!; [Dependency] private readonly RingerSystem _ringer = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly StoreSystem _store = default!; + [Dependency] private readonly EmergencyShuttleSystem _emergencyShuttleSystem = default!; [Dependency] private readonly IChatManager _chatManager = default!; [Dependency] private readonly UserInterfaceSystem _ui = default!; [Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!; [Dependency] private readonly ContainerSystem _containerSystem = default!; + [Dependency] private readonly IConfigurationManager _cfg = default!; public override void Initialize() { @@ -51,6 +59,8 @@ public override void Initialize() SubscribeLocalEvent(OnUiMessage); SubscribeLocalEvent(OnUiMessage); + SubscribeLocalEvent(OnEmergencyChanged); + SubscribeLocalEvent(OnNotification); SubscribeLocalEvent(OnStationRenamed); @@ -104,6 +114,11 @@ private void OnStationRenamed(StationRenamedEvent ev) UpdateAllPdaUisOnStation(); } + private void OnEmergencyChanged(RoundEndSystemChangedEvent ev) + { + UpdateAllPdaUisOnStation(); + } + private void OnAlertLevelChanged(AlertLevelChangedEvent args) { UpdateAllPdaUisOnStation(); @@ -166,9 +181,18 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null, EntityUid? acto var programs = _cartridgeLoader.GetAvailablePrograms(uid, loader); var id = CompOrNull(pda.ContainedId); - var balance = 0; - if (actor_uid != null && TryComp(actor_uid, out var account)) - balance = account.Balance; + int? balance = null; + if (actor_uid is not null && TryComp(actor_uid, out var account)) + balance = account.Balance; + + TimeSpan shuttleTime; + var station = _station.GetOwningStation(uid); + if (!TryComp(station, out var stationEmergencyShuttleComponent) && _roundEndSystem.ExpectedCountdownEnd is not null) + shuttleTime = _roundEndSystem.ExpectedCountdownEnd.Value; + + else + shuttleTime = TimeSpan.FromMinutes(_cfg.GetCVar(CCVars.EmergencyShuttleDockTime)); + var state = new PdaUpdateState( programs, @@ -186,6 +210,7 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null, EntityUid? acto StationAlertColor = pda.StationAlertColor }, balance, + shuttleTime, pda.StationName, showUplink, hasInstrument, diff --git a/Content.Shared/PDA/PdaUpdateState.cs b/Content.Shared/PDA/PdaUpdateState.cs index 840f8c5ac1c..70dbbc4f0a0 100644 --- a/Content.Shared/PDA/PdaUpdateState.cs +++ b/Content.Shared/PDA/PdaUpdateState.cs @@ -17,7 +17,8 @@ public sealed class PdaUpdateState : CartridgeLoaderUiState // WTF is this. what public bool HasUplink; public bool CanPlayMusic; public string? Address; - public int Balance; + public int? Balance; + public TimeSpan? EvacShuttleTime; public PdaUpdateState( List programs, @@ -27,7 +28,8 @@ public PdaUpdateState( bool hasPai, bool hasBook, PdaIdInfoText pdaOwnerInfo, - int balance, + int? balance, + TimeSpan? evacShuttleTime, string? stationName, bool hasUplink = false, bool canPlayMusic = false, @@ -44,6 +46,7 @@ public PdaUpdateState( StationName = stationName; Address = address; Balance = balance; + EvacShuttleTime = evacShuttleTime; } } diff --git a/Resources/Locale/ru-RU/pda/pda-component.ftl b/Resources/Locale/ru-RU/pda/pda-component.ftl index 43656ee32a1..af3af1625ef 100644 --- a/Resources/Locale/ru-RU/pda/pda-component.ftl +++ b/Resources/Locale/ru-RU/pda/pda-component.ftl @@ -29,4 +29,5 @@ 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] +comp-pda-ui-balance = Баланс: [color=white]{ $balance }$[/color] +comp-pda-ui-left-time = Время до эвакуации: [color=white]{ $time }[/color]