Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Тупой гит #23

Merged
merged 2 commits into from
Jun 5, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Отображение времени к прибытию эвак шаттла в КПК
VigersRay committed Jun 5, 2024
commit cb861c09faf56e861e73c4cadc8c8b5be6b110f2
3 changes: 3 additions & 0 deletions Content.Client/PDA/PdaMenu.xaml
Original file line number Diff line number Diff line change
@@ -43,6 +43,9 @@
<ContainerButton Name="StationTimeButton">
<RichTextLabel Name="StationTimeLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="ShuttleTimeButton">
<RichTextLabel Name="ShuttleTimeLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="StationAlertLevelInstructionsButton">
<RichTextLabel Name="StationAlertLevelInstructions" Access="Public"/>
</ContainerButton>
56 changes: 53 additions & 3 deletions Content.Client/PDA/PdaMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -32,7 +32,11 @@ 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");


// Sunrise-start
private TimeSpan? _evacShuttleTime;
private EvacShuttleStatus _evacShuttleStatus;
// Sunrise-end

private int _currentView;

@@ -125,7 +129,7 @@ public PdaMenu()
_clipboard.SetText(_instructions);
};




HideAllViews();
@@ -136,6 +140,11 @@ public void UpdateState(PdaUpdateState state)
{
FlashLightToggleButton.IsActive = state.FlashlightEnabled;

// Sunrise-start
_evacShuttleTime = state.PdaOwnerInfo.EvacShuttleTime;
_evacShuttleStatus = state.PdaOwnerInfo.EvacShuttleStatus;
// Sunrise-end

if (state.PdaOwnerInfo.ActualOwnerName != null)
{
_pdaOwner = state.PdaOwnerInfo.ActualOwnerName;
@@ -160,13 +169,25 @@ public void UpdateState(PdaUpdateState state)
_stationName = state.StationName ?? Loc.GetString("comp-pda-ui-unknown");
StationNameLabel.SetMarkup(Loc.GetString("comp-pda-ui-station",
("station", _stationName)));


var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);

StationTimeLabel.SetMarkup(Loc.GetString("comp-pda-ui-station-time",
("time", stationTime.ToString("hh\\:mm\\:ss"))));

// Sunrise-start
var remaining = TimeSpan.Zero;

if (state.PdaOwnerInfo.EvacShuttleTime != null)
remaining = TimeSpan.FromSeconds(Math.Max((state.PdaOwnerInfo.EvacShuttleTime.Value - _gameTiming.CurTime).TotalSeconds, 0));

var statusText = EvacShuttleTitle(_evacShuttleStatus);

ShuttleTimeLabel.SetMarkup(Loc.GetString(statusText,
("time", remaining.ToString("hh\\:mm\\:ss"))));
// Sunrise-end

var alertLevel = state.PdaOwnerInfo.StationAlertLevel;
var alertColor = state.PdaOwnerInfo.StationAlertColor;
var alertLevelKey = alertLevel != null ? $"alert-level-{alertLevel}" : "alert-level-unknown";
@@ -332,6 +353,23 @@ private void HideAllViews()
}
}

// Sunrise-start
private string EvacShuttleTitle(EvacShuttleStatus status)
{
switch (status)
{
case EvacShuttleStatus.WaitingToLaunch:
return "comp-pda-ui-shuttle-launch-time";
case EvacShuttleStatus.WaitingToArrival:
return "comp-pda-ui-shuttle-arrival-time";
case EvacShuttleStatus.WaitingToCall:
return "comp-pda-ui-shuttle-call-time";
default:
return "comp-pda-ui-shuttle-call-time";
}
}
// Sunrise-end

protected override void Draw(DrawingHandleScreen handle)
{
base.Draw(handle);
@@ -340,6 +378,18 @@ protected override void Draw(DrawingHandleScreen handle)

StationTimeLabel.SetMarkup(Loc.GetString("comp-pda-ui-station-time",
("time", stationTime.ToString("hh\\:mm\\:ss"))));

// Sunrise-start
var remaining = TimeSpan.Zero;

if (_evacShuttleTime != null)
remaining = TimeSpan.FromSeconds(Math.Max((_evacShuttleTime.Value - _gameTiming.CurTime).TotalSeconds, 0));

var statusText = EvacShuttleTitle(_evacShuttleStatus);

ShuttleTimeLabel.SetMarkup(Loc.GetString(statusText,
("time", remaining.ToString("hh\\:mm\\:ss"))));
// Sunrise-end
}
}
}
47 changes: 46 additions & 1 deletion Content.Server/PDA/PdaSystem.cs
Original file line number Diff line number Diff line change
@@ -5,6 +5,9 @@
using Content.Server.Instruments;
using Content.Server.Light.EntitySystems;
using Content.Server.PDA.Ringer;
using Content.Server.RoundEnd;
using Content.Server.Shuttles.Components;
using Content.Server.Shuttles.Systems;
using Content.Server.Station.Systems;
using Content.Server.Store.Components;
using Content.Server.Store.Systems;
@@ -19,9 +22,12 @@
using Content.Shared.Store.Components;
using Robust.Server.Containers;
using Robust.Server.GameObjects;
using Robust.Shared.Configuration;
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Robust.Shared.Utility;
using Content.Shared.CCVar;
using Robust.Shared.Timing;

