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>
This commit is contained in:
johnb432 2024-01-07 19:26:10 +01:00 committed by GitHub
parent 1563eb9336
commit 474ecdd93b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 35 deletions

View File

@ -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
];
};

View File

@ -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;

View File

@ -315,7 +315,7 @@
<German>Ändere die Zeitverschiebung für den UTC-Zeitstempel</German>
<Chinesesimp>更改UTC时间戳的时间偏移量</Chinesesimp>
<Korean>UTC 타임 스탬프의 시간 오프셋을 변경하십시오</Korean>
</Key>
</Key>
<Key ID="STR_ACE_Markers_TimestampUTCMinutesOffset">
<English>UTC Minutes Offset</English>
<Russian>UTC Минутное Смещение</Russian>
@ -404,17 +404,16 @@
<Portuguese>SS - Segundos</Portuguese>
</Key>
<Key ID="STR_ACE_Markers_TimestampFormatDescription4">
<English>"MM" - Milliseconds</English>
<Russian>"МС" - Миллисекунда</Russian>
<French>"MM" - Millisecondes</French>
<Japanese>"MM" - ミリ秒</Japanese>
<Spanish>"MM" - Milisegundos</Spanish>
<Polish>"MM" - Milisekundy</Polish>
<German>"MS" - Milisekunden</German>
<Italian>"MS" - Millisecondi</Italian>
<Chinesesimp>"MS"—毫秒</Chinesesimp>
<Korean>"MS" - 밀리초</Korean>
<Portuguese>MM - Milisegundos</Portuguese>
<English>"MM" - Milliseconds (from 0 to 59)</English>
<French>"MM" - Millisecondes (de 0 à 59)</French>
<German>"MS" - Milisekunden (von 0 bis 59)</German>
<Portuguese>"MS" - Milissegundos (de 0 a 59)</Portuguese>
</Key>
<Key ID="STR_ACE_Markers_TimestampFormatDescription5">
<English>"mmm" - Milliseconds (from 0 to 999)</English>
<French>"mmm" - Millisecondes (de 0 à 999)</French>
<German>"mmm" - Milisekunden (von 0 bis 999)</German>
<Portuguese>"mmm" - Milissegundos (de 0 a 999)</Portuguese>
</Key>
<Key ID="STR_ACE_Markers_TimestampHourFormat">
<English>Timestamp Hour Format</English>