Markers - Add timestamps (#7947)

* Add timestamps to markers

* Tiny tweaks

* Update addons/markers/functions/fnc_canTimestamp.sqf

Co-authored-by: Brett <brett@bmandesigns.com>

* Update addons/markers/functions/fnc_initInsertMarker.sqf

Co-authored-by: Brett <brett@bmandesigns.com>

* Add timestamp format setting

* Script cleanup, move checkbox under desc

* Fix stringtable validation

* Tweaks

* Remove styling from stringtable

* Edit timestamps instead of append

Credits to @PabstMirror

Co-authored-by: Brett <brett@bmandesigns.com>
This commit is contained in:
Freddo 2020-10-29 17:36:59 +01:00 committed by GitHub
parent 42f4edc9b7
commit afb3dad22b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 317 additions and 48 deletions

View File

@ -5,6 +5,7 @@ class RscStructuredText;
class RscButtonMenuOK;
class RscButtonMenuCancel;
class RscButtonMenu;
class RscCheckBox;
class RscEdit;
class RscCombo;
class RscSlider;
@ -16,17 +17,23 @@ class RscDisplayInsertMarker {
movingEnable = 1;
class controls {
class TimeStampText: RscStructuredText {
idc = IDC_ACE_INSERT_MARKER_TIMESTAMP_TEXT;
};
class TimeStamp: RscCheckBox {
idc = IDC_ACE_INSERT_MARKER_TIMESTAMP;
};
class MarkerShape: RscCombo {
idc = 1210;
idc = IDC_ACE_INSERT_MARKER_SHAPE;
};
class MarkerColor: RscCombo {
idc = 1211;
idc = IDC_ACE_INSERT_MARKER_COLOR;
};
class MarkerAngle: RscXSliderH {
idc = 1220;
idc = IDC_ACE_INSERT_MARKER_ANGLE;
};
class MarkerAngleText: RscText {
idc = 1221;
idc = IDC_ACE_INSERT_MARKER_ANGLE_TEXT;
};
};
};

View File

@ -14,3 +14,6 @@ PREP(canMove);
PREP(onMouseButtonDown);
PREP(onMouseButtonUp);
PREP(movePFH);
PREP(canTimestamp);
PREP(onButtonClickConfirm);
PREP(onCheckedChangedTimestamp);

View File

@ -0,0 +1,26 @@
#include "script_component.hpp"
/*
* Author: Freddo
* Checks whether a unit is able to timestamp.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Whether unit is able to timestamp <BOOL>
*
* Example:
* [ACE_Player] call ace_markers_fnc_canTimestamp
*
* Public: No
*/
params [["_unit", ACE_player]];
private _assignedItems = assignedItems _unit;
private _index = _assignedItems findIf {
([_x] call EFUNC(common,getItemType)) isEqualTo ["item", "watch"]
};
_index != -1

View File

@ -1,4 +1,5 @@
#include "script_component.hpp"
#include "\A3\ui_f\hpp\defineResincl.inc"
/*
* Author: BIS, commy2, Timi007
* Sets up the marker placement
@ -29,11 +30,11 @@
};
//BIS Controls:
private _text = _display displayctrl 101;
private _picture = _display displayctrl 102;
private _channel = _display displayctrl 103;
private _buttonOK = _display displayctrl 1;
private _buttonCancel = _display displayctrl 2;
private _text = _display displayctrl IDC_INSERT_MARKER;
private _picture = _display displayctrl IDC_INSERT_MARKER_PICTURE;
private _channel = _display displayctrl IDC_INSERT_MARKER_CHANNELS;
private _buttonOK = _display displayctrl IDC_OK;
private _buttonCancel = _display displayctrl IDC_CANCEL;
private _description = _display displayctrl 1100;
private _title = _display displayctrl 1001;
private _descriptionChannel = _display displayctrl 1101;
@ -41,14 +42,16 @@
//ACE Controls:
// _sizeX = _display displayctrl 1200;
// _sizeY = _display displayctrl 1201;
private _aceShapeLB = _display displayctrl 1210;
private _aceColorLB = _display displayctrl 1211;
private _aceAngleSlider = _display displayctrl 1220;
private _aceAngleSliderText = _display displayctrl 1221;
private _aceTimestamp = _display displayCtrl IDC_ACE_INSERT_MARKER_TIMESTAMP;
private _aceTimestampText = _display displayCtrl IDC_ACE_INSERT_MARKER_TIMESTAMP_TEXT;
private _aceShapeLB = _display displayctrl IDC_ACE_INSERT_MARKER_SHAPE;
private _aceColorLB = _display displayctrl IDC_ACE_INSERT_MARKER_COLOR;
private _aceAngleSlider = _display displayctrl IDC_ACE_INSERT_MARKER_ANGLE;
private _aceAngleSliderText = _display displayctrl IDC_ACE_INSERT_MARKER_ANGLE_TEXT;
private _mapDisplay = displayParent _display;
if (isNull _mapDisplay) exitWith {ERROR("No Map");};
private _mapCtrl = _mapDisplay displayCtrl 51;
private _mapCtrl = _mapDisplay displayCtrl IDC_MAP;
GVAR(editingMarker) = "";
(ctrlMapMouseOver _mapCtrl) params ["_mouseOverType", "_marker"];
@ -76,7 +79,10 @@
GVAR(currentMarkerPosition) = markerPos GVAR(editingMarker);
} else {
private _pos = ctrlPosition _picture;
_pos = [(_pos select 0) + (_pos select 2) / 2, (_pos select 1) + (_pos select 3) / 2];
_pos = [
(_pos select 0) + (_pos select 2) / 2,
(_pos select 1) + (_pos select 3) / 2
];
GVAR(currentMarkerPosition) = _mapCtrl ctrlMapScreenToWorld _pos;
};
@ -86,9 +92,19 @@
// prevent vanilla key input
_display displayAddEventHandler ["KeyDown", {(_this select 1) in [200, 208]}];
private _hasTimestamp = false;
if !((markerText GVAR(editingMarker)) isEqualTo "") then {
//fill text input with text from marker which is being edited
_text ctrlSetText (markerText GVAR(editingMarker));
// fill text input with text from marker which is being edited
private _originalText = markerText GVAR(editingMarker);
private _timeIndex = _originalText find (TIMESTAMP_SPACE + "[");
if (_timeIndex > 0 ) then {
// Shave off timestamp
_hasTimestamp = true;
_originalText = _originalText select [0,_timeIndex];
};
_text ctrlSetText _originalText;
};
//Focus on the text input
@ -112,33 +128,70 @@
//--- Description
_pos set [1, _posY - 1 * _posH];
if (GVAR(timestampEnabled)) then {
_pos set [3,7 * _posH + 7 * BORDER];
} else {
_pos set [3,6 * _posH + 6 * BORDER];
};
_description ctrlEnable false;
_description ctrlSetPosition _pos;
_description ctrlSetStructuredText parseText format ["<t size='0.8'>%1</t>", localize "str_lib_label_description"];
_description ctrlCommit 0;
//--- Shape
//--- Timestamp
private _timestampOffset = 0;
if (GVAR(timestampEnabled)) then {
_timestampOffset = _posH + BORDER;
_pos set [0, _posX];
_pos set [1, _posY + 1 * _posH + 2 * BORDER];
_pos set [2, _posW - _posH];
_pos set [3, _posH];
_aceTimestampText ctrlSetStructuredText parseText format ["<t size='0.8'>%1</t>", LLSTRING(Timestamp)];
_aceTimestampText ctrlSetPosition _pos;
_aceTimestampText ctrlCommit 0;
_pos set [0, _posX + _posW - _posH];
_pos set [2, _posH];
_pos set [3, _posH];
_aceTimestamp ctrlSetPosition _pos;
_aceTimestamp ctrlCommit 0;
if !([ACE_player] call FUNC(canTimestamp)) then {
_aceTimestamp ctrlEnable false;
_aceTimestamp ctrlSetTooltip LLSTRING(TimestampTooltipNoWatch);
} else {
_aceTimestamp cbSetChecked (GETUVAR(GVAR(timestampChecked),false) || _hasTimestamp);
};
} else {
_aceTimestampText ctrlEnable false;
_aceTimestampText ctrlShow false;
_aceTimestamp ctrlEnable false;
_aceTimestamp ctrlShow false;
};
//--- Shape
_pos set [0, _posX];
_pos set [1, _posY + 1 * _posH + 2 * BORDER + _timestampOffset];
_pos set [2, _posW];
_pos set [3, _posH];
_aceShapeLB ctrlSetPosition _pos;
_aceShapeLB ctrlCommit 0;
//--- Color
_pos set [1, _posY + 2 * _posH + 3 * BORDER];
_pos set [1, _posY + 2 * _posH + 3 * BORDER + _timestampOffset];
_pos set [2, _posW];
_aceColorLB ctrlSetPosition _pos;
_aceColorLB ctrlCommit 0;
//--- Angle
_pos set [1, _posY + 3 * _posH + 4 * BORDER];
_pos set [1, _posY + 3 * _posH + 4 * BORDER + _timestampOffset];
_pos set [2, _posW];
_aceAngleSlider ctrlSetPosition _pos;
_aceAngleSlider ctrlCommit 0;
//--- Angle Text
_pos set [1, _posY + 4 * _posH + 5 * BORDER];
_pos set [1, _posY + 4 * _posH + 5 * BORDER + _timestampOffset];
_pos set [2, _posW];
_aceAngleSliderText ctrlSetPosition _pos;
_aceAngleSliderText ctrlCommit 0;
@ -146,13 +199,13 @@
private _offsetButtons = 0;
if (isMultiplayer) then {
_pos set [1,_posY + 5 * _posH + 7 * BORDER];
_pos set [1,_posY + 5 * _posH + 7 * BORDER + _timestampOffset];
_pos set [3,_posH];
_descriptionChannel ctrlSetStructuredText parseText format ["<t size='0.8'>%1:</t>", localize "str_a3_cfgvehicles_modulerespawnposition_f_arguments_marker_0"];
_descriptionChannel ctrlSetPosition _pos;
_descriptionChannel ctrlCommit 0;
_pos set [1,_posY + 6 * _posH + 7 * BORDER];
_pos set [1,_posY + 6 * _posH + 7 * BORDER + _timestampOffset];
_pos set [3,_posH];
_channel ctrlSetPosition _pos;
_channel ctrlCommit 0;
@ -199,7 +252,7 @@
};
//--- ButtonOK
_pos set [1, _posY + _offsetButtons];
_pos set [1, _posY + _offsetButtons + _timestampOffset];
_pos set [2, _posW / 2 - BORDER];
_pos set [3, _posH];
_buttonOk ctrlSetPosition _pos;
@ -207,12 +260,18 @@
//--- ButtonCancel
_pos set [0, _posX + _posW / 2];
_pos set [1, _posY + _offsetButtons];
_pos set [1, _posY + _offsetButtons + _timestampOffset];
_pos set [2, _posW / 2];
_pos set [3, _posH];
_buttonCancel ctrlSetPosition _pos;
_buttonCancel ctrlCommit 0;
////////////////////
// init marker timestamp cb
_buttonOK ctrlAddEventHandler ['ButtonClick', FUNC(onButtonClickConfirm)];
_aceTimestamp ctrlAddEventHandler ['CheckedChanged', FUNC(onCheckedChangedTimestamp)];
////////////////////
// init marker shape lb
lbClear _aceShapeLB;

View File

@ -0,0 +1,42 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineResincl.inc"
/*
* Author: Freddo
* 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;
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;
private _ampm = switch (true) do {
case (GVAR(timestampHourFormat) == 24): {""};
case (_time < 12): {" am"};
case (_time > 12): {SUB(_time,12); " pm"};
};
_description ctrlSetText format [ // Add timestamp suffix
"%1%2[%2%3]",
ctrlText _description,
TIMESTAMP_SPACE,
[_time, GVAR(timestampFormat)] call BIS_fnc_timeToString,
_ampm
];
};
nil

View File

@ -0,0 +1,23 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineResincl.inc"
/*
* Author: Freddo
* When the timestamp checkbox is toggled
*
* Arguments:
* 0: Checkbox <CONTROL>
* 1: Value <NUMBER>
*
* Return Value:
* None
*
* Example:
* [_cbTimestamp,1] call ACE_markers_fnc_onCheckedChangedTimestamp
*
* Public: No
*/
params ["_cbTimestamp", "_checked"];
SETUVAR(GVAR(timestampChecked),(_checked == 1));
nil

View File

@ -1,4 +1,5 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineResincl.inc"
/*
* Author: commy2
* When the color list box is changed.
@ -29,10 +30,10 @@ GVAR(currentMarkerColorConfigName) = configName _config;
//Set map display to same color:
private _bisColorLB = switch (false) do {
case (isNull findDisplay 12): {(findDisplay 12) displayCtrl 1090};
case (isNull findDisplay 52): {(findDisplay 52) displayCtrl 1090};
case (isNull findDisplay 53): {(findDisplay 53) displayCtrl 1090};
case (isNull findDisplay 37): {(findDisplay 37) displayCtrl 1090};
case (isNull findDisplay 12): {(findDisplay 12) displayCtrl IDC_DIARY_MARKER_COLOR};
case (isNull findDisplay 52): {(findDisplay 52) displayCtrl IDC_DIARY_MARKER_COLOR};
case (isNull findDisplay 53): {(findDisplay 53) displayCtrl IDC_DIARY_MARKER_COLOR};
case (isNull findDisplay 37): {(findDisplay 37) displayCtrl IDC_DIARY_MARKER_COLOR};
default {controlNull};
};
if (_ctrl != _bisColorLB) then { //Don't set what we got a EH from

View File

@ -1,4 +1,5 @@
#include "script_component.hpp"
#include "\a3\ui_f\hpp\defineResincl.inc"
/*
* Author: commy2
* When the shape list box is changed.
@ -29,10 +30,10 @@ GVAR(currentMarkerConfigName) = configName _config;
//Set map display to same shape:
private _bisShapeLB = switch (false) do {
case (isNull findDisplay 12): {(findDisplay 12) displayCtrl 1091};
case (isNull findDisplay 52): {(findDisplay 52) displayCtrl 1091};
case (isNull findDisplay 53): {(findDisplay 53) displayCtrl 1091};
case (isNull findDisplay 37): {(findDisplay 37) displayCtrl 1091};
case (isNull findDisplay 12): {(findDisplay 12) displayCtrl IDC_DIARY_MARKER_ICON};
case (isNull findDisplay 52): {(findDisplay 52) displayCtrl IDC_DIARY_MARKER_ICON};
case (isNull findDisplay 53): {(findDisplay 53) displayCtrl IDC_DIARY_MARKER_ICON};
case (isNull findDisplay 37): {(findDisplay 37) displayCtrl IDC_DIARY_MARKER_ICON};
default {controlNull};
};
if (_ctrl != _bisShapeLB) then { //Don't set what we got a EH from

View File

@ -25,6 +25,6 @@ if (_direction < 0) then {
_direction = _direction + 360;
};
((ctrlParent _ctrl) displayCtrl 1221) ctrlSetText format [localize LSTRING(MarkerDirection), _direction];
((ctrlParent _ctrl) displayCtrl IDC_ACE_INSERT_MARKER_ANGLE_TEXT) ctrlSetText format [localize LSTRING(MarkerDirection), _direction];
GVAR(currentMarkerAngle) = _data;

View File

@ -1,7 +1,9 @@
private _categoryName = format ["ACE %1", localize ELSTRING(map,Module_DisplayName)];
[
QGVAR(moveRestriction), "LIST",
[LSTRING(MoveRestriction), LSTRING(MoveRestriction_Description)],
[format ["ACE %1", localize ELSTRING(map,Module_DisplayName)], localize LSTRING(Module_DisplayName)],
[_categoryName, LLSTRING(Module_DisplayName)],
[
[
MOVE_RESTRICTION_NOBODY,
@ -22,3 +24,56 @@
1
]
] call cba_settings_fnc_init;
[
QGVAR(timestampEnabled), "CHECKBOX",
[LSTRING(TimestampEnabled), LSTRING(TimestampEnabledDescription)],
[_categoryName, LLSTRING(Module_DisplayName)],
true
] call CBA_fnc_addSetting;
[
QGVAR(timestampHourFormat), "LIST",
[LSTRING(TimestampHourFormat), LSTRING(TimestampHourFormatDescription)],
[_categoryName, LLSTRING(Module_DisplayName)],
[
[
24,
12
],
[
LSTRING(TimestampHourFormat24),
LSTRING(TimestampHourFormat12)
],
0
]
] call CBA_fnc_addSetting;
private _formatDescription = [
LLSTRING(TimestampFormatDescription0),
LLSTRING(TimestampFormatDescription1),
LLSTRING(TimestampFormatDescription2),
LLSTRING(TimestampFormatDescription3),
LLSTRING(TimestampFormatDescription4)
] joinString "\n";
[
QGVAR(timestampFormat), "LIST",
[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"
],
1
]
] call CBA_fnc_addSetting;

View File

@ -24,9 +24,19 @@
localize "str_channel_vehicle" \
]
// 129 just looks like a space
#define TIMESTAMP_SPACE (toString [129])
#define MOVE_RESTRICTION_NOBODY -1
#define MOVE_RESTRICTION_ALL 0
#define MOVE_RESTRICTION_ADMINS 1
#define MOVE_RESTRICTION_GROUP_LEADERS 2
#define MOVE_RESTRICTION_GROUP_LEADERS_ADMINS 3
#define MOVE_RESTRICTION_OWNER 4
#define IDC_ACE_INSERT_MARKER_TIMESTAMP 1210
#define IDC_ACE_INSERT_MARKER_TIMESTAMP_TEXT 1211
#define IDC_ACE_INSERT_MARKER_SHAPE 1220
#define IDC_ACE_INSERT_MARKER_COLOR 1221
#define IDC_ACE_INSERT_MARKER_ANGLE 1230
#define IDC_ACE_INSERT_MARKER_ANGLE_TEXT 1231

View File

@ -150,5 +150,47 @@
<Czech>Tvůrce</Czech>
<Turkish>Yaratıcı</Turkish>
</Key>
<Key ID="STR_ACE_Markers_TimestampEnabled">
<English>Allow Timestamps</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampEnabledDescription">
<English>Whether to allow timestamps to be automatically applied to markers</English>
</Key>
<Key ID="STR_ACE_Markers_Timestamp">
<English>Add Timestamp:</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampTooltipNoWatch">
<English>Watch Required</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampFormat">
<English>Timestamp Format</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampFormatDescription0">
<English>Changes the timestamp format</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampFormatDescription1">
<English>"HH" - Hour</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampFormatDescription2">
<English>"MM" - Minute</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampFormatDescription3">
<English>"SS" - Seconds</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampFormatDescription4">
<English>"MM" - Milliseconds</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampHourFormat">
<English>Timestamp Hour Format</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampHourFormat24">
<English>24-Hour Clock</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampHourFormat12">
<English>12-Hour Clock</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampHourFormatDescription">
<English>Changes timestamp to use either 24-hour or 12-hour clock format</English>
</Key>
</Package>
</Project>