Skip to content

Commit

Permalink
Add option to lock position
Browse files Browse the repository at this point in the history
  • Loading branch information
Timi007 committed Jan 15, 2025
1 parent 4e8d409 commit d1cc8c8
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 15 deletions.
8 changes: 5 additions & 3 deletions addons/comments/functions/fnc_createComment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@
* 2: Tooltip <STRING> (default: "")
* 3: Comment color (RGBA) <ARRAY> (default: yellow)
* 4: Creator <STRING> (default: "")
* 5: Lock position <BOOLEAN> (default: false)
*
* Return Value:
* Id of the created comment <STRING>.
*
* Example:
* [[0, 0, 0], "My Comment", "This is a nice comment", [1, 0, 0, 0.7], "Joe"] call zen_comments_fnc_createComment
* [[0, 0, 0], "My Comment", "This is a nice comment", [1, 0, 0, 0.7], "Joe", false] call zen_comments_fnc_createComment
*
* Public: No
*/
Expand All @@ -28,11 +29,12 @@ params [
["_title", "", [""]],
["_tooltip", "", [""]],
["_color", DEFAULT_COLOR, [[]], 4],
["_creator", "", [""]]
["_creator", "", [""]],
["_lockPosition", false, [false]]
];

private _id = format ["%1:%2", COMMENT_TYPE_ZEUS, GVAR(nextID)];
private _data = [_position, _title, _tooltip, _color, _creator];
private _data = [_position, _title, _tooltip, _color, _creator, _lockPosition];
GVAR(nextID) = GVAR(nextID) + 1;

private _jipId = format [QGVAR(%1), _id];
Expand Down
7 changes: 4 additions & 3 deletions addons/comments/functions/fnc_onMouseButtonDown.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ params ["_ctrlIcon", "_button"];
if (_button != 0) exitWith {};

private _id = _ctrlIcon getVariable [QGVAR(comment), ""];
if (_id isEqualTo "") exitWith {ERROR("Moving invalid comment.")};
if (_id isEqualTo "" || {_id call FUNC(is3DENComment)}) exitWith {};

if (_id call FUNC(is3DENComment)) exitWith {};
(GVAR(comments) get _id) params ["_position", "", "", "", "", "_lockPosition"];

if (_lockPosition) exitWith {};

(GVAR(comments) get _id) params ["_position"];
GVAR(movingComment) = [_id, +_position];
14 changes: 9 additions & 5 deletions addons/comments/functions/fnc_openDialog.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,15 @@
params ["_positionOrId"];

private _id = ["", _positionOrId] select (_positionOrId isEqualType "");
private _isEditingComment = _id isNotEqualTo "";

(GVAR(comments) getOrDefault [_id, []]) params [
["_position", [], [[]], 3],
["_title", "", [""]],
["_tooltip", "", [""]],
["_color", DEFAULT_COLOR, [[]], 4]
["_color", DEFAULT_COLOR, [[]], 4],
["_creator", "", [""]],
["_lockPosition", false, [false]]
];

if (_positionOrId isEqualType [] && _position isEqualTo []) then {
Expand All @@ -36,16 +39,17 @@ if (_positionOrId isEqualType [] && _position isEqualTo []) then {
[
["EDIT", localize "str_3den_comment_attribute_name_displayname", [_title], true],
["EDIT:MULTI", localize "str_3den_comment_attribute_name_tooltip", [_tooltip], true],
["COLOR", localize "str_3den_marker_attribute_color_displayname", _color, (_id isNotEqualTo "")] // Force only when editing comment
["CHECKBOX", LLSTRING(LockPosition), _lockPosition, _isEditingComment],
["COLOR", localize "str_3den_marker_attribute_color_displayname", _color, _isEditingComment]
],
{
(_this select 0) params ["_title", "_tooltip", "_color"];
(_this select 0) params ["_title", "_tooltip", "_lockPosition", "_color"];
(_this select 1) params ["_id", "_position"];

if (_id isEqualTo "") then {
[QGVAR(createComment), [_position, _title, _tooltip, _color, profileName]] call CBA_fnc_serverEvent;
[QGVAR(createComment), [_position, _title, _tooltip, _color, profileName, _lockPosition]] call CBA_fnc_serverEvent;
} else {
[QGVAR(updateComment), [_id, _position, _title, _tooltip, _color, profileName]] call CBA_fnc_serverEvent;
[QGVAR(updateComment), [_id, _position, _title, _tooltip, _color, profileName, _lockPosition]] call CBA_fnc_serverEvent;
};
},
{},
Expand Down
10 changes: 6 additions & 4 deletions addons/comments/functions/fnc_updateComment.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
* 2: Title <STRING>
* 3: Tooltip <STRING>
* 4: Comment color (RGBA) <ARRAY>
* 4: Creator <STRING>
* 5: Creator <STRING>
* 6: Lock position <BOOLEAN>
*
* Return Value:
* None
*
* Example:
* ["zeus:2", [0, 0, 0], "My updated Comment", "This is a nice comment", [1, 0, 0, 0.7], "Joe"] call zen_comments_fnc_updateComment
* ["zeus:2", [0, 0, 0], "My updated Comment", "This is a nice comment", [1, 0, 0, 0.7], "Joe", false] call zen_comments_fnc_updateComment
*
* Public: No
*/
Expand All @@ -30,10 +31,11 @@ params [
["_title", "", [""]],
["_tooltip", "", [""]],
["_color", DEFAULT_COLOR, [[]], 4],
["_creator", "", [""]]
["_creator", "", [""]],
["_lockPosition", false, [false]]
];

private _data = [_position, _title, _tooltip, _color, _creator];
private _data = [_position, _title, _tooltip, _color, _creator, _lockPosition];
private _jipId = format [QGVAR(%1), _id];
[QGVAR(commentUpdated), [_id, _data], _jipId] call CBA_fnc_globalEventJIP;
TRACE_2("Comment updated",_id,_data);
4 changes: 4 additions & 0 deletions addons/comments/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,9 @@
<English>If selected, this comment will be shown in Zeus.</English>
<German>Wenn ausgewählt, wird dieser Kommentar in Zeus angezeigt.</German>
</Key>
<Key ID="STR_ZEN_Comments_LockPosition">
<English>Lock position</English>
<German>Position sperren</German>
</Key>
</Package>
</Project>

0 comments on commit d1cc8c8

Please sign in to comment.