ACE3/addons/vector/functions/fnc_onKeyHold.sqf

335 lines
8.9 KiB
Plaintext
Raw Normal View History

#include "..\script_component.hpp"
2015-01-15 06:18:57 +00:00
/*
* Author: commy2
* PFH executed while holding a vector key down.
*
* Arguments:
* 0: String <STRING>
* 1: Number <NUMBER>
*
* Return Value:
* None
*
* Example:
* ["5", 5] call ace_vector_fnc_onKeyHold
*
* Public: No
*/
2015-01-15 06:18:57 +00:00
if !((currentWeapon ACE_player) isKindOf ["ACE_Vector", configFile >> "CfgWeapons"]) exitWith {
2015-01-21 20:15:51 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
GVAR(currentMode) = "";
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
2015-01-15 06:18:57 +00:00
switch (_this select 0) do {
case ("azimuth"): {
private _isReady = diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.2;
2015-01-17 21:49:06 +00:00
2015-01-15 15:21:47 +00:00
[false] call FUNC(showCenter);
2015-01-17 21:49:06 +00:00
if (_isReady) then {
call FUNC(showAzimuth);
};
2015-01-15 06:18:57 +00:00
if (!GVAR(isKeyDownAzimuth)) then {
[_this select 1] call CBA_fnc_removePerFrameHandler;
2015-01-15 15:21:47 +00:00
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
2015-01-15 06:18:57 +00:00
};
};
case ("distance"): {
private _isReady = diag_tickTime > GVAR(keyDownTimeDistance) + 0.5;
2015-01-15 06:18:57 +00:00
[_isReady] call FUNC(showCenter);
if (!GVAR(isKeyDownDistance)) then {
if (_isReady) then {
call FUNC(showDistance);
2015-01-15 15:21:47 +00:00
[false] call FUNC(showCenter);
2015-01-15 06:18:57 +00:00
};
[_this select 1] call CBA_fnc_removePerFrameHandler;
2015-01-15 15:21:47 +00:00
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
case ("azimuth+distance"): {
call FUNC(showAzimuth);
private _isReady = diag_tickTime > GVAR(keyDownTimeDistance) + 0.5;
2015-01-15 15:21:47 +00:00
[_isReady] call FUNC(showCenter);
if (!GVAR(isKeyDownAzimuth) && {!GVAR(isKeyDownDistance)}) then {
if (_isReady) then {
call FUNC(showDistance);
[false] call FUNC(showCenter);
2015-03-12 17:57:44 +00:00
[] call FUNC(dataTransfer);
};
2015-01-15 15:21:47 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
2015-01-15 06:18:57 +00:00
};
};
2015-01-15 15:40:06 +00:00
case ("azimuth+inclination"): {
private _isReady = diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.2;
2015-01-15 15:40:06 +00:00
[false] call FUNC(showCenter);
if (_isReady) then {
call FUNC(showAzimuthInclination);
};
2015-01-15 15:40:06 +00:00
if (!GVAR(isKeyDownAzimuth)) then {
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
2015-01-15 16:24:19 +00:00
case ("height+distance"): {
private _isReady = diag_tickTime > GVAR(keyDownTimeDistance) + 0.5;
2015-01-15 16:24:19 +00:00
[_isReady] call FUNC(showCenter);
if (!GVAR(isKeyDownDistance)) then {
if (_isReady) then {
call FUNC(showHeightDistance);
[false] call FUNC(showCenter);
};
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
case ("relative_distance"): {
private _isReady = diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5;
[_isReady] call FUNC(showCenter);
if (!GVAR(isKeyDownAzimuth) && {!GVAR(isKeyDownDistance)}) then {
if (_isReady) then {
call FUNC(showRelativeDistance);
};
[false] call FUNC(showCenter);
[false] call FUNC(showP1);
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
2015-01-17 18:25:12 +00:00
case ("relative_height+length"): {
private _isReady = diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5;
2015-01-17 18:25:12 +00:00
[_isReady] call FUNC(showCenter);
if (!GVAR(isKeyDownAzimuth) && {!GVAR(isKeyDownDistance)}) then {
if (_isReady) then {
call FUNC(showRelativeHeightLength);
};
[false] call FUNC(showCenter);
[false] call FUNC(showP1);
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
case ("relative_azimuth+distance"): {
private _isReady = diag_tickTime > GVAR(keyDownTimeDistance) + 0.5;
[_isReady] call FUNC(showCenter);
if (!GVAR(isKeyDownAzimuth) && {!GVAR(isKeyDownDistance)}) then {
if (_isReady) then {
call FUNC(showRelativeAzimuthDistance);
};
[false] call FUNC(showCenter);
[false] call FUNC(showP1);
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
2015-04-05 20:18:28 +00:00
case ("fall_of_shot"): {
2015-01-17 18:25:12 +00:00
private _isReady = diag_tickTime > GVAR(keyDownTimeDistance) + 0.5;
2015-01-17 18:25:12 +00:00
[_isReady] call FUNC(showCenter);
if (!GVAR(isKeyDownAzimuth) && {!GVAR(isKeyDownDistance)}) then {
if (_isReady) then {
GVAR(FOSData) = call FUNC(getFallOfShot);
2015-04-05 20:18:28 +00:00
[false] call FUNC(showFallOfShot);
2015-01-17 18:25:12 +00:00
};
[false] call FUNC(showCenter);
[false] call FUNC(showP1);
[_this select 1] call CBA_fnc_removePerFrameHandler;
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
2015-01-21 20:15:51 +00:00
case ("settings"): {
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeMenu) + 1) exitWith {
GVAR(keyDownTimeAzimuth) = diag_tickTime;
2015-01-21 20:15:51 +00:00
};
2015-01-21 21:52:39 +00:00
[["meter", "feet"] select (GVAR(configTemp) select 0)] call FUNC(showText);
[["deg", "mil" ] select (GVAR(configTemp) select 1)] call FUNC(showText);
if (GVAR(keyDownTabCountAzimuth) >= 5) exitWith {
GVAR(useFeet) = GVAR(configTemp) select 0;
GVAR(useMil) = GVAR(configTemp) select 1;
["clear_left"] call FUNC(showText);
["clear_right"] call FUNC(showText);
["stor"] call FUNC(showText);
[_this select 1] call CBA_fnc_removePerFrameHandler;
GVAR(currentMode) = "";
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
2015-01-21 20:15:51 +00:00
2016-03-02 10:01:39 +00:00
if (GVAR(keyDownTabCountAzimuth) > 0 && {diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5}) exitWith {
2015-01-21 21:52:39 +00:00
["clear_left"] call FUNC(showText);
["clear_right"] call FUNC(showText);
["old_settings"] call FUNC(showText);
2015-01-21 20:15:51 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
GVAR(currentMode) = "";
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
case ("config"): {
2016-03-02 10:01:39 +00:00
if (diag_tickTime < GVAR(keyDownTimeMenu) + 1) exitWith {
GVAR(keyDownTimeDistance) = diag_tickTime;
2015-01-21 20:15:51 +00:00
};
2015-01-21 21:52:39 +00:00
switch (GVAR(configTemp)) do {
case (0): {
["eret"] call FUNC(showText);
["off"] call FUNC(showText);
};
case (1): {
["eret"] call FUNC(showText);
["on"] call FUNC(showText);
};
case (2): {
["nigt"] call FUNC(showText);
["on"] call FUNC(showText);
};
};
2015-01-21 20:15:51 +00:00
2015-01-21 21:52:39 +00:00
if (GVAR(keyDownTabCountDistance) >= 5) exitWith {
GVAR(modeReticle) = GVAR(configTemp);
["clear_left"] call FUNC(showText);
["clear_right"] call FUNC(showText);
["stor"] call FUNC(showText);
// set new config settings
switch (GVAR(configTemp)) do {
case (0): {
[false] call FUNC(adjustBrightness);
2015-01-21 22:05:19 +00:00
[false] call FUNC(showReticle);
2015-01-21 21:52:39 +00:00
};
case (1): {
[false] call FUNC(adjustBrightness);
2015-01-21 22:05:19 +00:00
[true] call FUNC(showReticle);
2015-01-21 21:52:39 +00:00
};
case (2): {
[true] call FUNC(adjustBrightness);
2015-01-21 22:05:19 +00:00
[true] call FUNC(showReticle);
2015-01-21 21:52:39 +00:00
};
};
[_this select 1] call CBA_fnc_removePerFrameHandler;
2015-01-21 20:15:51 +00:00
2015-01-21 21:52:39 +00:00
GVAR(currentMode) = "";
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
2015-01-21 20:15:51 +00:00
};
2015-01-21 21:52:39 +00:00
};
2015-01-21 20:15:51 +00:00
2016-03-02 10:01:39 +00:00
if (GVAR(keyDownTabCountDistance) > 0 && {diag_tickTime > GVAR(keyDownTimeDistance) + 0.5}) exitWith {
2015-01-21 21:52:39 +00:00
["clear_left"] call FUNC(showText);
["clear_right"] call FUNC(showText);
["old_config"] call FUNC(showText);
2015-01-21 20:15:51 +00:00
[_this select 1] call CBA_fnc_removePerFrameHandler;
GVAR(currentMode) = "";
if (GVAR(holdKeyHandler) > -1) then {
GVAR(holdKeyHandler) = -1;
};
};
};
2015-01-15 06:18:57 +00:00
};