ACE3/addons/vector/functions/fnc_onKeyDown.sqf

190 lines
6.0 KiB
Plaintext
Raw Permalink Normal View History

#include "..\script_component.hpp"
2015-01-15 06:18:57 +00:00
/*
* Author: commy2
* Handles pressing the special vector keys.
*
* Arguments:
* 0: String <STRING>
*
* Return Value:
* None
*
* Example:
* ["azimuth"] call ace_vector_fnc_onKeyDown
*
* Public: No
*/
2015-01-15 06:18:57 +00:00
2015-01-21 22:05:19 +00:00
// set vector config settings
switch (GVAR(modeReticle)) do {
case (0): {
[false] call FUNC(adjustBrightness);
[false] call FUNC(showReticle);
};
case (1): {
[false] call FUNC(adjustBrightness);
[true] call FUNC(showReticle);
};
case (2): {
[true] call FUNC(adjustBrightness);
[true] call FUNC(showReticle);
};
};
private _fnc_setPFH = {
2015-01-15 15:21:47 +00:00
if (GVAR(holdKeyHandler) > -1) then {
[GVAR(holdKeyHandler)] call CBA_fnc_removePerFrameHandler;
GVAR(holdKeyHandler) = -1;
};
2015-01-21 20:15:51 +00:00
GVAR(currentMode) = _this;
GVAR(holdKeyHandler) = [LINKFUNC(onKeyHold), 0, _this] call CBA_fnc_addPerFrameHandler;
2015-01-15 15:21:47 +00:00
};
2015-01-15 06:18:57 +00:00
switch (_this select 0) do {
case ("azimuth"): {
2015-01-21 21:52:39 +00:00
GVAR(keyDownTabCountDistance) = 0;
2015-01-15 06:18:57 +00:00
2015-01-21 20:15:51 +00:00
// handle input in option menu
if (GVAR(currentMode) == "settings") exitWith {
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeMenu) + 1) exitWith {};
2015-01-21 20:15:51 +00:00
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeAzimuth) + 0.5) then {
2015-01-21 20:15:51 +00:00
GVAR(keyDownTabCountAzimuth) = (GETGVAR(keyDownTabCountAzimuth,0)) + 1;
} else {
GVAR(keyDownTabCountAzimuth) = 1;
};
2016-03-02 10:01:39 +00:00
GVAR(keyDownTimeAzimuth) = diag_tickTime;
2015-01-21 20:15:51 +00:00
};
if (GVAR(currentMode) == "config") exitWith {
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeMenu) + 0.5) exitWith {};
2015-01-21 20:15:51 +00:00
2015-01-21 21:52:39 +00:00
["config"] call FUNC(nextMode);
2015-01-21 20:15:51 +00:00
};
2015-01-17 18:25:12 +00:00
// prevent additinal modifier input if advanced mode it set, spaghetti
if (GETGVAR(isKeyDownDistance,false) && {GETGVAR(currentMode,"") in ["relative_distance", "relative_height+length"]}) exitWith {};
2015-01-15 15:40:06 +00:00
["azimuth"] call FUNC(clearDisplay);
2015-01-15 06:18:57 +00:00
GVAR(isKeyDownAzimuth) = true;
[false] call FUNC(showP1);
2015-01-15 15:40:06 +00:00
// handle 5 times clicking
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeAzimuth) + 0.5) then {
GVAR(keyDownTabCountAzimuth) = (GETGVAR(keyDownTabCountAzimuth,0)) + 1;
2016-03-02 10:01:39 +00:00
GVAR(keyDownTimeAzimuth) = diag_tickTime;
} else {
GVAR(keyDownTabCountAzimuth) = 1;
};
2015-01-21 20:15:51 +00:00
// open settings menu
if (GVAR(keyDownTabCountAzimuth) == 5) exitWith {
2016-03-02 10:01:39 +00:00
GVAR(keyDownTimeMenu) = diag_tickTime;
GVAR(keyDownTimeAzimuth) = diag_tickTime;
2015-01-21 20:15:51 +00:00
GVAR(keyDownTabCountAzimuth) = 0;
2015-01-21 21:52:39 +00:00
GVAR(configTemp) = [GVAR(useFeet), GVAR(useMil)];
2015-01-21 20:15:51 +00:00
["settings"] call FUNC(showText);
"settings" call _fnc_setPFH;
};
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeAzimuth) + 0.5) exitWith {
2015-01-15 15:40:06 +00:00
"azimuth+inclination" call _fnc_setPFH;
};
2016-03-02 10:01:39 +00:00
GVAR(keyDownTimeAzimuth) = diag_tickTime;
2015-01-15 06:18:57 +00:00
2016-03-02 10:01:39 +00:00
if (diag_tickTime > GVAR(keyDownTimeDistance) + 0.5) then {
if !(GETGVAR(isKeyDownDistance,false)) then {
["distance"] call FUNC(clearDisplay);
"azimuth" call _fnc_setPFH;
2015-01-15 18:01:27 +00:00
};
2015-01-15 15:21:47 +00:00
} else {
2015-01-17 21:49:06 +00:00
if (GETGVAR(isKeyDownDistance,false)) then {
"azimuth+distance" call _fnc_setPFH;
} else {
["distance"] call FUNC(clearDisplay);
"azimuth" call _fnc_setPFH;
};
2015-01-15 15:21:47 +00:00
};
2015-01-15 06:18:57 +00:00
};
case ("distance"): {
2015-01-21 21:52:39 +00:00
GVAR(keyDownTabCountAzimuth) = 0;
2015-01-15 06:18:57 +00:00
2015-01-21 20:15:51 +00:00
// handle input in option menu
if (GVAR(currentMode) == "config") exitWith {
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeMenu) + 0.5) exitWith {};
2015-01-21 20:15:51 +00:00
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeDistance) + 0.5) then {
2015-01-21 20:15:51 +00:00
GVAR(keyDownTabCountDistance) = (GETGVAR(keyDownTabCountDistance,0)) + 1;
} else {
GVAR(keyDownTabCountDistance) = 1;
};
2016-03-02 10:01:39 +00:00
GVAR(keyDownTimeDistance) = diag_tickTime;
2015-01-21 20:15:51 +00:00
};
if (GVAR(currentMode) == "settings") exitWith {
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeMenu) + 0.5) exitWith {};
2015-01-21 20:15:51 +00:00
2015-01-21 21:52:39 +00:00
["settings"] call FUNC(nextMode);
2015-01-21 20:15:51 +00:00
};
2015-01-17 18:25:12 +00:00
// prevent additinal modifier input if advanced mode it set, spaghetti
2015-04-05 20:18:28 +00:00
if (GETGVAR(isKeyDownAzimuth,false) && {GETGVAR(currentMode,"") in ["relative_azimuth+distance", "fall_of_shot"]}) exitWith {};
2015-01-17 21:49:06 +00:00
// toggle fos values
2015-04-05 20:18:28 +00:00
if (GETGVAR(currentMode,"") == "fall_of_shot") exitWith {
[!(GETGVAR(FOSState,true))] call FUNC(showFallOfShot);
2015-01-17 21:49:06 +00:00
};
2015-01-15 15:40:06 +00:00
["distance"] call FUNC(clearDisplay);
2015-01-15 06:18:57 +00:00
GVAR(isKeyDownDistance) = true;
[false] call FUNC(showP1);
2015-01-15 15:40:06 +00:00
// handle 5 times clicking
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeDistance) + 0.5) then {
GVAR(keyDownTabCountDistance) = (GETGVAR(keyDownTabCountDistance,0)) + 1;
2016-03-02 10:01:39 +00:00
GVAR(keyDownTimeDistance) = diag_tickTime;
} else {
GVAR(keyDownTabCountDistance) = 1;
};
// open config menu
if (GVAR(keyDownTabCountDistance) == 5) exitWith {
2016-03-02 10:01:39 +00:00
GVAR(keyDownTimeMenu) = diag_tickTime;
GVAR(keyDownTimeDistance) = diag_tickTime;
2015-01-21 20:15:51 +00:00
GVAR(keyDownTabCountDistance) = 0;
2015-01-21 21:52:39 +00:00
GVAR(configTemp) = GVAR(modeReticle);
2015-01-21 20:15:51 +00:00
["config"] call FUNC(showText);
"config" call _fnc_setPFH;
};
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeDistance) + 0.5) exitWith {
2015-01-15 16:24:19 +00:00
"height+distance" call _fnc_setPFH;
2015-01-15 15:40:06 +00:00
};
2016-03-02 10:01:39 +00:00
GVAR(keyDownTimeDistance) = diag_tickTime;
2015-01-15 06:18:57 +00:00
2016-03-02 10:01:39 +00:00
if (diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5) then {
if !(GETGVAR(isKeyDownAzimuth,false)) then {
["azimuth"] call FUNC(clearDisplay);
2015-01-17 21:49:06 +00:00
"distance" call _fnc_setPFH;
2015-01-15 18:01:27 +00:00
};
2015-01-15 15:21:47 +00:00
} else {
2015-01-17 21:49:06 +00:00
if (GETGVAR(isKeyDownAzimuth,false)) then {
"azimuth+distance" call _fnc_setPFH;
} else {
["azimuth"] call FUNC(clearDisplay);
"distance" call _fnc_setPFH;
};
2015-01-15 15:21:47 +00:00
};
2015-01-15 06:18:57 +00:00
};
};