diff --git a/addons/maptools/ACE_Settings.hpp b/addons/maptools/ACE_Settings.hpp deleted file mode 100644 index 0a88948a7f..0000000000 --- a/addons/maptools/ACE_Settings.hpp +++ /dev/null @@ -1,6 +0,0 @@ -class ACE_Settings { - class GVAR(everyoneCanDrawOnBriefing) { - value = 1; - typeName = "BOOL"; - }; -}; diff --git a/addons/maptools/CfgVehicles.hpp b/addons/maptools/CfgVehicles.hpp index 063f88f38b..6c9bdc74d9 100644 --- a/addons/maptools/CfgVehicles.hpp +++ b/addons/maptools/CfgVehicles.hpp @@ -3,9 +3,26 @@ class CfgVehicles { class CAManBase: Man { class ACE_SelfActions { + class ACE_MapGpsShow { + displayName = CSTRING(MapGpsShow); + condition = QUOTE((!GVAR(mapGpsShow)) && {call FUNC(canUseMapGPS)}); + statement = QUOTE(GVAR(mapGpsShow) = true; [GVAR(mapGpsShow)] call FUNC(openMapGps)); + exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; + showDisabled = 0; + priority = 0; + }; + class ACE_MapGpsHide { + displayName = CSTRING(MapGpsHide); + condition = QUOTE((GVAR(mapGpsShow)) && {call FUNC(canUseMapGPS)}); + statement = QUOTE(GVAR(mapGpsShow) = false; [GVAR(mapGpsShow)] call FUNC(openMapGps)); + exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; + showDisabled = 0; + priority = 0; + }; + class ACE_MapTools { displayName = CSTRING(MapTools_Menu); - condition = QUOTE((call FUNC(canUseMapTools) || {call FUNC(canUseMapGPS)})); + condition = QUOTE(call FUNC(canUseMapTools)); statement = ""; exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; showDisabled = 0; @@ -13,7 +30,7 @@ class CfgVehicles { class ACE_MapToolsHide { displayName = CSTRING(MapToolsHide); - condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 0})); + condition = QUOTE(GVAR(mapTool_Shown) != 0); statement = QUOTE(GVAR(mapTool_Shown) = 0;); exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; showDisabled = 1; @@ -21,7 +38,7 @@ class CfgVehicles { }; class ACE_MapToolsShowNormal { displayName = CSTRING(MapToolsShowNormal); - condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 1})); + condition = QUOTE(GVAR(mapTool_Shown) != 1); statement = QUOTE(GVAR(mapTool_Shown) = 1;); exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; showDisabled = 1; @@ -29,7 +46,7 @@ class CfgVehicles { }; class ACE_MapToolsShowSmall { displayName = CSTRING(MapToolsShowSmall); - condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 2})); + condition = QUOTE(GVAR(mapTool_Shown) != 2); statement = QUOTE(GVAR(mapTool_Shown) = 2;); exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; showDisabled = 1; @@ -37,7 +54,7 @@ class CfgVehicles { }; class ACE_MapToolsAlignNorth { displayName = CSTRING(MapToolsAlignNorth); - condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 0})); + condition = QUOTE(GVAR(mapTool_Shown) != 0); statement = QUOTE(GVAR(mapTool_angle) = 0;); exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; showDisabled = 1; @@ -45,40 +62,12 @@ class CfgVehicles { }; class ACE_MapToolsAlignCompass { displayName = CSTRING(MapToolsAlignCompass); - condition = QUOTE((call FUNC(canUseMapTools) && {GVAR(mapTool_Shown) != 0} && {('ItemCompass' in assigneditems ACE_player) || {'ItemCompass' in assigneditems ACE_player}})); + condition = QUOTE((GVAR(mapTool_Shown) != 0) && {'ItemCompass' in assigneditems ACE_player}); statement = QUOTE(GVAR(mapTool_angle) = getDir ACE_player;); exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; showDisabled = 1; priority = 1; }; - class ACE_MapGpsShow { - displayName = CSTRING(MapGpsShow); - condition = QUOTE((call FUNC(canUseMapGPS) && {!GVAR(mapGpsShow)})); - statement = QUOTE(GVAR(mapGpsShow) = true; [GVAR(mapGpsShow)] call FUNC(openMapGps)); - exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; - showDisabled = 0; - priority = 0; - }; - class ACE_MapGpsHide { - displayName = CSTRING(MapGpsHide); - condition = QUOTE((call FUNC(canUseMapGPS) && {GVAR(mapGpsShow)})); - statement = QUOTE(GVAR(mapGpsShow) = false; [GVAR(mapGpsShow)] call FUNC(openMapGps)); - exceptions[] = {"isNotDragging", "notOnMap", "isNotInside", "isNotSitting"}; - showDisabled = 0; - priority = 0; - }; - }; - }; - - class ACE_Actions { - class ACE_MainActions { - class ACE_CopyMap { - displayName = CSTRING(CopyMap); - 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/maptools/MapControls.hpp b/addons/maptools/MapControls.hpp deleted file mode 100644 index 409796a6b1..0000000000 --- a/addons/maptools/MapControls.hpp +++ /dev/null @@ -1,80 +0,0 @@ -class controls { - class CA_PlayerName: RscText { - x = "2 * ( ((safezoneW / safezoneH) min 1.2) / 40)"; - }; - class ProfilePicture: RscPicture { - x = "13.5 * ( ((safezoneW / safezoneH) min 1.2) / 40)"; - }; - class ProfileBackground: RscText { - x = "13.3 * ( ((safezoneW / safezoneH) min 1.2) / 40)"; - }; - class Separator1: RscPicture { - x = "14.5 * ( ((safezoneW / safezoneH) min 1.2) / 40)"; - }; - class ColorBlack: RscButton { - idc = 36732; - x = "0 * (((safezoneW / safezoneH) min 1.2) / 40)"; - y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)"; - h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - colorBackground[] = {0.2,0.2,0.2,1}; - colorBackgroundActive[] = {0,0,0,1}; - colorFocused[] = {0,0,0,1}; - onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorBlack')]); - }; - class ColorRed: RscButton { - idc = 36733; - x = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)"; - y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)"; - h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - colorBackground[] = {0.8,0.2,0.2,1}; - colorBackgroundActive[] = {1,0,0,1}; - colorFocused[] = {1,0,0,1}; - onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorRed')]); - }; - class ColorGreen: RscButton { - idc = 36734; - x = "0.6 * (((safezoneW / safezoneH) min 1.2) / 40)"; - y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)"; - h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - colorBackground[] = {0.2,0.8,0.2,1}; - colorBackgroundActive[] = {0,1,0,1}; - colorFocused[] = {0,1,0,1}; - onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorGreen')]); - }; - class ColorBlue: RscButton { - idc = 36735; - x = "0.9 * (((safezoneW / safezoneH) min 1.2) / 40)"; - y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)"; - h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - colorBackground[] = {0.2,0.2,0.8,1}; - colorBackgroundActive[] = {0,0,1,1}; - colorFocused[] = {0,0,1,1}; - onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorBlue')]); - }; - class ColorYellow: RscButton { - idc = 36736; - x = "1.2 * (((safezoneW / safezoneH) min 1.2) / 40)"; - y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)"; - h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - colorBackground[] = {0.8,0.8,0.2,1}; - colorBackgroundActive[] = {1,1,0,1}; - colorFocused[] = {1,1,0,1}; - onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorYellow')]); - }; - class ColorWhite: RscButton { - idc = 36737; - x = "1.5 * (((safezoneW / safezoneH) min 1.2) / 40)"; - y = "0.25 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - w = "0.3 * (((safezoneW / safezoneH) min 1.2) / 40)"; - h = "1.00 * ((((safezoneW / safezoneH) min 1.2) / 1.2) / 25)"; - colorBackground[] = {0.8,0.8,0.8,1}; - colorBackgroundActive[] = {1,1,1,1}; - colorFocused[] = {1,1,1,1}; - onButtonClick = QUOTE(missionNamespace setVariable [ARR_2(QUOTE(QGVAR(drawing_drawColor)),'ColorWhite')]); - }; -}; diff --git a/addons/maptools/XEH_PREP.hpp b/addons/maptools/XEH_PREP.hpp index cff37aa65d..1670c59593 100644 --- a/addons/maptools/XEH_PREP.hpp +++ b/addons/maptools/XEH_PREP.hpp @@ -1,20 +1,9 @@ - -PREP(addLineMarker); PREP(calculateMapScale); -PREP(cancelDrawing); -PREP(canDraw); -PREP(canUseMapTools); PREP(canUseMapGPS); -PREP(copyMapReceiveMarkers); -PREP(copyMapRemoteSend); -PREP(copyMapStart); -PREP(handleKeyDown); +PREP(canUseMapTools); PREP(handleMouseButton); PREP(handleMouseMove); -PREP(handleMouseZChanged); PREP(isInsideMapTool); PREP(openMapGps); PREP(openMapGpsUpdate); -PREP(removeLineMarker); PREP(updateMapToolMarkers); -PREP(updateLineMarker); diff --git a/addons/maptools/XEH_postInitClient.sqf b/addons/maptools/XEH_postInitClient.sqf index ec2293b3e2..388ffd6b81 100644 --- a/addons/maptools/XEH_postInitClient.sqf +++ b/addons/maptools/XEH_postInitClient.sqf @@ -5,7 +5,6 @@ if (!hasInterface) exitWith {}; // Init variables -GVAR(mapVisableLastFrame) = false; GVAR(mapGpsShow) = true; GVAR(mapTool_Shown) = 0; @@ -14,57 +13,14 @@ GVAR(mapTool_angle) = 0; GVAR(mapTool_isDragging) = false; GVAR(mapTool_isRotating) = false; -GVAR(drawing_isDrawing) = false; -GVAR(drawing_tempLineMarker) = []; -GVAR(drawing_lineMarkers) = []; -GVAR(drawing_drawColor) = "ColorBlack"; -GVAR(drawing_controls) = [36732, 36733, 36734, 36735, 36736, 36737]; - -// This spawn is probably worth keeping, as pfh don't work natively on the briefing screen and IDK how reliable the hack we implemented for them is. -// The thread dies as soon as the mission start, so it's not really compiting for scheduler space. -[] spawn { - _fnc_installMapEvents = { - private "_d"; - _d = _this; - ((findDisplay _d) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {_this call FUNC(handleMouseMove);}]; - ((findDisplay _d) displayCtrl 51) ctrlAddEventHandler ["MouseButtonDown", {[1, _this] call FUNC(handleMouseButton);}]; - ((findDisplay _d) displayCtrl 51) ctrlAddEventHandler ["MouseButtonUp", {[0, _this] call FUNC(handleMouseButton)}]; - ((findDisplay _d) displayCtrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(updateMapToolMarkers);}]; - (findDisplay _d) displayAddEventHandler ["KeyDown", {_this call FUNC(handleKeyDown);}]; - }; - - // Wait until the briefing map is detected - // display = 37 for SP - // display = 52 for host server on MP; - // display = 53 for MP clients) - waitUntil {(!isNull findDisplay 37) || (!isNull findDisplay 52) || (!isNull findDisplay 53) || (!isNull findDisplay 12)}; - - if (isNull findDisplay 12) then { - // Install event handlers on the map control of the briefing screen (control = 51) - GVAR(drawing_syncMarkers) = true; - if (!isNull findDisplay 52) then { - 52 call _fnc_installMapEvents; - } else { - if (!isNull findDisplay 53) then { - 53 call _fnc_installMapEvents; - } else { - 37 call _fnc_installMapEvents; - }; - }; - } else { - // Briefing screen was skipped; the player is JIP, create the markers defined during the briefing - GVAR(drawing_syncMarkers) = false; - { - _x call FUNC(addLineMarker); - } forEach GVAR(drawing_serverLineMarkers); - }; - - // Wait until the main map display is detected (display = 12) - waitUntil { !isNull findDisplay 12 }; - // Install event handlers on the map control and display (control = 51) - GVAR(drawing_syncMarkers) = false; - 12 call _fnc_installMapEvents; -}; +//Install the event handers for the map tools on the main in-game map +[{!isNull findDisplay 12}, +{ + ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {_this call FUNC(handleMouseMove);}]; + ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonDown", {[1, _this] call FUNC(handleMouseButton);}]; + ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonUp", {[0, _this] call FUNC(handleMouseButton)}]; + ((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {_this call FUNC(updateMapToolMarkers);}]; +}, []] call CBA_fnc_waitUntilAndExecute; ["ace_visibleMapChanged", { params ["", "_mapOn"]; @@ -74,7 +30,5 @@ GVAR(drawing_controls) = [36732, 36733, 36734, 36735, 36736, 36737]; } else { // Hide GPS [false] call FUNC(openMapGps); - // Cancel drawing - call FUNC(cancelDrawing); }; }] call CBA_fnc_addEventHandler; diff --git a/addons/maptools/XEH_preInit.sqf b/addons/maptools/XEH_preInit.sqf index 76daa4f305..a7feade1c3 100644 --- a/addons/maptools/XEH_preInit.sqf +++ b/addons/maptools/XEH_preInit.sqf @@ -4,16 +4,4 @@ ADDON = false; #include "XEH_PREP.hpp" -if (isServer) then { - GVAR(drawing_serverLineMarkers) = []; - publicVariable QGVAR(drawing_serverLineMarkers); -}; - -//Add Event Handlers: -[QGVAR(removeLineMarker), FUNC(removeLineMarker)] call CBA_fnc_addEventHandler; -[QGVAR(addLineMarker), FUNC(addLineMarker)] call CBA_fnc_addEventHandler; - -[QGVAR(requestMarkers), FUNC(copyMapRemoteSend)] call CBA_fnc_addEventHandler; -[QGVAR(sendbackMarkers), FUNC(copyMapReceiveMarkers)] call CBA_fnc_addEventHandler; - ADDON = true; diff --git a/addons/maptools/config.cpp b/addons/maptools/config.cpp index f5267ad11a..45239b67ae 100644 --- a/addons/maptools/config.cpp +++ b/addons/maptools/config.cpp @@ -12,8 +12,6 @@ class CfgPatches { }; }; -#include "ACE_Settings.hpp" - class RscControlsGroup; class RscActiveText; class RscPicture; @@ -29,47 +27,3 @@ class RscEdit; #include "CfgEventHandlers.hpp" #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" - - -// REGULAR MAP -class RscDisplayMainMap { - // Create the drawing color selector - class controls { - class TopRight: RscControlsGroup { - #include "MapControls.hpp" - }; - }; -}; - -// BRIEFING SCREEN -class RscDisplayGetReady: RscDisplayMainMap { - // Create the drawing color selector - class controls { - class TopRight: RscControlsGroup { - #include "MapControls.hpp" - }; - }; -}; -class RscDisplayClientGetReady: RscDisplayGetReady { - // Create the drawing color selector - class controls { - class TopRight: RscControlsGroup { - #include "MapControls.hpp" - }; - }; -}; -class RscDisplayServerGetReady: RscDisplayGetReady { - // Create the drawing color selector - class controls { - class TopRight: RscControlsGroup { - #include "MapControls.hpp" - }; - }; -}; - -class ACE_newEvents { - drawing_sendbackMarkers = QGVAR(sendbackMarkers); - drawing_requestMarkers = QGVAR(requestMarkers); - drawing_addLineMarker = QGVAR(addLineMarker); - drawing_removeLineMarker = QGVAR(removeLineMarker); -}; diff --git a/addons/maptools/functions/fnc_addLineMarker.sqf b/addons/maptools/functions/fnc_addLineMarker.sqf deleted file mode 100644 index 017dc5b494..0000000000 --- a/addons/maptools/functions/fnc_addLineMarker.sqf +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Author: esteldunedain - * Add the line marker - * - * Arguments: - * 0: Marker Name - * 1: Marker start pos - * 2: Marker end pos - * 3: Color index - * - * Return value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -params ["_name", "_startPos", "_endPos", "_color"]; - -private ["_marker", "_difPos", "_mag"]; - -_difPos = _endPos vectorDiff _startPos; - -_marker = createMarkerLocal [_name, _startPos]; -_name setMarkerShapeLocal "RECTANGLE"; -_name setMarkerAlphaLocal 1; -_name setMarkerColorLocal _color; -_name setMarkerPosLocal (_startPos vectorAdd (_difPos vectorMultiply 0.5)); -_mag = vectorMagnitude _difPos; -if (_mag > 0) then { - _name setMarkerSizeLocal [5, _mag / 2]; - _name setMarkerDirLocal (180 + (_difPos select 0) atan2 (_difPos select 1) mod 360); -} else { - _name setMarkerSizeLocal [5, 5]; - _name setMarkerDirLocal 0; -}; - -GVAR(drawing_lineMarkers) pushBack (+_this); - -if (isServer && GVAR(drawing_syncMarkers)) then { - GVAR(drawing_serverLineMarkers) pushBack (+_this); - publicVariable QGVAR(drawing_serverLineMarkers); -}; diff --git a/addons/maptools/functions/fnc_calculateMapScale.sqf b/addons/maptools/functions/fnc_calculateMapScale.sqf index 018edf68d9..525955cdcd 100644 --- a/addons/maptools/functions/fnc_calculateMapScale.sqf +++ b/addons/maptools/functions/fnc_calculateMapScale.sqf @@ -12,9 +12,7 @@ */ #include "script_component.hpp" -private ["_screenOffset", "_pos"]; - -_pos = ((findDisplay 12) displayCtrl 51) ctrlMapScreenToWorld [0.5, 0.5]; -_screenOffset = ((findDisplay 12) displayCtrl 51) posWorldToScreen [(_pos select 0) + 100, (_pos select 1)]; +private _pos = ((findDisplay 12) displayCtrl 51) ctrlMapScreenToWorld [0.5, 0.5]; +private _screenOffset = ((findDisplay 12) displayCtrl 51) posWorldToScreen [(_pos select 0) + 100, (_pos select 1)]; (_screenOffset select 0) - 0.5 diff --git a/addons/maptools/functions/fnc_canDraw.sqf b/addons/maptools/functions/fnc_canDraw.sqf deleted file mode 100644 index da55043d85..0000000000 --- a/addons/maptools/functions/fnc_canDraw.sqf +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Author: esteldunedain - * canDraw - * - * Arguments: - * None - * - * Return value: - * - * - * Public: No - */ -#include "script_component.hpp" - -(missionNameSpace getVariable [QGVAR(drawing_syncMarkers), true] && {GVAR(EveryoneCanDrawOnBriefing)}) || -{(!isNull ACE_player) && {"ACE_MapTools" in items ACE_player}} diff --git a/addons/maptools/functions/fnc_cancelDrawing.sqf b/addons/maptools/functions/fnc_cancelDrawing.sqf deleted file mode 100644 index bc80602cfc..0000000000 --- a/addons/maptools/functions/fnc_cancelDrawing.sqf +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Author: esteldunedain - * Cancel the drawing of the current line marker - * - * Arguments: - * None - * - * Return value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -GVAR(drawing_isDrawing) = false; -if (count GVAR(drawing_tempLineMarker) > 0) then { - deleteMarkerLocal (GVAR(drawing_tempLineMarker) select 0); -}; -GVAR(drawing_tempLineMarker) = []; diff --git a/addons/maptools/functions/fnc_copyMapReceiveMarkers.sqf b/addons/maptools/functions/fnc_copyMapReceiveMarkers.sqf deleted file mode 100644 index 6c3c706208..0000000000 --- a/addons/maptools/functions/fnc_copyMapReceiveMarkers.sqf +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Author: esteldunedain - * Copy recieved markers to map - * - * Arguments: - * 0: Array of markers to copy - * - * Return value: - * None - * - * Public: No - */ -#include "script_component.hpp" - -params ["_lineMarkers"]; - -{ - private "_marker"; - _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); - }; -} forEach _lineMarkers; diff --git a/addons/maptools/functions/fnc_copyMapRemoteSend.sqf b/addons/maptools/functions/fnc_copyMapRemoteSend.sqf deleted file mode 100644 index 56ea2683e9..0000000000 --- a/addons/maptools/functions/fnc_copyMapRemoteSend.sqf +++ /dev/null @@ -1,17 +0,0 @@ -/* - * Author: esteldunedain - * - * Send Map markers to other player - * - * Argument: - * 0: Target player (Unit) - * - * Return value: - * Return - */ - -#include "script_component.hpp" - -params ["_requester"]; - -[QGVAR(sendbackMarkers), [GVAR(drawing_lineMarkers)], _requester] call CBA_fnc_targetEvent; diff --git a/addons/maptools/functions/fnc_copyMapStart.sqf b/addons/maptools/functions/fnc_copyMapStart.sqf deleted file mode 100644 index 62361447f6..0000000000 --- a/addons/maptools/functions/fnc_copyMapStart.sqf +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Author: esteldunedain - * Send request to remote player - * - * Arguments: - * 0: Player - * 0: Target player - * - * 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 ["_player", "_target"]; - -[QGVAR(requestMarkers), [_player], _target] call CBA_fnc_targetEvent; diff --git a/addons/maptools/functions/fnc_handleKeyDown.sqf b/addons/maptools/functions/fnc_handleKeyDown.sqf deleted file mode 100644 index c93ce4724c..0000000000 --- a/addons/maptools/functions/fnc_handleKeyDown.sqf +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Author: esteldunedain - * Handle key down on map. - * - * Arguments: - * 0: Display (display) - * 1: Key code (number) - * 2: Shift Key (boolean) - * 3: Ctrl Key (boolean) - * 4: Alt Key (boolean) - * - * Return value: - * Boolean, true if event was handled - */ - -#include "script_component.hpp" - -params ["", "_code"]; -TRACE_1("params",_code); - -private ["_handled", "_relPos", "_diffVector", "_magDiffVector", "_lambdaLong", "_lambdaTrasAbs"]; - -_handled = false; - -#define DIK_ESCAPE 0x01 -#define DIK_DELETE 0xD3 - -// If pressed Esc while drawing -if (_code == DIK_ESCAPE) exitWith { - if (GVAR(drawing_isDrawing)) then { - call FUNC(cancelDrawing); - _handled = true; - }; - _handled -}; - -if (_code == DIK_DELETE) exitWith { - if (GVAR(drawing_isDrawing)) then { - call FUNC(cancelDrawing); - _handled = true; - } else { - - // Check if a line marker needs to be deleted - { - _relPos = GVAR(mousePosition) vectorDiff (_x select 1); - _diffVector = (_x select 2) vectorDiff (_x select 1); - _magDiffVector = vectorMagnitude _diffVector; - if (_magDiffVector == 0) then { - _diffVector = [10,0,0]; - _magDiffVector = vectorMagnitude _diffVector; - }; - _diffVector = _diffVector vectorMultiply (1/_magDiffVector); - - // Projection of the relative position over the longitudinal axis - _lambdaLong = _diffVector vectorDotProduct _relPos; - // Projection of the relative position over the trasversal axis - _lambdaTrasAbs = vectorMagnitude (_relPos vectorDiff (_diffVector vectorMultiply _lambdaLong)); - if (_lambdaLong >= 0 && _lambdaLong <= _magDiffVector && _lambdaTrasAbs <= 5) exitWith { - // Delete the line marker - if (GVAR(drawing_syncMarkers)) then { - [QGVAR(removeLineMarker), [_x select 0]] call CBA_fnc_globalEvent; - } else { - deleteMarkerLocal (_x select 0); - GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x]; - }; - _handled = true; - }; - } forEach GVAR(drawing_lineMarkers); - }; - _handled -}; - -_handled diff --git a/addons/maptools/functions/fnc_handleMouseButton.sqf b/addons/maptools/functions/fnc_handleMouseButton.sqf index 62debbb55f..57a08456e5 100644 --- a/addons/maptools/functions/fnc_handleMouseButton.sqf +++ b/addons/maptools/functions/fnc_handleMouseButton.sqf @@ -9,16 +9,13 @@ * Return value: * Boolean, true if event was handled */ - #include "script_component.hpp" params ["_dir", "_params"]; _params params ["_control", "_button", "_screenPosX", "_screenPosY", "_shiftKey", "_ctrlKey", "_altKey"]; TRACE_2("params",_dir,_params); -private["_gui", "_handled", "_marker", "_pos"]; - -_handled = false; +private _handled = false; // If it's not a left button event, exit if (_button != 0) exitWith {_handled}; @@ -32,51 +29,24 @@ if (_dir != 1) then { }; } else { // If clicking - if !(call FUNC(canDraw)) exitWith {_handled = false;}; + if !(call FUNC(canUseMapTools)) exitWith {}; // Transform mouse screen position to coordinates - _pos = _control ctrlMapScreenToWorld [_screenPosX, _screenPosY]; + private _pos = _control ctrlMapScreenToWorld [_screenPosX, _screenPosY]; _pos set [count _pos, 0]; - if (GVAR(drawing_isDrawing)) exitWith { - // Already drawing -> Add tempLineMarker to permanent list - if (GVAR(drawing_syncMarkers)) then { - deleteMarkerLocal (GVAR(drawing_tempLineMarker) select 0); - [QGVAR(addLineMarker), GVAR(drawing_tempLineMarker)] call CBA_fnc_globalEvent; - // Log who drew on the briefing screen - [ACE_INFOFORMAT_1("Player %1 drew on the briefing screen", profileName)] call EFUNC(common,serverLog); - } else { - GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker); - GVAR(drawing_lineMarkers) pushBack (+GVAR(drawing_tempLineMarker)); - }; - GVAR(drawing_tempLineMarker) = []; - GVAR(drawing_isDrawing) = false; - _handled = true; - }; - - if (_altKey) exitWith { - // Start drawing - GVAR(drawing_isDrawing) = true; - // Create tempLineMarker - _gui = format ["%1%2%3%4", random (100), random (100), random (100), random (100)]; - GVAR(drawing_tempLineMarker) = [_gui, + _pos, + _pos, GVAR(drawing_drawColor)]; - _marker = createMarkerLocal [_gui, [0,0]]; - GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker); - _handled = true; - }; - GVAR(mapTool_isDragging) = false; GVAR(mapTool_isRotating) = false; // If no map tool marker then exit - if (GVAR(mapTool_Shown) == 0) exitWith {_handled = false;}; + if (GVAR(mapTool_Shown) == 0) exitWith {}; // Check if clicking the maptool if (_pos call FUNC(isInsideMapTool)) exitWith { // Store data for dragging GVAR(mapTool_startPos) = + GVAR(mapTool_pos); GVAR(mapTool_startDragPos) = + _pos; - if (_ctrlKey) then { + if (_altKey) then { // Store data for rotating GVAR(mapTool_startAngle) = + GVAR(mapTool_angle); GVAR(mapTool_startDragAngle) = (180 + ((GVAR(mapTool_startDragPos) select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((GVAR(mapTool_startDragPos) select 1) - (GVAR(mapTool_startPos) select 1)) mod 360); @@ -88,7 +58,6 @@ if (_dir != 1) then { }; _handled = true; }; - _handled }; _handled diff --git a/addons/maptools/functions/fnc_handleMouseMove.sqf b/addons/maptools/functions/fnc_handleMouseMove.sqf index b27087290b..86c0c11212 100644 --- a/addons/maptools/functions/fnc_handleMouseMove.sqf +++ b/addons/maptools/functions/fnc_handleMouseMove.sqf @@ -15,44 +15,28 @@ params ["_control", "_mousePosX", "_mousePosY"]; TRACE_3("params",_control,_mousePosX,_mousePosY); -private ["_control", "_pos"]; - -GVAR(mousePosition) = _control ctrlMapScreenToWorld [_mousePosX, _mousePosY]; -GVAR(mousePosition) set [2, 0]; //convert 2d pos to 3d - -// If cannot draw then exit -if !(call FUNC(canDraw)) exitWith { - // If was drawing, cancel - if (GVAR(drawing_isDrawing)) then { - call FUNC(cancelDrawing); - }; +// If have no map tools, then exit +if (((isNull ACE_player) || {!("ACE_MapTools" in items ACE_player)})) exitWith { false }; -// Handle drawing -if (GVAR(drawing_isDrawing)) exitWith { - GVAR(drawing_tempLineMarker) set [2, GVAR(mousePosition)]; - TRACE_1("updating line pos",GVAR(mousePosition)); - GVAR(drawing_tempLineMarker) call FUNC(updateLineMarker); - false -}; - -// Handle Map tools +// If map tools not shown, then exit if (GVAR(mapTool_Shown) == 0) exitWith {false}; +private _mousePosition = _control ctrlMapScreenToWorld [_mousePosX, _mousePosY]; + // Translation if (GVAR(mapTool_isDragging)) exitWith { - GVAR(mapTool_pos) set [0, (GVAR(mapTool_startPos) select 0) + (GVAR(mousePosition) select 0) - (GVAR(mapTool_startDragPos) select 0)]; - GVAR(mapTool_pos) set [1, (GVAR(mapTool_startPos) select 1) + (GVAR(mousePosition) select 1) - (GVAR(mapTool_startDragPos) select 1)]; + GVAR(mapTool_pos) set [0, (GVAR(mapTool_startPos) select 0) + (_mousePosition select 0) - (GVAR(mapTool_startDragPos) select 0)]; + GVAR(mapTool_pos) set [1, (GVAR(mapTool_startPos) select 1) + (_mousePosition select 1) - (GVAR(mapTool_startDragPos) select 1)]; true }; // Rotation if (GVAR(mapTool_isRotating)) exitWith { - private "_angle"; // Get new angle - _angle = (180 + ((GVAR(mousePosition) select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((GVAR(mousePosition) select 1) - (GVAR(mapTool_startPos) select 1)) mod 360); + private _angle = (180 + ((_mousePosition select 0) - (GVAR(mapTool_startPos) select 0)) atan2 ((_mousePosition select 1) - (GVAR(mapTool_startPos) select 1)) mod 360); GVAR(mapTool_angle) = GVAR(mapTool_startAngle) + _angle - GVAR(mapTool_startDragAngle); true diff --git a/addons/maptools/functions/fnc_handleMouseZChanged.sqf b/addons/maptools/functions/fnc_handleMouseZChanged.sqf deleted file mode 100644 index 0af86a81c5..0000000000 --- a/addons/maptools/functions/fnc_handleMouseZChanged.sqf +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Author: esteldunedain - * - * Handle mouse wheel. - * - * Argument: - * 0: Control - * 1: Scroll Amount - * - * Return value: - * Boolean, true if event was handled - */ - -#include "script_component.hpp" - -private ["_dir", "_params", "_control", "_button", "_screenPos", "_shiftKey", "_ctrlKey", "_handled", "_pos"]; - -_control = _this select 0; -_dir = _this select 1; -_handled = false; - -_handled = true; -// If drawing, change line color - - -//@todo AGM bug: -// ACE_Map_drawColors is never defined - -/* if (count GVAR(drawing_tempLineMarker) > 0) then { -ACE_Map_drawColor = if (_dir > 0) then {ACE_Map_drawColor + 1} else {ACE_Map_drawColor - 1}; -if (ACE_Map_drawColor >= count ACE_Map_drawColors) then { - ACE_Map_drawColor = ACE_Map_drawColor - count ACE_Map_drawColors; -}; -if (ACE_Map_drawColor < 0) then { - ACE_Map_drawColor = ACE_Map_drawColor + count ACE_Map_drawColors; -}; -GVAR(drawing_tempLineMarker) set [3, ACE_Map_drawColor]; -GVAR(drawing_tempLineMarker) call ACE_Map_fnc_updateLineMarker; - -_handled = true; -}; */ -_handled diff --git a/addons/maptools/functions/fnc_isInsideMapTool.sqf b/addons/maptools/functions/fnc_isInsideMapTool.sqf index eeaf8f346a..d86828ad07 100644 --- a/addons/maptools/functions/fnc_isInsideMapTool.sqf +++ b/addons/maptools/functions/fnc_isInsideMapTool.sqf @@ -16,21 +16,19 @@ #define DIST_TOP_TO_CENTER_PERC 0.65 #define DIST_LEFT_TO_CENTER_PERC 0.30 -private ["_textureWidth", "_relPos", "_dirVector", "_lambdaLong", "_lambdaTrasAbs", "_pos"]; - if (GVAR(mapTool_Shown) == 0) exitWith {false}; -_textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapTool_Shown) - 1); +private _textureWidth = [TEXTURE_WIDTH_IN_M, TEXTURE_WIDTH_IN_M / 2] select (GVAR(mapTool_Shown) - 1); -_pos = [_this select 0, _this select 1, 0]; -_relPos = _pos vectorDiff [GVAR(mapTool_pos) select 0, GVAR(mapTool_pos) select 1, 0]; -_dirVector = [sin(GVAR(mapTool_angle)), cos(GVAR(mapTool_angle)), 0]; +private _pos = [_this select 0, _this select 1, 0]; +private _relPos = _pos vectorDiff [GVAR(mapTool_pos) select 0, GVAR(mapTool_pos) select 1, 0]; +private _dirVector = [sin(GVAR(mapTool_angle)), cos(GVAR(mapTool_angle)), 0]; // Projection of the relative position over the longitudinal axis of the map tool -_lambdaLong = _dirVector vectorDotProduct _relPos; +private _lambdaLong = _dirVector vectorDotProduct _relPos; if (_lambdaLong < DIST_BOTTOM_TO_CENTER_PERC * _textureWidth) exitWith {false}; // Projection of the relative position over the trasversal axis of the map tool -_lambdaTrasAbs = vectorMagnitude (_relPos vectorDiff (_dirVector vectorMultiply _lambdaLong)); +private _lambdaTrasAbs = vectorMagnitude (_relPos vectorDiff (_dirVector vectorMultiply _lambdaLong)); if (_lambdaLong > DIST_TOP_TO_CENTER_PERC * _textureWidth) exitWith {false}; if (_lambdaTrasAbs > DIST_LEFT_TO_CENTER_PERC * _textureWidth) exitWith {false}; diff --git a/addons/maptools/functions/fnc_openMapGps.sqf b/addons/maptools/functions/fnc_openMapGps.sqf index dc2df07b57..0f4bb62c87 100644 --- a/addons/maptools/functions/fnc_openMapGps.sqf +++ b/addons/maptools/functions/fnc_openMapGps.sqf @@ -14,9 +14,7 @@ params ["_shouldOpenGps"]; -private ["_isOpen"]; - -_isOpen = !(isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull])); +private _isOpen = !(isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull])); if (_shouldOpenGps && {"ItemGPS" in assignedItems ACE_player} && {!_isOpen}) then { ("RscACE_MapGps" call BIS_fnc_rscLayer) cutRsc ["RscACE_MapGps","PLAIN"]; diff --git a/addons/maptools/functions/fnc_openMapGpsUpdate.sqf b/addons/maptools/functions/fnc_openMapGpsUpdate.sqf index 4a77f4a6c3..719bf37763 100644 --- a/addons/maptools/functions/fnc_openMapGpsUpdate.sqf +++ b/addons/maptools/functions/fnc_openMapGpsUpdate.sqf @@ -3,16 +3,14 @@ #include "script_component.hpp" -private ["_mapGpsDisplay", "_ctrl"]; - if ((!("ItemGPS" in assigneditems ACE_player)) || {isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull])}) exitWith { ("RscACE_MapGps" call BIS_fnc_rscLayer) cutText ["","PLAIN"]; // Close GPS RSC [(_this select 1)] call CBA_fnc_removePerFrameHandler; // Remove frameHandler }; disableSerialization; -_mapGpsDisplay = uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]; -_ctrl = _mapGpsDisplay displayCtrl 913590; +private _mapGpsDisplay = uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]; +private _ctrl = _mapGpsDisplay displayCtrl 913590; _ctrl ctrlSetText str (round (getDir ACE_player)); // Set Heading _ctrl = _mapGpsDisplay displayCtrl 913591; _ctrl ctrlSetText str (round ((getPosASL ACE_player) select 2) + EGVAR(common,mapAltitude)); // Set Altitude diff --git a/addons/maptools/functions/fnc_removeLineMarker.sqf b/addons/maptools/functions/fnc_removeLineMarker.sqf deleted file mode 100644 index bd0a16adb1..0000000000 --- a/addons/maptools/functions/fnc_removeLineMarker.sqf +++ /dev/null @@ -1,30 +0,0 @@ -/* - * Author: esteldunedain - * Remove the line marker - * - * Arguments: - * 0: Marker Name - * - * Return value: - * Return - */ - -#include "script_component.hpp" - -params ["_name"]; - -deleteMarkerLocal _name; -{ - if ((_x select 0) == _name) exitWith { - GVAR(drawing_lineMarkers) = GVAR(drawing_lineMarkers) - [_x]; - }; -} forEach GVAR(drawing_lineMarkers); - -if (isServer && GVAR(drawing_syncMarkers)) then { - { - if ((_x select 0) == _name) exitWith { - GVAR(drawing_serverLineMarkers) = GVAR(drawing_serverLineMarkers) - [_x]; - publicVariable QGVAR(drawing_serverLineMarkers); - }; - } forEach GVAR(drawing_serverLineMarkers); -}; diff --git a/addons/maptools/functions/fnc_updateLineMarker.sqf b/addons/maptools/functions/fnc_updateLineMarker.sqf deleted file mode 100644 index 12aee5b1df..0000000000 --- a/addons/maptools/functions/fnc_updateLineMarker.sqf +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Author: esteldunedain - * Updates the line marker position and scale - * - * Arguments: - * 0: Marker Name - * 1: Marker start pos - * 2: Marker end pos - * 3: Color index - * - * Return value: - * None - */ -#include "script_component.hpp" - -params ["_name", "_startPos", "_endPos", "_color"]; -TRACE_4("params",_name,_startPos,_endPos,_color); - -private ["_difPos", "_mag"]; - -_difPos = _endPos vectorDiff _startPos; - -_name setMarkerShapeLocal "RECTANGLE"; -_name setMarkerAlphaLocal 1; -_name setMarkerColorLocal GVAR(drawing_drawColor); -_name setMarkerPosLocal (_startPos vectorAdd (_difPos vectorMultiply 0.5)); -_mag = vectorMagnitude _difPos; -if (_mag > 0) then { - _name setMarkerSizeLocal [5, _mag / 2]; - _name setMarkerDirLocal (180 + (_difPos select 0) atan2 (_difPos select 1) mod 360); -} else { - _name setMarkerSizeLocal [5, 5]; - _name setMarkerDirLocal 0; -}; diff --git a/addons/maptools/functions/fnc_updateMapToolMarkers.sqf b/addons/maptools/functions/fnc_updateMapToolMarkers.sqf index 530d213773..5a3b0e0821 100644 --- a/addons/maptools/functions/fnc_updateMapToolMarkers.sqf +++ b/addons/maptools/functions/fnc_updateMapToolMarkers.sqf @@ -18,22 +18,10 @@ params ["_theMap"]; -private ["_rotatingTexture", "_textureWidth", "_scaleX", "_scaleY", "_xPos", "_yPos"]; +if ((GVAR(mapTool_Shown) == 0) || {!("ACE_MapTools" in items ACE_player)}) exitWith {}; -// Show/Hide draw buttons -if ([] call FUNC(canDraw)) then { - { ((findDisplay 12) displayCtrl _x) ctrlShow true; } forEach GVAR(drawing_controls); -} else { - { ((findDisplay 12) displayCtrl _x) ctrlShow false; } forEach GVAR(drawing_controls); - if (GVAR(drawing_isDrawing)) then { - call FUNC(cancelDrawing); - }; -}; - -if (!("ACE_MapTools" in items ACE_player)|| {GVAR(mapTool_Shown) == 0}) exitWith {}; - -_rotatingTexture = ""; -_textureWidth = 0; +private _rotatingTexture = ""; +private _textureWidth = 0; if (GVAR(mapTool_Shown) == 1) then { _rotatingTexture = QPATHTOF(data\mapToolRotatingNormal.paa); _textureWidth = TEXTURE_WIDTH_IN_M; @@ -44,12 +32,12 @@ if (GVAR(mapTool_Shown) == 1) then { // Update scale of both parts getResolution params ["_resWidth", "_resHeight", "", "", "_aspectRatio"]; -_scaleX = 32 * _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale)); -_scaleY = _scaleX * ((_resWidth / _resHeight) / _aspectRatio); //handle bad aspect ratios +private _scaleX = 32 * _textureWidth * CONSTANT_SCALE * (call FUNC(calculateMapScale)); +private _scaleY = _scaleX * ((_resWidth / _resHeight) / _aspectRatio); //handle bad aspect ratios // Position of the fixed part -_xPos = GVAR(mapTool_pos) select 0; -_yPos = (GVAR(mapTool_pos) select 1) + _textureWidth * CENTER_OFFSET_Y_PERC; +private _xPos = GVAR(mapTool_pos) select 0; +private _yPos = (GVAR(mapTool_pos) select 1) + _textureWidth * CENTER_OFFSET_Y_PERC; _theMap drawIcon [QPATHTOF(data\mapToolFixed.paa), [1,1,1,1], [_xPos,_yPos], _scaleX, _scaleY, 0, "", 0]; diff --git a/addons/maptools/stringtable.xml b/addons/maptools/stringtable.xml index 3db0d4d972..b86a67633c 100644 --- a/addons/maptools/stringtable.xml +++ b/addons/maptools/stringtable.xml @@ -121,18 +121,6 @@ Schovat GPS na mapě Скрыть GPS на карте - - Copy Map - Karte kopieren - Copiar mapa - Скопировать карту - Kopiuj oznaczenia mapy - Copier la carte - Zkopírovat mapu - Copiare Carta - Térkép másolása - Copiar Mapa - Direction: %1° Drehung: %1°