From 1563eb9336368b85842ea243b12292c39d3c84cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl?= <78355193+Daniel-H123@users.noreply.github.com> Date: Sun, 7 Jan 2024 19:06:35 +0100 Subject: [PATCH] Markers - Add the option for UTC/System time timestamps (#9121) * Markers - Add setting for system timestamps * Moved time zone to different setting Added UTC Time zone Added UTC time offset slider Added translation in stringtable * Update fnc_onButtonClickConfirm.sqf Fixed mistake that added offset twice * - Removed tabs - Fixed calculating error * - Fixed tab problem Was a bit enthusiastic with removing tabs. This should to the trick. * - Changed tabs to spaces (Finaly) - Checked SQF with sqf_validator.py - Fixed decimal error by CBA menu * Delete build/_deps directory - This does not belong here * Update fnc_onButtonClickConfirm.sqf Added empty line back * Update addons/markers/functions/fnc_onButtonClickConfirm.sqf Formatting update Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * Update addons/markers/functions/fnc_onButtonClickConfirm.sqf Formatting update Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * Update initSettings.sqf Added newline at end of file * Update fnc_onButtonClickConfirm.sqf Fixed fnc header formatting * Update addons/markers/functions/fnc_onButtonClickConfirm.sqf Formatting Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> * Update fnc_onButtonClickConfirm.sqf Updated formatting * Implemented review changes * Review suggestion * Bugfix return absolute positive number with modulo * Updated script to allow offset to exeed midnight in the past * Updated script to allow offset to exeed midnight in the past * Updated script to allow offset to exeed midnight in the past * Updated hour offset calculation * Add support for UTC+13 and +14 timezone * Add minutes UTC offset to timestamp * Add UTC minutes offset setting * Add translation for UTC minute offset setting * Prevent timestamp going over 24 after adding minutes offset * Modify english description for offset settings * Update addons/markers/initSettings.sqf * Properly handle minute offset with negative timezone * Implemented better solution to handle negative timestamp seconds offset * reverted 'Implemented better solution to handle negative timestamp seconds offset' * Revert "Implemented better solution to handle negative timestamp seconds offset" This reverts commit d2599bd9aa6d954552bc01ca05a17901dfa1df06. * Update timestamp calculation comments * Update timestamp calculation comments * Update documentation in UTC timestamp calculation --------- Co-authored-by: PabstMirror Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com> --- .../functions/fnc_onButtonClickConfirm.sqf | 27 ++++- addons/markers/initSettings.inc.sqf | 31 ++++++ addons/markers/stringtable.xml | 99 +++++++++++++++++++ 3 files changed, 154 insertions(+), 3 deletions(-) diff --git a/addons/markers/functions/fnc_onButtonClickConfirm.sqf b/addons/markers/functions/fnc_onButtonClickConfirm.sqf index 2822cd69f0..c119e9f40e 100644 --- a/addons/markers/functions/fnc_onButtonClickConfirm.sqf +++ b/addons/markers/functions/fnc_onButtonClickConfirm.sqf @@ -1,6 +1,6 @@ #include "..\script_component.hpp" /* - * Author: Freddo + * Author: Freddo, Daniël H. * When the confirm button is pressed. * * Arguments: @@ -17,12 +17,33 @@ params ["_buttonOk"]; private _display = ctrlParent _buttonOk; -private _description = _display displayctrl IDC_INSERT_MARKER; +private _description = _display displayCtrl IDC_INSERT_MARKER; private _aceTimestamp = _display displayCtrl IDC_ACE_INSERT_MARKER_TIMESTAMP; // handle timestamp if (cbChecked _aceTimestamp && {ACE_player call FUNC(canTimestamp)}) then { - private _time = daytime; + // determine marker timestamp based on time settings + private _time = switch (GVAR(timestampTimezone)) do { + case 1: { + systemTime params ["", "", "", "_hour", "_min", "_sec"]; + _hour + _min/60 + _sec/3600 + }; + case 2: { + systemTimeUTC params ["", "", "", "_hour", "_min", "_sec"]; + _hourOffset = round (GVAR(timestampUTCOffset)); + _hour = _hour + _hourOffset; + + // add or subtract minutes offset based on the negative or positive timezone + _min = if (_hourOffset < 0) then { _min - GVAR(timestampUTCMinutesOffset) } else { _min + GVAR(timestampUTCMinutesOffset) }; + + // prevent the timestamp from exceeding 24 hours or going below 0 hours + _time = ((_hour + _min/60 + _sec/3600) % 24 + 24) % 24; + _time + }; + default { + dayTime + }; + }; // add timestamp suffix private _periodPostfix = ""; diff --git a/addons/markers/initSettings.inc.sqf b/addons/markers/initSettings.inc.sqf index ce8e8e0473..795ecb6aa5 100644 --- a/addons/markers/initSettings.inc.sqf +++ b/addons/markers/initSettings.inc.sqf @@ -32,6 +32,37 @@ private _categoryName = format ["ACE %1", localize ELSTRING(map,Module_DisplayNa true ] call CBA_fnc_addSetting; +[ + QGVAR(timestampTimezone), "LIST", + [LSTRING(TimestampTimezone), LSTRING(TimestampTimezoneDescription)], + [_categoryName, LLSTRING(Module_DisplayName)], + [ + [0, 1, 2], + [LSTRING(TimestampTimezoneIngameTime), LSTRING(TimestampTimezoneSystemTime), LSTRING(TimestampTimezoneUTCTime)], + 0 + ], + true +] call CBA_fnc_addSetting; + +[ + QGVAR(timestampUTCOffset), "SLIDER", + [LSTRING(TimestampUTCOffset), LSTRING(TimestampUTCOffsetDescription)], + [_categoryName, LLSTRING(Module_DisplayName)], + [-12, 14, 0, 0], + true +] call CBA_fnc_addSetting; + +[ + QGVAR(TimestampUTCMinutesOffset), "LIST", + [LSTRING(TimestampUTCMinutesOffset), LSTRING(TimestampUTCMinutesOffsetDescription)], + [_categoryName, LLSTRING(Module_DisplayName)], + [ + [0, 15, 30, 45], + [0, 15, 30, 45], + 0 + ] +] call CBA_fnc_addSetting; + [ QGVAR(timestampHourFormat), "LIST", [LSTRING(TimestampHourFormat), LSTRING(TimestampHourFormatDescription)], diff --git a/addons/markers/stringtable.xml b/addons/markers/stringtable.xml index f15394e3b5..b397b0520b 100644 --- a/addons/markers/stringtable.xml +++ b/addons/markers/stringtable.xml @@ -239,6 +239,105 @@ 시계 필요함 Relógio necessário + + Time Zone + Часовой пояс + Fuseau horaire + 時間帯 + Zona horaria + Strefa czasowa + Zeitzone + 时区 + 시간대 + + + Changes the time zone for the timestamp + Измените часовой пояс для метки времени + Modifiez le fuseau horaire pour l'horodatage + タイムスタンプの時間帯を変更します + Cambie la zona horaria para la marca de tiempo + Zmień strefę czasową dla znaczników czasu + Ändern Sie die Zeitzone für den Zeitstempel + 更改时间戳的时区 + 타임스탬프의 시간대를 변경하십시오 + + + In-game Time + Время в игре + Heure de jeu + ゲーム内時刻 + Hora del juego + Czas gry + Ingame-Zeit + 游戏内时间 + 게임 시간 + + + System Time + Системное время + Heure système + システム時刻 + Hora del sistema + Czas systemowy + Systemzeit + 系统时间 + 시스템 시간 + + + UTC Time + Время UTC + Heure UTC + UTC時刻 + Hora UTC + Czas UTC + UTC-Zeit + UTC时间 + UTC 시간 + + + UTC Offset + Смещение UTC + Décalage UTC + UTCオフセット + Desplazamiento UTC + Przesunięcie UTC + UTC-Verschiebung + UTC偏移量 + UTC 오프셋 + + + Changes the time offset for the UTC timestamp + Измените смещение времени для метки времени UTC + Modifier le décalage horaire pour l'horodatage UTC + UTCタイムスタンプの時差を変更する + Cambiar el desplazamiento horario para la marca de tiempo UTC + Zmień przesunięcie czasu dla sygnatury czasowej UTC + Ändere die Zeitverschiebung für den UTC-Zeitstempel + 更改UTC时间戳的时间偏移量 + UTC 타임 스탬프의 시간 오프셋을 변경하십시오 + + + UTC Minutes Offset + UTC Минутное Смещение + Décalage des minutes UTC + UTC分オフセット + Desplazamiento de minutos UTC + Przesunięcie minut UTC + UTC-Minutenversatz + UTC分钟偏移量 + UTC 분 오프셋 + + + Change the minute offset for the UTC timestamp + Изменить минутное смещение для времени UTC + Modifier le décalage des minutes pour l'horodatage UTC + UTCタイムスタンプの分差を変更する + Cambiar el desplazamiento de minutos para la marca de tiempo UTC + Zmień przesunięcie minut dla sygnatury czasowej UTC + Ändere den Minutenversatz für den UTC-Zeitstempel + 更改UTC时间戳的分钟偏移量 + UTC 타임 스탬프의 분 오프셋을 변경하십시오 + Timestamp Format Формат времени