namespace Content.Server.PDA
{
@@ -36,6 +42,9 @@ public sealed class PdaSystem : SharedPdaSystem
[Dependency] private readonly UserInterfaceSystem _ui = default!;
[Dependency] private readonly UnpoweredFlashlightSystem _unpoweredFlashlight = default!;
[Dependency] private readonly ContainerSystem _containerSystem = default!;
[Dependency] private readonly RoundEndSystem _roundEndSystem = default!;
[Dependency] private readonly EmergencyShuttleSystem _emergencyShuttleSystem = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;

public override void Initialize()
{
@@ -67,6 +76,7 @@ protected override void OnComponentInit(EntityUid uid, PdaComponent pda, Compone

UpdateAlertLevel(uid, pda);
UpdateStationName(uid, pda);
UpdateEvacShuttle(uid, pda); // Sunrise-edit
}

protected override void OnItemInserted(EntityUid uid, PdaComponent pda, EntInsertedIntoContainerMessage args)
@@ -158,6 +168,7 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)

UpdateStationName(uid, pda);
UpdateAlertLevel(uid, pda);
UpdateEvacShuttle(uid, pda); // Sunrise-edit
// 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.

@@ -179,7 +190,9 @@ public void UpdatePdaUi(EntityUid uid, PdaComponent? pda = null)
IdOwner = id?.FullName,
JobTitle = id?.JobTitle,
StationAlertLevel = pda.StationAlertLevel,
StationAlertColor = pda.StationAlertColor
StationAlertColor = pda.StationAlertColor,
EvacShuttleStatus = pda.ShuttleStatus, // Sunrise-edit
EvacShuttleTime = pda.ShuttleTime // Sunrise-edit
},
pda.StationName,
showUplink,
@@ -266,6 +279,38 @@ private void UpdateStationName(EntityUid uid, PdaComponent pda)
pda.StationName = station is null ? null : Name(station.Value);
}

// Sunrise-start
private void UpdateEvacShuttle(EntityUid uid, PdaComponent pda)
{
TimeSpan? shuttleTime;
EvacShuttleStatus shuttleStatus;
if (_emergencyShuttleSystem.EmergencyShuttleArrived)
{
shuttleTime = _gameTiming.CurTime + TimeSpan.FromSeconds(_emergencyShuttleSystem.СonsoleAccumulator);
shuttleStatus = EvacShuttleStatus.WaitingToLaunch;
}
else
{
if (_roundEndSystem.ExpectedCountdownEnd != null)
{
shuttleTime = _roundEndSystem.ExpectedCountdownEnd;
shuttleStatus = EvacShuttleStatus.WaitingToArrival;
}
else
{
shuttleTime = _roundEndSystem.TimeToCallShuttle();
shuttleStatus = EvacShuttleStatus.WaitingToCall;
}
}
var station = _station.GetOwningStation(uid);
if (!TryComp<StationEmergencyShuttleComponent>(station, out var stationEmergencyShuttleComponent))
return;

pda.ShuttleStatus = shuttleStatus;
pda.ShuttleTime = shuttleTime;
}
// Sunrise-end

private void UpdateAlertLevel(EntityUid uid, PdaComponent pda)
{
var station = _station.GetOwningStation(uid);
10 changes: 10 additions & 0 deletions Content.Server/RoundEnd/RoundEndSystem.cs
Original file line number Diff line number Diff line change
@@ -363,6 +363,16 @@ public override void Update(float frameTime)
SetAutoCallTime();
}
}

// Sunrise-start
public TimeSpan TimeToCallShuttle()
{
var autoCalledBefore = _autoCalledBefore
? _cfg.GetCVar(CCVars.EmergencyShuttleAutoCallExtensionTime)
: _cfg.GetCVar(CCVars.EmergencyShuttleAutoCallTime);
return AutoCallStartTime + TimeSpan.FromMinutes(autoCalledBefore);
}
// Sunrise-end
}

public sealed class RoundEndSystemChangedEvent : EntityEventArgs
Original file line number Diff line number Diff line change
@@ -39,6 +39,10 @@ public sealed partial class EmergencyShuttleSystem
/// </summary>
private float _consoleAccumulator = float.MinValue;

// Sunrise-start
public float СonsoleAccumulator => _consoleAccumulator;
// Sunrise-end

