From 687c7e98aafa19c17c47edf14bcd08489369b2a0 Mon Sep 17 00:00:00 2001 From: PabstMirror Date: Fri, 16 Jan 2015 02:13:29 -0600 Subject: [PATCH] almost done --- addons/map/CfgVehicles.hpp | 20 +- addons/map/MapGpsUI.hpp | 3 +- addons/map/XEH_postInitClient.sqf | 204 +++++------------- addons/map/XEH_preInit.sqf | 5 +- .../map/functions/fnc_blueForceTracking.sqf | 34 --- .../functions/fnc_blueForceTrackingModule.sqf | 32 +++ .../functions/fnc_blueForceTrackingUpdate.sqf | 38 ++++ addons/map/functions/fnc_canDraw.sqf | 2 +- addons/map/functions/fnc_mapStateUpdater.sqf | 39 ++++ addons/map/functions/fnc_openMapGps.sqf | 44 ++-- addons/map/functions/fnc_openMapGpsUpdate.sqf | 18 ++ .../functions/fnc_updateMapToolMarkers.sqf | 16 +- 12 files changed, 224 insertions(+), 231 deletions(-) delete mode 100644 addons/map/functions/fnc_blueForceTracking.sqf create mode 100644 addons/map/functions/fnc_blueForceTrackingModule.sqf create mode 100644 addons/map/functions/fnc_blueForceTrackingUpdate.sqf create mode 100644 addons/map/functions/fnc_mapStateUpdater.sqf create mode 100644 addons/map/functions/fnc_openMapGpsUpdate.sqf diff --git a/addons/map/CfgVehicles.hpp b/addons/map/CfgVehicles.hpp index 4dce6d8125..d00383868c 100644 --- a/addons/map/CfgVehicles.hpp +++ b/addons/map/CfgVehicles.hpp @@ -20,8 +20,8 @@ class CfgVehicles { class ACE_MapToolsHide { displayName = "$STR_ACE_Map_MapToolsHide"; - condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapToolsShown > 0}"; - statement = "ACE_Map_mapToolsShown = 0; [] call ACE_Map_fnc_updateMapToolMarkers"; + condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapTool_Shown > 0}"; + statement = "ACE_Map_mapTool_Shown = 0; [] call ACE_Map_fnc_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_mapToolsShown != 1}"; - statement = "ACE_Map_mapToolsShown = 1; [] call ACE_Map_fnc_updateMapToolMarkers"; + condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapTool_Shown != 1}"; + statement = "ACE_Map_mapTool_Shown = 1; [] call ACE_Map_fnc_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_mapToolsShown != 2}"; - statement = "ACE_Map_mapToolsShown = 2; [] call ACE_Map_fnc_updateMapToolMarkers"; + condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapTool_Shown != 2}"; + statement = "ACE_Map_mapTool_Shown = 2; [] call ACE_Map_fnc_updateMapToolMarkers"; exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 1; priority = 3; @@ -47,7 +47,7 @@ class CfgVehicles { }; class ACE_MapToolsAlignNorth { displayName = "$STR_ACE_Map_MapToolsAlignNorth"; - condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapToolsShown != 0}"; + condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapTool_Shown != 0}"; statement = "ACE_Map_angle = 0; [] call ACE_Map_fnc_updateMapToolMarkers"; exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 1; @@ -56,7 +56,7 @@ class CfgVehicles { }; class ACE_MapToolsAlignCompass { displayName = "$STR_ACE_Map_MapToolsAlignCompass"; - condition = "(call ACE_Map_fnc_canUseMapTools) && {ACE_Map_mapToolsShown != 0} && {(""ItemCompass"" in assignedItems player) || {""ItemGPS"" in assignedItems player}}"; + 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"; exceptions[] = {"ACE_Drag_isNotDragging", "ACE_Core_notOnMap"}; showDisabled = 1; @@ -87,7 +87,7 @@ class CfgVehicles { class ACE_Actions { class ACE_CopyMap { displayName = "$STR_ACE_Map_CopyMap"; - condition = "isPlayer ACE_Interaction_Target && {""ItemMap"" in assignedItems player} && {""ACE_MapTools"" in items player} && {""ItemMap"" in assignedItems ACE_Interaction_Target}"; + 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"; showDisabled = 0; priority = -1; @@ -135,7 +135,7 @@ class CfgVehicles { author = "$STR_ACE_Common_ACETeam"; category = "ACE"; displayName = "Blue Force Tracking"; - function = "ACE_Map_fnc_blueForceTracking"; + function = QFUNC(blueForceTrackingModule); scope = 2; isGlobal = 1; icon = PATHTOF(UI\IconBFTracking_ca.paa); diff --git a/addons/map/MapGpsUI.hpp b/addons/map/MapGpsUI.hpp index ba49204cd9..f6caec29c9 100644 --- a/addons/map/MapGpsUI.hpp +++ b/addons/map/MapGpsUI.hpp @@ -19,7 +19,8 @@ class RscTitles { duration = 3600; fadein = 0; fadeout = 0; - onLoad = QUOTE(uiNamespace setVariable [ARR_2(QGVAR(ui_mapGpsDisplay), _this select 0)];); + // onLoad = QUOTE(uiNamespace setVariable [ARR_2(QGVAR(ui_mapGpsDisplay), _this select 0)];); @todo cbaify this + onLoad = "uiNamespace setVariable ['ACE_map_ui_mapGpsDisplay', _this select 0];"; //onUnLoad = "_this call onRscLoad"; class controls { class back:RscPicture { diff --git a/addons/map/XEH_postInitClient.sqf b/addons/map/XEH_postInitClient.sqf index e25a7e4dd8..a151ceee66 100644 --- a/addons/map/XEH_postInitClient.sqf +++ b/addons/map/XEH_postInitClient.sqf @@ -4,154 +4,68 @@ if (!hasInterface) exitWith{}; +// Init variables +GVAR(mapVisableLastFrame) = false; +GVAR(mapGpsShow) = true; + +GVAR(mapTool_Shown) = 0; +GVAR(mapTool_pos) = [0,0]; +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 is a one and done spawn, probably ok?? [] spawn { - while {true} do { - sleep 5; - _markers = []; + _fnc_installMapEvents = { + _d = _this; + diag_log format ["Installing EH in display %1", _d]; + ((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", {[] call FUNC(updateMapToolMarkers);}]; + (finddisplay _d) displayAddEventHandler ["KeyDown", {_this call FUNC(handleKeyDown);}]; + }; - while {GVAR(BFT_Enabled) and {(!isNil "ACE_player") and {alive ACE_player}}} do { + // 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)}; - _groups = []; - _playerSide = call EFUNC(common,playerSide); + 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); + }; - if (GVAR(BFT_HideAiGroups)) then { - _groups = [allGroups, {side _this == _playerSide}] call EFUNC(common,filter); - } else { - _groups = [allGroups, { - _anyPlayers = { - [_x] call EFUNC(common,isPlayer); - } count units _this; - (side _this == _playerSide) && _anyPlayers > 0 - }] call EFUNC(common,filter); - }; + // 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; - { - deleteMarkerLocal _x; - } forEach _markers; - _markers = []; - - for "_i" from 0 to (count _groups - 1) do { - _group1 = _groups select _i; - - _markerType = [_group1] call EFUNC(common,getMarkerType); - - _colour = format ["Color%1", side _group1]; - - _marker = createMarkerLocal [format ["ACE_BFT_%1", _i], [(getPos leader _group1) select 0, (getPos leader _group1) select 1]]; - _marker setMarkerTypeLocal _markerType; - _marker setMarkerColorLocal _colour; - _marker setMarkerTextLocal (groupID _group1); - - _markers pushBack _marker; - }; - - sleep GVAR(BFT_Interval); - }; - - // Delete markers as soon as the player dies - { - deleteMarkerLocal _x; - } forEach _markers; - }; -}; - -[] spawn { - // Init variables - GVAR(mapTool_Shown) = 0; - GVAR(mapTool_pos) = [0,0]; - GVAR(mapTool_angle) = 0; - GVAR(mapTool_isDragging) = false; - GVAR(mapTool_isRotating) = false; - - GVAR(mapGpsShow) = true; - - GVAR(drawing_isDrawing) = false; - GVAR(drawing_tempLineMarker) = []; - GVAR(drawing_lineMarkers) = []; - GVAR(drawing_drawColor) = "ColorBlack"; - GVAR(drawing_controls) = [36732, 36733, 36734, 36735, 36736, 36737]; - - _fnc_installMapEvents = { - _d = _this; - diag_log format ["Installing EH in display %1", _d]; - ((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", {[] 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; - - // Update the size and rotation of map tools - [] call FUNC(updateMapToolMarkers); - - while {true} do { - waitUntil {visibleMap}; - - // Show and update map tools if required - [] call FUNC(updateMapToolMarkers); - // Show GPS if required - [GVAR(mapGpsShow)] call FUNC(openMapGps); - - // Update visibility of maptools and gps, handling inventory changes - [] spawn { - while {visibleMap} do { - // Show/Hide draw buttons - if ("ACE_MapTools" in items player) 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); - }; - }; - sleep 1; - }; - }; - - waitUntil {!visibleMap}; - - // Hide GPS - [false] call FUNC(openMapGps); - // Hide Map tools - deleteMarkerLocal MARKERNAME_MAPTOOL_FIXED; - deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGNORMAL; - deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGSMALL; - GVAR(mapTool_markerRotatingFixed) = nil; - GVAR(mapTool_markerRotatingNormal) = nil; - GVAR(mapTool_markerRotatingSmall) = nil; - // Cancel drawing - call FUNC(cancelDrawing); - }; + // Update the size and rotation of map tools + [] call FUNC(updateMapToolMarkers); + + [FUNC(mapStateUpdater), 0, []] call CBA_fnc_addPerFrameHandler; }; diff --git a/addons/map/XEH_preInit.sqf b/addons/map/XEH_preInit.sqf index 87b7d4294a..5aa74bb7a3 100644 --- a/addons/map/XEH_preInit.sqf +++ b/addons/map/XEH_preInit.sqf @@ -1,7 +1,8 @@ #include "script_component.hpp" PREP(addLineMarker); -PREP(blueForceTracking); +PREP(blueForceTrackingModule); +PREP(blueForceTrackingUpdate); PREP(calculateMapScale); PREP(cancelDrawing); PREP(canDraw); @@ -13,7 +14,9 @@ PREP(handleMouseButton); PREP(handleMouseMove); PREP(handleMouseZChanged); PREP(isInsideMapTool); +PREP(mapStateUpdater); PREP(openMapGps); +PREP(openMapGpsUpdate); PREP(removeLineMarker); PREP(sendMapMarkers); PREP(updateMapToolMarkers); diff --git a/addons/map/functions/fnc_blueForceTracking.sqf b/addons/map/functions/fnc_blueForceTracking.sqf deleted file mode 100644 index 69659705c8..0000000000 --- a/addons/map/functions/fnc_blueForceTracking.sqf +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Author: KoffeinFlummi - * - * Initializes the blue force tracking module. - * - * Arguments: - * Whatever the module provides. (I dunno.) - * - * Return Value: - * None - */ - -#include "script_component.hpp" - -if !(hasInterface) exitWith {}; - -_logic = _this select 0; -_units = _this select 1; -_activated = _this select 2; - -if !(_activated) exitWith {}; - -_logic spawn { - waitUntil {alive player}; - - GVAR(BFT_Enabled) = true; - [_this, QGVAR(BFT_Interval), "Interval"] call EFUNC(common,readNumericParameterFromModule); - [_this, QGVAR(BFT_HideAiGroups), "HideAiGroups"] call EFUNC(common,readBooleanParameterFromModule); - - diag_log text "[ACE]: Blue Force Tracking Module initialized."; - TRACE_2("[ACE]: Blue Force Tracking Module initialized.",GVAR(BFT_Interval), GVAR(BFT_HideAiGroups)); - - //@toDo start BFT here: -}; diff --git a/addons/map/functions/fnc_blueForceTrackingModule.sqf b/addons/map/functions/fnc_blueForceTrackingModule.sqf new file mode 100644 index 0000000000..3951473026 --- /dev/null +++ b/addons/map/functions/fnc_blueForceTrackingModule.sqf @@ -0,0 +1,32 @@ +/* +* Author: KoffeinFlummi +* +* Initializes the blue force tracking module. +* +* Arguments: +* Whatever the module provides. (I dunno.) +* +* Return Value: +* None +*/ + +#include "script_component.hpp" + +if !(hasInterface) exitWith {}; + +_logic = _this select 0; +_units = _this select 1; +_activated = _this select 2; + +if !(_activated) exitWith {}; + +GVAR(BFT_Enabled) = true; +[_logic, QGVAR(BFT_Interval), "Interval"] call EFUNC(common,readNumericParameterFromModule); +[_logic, QGVAR(BFT_HideAiGroups), "HideAiGroups"] call EFUNC(common,readBooleanParameterFromModule); + +diag_log text "[ACE]: Blue Force Tracking Module initialized."; +TRACE_2("[ACE]: Blue Force Tracking Module initialized.",GVAR(BFT_Interval), GVAR(BFT_HideAiGroups)); + +//start BFT: +GVAR(BFT_markers) = []; +[FUNC(blueForceTrackingUpdate), GVAR(BFT_Interval), []] call CBA_fnc_addPerFrameHandler; diff --git a/addons/map/functions/fnc_blueForceTrackingUpdate.sqf b/addons/map/functions/fnc_blueForceTrackingUpdate.sqf new file mode 100644 index 0000000000..b2619155c2 --- /dev/null +++ b/addons/map/functions/fnc_blueForceTrackingUpdate.sqf @@ -0,0 +1,38 @@ +#include "script_component.hpp" + +// Delete last set of markers (always) +{ + deleteMarkerLocal _x; +} forEach GVAR(BFT_markers); + + +if (GVAR(BFT_Enabled) and {(!isNil "ACE_player") and {alive ACE_player}}) then { + + _groupsToDrawMarkers = []; + _playerSide = call EFUNC(common,playerSide); + + if (GVAR(BFT_HideAiGroups)) then { + _groupsToDrawMarkers = [allGroups, {side _this == _playerSide}] call EFUNC(common,filter); + } else { + _groupsToDrawMarkers = [allGroups, { + _anyPlayers = { + [_x] call EFUNC(common,isPlayer); + } count units _this; + (side _this == _playerSide) && _anyPlayers > 0 + }] call EFUNC(common,filter); + }; + + + { + _markerType = [_x] call EFUNC(common,getMarkerType); + + _colour = format ["Color%1", side _x]; + + _marker = createMarkerLocal [format ["ACE_BFT_%1", _i], [(getPos leader _x) select 0, (getPos leader _x) select 1]]; + _marker setMarkerTypeLocal _markerType; + _marker setMarkerColorLocal _colour; + _marker setMarkerTextLocal (groupID _x); + + GVAR(BFT_markers) pushBack _marker; + } forEach _groupsToDrawMarkers; +}; diff --git a/addons/map/functions/fnc_canDraw.sqf b/addons/map/functions/fnc_canDraw.sqf index 8694bfee0a..2c3cc68e21 100644 --- a/addons/map/functions/fnc_canDraw.sqf +++ b/addons/map/functions/fnc_canDraw.sqf @@ -3,4 +3,4 @@ #include "script_component.hpp" (missionNameSpace getVariable [QGVAR(drawing_syncMarkers), true] && {GVAR(EveryoneCanDrawOnBriefing)}) || -{(!isNull player) && {"ACE_MapTools" in items player}} +{(!isNull ACE_player) && {"ACE_MapTools" in items ACE_player}} diff --git a/addons/map/functions/fnc_mapStateUpdater.sqf b/addons/map/functions/fnc_mapStateUpdater.sqf new file mode 100644 index 0000000000..cbbcb46393 --- /dev/null +++ b/addons/map/functions/fnc_mapStateUpdater.sqf @@ -0,0 +1,39 @@ + +#include "script_component.hpp" + +if (visibleMap) then { + // Show/Hide draw buttons + if ("ACE_MapTools" in items ACE_player) 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); + }; + }; +}; + +//When Map is Closed: +if (GVAR(mapVisableLastFrame) && (!visibleMap)) then { + GVAR(mapVisableLastFrame) = false; + // Hide GPS + [false] call FUNC(openMapGps); + // Hide Map tools + deleteMarkerLocal MARKERNAME_MAPTOOL_FIXED; + deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGNORMAL; + deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGSMALL; + GVAR(mapTool_markerRotatingFixed) = nil; + GVAR(mapTool_markerRotatingNormal) = nil; + GVAR(mapTool_markerRotatingSmall) = nil; + // Cancel drawing + call FUNC(cancelDrawing); +}; + +//When Map is Opened: +if ((!GVAR(mapVisableLastFrame)) && (visibleMap)) then { + GVAR(mapVisableLastFrame) = true; + // Show and update map tools if required + [] call FUNC(updateMapToolMarkers); + // Show GPS if required + [GVAR(mapGpsShow)] call FUNC(openMapGps); +}; diff --git a/addons/map/functions/fnc_openMapGps.sqf b/addons/map/functions/fnc_openMapGps.sqf index f75e874497..c89416401b 100644 --- a/addons/map/functions/fnc_openMapGps.sqf +++ b/addons/map/functions/fnc_openMapGps.sqf @@ -1,42 +1,24 @@ /* - * Author: CAA-Picard - * - * Opens or closes the gps on the map screen, showing coordinates - * - * Argument: - * 0: Open GPS? (Boolean) - * - * Return value: - * Nothing - */ +* Author: CAA-Picard +* +* Opens or closes the gps on the map screen, showing coordinates +* +* Argument: +* 0: Open GPS? (Boolean) +* +* Return value: +* Nothing +*/ #include "script_component.hpp" -_open = _this select 0; +_shouldOpenGps = _this select 0; _isOpen = !(isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull])); -if (_open && {"ItemGPS" in assignedItems player} && {!_isOpen}) then { +if (_shouldOpenGps && {"ItemGPS" in assignedItems ACE_player} && {!_isOpen}) then { ("RscACE_MapGps" call BIS_fnc_rscLayer) cutRsc ["RscACE_MapGps","PLAIN"]; - // Spawn a thread to update gps display - [] spawn { - disableSerialization; - while {!(isNull (uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]))} do { - if !("ItemGPS" in assignedItems player) exitWith {}; - - _mapGpsDisplay = uiNamespace getVariable [QGVAR(ui_mapGpsDisplay), displayNull]; - _ctrl = _mapGpsDisplay displayCtrl 913590; - _ctrl ctrlSetText str(round(getDir player)); - _ctrl = _mapGpsDisplay displayCtrl 913591; - _ctrl ctrlSetText str(round((getPosASL player) select 2)); - _ctrl = _mapGpsDisplay displayCtrl 913592; - _ctrl ctrlSetText mapGridPosition player; - - sleep 0.5; - }; - ("RscACE_MapGps" call BIS_fnc_rscLayer) cutText ["","PLAIN"]; - }; - + [FUNC(openMapGpsUpdate), 0.5, []] call CBA_fnc_addPerFrameHandler; //update bearing/altitude every 0.5 sec (ticktime) } else { ("RscACE_MapGps" call BIS_fnc_rscLayer) cutText ["","PLAIN"]; }; diff --git a/addons/map/functions/fnc_openMapGpsUpdate.sqf b/addons/map/functions/fnc_openMapGpsUpdate.sqf new file mode 100644 index 0000000000..ea022b4cf2 --- /dev/null +++ b/addons/map/functions/fnc_openMapGpsUpdate.sqf @@ -0,0 +1,18 @@ +//CAA-Picard +//update gps display + +#include "script_component.hpp" + +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; +_ctrl ctrlSetText str(round(getDir player)); //set Heading +_ctrl = _mapGpsDisplay displayCtrl 913591; +_ctrl ctrlSetText str(round((getPosASL player) select 2)); //set Altitude +_ctrl = _mapGpsDisplay displayCtrl 913592; +_ctrl ctrlSetText mapGridPosition player; //set grid cords diff --git a/addons/map/functions/fnc_updateMapToolMarkers.sqf b/addons/map/functions/fnc_updateMapToolMarkers.sqf index 91af97af76..a167a8eb45 100644 --- a/addons/map/functions/fnc_updateMapToolMarkers.sqf +++ b/addons/map/functions/fnc_updateMapToolMarkers.sqf @@ -17,38 +17,38 @@ #define CONSTANT_SCALE 0.2 // If markers exist and they should'nt, delete them -if (!("ACE_MapTools" in items player) || {GVAR(mapTool_Shown) == 0}) then { +if (!("ACE_MapTools" in items ACE_player) || {GVAR(mapTool_Shown) == 0}) then { // If markers exist, delete them if (!isNil QGVAR(mapTool_markerRotatingFixed)) then { deleteMarkerLocal MARKERNAME_MAPTOOL_FIXED; GVAR(mapTool_markerRotatingFixed) = nil; }; }; -if (!("ACE_MapTools" in items player) || {GVAR(mapTool_Shown) != 1}) then { - if (!isNil "GVAR(mapTool_markerRotatingNormal)") then { +if (!("ACE_MapTools" in items ACE_player) || {GVAR(mapTool_Shown) != 1}) then { + if (!isNil QGVAR(mapTool_markerRotatingNormal)) then { deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGNORMAL; GVAR(mapTool_markerRotatingNormal) = nil; }; }; -if (!("ACE_MapTools" in items player) || {GVAR(mapTool_Shown) != 2}) then { - if (!isNil "GVAR(mapTool_markerRotatingSmall)") then { +if (!("ACE_MapTools" in items ACE_player) || {GVAR(mapTool_Shown) != 2}) then { + if (!isNil QGVAR(mapTool_markerRotatingSmall)) then { deleteMarkerLocal MARKERNAME_MAPTOOL_ROTATINGSMALL; GVAR(mapTool_markerRotatingSmall) = nil; }; }; -if (!("ACE_MapTools" in items player)|| {GVAR(mapTool_Shown) == 0}) exitWith {}; +if (!("ACE_MapTools" in items ACE_player)|| {GVAR(mapTool_Shown) == 0}) exitWith {}; // If markers don't exist and should, create them if (isNil QGVAR(mapTool_markerRotatingFixed)) then { GVAR(mapTool_markerRotatingFixed) = createMarkerLocal [MARKERNAME_MAPTOOL_FIXED, GVAR(mapTool_pos)]; MARKERNAME_MAPTOOL_FIXED setMarkerType MARKERNAME_MAPTOOL_FIXED; }; -if ((isNil "GVAR(mapTool_markerRotatingNormal)") && {GVAR(mapTool_Shown) == 1}) then { +if ((isNil QGVAR(mapTool_markerRotatingNormal)) && {GVAR(mapTool_Shown) == 1}) then { GVAR(mapTool_markerRotatingNormal) = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGNORMAL, GVAR(mapTool_pos)]; MARKERNAME_MAPTOOL_ROTATINGNORMAL setMarkerType MARKERNAME_MAPTOOL_ROTATINGNORMAL; }; -if ((isNil "GVAR(mapTool_markerRotatingSmall)") && {GVAR(mapTool_Shown) == 2}) then { +if ((isNil QGVAR(mapTool_markerRotatingSmall)) && {GVAR(mapTool_Shown) == 2}) then { GVAR(mapTool_markerRotatingSmall) = createMarkerLocal [MARKERNAME_MAPTOOL_ROTATINGSMALL, GVAR(mapTool_pos)]; MARKERNAME_MAPTOOL_ROTATINGSMALL setMarkerType MARKERNAME_MAPTOOL_ROTATINGSMALL; };