From 89654a42d2f8449775f5c9f3815b5159b8eba92c Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 16 Jan 2015 17:13:26 -0600 Subject: [PATCH] Needs Testing --- addons/map/CfgVehicles.hpp | 34 +++++++++---------- addons/map/XEH_preInit.sqf | 12 +++++-- addons/map/functions/fnc_addLineMarker.sqf | 2 ++ ...kers.sqf => fnc_copyMapReceiveMarkers.sqf} | 6 ++-- ...pMarkers.sqf => fnc_copyMapRemoteSend.sqf} | 4 ++- addons/map/functions/fnc_copyMapStart.sqf | 23 +++++++++++++ addons/map/functions/fnc_handleKeyDown.sqf | 5 ++- .../map/functions/fnc_handleMouseButton.sqf | 6 +++- 8 files changed, 67 insertions(+), 25 deletions(-) rename addons/map/functions/{fnc_copyMapMarkers.sqf => fnc_copyMapReceiveMarkers.sqf} (76%) rename addons/map/functions/{fnc_sendMapMarkers.sqf => fnc_copyMapRemoteSend.sqf} (58%) create mode 100644 addons/map/functions/fnc_copyMapStart.sqf diff --git a/addons/map/CfgVehicles.hpp b/addons/map/CfgVehicles.hpp index d00383868c..f38a3727d6 100644 --- a/addons/map/CfgVehicles.hpp +++ b/addons/map/CfgVehicles.hpp @@ -10,7 +10,7 @@ class CfgVehicles { class ACE_MapTools { displayName = "$STR_ACE_Map_MapTools_Menu"; - condition = "(call ACE_Map_fnc_canUseMapTools) || (call ACE_Map_fnc_canUseMapGPS)"; + condition = QUOTE(call FUNC(canUseMapTools) || {call FUNC(canUseMapGPS)}); statement = ""; exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 0; @@ -20,8 +20,8 @@ class CfgVehicles { class ACE_MapToolsHide { displayName = "$STR_ACE_Map_MapToolsHide"; - condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapTool_Shown > 0}"; - statement = "ACE_Map_mapTool_Shown = 0; [] call ACE_Map_fnc_updateMapToolMarkers"; + condition = QUOTE(call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 0}); + statement = QUOTE(GVAR(mapTool_Shown) = 0; [] call FUNC(updateMapToolMarkers)); exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 1; priority = 5; @@ -29,8 +29,8 @@ class CfgVehicles { }; class ACE_MapToolsShowNormal { displayName = "$STR_ACE_Map_MapToolsShowNormal"; - condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapTool_Shown != 1}"; - statement = "ACE_Map_mapTool_Shown = 1; [] call ACE_Map_fnc_updateMapToolMarkers"; + condition = QUOTE(call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 1}); + statement = QUOTE(GVAR(mapTool_Shown) = 1; [] call FUNC(updateMapToolMarkers)); exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 1; priority = 4; @@ -38,8 +38,8 @@ class CfgVehicles { }; class ACE_MapToolsShowSmall { displayName = "$STR_ACE_Map_MapToolsShowSmall"; - condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapTool_Shown != 2}"; - statement = "ACE_Map_mapTool_Shown = 2; [] call ACE_Map_fnc_updateMapToolMarkers"; + condition = QUOTE(call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 2}); + statement = QUOTE(GVAR(mapTool_Shown) = 2; [] call FUNC(updateMapToolMarkers)); exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 1; priority = 3; @@ -47,8 +47,8 @@ class CfgVehicles { }; class ACE_MapToolsAlignNorth { displayName = "$STR_ACE_Map_MapToolsAlignNorth"; - condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapTool_Shown != 0}"; - statement = "ACE_Map_angle = 0; [] call ACE_Map_fnc_updateMapToolMarkers"; + condition = QUOTE(call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 0}); + statement = QUOTE(GVAR(mapTool_angle) = 0; [] call FUNC(updateMapToolMarkers)); exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 1; priority = 2; @@ -56,8 +56,8 @@ class CfgVehicles { }; class ACE_MapToolsAlignCompass { displayName = "$STR_ACE_Map_MapToolsAlignCompass"; - condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapTool_Shown != 0} && {(""ItemCompass"" in assigneditems ACE_player) || {""ItemGPS"" in assigneditems ACE_player}}"; - statement = "ACE_Map_angle = getDir player; [] call ACE_Map_fnc_updateMapToolMarkers"; + condition = QUOTE(call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 0} && {('ItemCompass' in assigneditems ACE_player) || {'ItemCompass' in assigneditems ACE_player}}); + statement = QUOTE(GVAR(mapTool_angle) = getDir ACE_player; [] call FUNC(updateMapToolMarkers)); exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 1; priority = 1; @@ -65,8 +65,8 @@ class CfgVehicles { }; class ACE_MapGpsShow { displayName = "$STR_ACE_Map_MapGpsShow"; - condition = "(call ACE_Map_fnc_canUseMapGPS) && {!ACE_Map_mapGpsShow}"; - statement = "ACE_Map_mapGpsShow = true; [ACE_Map_mapGpsShow] call ACE_Map_fnc_openMapGps"; + condition = QUOTE(call FUNC(canUseMapGPS) && {!GVAR(mapGpsShow)}); + statement = QUOTE(GVAR(mapGpsShow) = true; [GVAR(mapGpsShow)] call FUNC(openMapGps)); exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 0; priority = 0; @@ -74,8 +74,8 @@ class CfgVehicles { }; class ACE_MapGpsHide { displayName = "$STR_ACE_Map_MapGpsHide"; - condition = "(call ACE_Map_fnc_canUseMapGPS) && ACE_Map_mapGpsShow"; - statement = "ACE_Map_mapGpsShow = false; [ACE_Map_mapGpsShow] call ACE_Map_fnc_openMapGps"; + condition = QUOTE(call FUNC(canUseMapGPS) && {GVAR(mapGpsShow)}); + statement = QUOTE(GVAR(mapGpsShow) = false; [GVAR(mapGpsShow)] call FUNC(openMapGps)); exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 0; priority = 0; @@ -87,8 +87,8 @@ class CfgVehicles { class ACE_Actions { class ACE_CopyMap { displayName = "$STR_ACE_Map_CopyMap"; - condition = "isPlayer ACE_Interaction_Target && {""ItemMap"" in assigneditems ACE_player} && {""ACE_MapTools"" in items ACE_player} && {""ItemMap"" in assignedItems ACE_Interaction_Target}"; - statement = "[player, ""ACE_Map_fnc_sendMapMarkers"", ACE_Interaction_Target] call ACE_Core_fnc_execRemoteFnc"; + condition = QUOTE([_target] call EFUNC(common,isPlayer) && {'ItemMap' in assigneditems _player} && {'ACE_MapTools' in items _player} && {'ItemMap' in assignedItems _target}); + statement = QUOTE([ARR_2(_player,_target)] call FUNC(copyMapStart)); showDisabled = 0; priority = -1; }; diff --git a/addons/map/XEH_preInit.sqf b/addons/map/XEH_preInit.sqf index 5aa74bb7a3..b13b0ca384 100644 --- a/addons/map/XEH_preInit.sqf +++ b/addons/map/XEH_preInit.sqf @@ -8,7 +8,9 @@ PREP(cancelDrawing); PREP(canDraw); PREP(canUseMapTools); PREP(canUseMapGPS); -PREP(copyMapMarkers); +PREP(copyMapReceiveMarkers); +PREP(copyMapRemoteSend); +PREP(copyMapStart); PREP(handleKeyDown); PREP(handleMouseButton); PREP(handleMouseMove); @@ -18,6 +20,12 @@ PREP(mapStateUpdater); PREP(openMapGps); PREP(openMapGpsUpdate); PREP(removeLineMarker); -PREP(sendMapMarkers); PREP(updateMapToolMarkers); PREP(updateLineMarker); + +//Add Event Handlers: +["drawing_removeLineMarker", FUNC(removeLineMarker) ] call EFUNC(common,addEventHandler); +["drawing_addLineMarker", FUNC(addLineMarker) ] call EFUNC(common,addEventHandler); + +["drawing_requestMarkers", FUNC(copyMapRemoteSend) ] call EFUNC(common,addEventHandler); +["drawing_sendbackMarkers", FUNC(copyMapReceiveMarkers) ] call EFUNC(common,addEventHandler); diff --git a/addons/map/functions/fnc_addLineMarker.sqf b/addons/map/functions/fnc_addLineMarker.sqf index 5c9978a9f8..f94f506a86 100644 --- a/addons/map/functions/fnc_addLineMarker.sqf +++ b/addons/map/functions/fnc_addLineMarker.sqf @@ -15,6 +15,8 @@ #include "script_component.hpp" +systemChat "new global marker"; + _name = _this select 0; _startPos = _this select 1; _difPos = (_this select 2) vectorDiff _startPos ; diff --git a/addons/map/functions/fnc_copyMapMarkers.sqf b/addons/map/functions/fnc_copyMapReceiveMarkers.sqf similarity index 76% rename from addons/map/functions/fnc_copyMapMarkers.sqf rename to addons/map/functions/fnc_copyMapReceiveMarkers.sqf index 08492c4d4b..dcae05c572 100644 --- a/addons/map/functions/fnc_copyMapMarkers.sqf +++ b/addons/map/functions/fnc_copyMapReceiveMarkers.sqf @@ -1,7 +1,7 @@ /* * Author: CAA-Picard * - * Copy markers to mapd + * Copy recieved markers to map * * Argument: * 0: Array of markers to copy (Array) @@ -12,11 +12,11 @@ #include "script_component.hpp" -_lineMarkers = _this; +PARAMS_1(_lineMarkers); { _marker = _x; - + //Add marker if we don't already have it if (({(_x select 0) == (_marker select 0)} count GVAR(drawing_lineMarkers)) == 0) then { _marker call FUNC(addLineMarker); }; diff --git a/addons/map/functions/fnc_sendMapMarkers.sqf b/addons/map/functions/fnc_copyMapRemoteSend.sqf similarity index 58% rename from addons/map/functions/fnc_sendMapMarkers.sqf rename to addons/map/functions/fnc_copyMapRemoteSend.sqf index 497202a456..27e0a61b72 100644 --- a/addons/map/functions/fnc_sendMapMarkers.sqf +++ b/addons/map/functions/fnc_copyMapRemoteSend.sqf @@ -12,4 +12,6 @@ #include "script_component.hpp" -[GVAR(drawing_lineMarkers), QFUNC(copyMapMarkers), _this] call EFUNC(common,execRemoteFnc); +PARAMS_1(_requester); + +["drawing_sendbackMarkers", _requester, [GVAR(drawing_lineMarkers)]] call EFUNC(common,targetEvent); diff --git a/addons/map/functions/fnc_copyMapStart.sqf b/addons/map/functions/fnc_copyMapStart.sqf new file mode 100644 index 0000000000..d3a1efaa80 --- /dev/null +++ b/addons/map/functions/fnc_copyMapStart.sqf @@ -0,0 +1,23 @@ +/* + * Author: CAA-Picard + * + * Send request to remote player + * + * Argument: + * 0: Player (Unit) + * 0: Target player (Unit) + * + * Code Chain: + * START: copyMapStart: triggers event drawing_requestMarkers on remote + * handeled by: copyMapRemoteSend: triggers event "drawing_sendbackMarkers" on origin + * handeled by: copyMapReceiveMarkers + * + * Return value: + * Return + */ + +#include "script_component.hpp" + +PARAMS_1(_player,_target); + +["drawing_requestMarkers", _target, [_player]] call EFUNC(common,targetEvent); diff --git a/addons/map/functions/fnc_handleKeyDown.sqf b/addons/map/functions/fnc_handleKeyDown.sqf index 28723d5640..bb8b84bb5c 100644 --- a/addons/map/functions/fnc_handleKeyDown.sqf +++ b/addons/map/functions/fnc_handleKeyDown.sqf @@ -60,8 +60,11 @@ if (_code == DIK_DELETE) exitWith { if (_lambdaLong >= 0 && _lambdaLong <= _magDiffVector && _lambdaTrasAbs <= 5) exitWith { // Delete the line marker if (GVAR(drawing_syncMarkers)) then { - [[_x select 0], QFUNC(removeLineMarker), 2] call EFUNC(common,execRemoteFnc); + // [[_x select 0], QFUNC(removeLineMarker), 2] call EFUNC(common,execRemoteFnc); + systemChat "global"; + ["drawing_removeLineMarker", [_x select 0]] call ace_common_fnc_globalEvent; } else { + systemChat "local"; deleteMarkerLocal (_x select 0); GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x]; }; diff --git a/addons/map/functions/fnc_handleMouseButton.sqf b/addons/map/functions/fnc_handleMouseButton.sqf index a524320455..5fdfd3890d 100644 --- a/addons/map/functions/fnc_handleMouseButton.sqf +++ b/addons/map/functions/fnc_handleMouseButton.sqf @@ -25,6 +25,7 @@ _ctrlKey = _params select 5; _altKey = _params select 6; _handled = false; + // If it's not a left button event, exit if (_button != 0) exitWith {}; @@ -48,11 +49,14 @@ if (_dir == 1) exitWith { if (GVAR(drawing_isDrawing)) exitWith { // Already drawing -> Add tempLineMarker to permanent list if (GVAR(drawing_syncMarkers)) then { + systemChat "global"; deleteMarkerLocal (GVAR(drawing_tempLineMarker) select 0); - [GVAR(drawing_tempLineMarker), "FUNC(addLineMarker)", 2] call EFUNC(common,execRemoteFnc); + // [GVAR(drawing_tempLineMarker), "FUNC(addLineMarker)", 2] call EFUNC(common,execRemoteFnc); + ["drawing_addLineMarker", GVAR(drawing_tempLineMarker)] call EFUNC(common,globalEvent); // Log who drew on the briefing screen (text format ["[ACE] Server: Player %1 drew on the briefing screen", name player]) call EFUNC(common,serverLog); } else { + systemChat "local"; GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker); GVAR(drawing_lineMarkers) pushBack (+GVAR(drawing_tempLineMarker)); };