ACE3/addons/vector/functions/fnc_onKeyDown.sqf
2015-01-15 19:01:27 +01:00

71 lines
1.7 KiB
Plaintext

/*
by commy2
Handles pressing the special vector keys.
*/
#include "script_component.hpp"
private "_fnc_setPFH";
_fnc_setPFH = {
if (GVAR(holdKeyHandler) > -1) then {
[GVAR(holdKeyHandler)] call CBA_fnc_removePerFrameHandler;
GVAR(holdKeyHandler) = -1;
};
GVAR(holdKeyHandler) = [FUNC(onKeyHold), 0, _this] call CBA_fnc_addPerFrameHandler;
};
switch (_this select 0) do {
case ("azimuth"): {
["azimuth"] call FUNC(clearDisplay);
GVAR(isKeyDownAzimuth) = true;
if (diag_tickTime < GVAR(keyDownTimeAzimuth) + 0.5) exitWith {
"azimuth+inclination" call _fnc_setPFH;
};
GVAR(keyDownTimeAzimuth) = diag_tickTime;
if (diag_tickTime > GVAR(keyDownTimeDistance) + 0.5) then {
if (GETVARD(isKeyDownDistance,false)) exitWith {
hint "P1 relative distance mode";
};
["distance"] call FUNC(clearDisplay);
"azimuth" call _fnc_setPFH;
} else {
"azimuth+distance" call _fnc_setPFH;
};
};
case ("distance"): {
["distance"] call FUNC(clearDisplay);
GVAR(isKeyDownDistance) = true;
if (diag_tickTime < GVAR(keyDownTimeDistance) + 0.5) exitWith {
"height+distance" call _fnc_setPFH;
};
GVAR(keyDownTimeDistance) = diag_tickTime;
if (diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5) then {
if (GETVARD(isKeyDownAzimuth,false)) exitWith {
hint "P1 relative azimuth + non-slope distance mode";
};
["azimuth"] call FUNC(clearDisplay);
"distance" call _fnc_setPFH;
} else {
"azimuth+distance" call _fnc_setPFH;
};
};
};