Map Opened/Closed Events + use in maptools

This commit is contained in:
PabstMirror 2015-06-28 13:08:47 -05:00
parent f52babe546
commit fde8f7383f
5 changed files with 42 additions and 36 deletions

View File

@ -353,5 +353,23 @@ GVAR(deviceKeyCurrentIndex) = -1;
{false},
[0xC7, [true, false, false]], false] call cba_fnc_addKeybind; //SHIFT + Home Key
//Map opened/closed Events:
GVAR(mapOpened) = false;
[] spawn {
waitUntil {(!isNull findDisplay 12)};
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {
if (!GVAR(mapOpened)) then {
GVAR(mapOpened) = true;
["mapOpened", []] call FUNC(localEvent);
[{
if (!visibleMap) then {
GVAR(mapOpened) = false;
["mapClosed", []] call FUNC(localEvent);
[_this select 1] call CBA_fnc_removePerFrameHandler;
};
}, 0, []] call CBA_fnc_addPerFrameHandler;
};
}];
};
GVAR(commonPostInited) = true;

View File

@ -67,6 +67,18 @@ GVAR(drawing_controls) = [36732, 36733, 36734, 36735, 36736, 36737];
// Update the size and rotation of map tools
[] call FUNC(updateMapToolMarkers);
[FUNC(mapStateUpdater), 0, []] call CBA_fnc_addPerFrameHandler;
};
["mapOpened", {
// Show and update map tools if required
[] call FUNC(updateMapToolMarkers);
// Show GPS if required
[GVAR(mapGpsShow)] call FUNC(openMapGps);
}] call EFUNC(common,addEventHandler);
["mapClosed", {
// Hide GPS
[false] call FUNC(openMapGps);
// Cancel drawing
call FUNC(cancelDrawing);
}] call EFUNC(common,addEventHandler);

View File

@ -16,7 +16,6 @@ PREP(handleMouseButton);
PREP(handleMouseMove);
PREP(handleMouseZChanged);
PREP(isInsideMapTool);
PREP(mapStateUpdater);
PREP(openMapGps);
PREP(openMapGpsUpdate);
PREP(removeLineMarker);

View File

@ -1,33 +0,0 @@
#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);
// Cancel drawing
call FUNC(cancelDrawing);
};
//When Map is Opened:
if ((!GVAR(mapVisableLastFrame)) && (visibleMap)) then {
//todo: "mapOpened" Event????
GVAR(mapVisableLastFrame) = true;
// Show and update map tools if required
[] call FUNC(updateMapToolMarkers);
// Show GPS if required
[GVAR(mapGpsShow)] call FUNC(openMapGps);
};

View File

@ -20,6 +20,16 @@ PARAMS_1(_theMap);
private ["_rotatingTexture", "_textureWidth", "_scale", "_xPos", "_yPos"];
// 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);
};
};
if (!("ACE_MapTools" in items ACE_player)|| {GVAR(mapTool_Shown) == 0}) exitWith {};
_rotatingTexture = "";