From 474ecdd93b0358ab88026993fbe9d10f5a2b0733 Mon Sep 17 00:00:00 2001
From: johnb432 <58661205+johnb432@users.noreply.github.com>
Date: Sun, 7 Jan 2024 19:26:10 +0100
Subject: [PATCH] Markers - Add true milliseconds as a timestamp option (#9690)
* Added real milliseconds to marker timestamp options
* Fixed tabs
* portuguese translation
* Update fnc_onButtonClickConfirm.sqf
---------
Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com>
---
.../functions/fnc_onButtonClickConfirm.sqf | 79 ++++++++++++++-----
addons/markers/initSettings.inc.sqf | 7 +-
addons/markers/stringtable.xml | 23 +++---
3 files changed, 74 insertions(+), 35 deletions(-)
diff --git a/addons/markers/functions/fnc_onButtonClickConfirm.sqf b/addons/markers/functions/fnc_onButtonClickConfirm.sqf
index c119e9f40e..622a306e38 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, Daniël H.
+ * Author: Freddo, Daniël H., johnb43
* When the confirm button is pressed.
*
* Arguments:
@@ -14,61 +14,100 @@
*
* Public: No
*/
+
params ["_buttonOk"];
private _display = ctrlParent _buttonOk;
private _description = _display displayCtrl IDC_INSERT_MARKER;
private _aceTimestamp = _display displayCtrl IDC_ACE_INSERT_MARKER_TIMESTAMP;
-// handle timestamp
+// Handle timestamp
if (cbChecked _aceTimestamp && {ACE_player call FUNC(canTimestamp)}) then {
- // determine marker timestamp based on time settings
+ // 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
+ systemTime select [3]
};
case 2: {
- systemTimeUTC params ["", "", "", "_hour", "_min", "_sec"];
- _hourOffset = round (GVAR(timestampUTCOffset));
+ systemTimeUTC params ["", "", "", "_hour", "_min", "_sec", "_msec"];
+
+ private _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) };
+ // Add or subtract minutes offset based on the negative or positive timezone
+ if (GVAR(timestampUTCMinutesOffset) != 0) then {
+ _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
+ // Add/remove extra hours from minutes
+ _hour = _hour + floor (_min / 60);
+ _min = (_min % 60 + 60) % 60; // ensure that minutes are between 0 and 59 (included)
+ };
+
+ [(_hour % 24 + 24) % 24, _min, _sec, _msec] // ensure that hours are between 0 and 23 (included)
};
default {
- dayTime
+ private _daytime = dayTime;
+
+ private _hour = floor _daytime;
+ private _min = floor ((_daytime - _hour) * 60);
+ private _sec = floor ((((_daytime - _hour) * 60) - _min) * 60);
+ private _msec = floor ((((((_daytime - _hour) * 60) - _min) * 60) - _sec) * 1000);
+
+ [_hour, _min, _sec, _msec]
};
};
- // add timestamp suffix
+ _time params ["_hour", "_min", "_sec", "_msec"];
+
+ // Add timestamp suffix
private _periodPostfix = "";
+
if (GVAR(timestampHourFormat) == 12) then {
- if (floor _time == 0) exitWith {
- _time = _time + 12;
+ if (_hour == 0) exitWith {
+ _hour = _hour + 12;
_periodPostfix = " am";
};
- if (floor _time == 12) exitWith {
+ if (_hour == 12) exitWith {
_periodPostfix = " pm";
};
- if (_time < 12) then {
+ if (_hour < 12) then {
_periodPostfix = " am";
} else {
- _time = _time - 12;
+ _hour = _hour - 12;
_periodPostfix = " pm";
};
};
+ private _format = switch (GVAR(timestampFormat)) do {
+ case "HH": {"%1"};
+ case "HH:MM": {"%1:%2"};
+ case "HH:MM:SS": {"%1:%2:%3"};
+ case "HH:MM:SS:MM": { // milliseconds are displayed as 0 to 59
+ _msec = [_msec * 60 / 1000, 2] call CBA_fnc_formatNumber;
+
+ "%1:%2:%3:%4"
+ };
+ case "HH:MM:SS.mmm": { // milliseconds are displayed as 0 to 999
+ _msec = [_msec, 3] call CBA_fnc_formatNumber;
+
+ "%1:%2:%3.%4"
+ };
+ };
+
+ _time = format [
+ _format,
+ [_hour, 2] call CBA_fnc_formatNumber,
+ [_min, 2] call CBA_fnc_formatNumber,
+ [_sec, 2] call CBA_fnc_formatNumber,
+ _msec
+ ];
+
_description ctrlSetText format [
"%1 [%2%3]",
ctrlText _description,
- [_time, GVAR(timestampFormat)] call BIS_fnc_timeToString,
+ _time,
_periodPostfix
];
};
diff --git a/addons/markers/initSettings.inc.sqf b/addons/markers/initSettings.inc.sqf
index 795ecb6aa5..65bf17e8b6 100644
--- a/addons/markers/initSettings.inc.sqf
+++ b/addons/markers/initSettings.inc.sqf
@@ -79,7 +79,8 @@ private _formatDescription = [
LLSTRING(TimestampFormatDescription1),
LLSTRING(TimestampFormatDescription2),
LLSTRING(TimestampFormatDescription3),
- LLSTRING(TimestampFormatDescription4)
+ LLSTRING(TimestampFormatDescription4),
+ LLSTRING(TimestampFormatDescription5)
] joinString endl;
[
@@ -87,8 +88,8 @@ private _formatDescription = [
[LSTRING(timestampFormat), _formatDescription],
[_categoryName, LLSTRING(Module_DisplayName)],
[
- ["HH", "HH:MM", "HH:MM:SS", "HH:MM:SS:MM"],
- ["HH", "HH:MM", "HH:MM:SS", "HH:MM:SS:MM"],
+ ["HH", "HH:MM", "HH:MM:SS", "HH:MM:SS:MM", "HH:MM:SS.mmm"],
+ ["HH", "HH:MM", "HH:MM:SS", "HH:MM:SS:MM", "HH:MM:SS.mmm"],
1
]
] call CBA_fnc_addSetting;
diff --git a/addons/markers/stringtable.xml b/addons/markers/stringtable.xml
index b397b0520b..b4a772e171 100644
--- a/addons/markers/stringtable.xml
+++ b/addons/markers/stringtable.xml
@@ -315,7 +315,7 @@
Ändere die Zeitverschiebung für den UTC-Zeitstempel
更改UTC时间戳的时间偏移量
UTC 타임 스탬프의 시간 오프셋을 변경하십시오
-
+
UTC Minutes Offset
UTC Минутное Смещение
@@ -404,17 +404,16 @@
SS - Segundos
- "MM" - Milliseconds
- "МС" - Миллисекунда
- "MM" - Millisecondes
- "MM" - ミリ秒
- "MM" - Milisegundos
- "MM" - Milisekundy
- "MS" - Milisekunden
- "MS" - Millisecondi
- "MS"—毫秒
- "MS" - 밀리초
- MM - Milisegundos
+ "MM" - Milliseconds (from 0 to 59)
+ "MM" - Millisecondes (de 0 à 59)
+ "MS" - Milisekunden (von 0 bis 59)
+ "MS" - Milissegundos (de 0 a 59)
+
+
+ "mmm" - Milliseconds (from 0 to 999)
+ "mmm" - Millisecondes (de 0 à 999)
+ "mmm" - Milisekunden (von 0 bis 999)
+ "mmm" - Milissegundos (de 0 a 999)
Timestamp Hour Format