markers - add setting allowing only marker creator to move (#6734)

* markers - add setting allowing only marker creator to move

* shorten setting display names

* delete some whitespace, superfluous command

* single arg needs no array

* delete some whitespace

* don't save directPlayID default value

* Save array of user placed markers
This commit is contained in:
McDiod 2019-01-03 20:31:21 +01:00 committed by PabstMirror
parent f57d5ac180
commit fcfe278f7f
7 changed files with 53 additions and 12 deletions

View File

@ -18,6 +18,8 @@ GVAR(currentMarkerAngle) = 0;
GVAR(currentMarkerColorConfigName) = "";
GVAR(currentMarkerConfigName) = "";
GVAR(userPlacedMarkers) = [];
// set marker pos local on every machine (prevent markers visible for everyone)
[QGVAR(setMarkerPosLocal), {
params ["_marker", "_pos"];
@ -28,6 +30,7 @@ GVAR(currentMarkerConfigName) = "";
private _index = (GETGVAR(allMapMarkers,[])) find _marker; // case-sensitive, but should be fine
if (_index < 0) exitWith {
if (!isMultiplayer) exitWith {};
WARNING_1("Could not find data for %1", _marker);
};

View File

@ -4,17 +4,19 @@
* Checks whether the player can move markers.
*
* Arguments:
* None
* 0: Marker Name <STRING>
*
* Return Value:
* Whether the player can move markers <BOOL>
*
* Example:
* [] call ace_markers_fnc_canMove
* ["X"] call ace_markers_fnc_canMove
*
* Public: No
*/
params [["_marker",""]];
switch (GVAR(moveRestriction)) do {
case MOVE_RESTRICTION_NOBODY: {false};
case MOVE_RESTRICTION_ALL: {true};
@ -25,5 +27,8 @@ switch (GVAR(moveRestriction)) do {
case MOVE_RESTRICTION_GROUP_LEADERS_ADMINS: {
(leader ACE_player == ACE_player) || IS_ADMIN
};
case MOVE_RESTRICTION_OWNER: {
_marker in GVAR(userPlacedMarkers)
};
default {true};
}; // return

View File

@ -27,7 +27,7 @@ if (_button != 0 || {!([_shift, _ctrl, _alt] isEqualTo [false, false, true])}) e
ctrlMapMouseOver _ctrlMap params [["_type", ""], "_marker"];
if (_type == "marker" && {_marker find "_USER_DEFINED" != -1 && {call FUNC(canMove)}}) then {
if (_type == "marker" && {_marker find "_USER_DEFINED" != -1 && {_marker call FUNC(canMove)}}) then {
_ctrlMap ctrlMapCursor ["Track", "Move"];
private _originalPos = getMarkerPos _marker;

View File

@ -16,19 +16,45 @@
* Public: No
*/
disableserialization;
params ["_display", "_closeNum"];
TRACE_2("params",_display,_closeNum);
private _editingMarker = !(GVAR(editingMarker) isEqualTo "");
if (_closeNum isEqualTo 1) then {
if !(GVAR(editingMarker) isEqualTo "") then {
if (_editingMarker) then {
//delete "old" marker
deleteMarker GVAR(editingMarker);
};
// set and send marker data the next frame. the actual marker isn't created yet
[{
params ["_startingMarkers", "_editingMarker"];
private _newMarkers = allMapMarkers - _startingMarkers;
private _newestMarker = "";
private _newestMarkerDist = 1e10;
{
private _distX = GVAR(currentMarkerPosition) distance2d (getMarkerPos _x);
if (_distX < _newestMarkerDist) then {
_newestMarker = _x;
_newestMarkerDist = _distX;
};
} forEach _newMarkers;
TRACE_3("",_newestMarker,_newestMarkerDist,_newMarkers);
if (_newestMarker == "") exitWith {ERROR_1("could not find user placed marker from %1",_newMarkers);};
// provide hook for external scripts
[QGVAR(markerPlaced),[_newestMarker, _editingMarker]] call CBA_fnc_localEvent;
// Add to list of user placed markers, and then filter for deleted
GVAR(userPlacedMarkers) pushBack _newestMarker;
GVAR(userPlacedMarkers) = GVAR(userPlacedMarkers) select {!((getMarkerPos _x) isEqualTo [0,0,0])};
[QGVAR(setMarkerNetwork), [
allMapMarkers select (count allMapMarkers - 1), [
_newestMarker, [
GETGVAR(currentMarkerConfigName,""),
GETGVAR(currentMarkerColorConfigName,""),
GETGVAR(currentMarkerPosition,[]),
@ -36,10 +62,10 @@ if (_closeNum isEqualTo 1) then {
]
]] call CBA_fnc_globalEvent;
}, []] call CBA_fnc_execNextFrame;
}, [allMapMarkers, _editingMarker]] call CBA_fnc_execNextFrame;
} else {
if !(GVAR(editingMarker) isEqualTo "") then {
//editing was canceled show the original marker again
if (_editingMarker) then {
// editing was canceled show the original marker again
GVAR(editingMarker) setMarkerAlphaLocal 1;
};
};

View File

@ -1,21 +1,23 @@
[
QGVAR(moveRestriction), "LIST",
[LSTRING(MoveRestriction), LSTRING(MoveRestriction_Description)],
format ["ACE %1", localize ELSTRING(map,Module_DisplayName)],
[format ["ACE %1", localize ELSTRING(map,Module_DisplayName)], localize LSTRING(Module_DisplayName)],
[
[
MOVE_RESTRICTION_NOBODY,
MOVE_RESTRICTION_ALL,
MOVE_RESTRICTION_ADMINS,
MOVE_RESTRICTION_GROUP_LEADERS,
MOVE_RESTRICTION_GROUP_LEADERS_ADMINS
MOVE_RESTRICTION_GROUP_LEADERS_ADMINS,
MOVE_RESTRICTION_OWNER
],
[
LSTRING(MoveRestriction_Nobody),
LSTRING(MoveRestriction_All),
LSTRING(MoveRestriction_Admins),
LSTRING(MoveRestriction_GroupLeaders),
LSTRING(MoveRestriction_GroupLeadersAndAdmins)
LSTRING(MoveRestriction_GroupLeadersAndAdmins),
LSTRING(MoveRestriction_Owner)
],
1
]

View File

@ -29,3 +29,4 @@
#define MOVE_RESTRICTION_ADMINS 1
#define MOVE_RESTRICTION_GROUP_LEADERS 2
#define MOVE_RESTRICTION_GROUP_LEADERS_ADMINS 3
#define MOVE_RESTRICTION_OWNER 4

View File

@ -97,5 +97,9 @@
<Korean>분대장과 관리자</Korean>
<Polish>Przywódcy grup i Administratorzy</Polish>
</Key>
<Key ID="STR_ACE_Markers_MoveRestriction_Owner">
<English>Creator</English>
<German>Ersteller</German>
</Key>
</Package>
</Project>