Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Markers - Add timestamps #7947

Merged
merged 10 commits into from
Oct 29, 2020
Merged
13 changes: 9 additions & 4 deletions addons/markers/InsertMarker.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class RscStructuredText;
class RscButtonMenuOK;
class RscButtonMenuCancel;
class RscButtonMenu;
class RscCheckBox;
class RscEdit;
class RscCombo;
class RscSlider;
Expand All @@ -16,17 +17,21 @@ class RscDisplayInsertMarker {
movingEnable = 1;

class controls {
class TimeStamp: RscCheckBox {
idc = IDC_ACE_INSERT_MARKER_TIMESTAMP;
tooltip = CSTRING(TimestampTooltip);
};
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;
};
};
};
1 change: 1 addition & 0 deletions addons/markers/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ PREP(canMove);
PREP(onMouseButtonDown);
PREP(onMouseButtonUp);
PREP(movePFH);
PREP(canTimestamp);
26 changes: 26 additions & 0 deletions addons/markers/functions/fnc_canTimestamp.sqf
Original file line number Diff line number Diff line change
@@ -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]];
Freddo3000 marked this conversation as resolved.
Show resolved Hide resolved

private _assignedItems = assignedItems _unit;

private _index = _assignedItems findIf {
([_x] call EFUNC(common,getItemType)) isEqualTo ["item", "watch"]
};

_index != -1
76 changes: 59 additions & 17 deletions addons/markers/functions/fnc_initInsertMarker.sqf
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "script_component.hpp"
#include "\A3\ui_f\hpp\defineResincl.inc"
/*
* Author: BIS, commy2, Timi007
* Sets up the marker placement
Expand Down Expand Up @@ -29,26 +30,27 @@
};

//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 _description = _display displayctrl 1100;
private _title = _display displayctrl 1001;
private _descriptionChannel = _display displayctrl 1101;
private _text = _display displayctrl IDC_INSERT_MARKER;
veteran29 marked this conversation as resolved.
Show resolved Hide resolved
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;

//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 _mapDisplay = displayParent _display;
// _sizeX = _display displayctrl 1200;
// _sizeY = _display displayctrl 1201;
private _aceTimestamp = _display displayCtrl IDC_ACE_INSERT_MARKER_TIMESTAMP;
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"];
Expand Down Expand Up @@ -118,7 +120,23 @@
_description ctrlSetStructuredText parseText format ["<t size='0.8'>%1</t>", localize "str_lib_label_description"];
_description ctrlCommit 0;

//--- Timestamp
if (GVAR(timestampEnabled)) then {
_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(TimestampTooltip) + "\n" + LLSTRING(TimestampTooltipNoWatch));
} else {
_aceTimestamp cbSetChecked GETUVAR(GVAR(timestampChecked),false);
};
};

//--- Shape
_pos set [0, _posX];
_pos set [1, _posY + 1 * _posH + 2 * BORDER];
_pos set [2, _posW];
_pos set [3, _posH];
Expand Down Expand Up @@ -213,6 +231,30 @@
_buttonCancel ctrlSetPosition _pos;
_buttonCancel ctrlCommit 0;

////////////////////
// init marker timestamp cb

if (GVAR(timestampEnabled) && [ACE_player] call FUNC(canTimestamp)) then {
Freddo3000 marked this conversation as resolved.
Show resolved Hide resolved
_buttonOK ctrlAddEventHandler ['ButtonClick', {
if (GETUVAR(GVAR(timestampChecked),false)) then {
params ["_buttonOk"];
private _description = (ctrlParent _buttonOk) displayctrl IDC_INSERT_MARKER;

_description ctrlSetText format [ // Add timestamp suffix
"%1 [%2]",
ctrlText _description,
[daytime, "HH:MM"] call BIS_fnc_timeToString
Freddo3000 marked this conversation as resolved.
Show resolved Hide resolved
];
};
false
}];

_aceTimestamp ctrlAddEventHandler ['CheckedChanged', {
params ["_cbTimestamp", "_checked"];
SETUVAR(GVAR(timestampChecked),(_checked == 1));
}];
};

////////////////////
// init marker shape lb
lbClear _aceShapeLB;
Expand Down
11 changes: 10 additions & 1 deletion addons/markers/initSettings.sqf
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -22,3 +24,10 @@
1
]
] call cba_settings_fnc_init;

[
QGVAR(timestampEnabled), "CHECKBOX",
[LSTRING(TimestampEnabled), LSTRING(TimestampEnabledDescription)],
[_categoryName, LLSTRING(Module_DisplayName)],
true
] call CBA_fnc_addSetting;
6 changes: 6 additions & 0 deletions addons/markers/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,9 @@
#define MOVE_RESTRICTION_GROUP_LEADERS 2
#define MOVE_RESTRICTION_GROUP_LEADERS_ADMINS 3
#define MOVE_RESTRICTION_OWNER 4

#define IDC_ACE_INSERT_MARKER_TIMESTAMP 1200
#define IDC_ACE_INSERT_MARKER_SHAPE 1210
#define IDC_ACE_INSERT_MARKER_COLOR 1211
#define IDC_ACE_INSERT_MARKER_ANGLE 1220
#define IDC_ACE_INSERT_MARKER_ANGLE_TEXT 1221
12 changes: 12 additions & 0 deletions addons/markers/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,17 @@
<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_TimestampTooltip">
<English>Add Timestamp</English>
</Key>
<Key ID="STR_ACE_Markers_TimestampTooltipNoWatch">
<English>Watch Required</English>
</Key>
</Package>
</Project>