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

фикс времени пда #142

Merged
merged 5 commits into from
Jun 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
6 changes: 3 additions & 3 deletions Content.Client/PDA/PdaMenu.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,12 @@
<ContainerButton Name="StationAlertLevelButton">
<RichTextLabel Name="StationAlertLevelLabel" Access="Public"/>
</ContainerButton>
<ContainerButton Name="StartTimeButton">
<RichTextLabel Name="StartTimeLabel" Access="Public"/>
</ContainerButton>
<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
30 changes: 17 additions & 13 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 Content.Shared._Sunrise.Time;
using Content.Client._Sunrise.Time;
using Content.Shared.CartridgeLoader;
using Content.Client.Message;
using Robust.Client.UserInterface;
Expand Down Expand Up @@ -122,13 +122,15 @@ public PdaMenu()
StationTimeButton.OnPressed += _ =>
{
var stationTime = _entitySystem.GetEntitySystem<TimeSystem>().GetStationTime();
_clipboard.SetText((stationTime.Time.ToString("hh\\:mm\\:ss")));
_clipboard.SetText($"{stationTime.Date} {stationTime.Time:hh\\:mm}");
};
StationDateButton.OnPressed += _ =>

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

StationAlertLevelInstructionsButton.OnPressed += _ =>
{
_clipboard.SetText(_instructions);
Expand Down Expand Up @@ -178,12 +180,13 @@ public void UpdateState(PdaUpdateState state)

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

StartTimeLabel.SetMarkup(Loc.GetString("comp-pda-ui-start-time",
("time", startTime.ToString("hh\\:mm"))));

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

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

// Sunrise-start
var remaining = TimeSpan.Zero;
Expand Down Expand Up @@ -385,12 +388,13 @@ protected override void Draw(DrawingHandleScreen handle)

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

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

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

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

namespace Content.Client._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 moscowTime = DateTime.UtcNow + TimeSpan.FromHours(3);
var stationTime = moscowTime.TimeOfDay;

var daysPassed = (int)stationTime.TotalHours / 24;
stationTime = stationTime.Subtract(TimeSpan.FromHours(daysPassed * 24));

var date = 13 + daysPassed;

return (stationTime, date);
}

public TimeSpan GetCurrentServerTime()
{
var moscowTime = DateTime.UtcNow + TimeSpan.FromHours(3);
return moscowTime.TimeOfDay;
}

public string GetDate()
{
return DateTime.Now.AddYears(1000).ToString("dd.MM.yyyy");
}
}
44 changes: 0 additions & 44 deletions Content.Shared/_Sunrise/Time/TimeSystem.cs

This file was deleted.

1 change: 0 additions & 1 deletion Resources/Locale/en-US/_sunrise/time/time.ftl

This file was deleted.

4 changes: 2 additions & 2 deletions Resources/Locale/en-US/pda/pda-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ 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 = Time: [color=white]{ $time }[/color]
comp-pda-ui-station-time = Date and Time: [color=white]{ $time }, { $date }[/color]

comp-pda-ui-station-date = Date: [color=white]{ $date }[/color]
comp-pda-ui-start-time = Shift duration: [color=white]{ $time }[/color]

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

Expand Down
1 change: 0 additions & 1 deletion Resources/Locale/ru-RU/_sunrise/time/time.ftl

This file was deleted.

22 changes: 20 additions & 2 deletions Resources/Locale/ru-RU/pda/pda-component.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,41 @@

# For the PDA screen
comp-pda-ui = ID: [color=white]{ $owner }[/color], [color=yellow]{ CAPITALIZE($jobTitle) }[/color]

comp-pda-ui-blank = ID:

comp-pda-ui-owner = Владелец: [color=white]{ $actualOwnerName }[/color]

comp-pda-io-program-list-button = Программы

comp-pda-io-settings-button = Настройки

comp-pda-io-program-fallback-title = Программа

comp-pda-io-no-programs-available = Нет доступных программ

pda-bound-user-interface-show-uplink-title = Открыть аплинк

pda-bound-user-interface-show-uplink-description = Получите доступ к своему аплинку

pda-bound-user-interface-lock-uplink-title = Закрыть аплинк

pda-bound-user-interface-lock-uplink-description = Предотвратите доступ к вашему аплинку персон без кода

comp-pda-ui-menu-title = КПК

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-date = Текущая дата: [color=white]{ $date }[/color]

comp-pda-ui-station-time = Время и дата: [color=white]{ $time }, { $date }[/color]

comp-pda-ui-start-time = Длительность смены: [color=white]{ $time }[/color]

comp-pda-ui-eject-id-button = Извлечь ID
comp-pda-ui-eject-pen-button = Извлечь ручку
comp-pda-ui-ringtone-button-description = Измените рингтон вашего КПК
Expand Down
Loading