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
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 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,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;
};
};
};
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
117 changes: 88 additions & 29 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 All @@ -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
Expand All @@ -112,47 +128,84 @@

//--- 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 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 [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 +252,26 @@
};

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

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem right?
description, space, space, time

you give 4 parameter but only use 3, and the space seems wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah looks like I made a typo, should probably be "%1%2[%3%4]"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, am-pm is completely broken in this pull request. Even if this part was repaired, am-pm will not be shown for 12 and 24-hours, and even if that part is repaired, it will show the wrong one.

Should all be fixed here: https://github.com/acemod/ACE3/pull/8034/files#diff-4b395ce5b5e0cc52ea30d46cdc2cb9d5fea1eb22d6ca4cfe885b60ef68b1e45eR48

ctrlText _description,
TIMESTAMP_SPACE,
[_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