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

Отображение даты в КПК #47

Merged
merged 11 commits into from
Jun 8, 2024
3 changes: 3 additions & 0 deletions Content.Client/PDA/PdaMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@
<ContainerButton Name="StationTimeButton">
<RichTextLabel Name="StationTimeLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="StationDateButton">
<RichTextLabel Name="StationDateLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="ShuttleTimeButton">
<RichTextLabel Name="ShuttleTimeLabel" Access="Public"/>
</ContainerButton>
Expand Down
29 changes: 21 additions & 8 deletions Content.Client/PDA/PdaMenu.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Content.Client.GameTicking.Managers;
using Content.Shared.PDA;
using Robust.Shared.Utility;
using Content.Shared._Sunrise.Time;
using Content.Shared.CartridgeLoader;
using Content.Client.Message;
using Robust.Client.UserInterface;
Expand All @@ -9,6 +9,7 @@
using Robust.Client.UserInterface.XAML;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Timing;
using Robust.Shared.Utility;

namespace Content.Client.PDA
{
Expand Down Expand Up @@ -120,10 +121,14 @@ public PdaMenu()

StationTimeButton.OnPressed += _ =>
{
var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
_clipboard.SetText((stationTime.ToString("hh\\:mm\\:ss")));
var stationTime = _entitySystem.GetEntitySystem<TimeSystem>().GetStationTime();
_clipboard.SetText((stationTime.Time.ToString("hh\\:mm\\:ss")));
};
StationDateButton.OnPressed += _ =>
{
var stationDate = _entitySystem.GetEntitySystem<TimeSystem>().GetDate();
_clipboard.SetText((stationDate));
};

StationAlertLevelInstructionsButton.OnPressed += _ =>
{
_clipboard.SetText(_instructions);
Expand Down Expand Up @@ -171,10 +176,14 @@ public void UpdateState(PdaUpdateState state)
("station", _stationName)));


var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
var stationTime = _entitySystem.GetEntitySystem<TimeSystem>().GetStationTime();
var stationDate = _entitySystem.GetEntitySystem<TimeSystem>().GetDate();

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

StationDateLabel.SetMarkup(Loc.GetString("comp-pda-ui-station-date",
("date", stationDate)));

// Sunrise-start
var remaining = TimeSpan.Zero;
Expand Down Expand Up @@ -374,10 +383,14 @@ protected override void Draw(DrawingHandleScreen handle)
{
base.Draw(handle);

var stationTime = _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan);
var stationTime = _entitySystem.GetEntitySystem<TimeSystem>().GetStationTime();
var stationDate = _entitySystem.GetEntitySystem<TimeSystem>().GetDate();

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

StationDateLabel.SetMarkup(Loc.GetString("comp-pda-ui-station-date",
("date", stationDate)));

// Sunrise-start
var remaining = TimeSpan.Zero;
Expand Down
44 changes: 44 additions & 0 deletions Content.Shared/_Sunrise/Time/TimeSystem.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using Content.Shared.Examine;
using Content.Shared.GameTicking;
using Robust.Shared.Timing;

namespace Content.Shared._Sunrise.Time
{
public sealed class TimeSystem : EntitySystem
{
[Dependency] private readonly IGameTiming _timing = default!;

private TimeSpan _roundStart;

public override void Initialize()
{
base.Initialize();
SubscribeNetworkEvent<TickerLobbyStatusEvent>(LobbyStatus);
}

private void LobbyStatus(TickerLobbyStatusEvent ev)
{
_roundStart = ev.RoundStartTimeSpan;
}

public (TimeSpan Time, int Date) GetStationTime()
{
var stationTime = _timing.CurTime.Subtract(_roundStart).Add(TimeSpan.FromHours(12));

var date = 13;
while (stationTime.TotalHours >= 24)
{
stationTime.Subtract(TimeSpan.FromHours(24));
date = date + 1;
}

return (stationTime, date);
}

public string GetDate()
{
// please tell me you guys aren't gonna have a 4 week round yet...
return DateTime.UtcNow.AddYears(1000).ToString("dd.MM.yyyy");
}
}
}
1 change: 1 addition & 0 deletions Resources/Locale/en-US/_sunrise/time/time.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
standard-date = 417/11/{$date}
2 changes: 1 addition & 1 deletion Resources/Locale/en-US/pda/pda-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ comp-pda-ui-station-alert-level = Alert Level: [color={ $color }]{ $level }[/col

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-station-time = The current time since the start of the shift: [color=white]{ $time } { $date }[/color]

comp-pda-ui-eject-id-button = Eject ID

Expand Down
1 change: 1 addition & 0 deletions Resources/Locale/ru-RU/_sunrise/time/time.ftl
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
standard-date = 417/11/{$date}
3 changes: 2 additions & 1 deletion Resources/Locale/ru-RU/pda/pda-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ comp-pda-ui-footer = Карманный Персональный Компьют
comp-pda-ui-station = Станция: [color=white]{ $station }[/color]
comp-pda-ui-station-alert-level = Уровень угрозы: [color={ $color }]{ $level }[/color]
comp-pda-ui-station-alert-level-instructions = Инструкции: [color=white]{ $instructions }[/color]
comp-pda-ui-station-time = Продолжительность смены: [color=white]{ $time }[/color]
comp-pda-ui-station-time = Текущее время с начала смены: [color=white]{ $time }[/color]
comp-pda-ui-station-date = Текущая дата: [color=white]{ $date }[/color]
comp-pda-ui-eject-id-button = Извлечь ID
comp-pda-ui-eject-pen-button = Извлечь ручку
comp-pda-ui-ringtone-button-description = Измените рингтон вашего КПК
Expand Down
Loading