vector distance + azmimuth mode

This commit is contained in:
commy2 2015-01-15 16:21:47 +01:00
parent bc43ee5136
commit 79426252a1
3 changed files with 63 additions and 13 deletions

View File

@ -25,6 +25,7 @@ PREP(showAzimuth);
PREP(showCenter);
PREP(showDistance);
GVAR(holdKeyHandler) = -1;
GVAR(isKeyDownAzimuth) = false;
GVAR(isKeyDownDistance) = false;
GVAR(keyDownTimeAzimuth) = -1;

View File

@ -7,28 +7,44 @@ 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"): {
if (diag_tickTime > GVAR(keyDownTimeDistance) + 0.5) then {
GVAR(isKeyDownDistance) = false; // emulate key release
["distance"] call FUNC(clearDisplay);
};
GVAR(isKeyDownAzimuth) = true;
GVAR(keyDownTimeAzimuth) = diag_tickTime;
[FUNC(onKeyHold), 0, "azimuth"] call CBA_fnc_addPerFrameHandler;
["azimuth"] call FUNC(clearDisplay);
if (diag_tickTime > GVAR(keyDownTimeDistance) + 0.5) then {
["distance"] call FUNC(clearDisplay);
"azimuth" call _fnc_setPFH;
} else {
"azimuth+distance" call _fnc_setPFH;
};
};
case ("distance"): {
if (diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5) then {
GVAR(isKeyDownAzimuth) = false; // emulate key release
["azimuth"] call FUNC(clearDisplay);
};
GVAR(isKeyDownDistance) = true;
GVAR(keyDownTimeDistance) = diag_tickTime;
[FUNC(onKeyHold), 0, "distance"] call CBA_fnc_addPerFrameHandler;
["distance"] call FUNC(clearDisplay);
if (diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5) then {
["azimuth"] call FUNC(clearDisplay);
"distance" call _fnc_setPFH;
} else {
"azimuth+distance" call _fnc_setPFH;
};
};
};

View File

@ -10,12 +10,16 @@ PFH executed while holding a vector key down.
switch (_this select 0) do {
case ("azimuth"): {
if (diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5) then {
[false] call FUNC(showCenter);
call FUNC(showAzimuth);
};
if (!GVAR(isKeyDownAzimuth)) then {
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
@ -30,10 +34,39 @@ switch (_this select 0) do {
if (!GVAR(isKeyDownDistance)) then {
if (_isReady) then {
call FUNC(showDistance);
[false] call FUNC(showCenter);
};
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
case ("azimuth+distance"): {
call FUNC(showAzimuth);
private "_isReady";
_isReady = diag_tickTime > GVAR(keyDownTimeDistance) + 0.5;
[_isReady] call FUNC(showCenter);
if (!GVAR(isKeyDownAzimuth) && {!GVAR(isKeyDownDistance)}) then {
call FUNC(showDistance);
[false] call FUNC(showCenter);
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
};
systemChat str (_this select 0);//