ACE3/addons/markers/functions/fnc_onButtonClickConfirm.sqf

114 lines
3.3 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
/*
* Author: Freddo, Daniël H., johnb43
* When the confirm button is pressed.
*
* Arguments:
* 0: Confirm button <CONTROL>
*
* Return Value:
* None
*
* Example:
* [_buttonOk] call ACE_markers_fnc_onButtonClickConfirm
*
* Public: No
*/
params ["_buttonOk"];
private _display = ctrlParent _buttonOk;
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 <pabstmirror@gmail.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-01-07 18:06:35 +00:00
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 {
// Determine marker timestamp based on time settings
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 <pabstmirror@gmail.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-01-07 18:06:35 +00:00
private _time = switch (GVAR(timestampTimezone)) do {
case 1: {
systemTime select [3]
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 <pabstmirror@gmail.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-01-07 18:06:35 +00:00
};
case 2: {
systemTimeUTC params ["", "", "", "_hour", "_min", "_sec", "_msec"];
private _hourOffset = round GVAR(timestampUTCOffset);
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 <pabstmirror@gmail.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-01-07 18:06:35 +00:00
_hour = _hour + _hourOffset;
// 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) };
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 <pabstmirror@gmail.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-01-07 18:06:35 +00:00
// 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)
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 <pabstmirror@gmail.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-01-07 18:06:35 +00:00
};
default {
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]
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 <pabstmirror@gmail.com> Co-authored-by: Grim <69561145+LinkIsGrim@users.noreply.github.com> Co-authored-by: johnb432 <58661205+johnb432@users.noreply.github.com>
2024-01-07 18:06:35 +00:00
};
};
_time params ["_hour", "_min", "_sec", "_msec"];
// Add timestamp suffix
private _periodPostfix = "";
if (GVAR(timestampHourFormat) == 12) then {
if (_hour == 0) exitWith {
_hour = _hour + 12;
_periodPostfix = " am";
};
if (_hour == 12) exitWith {
_periodPostfix = " pm";
};
if (_hour < 12) then {
_periodPostfix = " am";
} else {
_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,
_periodPostfix
];
};