/// <summary>
/// How long after the transit is over to end the round.
/// </summary>
17 changes: 17 additions & 0 deletions Content.Server/Shuttles/Systems/EmergencyShuttleSystem.cs
Original file line number Diff line number Diff line change
@@ -37,6 +37,7 @@
using Robust.Shared.Random;
using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Content.Server.GameTicking;

namespace Content.Server.Shuttles.Systems;

@@ -71,6 +72,10 @@ public sealed partial class EmergencyShuttleSystem : EntitySystem

private const float ShuttleSpawnBuffer = 1f;

// Sunrise-start
public TimeSpan? DockTime;
// Sunrise-end

private bool _emergencyShuttleEnabled;

[ValidatePrototypeId<TagPrototype>]
@@ -91,9 +96,17 @@ public override void Initialize()
SubscribeLocalEvent<EmergencyShuttleComponent, FTLStartedEvent>(OnEmergencyFTL);
SubscribeLocalEvent<EmergencyShuttleComponent, FTLCompletedEvent>(OnEmergencyFTLComplete);
SubscribeNetworkEvent<EmergencyShuttleRequestPositionMessage>(OnShuttleRequestPosition);
SubscribeLocalEvent<RoundEndTextAppendEvent>(OnRoundEnded); // Sunrise-edit
InitializeEmergencyConsole();
}

// Sunrise-start
private void OnRoundEnded(RoundEndTextAppendEvent ev)
{
DockTime = null;
}
// Sunrise-end

private void OnRoundStart(RoundStartingEvent ev)
{
CleanupEmergencyConsole();
@@ -271,6 +284,10 @@ public void CallEmergencyShuttle(EntityUid stationUid, StationEmergencyShuttleCo

var targetGrid = _station.GetLargestGrid(Comp<StationDataComponent>(stationUid));

// Sunrise-start
DockTime = _timing.CurTime;
// Sunrise-end

// UHH GOOD LUCK
if (targetGrid == null)
{
2 changes: 2 additions & 0 deletions Content.Shared/PDA/PdaComponent.cs
Original file line number Diff line number Diff line change
@@ -40,5 +40,7 @@ public sealed partial class PdaComponent : Component
[ViewVariables] public string? StationName;
[ViewVariables] public string? StationAlertLevel;
[ViewVariables] public Color StationAlertColor = Color.White;
[ViewVariables] public TimeSpan? ShuttleTime; // Sunrise-edit
[ViewVariables] public EvacShuttleStatus ShuttleStatus; // Sunrise-edit
}
}
11 changes: 11 additions & 0 deletions Content.Shared/PDA/PdaUpdateState.cs
Original file line number Diff line number Diff line change
@@ -49,5 +49,16 @@ public struct PdaIdInfoText
public string? JobTitle;
public string? StationAlertLevel;
public Color StationAlertColor;
public TimeSpan? EvacShuttleTime; // Sunrise-edit
public EvacShuttleStatus EvacShuttleStatus; // Sunrise-edit
}

// Sunrise-start
public enum EvacShuttleStatus
{
WaitingToCall,
WaitingToArrival,
WaitingToLaunch
}
// Sunrise-end
}
6 changes: 6 additions & 0 deletions Resources/Locale/ru-RU/pda/pda-component.ftl
Original file line number Diff line number Diff line change
@@ -29,3 +29,9 @@ comp-pda-ui-unknown = Неизвестно
comp-pda-ui-unassigned = Не назначено
pda-notification-message = [font size=12][bold]КПК[/bold] { $header }: [/font]
"{ $message }"

# Sunrise-start
comp-pda-ui-shuttle-call-time = До смены экипажа: [color=white]{ $time }[/color]
comp-pda-ui-shuttle-arrival-time = До прибытия шаттла: [color=white]{ $time }[/color]
comp-pda-ui-shuttle-launch-time = До запуска шаттла: [color=white]{ $time }[/color]
# Sunrise-end

Unchanged files with check annotations Beta

# Attempted to keep the files in alphabetical order so its easier to audit.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 0.license: 'CLA' is not a license.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 1.license: 'CLA' is not a license.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 2.license: 'CLA' is not a license.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 3.license: 'CLA' is not a license.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 4.license: 'CLA' is not a license.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 5.license: 'CLA' is not a license.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 6.license: 'CLA' is not a license.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 7.license: 'CLA' is not a license.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 8.license: 'CLA' is not a license.

Check failure on line 1 in Resources/Textures/Tiles/attributions.yml

GitHub Actions / YAML RGA schema validator

[/Resources/Textures/Tiles/attributions.yml] 9.license: 'CLA' is not a license.
# Finding individual authors is an unfeasible task. If you can reference the author please do so.
- files: ["tech_maint.png"]