ACE3/addons/maptools/XEH_postInitClient.sqf

81 lines
3.0 KiB
Plaintext
Raw Normal View History

2015-03-24 04:18:00 +00:00
// by esteldunedain
#include "script_component.hpp"
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 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 = {
2015-04-17 23:13:09 +00:00
private "_d";
_d = _this;
2015-08-18 02:51:40 +00:00
((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;
};
["ace_visibleMapChanged", {
2015-08-30 20:26:43 +00:00
params ["", "_mapOn"];
if (_mapOn) then {
// Show GPS if required
[GVAR(mapGpsShow)] call FUNC(openMapGps);
} else {
// Hide GPS
[false] call FUNC(openMapGps);
// Cancel drawing
call FUNC(cancelDrawing);
};
}] call CBA_fnc_addEventHandler;