From d1cc8c82551b4b9467c5fd8eee861d6f9f1190f2 Mon Sep 17 00:00:00 2001 From: Timi007 Date: Thu, 16 Jan 2025 00:08:58 +0100 Subject: [PATCH] Add option to lock position --- addons/comments/functions/fnc_createComment.sqf | 8 +++++--- .../comments/functions/fnc_onMouseButtonDown.sqf | 7 ++++--- addons/comments/functions/fnc_openDialog.sqf | 14 +++++++++----- addons/comments/functions/fnc_updateComment.sqf | 10 ++++++---- addons/comments/stringtable.xml | 4 ++++ 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/addons/comments/functions/fnc_createComment.sqf b/addons/comments/functions/fnc_createComment.sqf index 47e6e3b99..af3d0545d 100644 --- a/addons/comments/functions/fnc_createComment.sqf +++ b/addons/comments/functions/fnc_createComment.sqf @@ -9,12 +9,13 @@ * 2: Tooltip (default: "") * 3: Comment color (RGBA) (default: yellow) * 4: Creator (default: "") + * 5: Lock position (default: false) * * Return Value: * Id of the created comment . * * 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 */ @@ -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]; diff --git a/addons/comments/functions/fnc_onMouseButtonDown.sqf b/addons/comments/functions/fnc_onMouseButtonDown.sqf index 3725f929b..7e8ba8ffb 100644 --- a/addons/comments/functions/fnc_onMouseButtonDown.sqf +++ b/addons/comments/functions/fnc_onMouseButtonDown.sqf @@ -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]; diff --git a/addons/comments/functions/fnc_openDialog.sqf b/addons/comments/functions/fnc_openDialog.sqf index 665d58a06..16d6eb6b2 100644 --- a/addons/comments/functions/fnc_openDialog.sqf +++ b/addons/comments/functions/fnc_openDialog.sqf @@ -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 { @@ -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; }; }, {}, diff --git a/addons/comments/functions/fnc_updateComment.sqf b/addons/comments/functions/fnc_updateComment.sqf index e64ae08f6..b582b62ef 100644 --- a/addons/comments/functions/fnc_updateComment.sqf +++ b/addons/comments/functions/fnc_updateComment.sqf @@ -9,13 +9,14 @@ * 2: Title * 3: Tooltip * 4: Comment color (RGBA) - * 4: Creator + * 5: Creator + * 6: Lock position * * 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 */ @@ -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); diff --git a/addons/comments/stringtable.xml b/addons/comments/stringtable.xml index dc46a3d2c..3f172bda4 100644 --- a/addons/comments/stringtable.xml +++ b/addons/comments/stringtable.xml @@ -41,5 +41,9 @@ If selected, this comment will be shown in Zeus. Wenn ausgewählt, wird dieser Kommentar in Zeus angezeigt. + + Lock position + Position sperren +