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
16 changes: 12 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,24 @@ class RscDisplayInsertMarker {
movingEnable = 1;

class controls {
class TimeStampText: RscStructuredText {
text = CSTRING(TimestampTooltip);
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;
};
};
};
3 changes: 3 additions & 0 deletions addons/markers/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,6 @@ PREP(canMove);
PREP(onMouseButtonDown);
PREP(onMouseButtonUp);
PREP(movePFH);
PREP(canTimestamp);
PREP(onButtonClickConfirm);
PREP(onCheckedChangedTimestamp);
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]];

private _assignedItems = assignedItems _unit;

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

_index != -1
95 changes: 68 additions & 27 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,28 @@
};

//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 _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"];
Expand Down Expand Up @@ -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;
};

Expand Down Expand Up @@ -112,47 +118,75 @@

//--- Description
_pos set [1, _posY - 1 * _posH];
_pos set [3,6 * _posH + 6 * BORDER];
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;

//--- 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 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);
};
};

//--- Shape
_pos set [1, _posY + 1 * _posH + 2 * BORDER];
_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;

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;
Expand Down Expand Up @@ -199,20 +233,27 @@
};

//--- 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;
_buttonOk ctrlCommit 0;

//--- 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)];
_aceTimestamp cbSetChecked GETUVAR(GVAR(timestampChecked),false);

////////////////////
// init marker shape lb
lbClear _aceShapeLB;
Expand Down
38 changes: 38 additions & 0 deletions addons/markers/functions/fnc_onButtonClickConfirm.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#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"];

// Handle timestamp
if (GETUVAR(GVAR(timestampChecked),false) && {[ACE_player] call FUNC(canTimestamp)}) then {
private _description = (ctrlParent _buttonOk) displayctrl IDC_INSERT_MARKER;
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%3]",
ctrlText _description,
[_time, GVAR(timestampFormat)] call BIS_fnc_timeToString,
_ampm
];
};

nil
23 changes: 23 additions & 0 deletions addons/markers/functions/fnc_onCheckedChangedTimestamp.sqf
Original file line number Diff line number Diff line change
@@ -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
9 changes: 5 additions & 4 deletions addons/markers/functions/fnc_onLBSelChangedColor.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: commy2
* When the color list box is changed.
Expand Down Expand Up @@ -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
Expand Down
9 changes: 5 additions & 4 deletions addons/markers/functions/fnc_onLBSelChangedShape.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: commy2
* When the shape list box is changed.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion addons/markers/functions/fnc_onSliderPosChangedAngle.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Loading