2015-01-15 21:50:48 +00:00
|
|
|
#include "script_component.hpp"
|
|
|
|
|
2015-06-21 19:10:50 +00:00
|
|
|
// Exit on Headless as well
|
2015-08-11 17:49:39 +00:00
|
|
|
if (!hasInterface) exitWith {};
|
2015-06-21 19:10:50 +00:00
|
|
|
|
2015-03-14 19:58:05 +00:00
|
|
|
LOG(MSG_INIT);
|
2015-01-16 08:13:29 +00:00
|
|
|
|
2015-03-14 19:58:05 +00:00
|
|
|
// Calculate the maximum zoom allowed for this map
|
|
|
|
call FUNC(determineZoom);
|
2015-01-16 08:13:29 +00:00
|
|
|
|
2015-08-11 17:49:39 +00:00
|
|
|
[{
|
|
|
|
if (isNull findDisplay 12) exitWith {};
|
2015-01-16 08:13:29 +00:00
|
|
|
|
2015-03-14 19:58:05 +00:00
|
|
|
GVAR(lastStillPosition) = ((findDisplay 12) displayCtrl 51) ctrlMapScreenToWorld [0.5, 0.5];
|
2015-05-21 16:42:44 +00:00
|
|
|
GVAR(lastStillTime) = ACE_time;
|
2015-03-14 19:58:05 +00:00
|
|
|
GVAR(isShaking) = false;
|
2015-01-16 08:13:29 +00:00
|
|
|
|
2015-08-11 17:49:39 +00:00
|
|
|
//map sizes are multiples of 1280
|
|
|
|
GVAR(worldSize) = worldSize / 1280;
|
|
|
|
GVAR(mousePos) = [0.5,0.5];
|
|
|
|
|
2015-07-01 05:13:55 +00:00
|
|
|
//Allow panning the lastStillPosition while mapShake is active
|
|
|
|
GVAR(rightMouseButtonLastPos) = [];
|
2015-03-14 19:58:05 +00:00
|
|
|
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["Draw", {[] call FUNC(updateMapEffects);}];
|
2015-07-01 05:13:55 +00:00
|
|
|
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {
|
|
|
|
if (GVAR(isShaking) && {(count GVAR(rightMouseButtonLastPos)) == 2}) then {
|
|
|
|
private["_lastPos", "_newPos"];
|
|
|
|
_lastPos = (_this select 0) ctrlMapScreenToWorld GVAR(rightMouseButtonLastPos);
|
|
|
|
_newPos = (_this select 0) ctrlMapScreenToWorld (_this select [1,2]);
|
|
|
|
GVAR(lastStillPosition) set [0, (GVAR(lastStillPosition) select 0) + (_lastPos select 0) - (_newPos select 0)];
|
|
|
|
GVAR(lastStillPosition) set [1, (GVAR(lastStillPosition) select 1) + (_lastPos select 1) - (_newPos select 1)];
|
|
|
|
GVAR(rightMouseButtonLastPos) = _this select [1,2];
|
|
|
|
TRACE_3("Mouse Move",_lastPos,_newPos,GVAR(rightMouseButtonLastPos));
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonDown", {
|
|
|
|
if ((_this select 1) == 1) then {
|
|
|
|
GVAR(rightMouseButtonLastPos) = _this select [2,2];
|
|
|
|
};
|
|
|
|
}];
|
|
|
|
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseButtonUp", {
|
|
|
|
if ((_this select 1) == 1) then {
|
|
|
|
GVAR(rightMouseButtonLastPos) = [];
|
|
|
|
};
|
|
|
|
}];
|
2015-08-11 17:49:39 +00:00
|
|
|
|
|
|
|
//get mouse position on map
|
|
|
|
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseMoving", {
|
|
|
|
GVAR(mousePos) = (_this select 0) ctrlMapScreenToWorld [_this select 1, _this select 2];
|
|
|
|
}];
|
|
|
|
((findDisplay 12) displayCtrl 51) ctrlAddEventHandler ["MouseHolding", {
|
|
|
|
GVAR(mousePos) = (_this select 0) ctrlMapScreenToWorld [_this select 1, _this select 2];
|
|
|
|
}];
|
|
|
|
|
|
|
|
[_this select 1] call CBA_fnc_removePerFrameHandler;
|
|
|
|
}, 0] call CBA_fnc_addPerFrameHandler;
|
2015-03-14 19:58:05 +00:00
|
|
|
|
2015-06-21 02:19:12 +00:00
|
|
|
["SettingsInitialized", {
|
|
|
|
// Start Blue Force Tracking if Enabled
|
|
|
|
if (GVAR(BFT_Enabled)) then {
|
|
|
|
GVAR(BFT_markers) = [];
|
|
|
|
[FUNC(blueForceTrackingUpdate), GVAR(BFT_Interval), []] call CBA_fnc_addPerFrameHandler;
|
|
|
|
};
|
2015-08-11 17:49:39 +00:00
|
|
|
|
|
|
|
//illumination settings
|
|
|
|
if (GVAR(mapIllumination)) then {
|
|
|
|
GVAR(flashlightInUse) = "";
|
|
|
|
GVAR(glow) = objNull;
|
|
|
|
|
|
|
|
["playerInventoryChanged", {
|
|
|
|
_flashlights = [ACE_player] call FUNC(getUnitFlashlights);
|
|
|
|
if ((GVAR(flashlightInUse) != "") && !(GVAR(flashlightInUse) in _flashlights)) then {
|
|
|
|
GVAR(flashlightInUse) = "";
|
|
|
|
};
|
|
|
|
}] call EFUNC(common,addEventHandler);
|
|
|
|
|
|
|
|
if (GVAR(mapGlow)) then {
|
|
|
|
["visibleMapChanged", {
|
|
|
|
params ["_player", "_mapOn"];
|
|
|
|
if (_mapOn) then {
|
|
|
|
if (!alive _player && !isNull GVAR(glow)) then {
|
|
|
|
GVAR(flashlightInUse) = "";
|
|
|
|
};
|
|
|
|
if (GVAR(flashlightInUse) != "") then {
|
|
|
|
if (isNull GVAR(glow)) then {
|
|
|
|
[GVAR(flashlightInUse)] call FUNC(flashlightGlow);
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
if (!isNull GVAR(glow)) then {
|
|
|
|
[""] call FUNC(flashlightGlow);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} else {
|
|
|
|
if (!isNull GVAR(glow)) then {
|
|
|
|
[""] call FUNC(flashlightGlow);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}] call EFUNC(common,addEventHandler);
|
|
|
|
};
|
|
|
|
};
|
2015-09-01 23:59:07 +00:00
|
|
|
}] call EFUNC(common,addEventHandler);
|
|
|
|
|
|
|
|
// hide clock on map if player has no watch
|
|
|
|
GVAR(hasWatch) = true;
|
|
|
|
|
|
|
|
["playerInventoryChanged", {
|
|
|
|
if (isNull (_this select 0)) exitWith {
|
|
|
|
GVAR(hasWatch) = true;
|
|
|
|
};
|
|
|
|
GVAR(hasWatch) = "ItemWatch" in (_this select 1 select 17);
|
2015-09-03 11:37:36 +00:00
|
|
|
}] call EFUNC(common,addEventHandler)
|