From addc7feb40edcd26bffa1559306ad3bd6eac8440 Mon Sep 17 00:00:00 2001 From: commy2 Date: Fri, 16 Jan 2015 01:48:43 +0100 Subject: [PATCH] vector, relative slope distance and relative azimuth + distance modes, spaghetti --- addons/vector/XEH_preInit.sqf | 15 ++-- .../functions/fnc_getHeightDistance.sqf | 2 +- .../fnc_getRelativeAzimuthDistance.sqf | 49 ++++-------- .../functions/fnc_getRelativeDistance.sqf | 25 ++++++ .../fnc_modeRelativeAzimuthDistance.sqf | 72 ----------------- .../functions/fnc_modeRelativeDistance.sqf | 58 -------------- addons/vector/functions/fnc_onKeyDown.sqf | 23 +++--- addons/vector/functions/fnc_onKeyHold.sqf | 52 +++++++++++- addons/vector/functions/fnc_onKeyUp.sqf | 29 +++++++ addons/vector/functions/fnc_showAzimuth.sqf | 15 ++-- .../functions/fnc_showAzimuthInclination.sqf | 27 +++---- addons/vector/functions/fnc_showDistance.sqf | 15 ++-- .../functions/fnc_showHeightDistance.sqf | 27 +++---- addons/vector/functions/fnc_showP1.sqf | 2 +- .../fnc_showRelativeAzimuthDistance.sqf | 79 ++++--------------- .../functions/fnc_showRelativeDistance.sqf | 19 +++++ 16 files changed, 204 insertions(+), 305 deletions(-) create mode 100644 addons/vector/functions/fnc_getRelativeDistance.sqf delete mode 100644 addons/vector/functions/fnc_modeRelativeAzimuthDistance.sqf delete mode 100644 addons/vector/functions/fnc_modeRelativeDistance.sqf create mode 100644 addons/vector/functions/fnc_showRelativeDistance.sqf diff --git a/addons/vector/XEH_preInit.sqf b/addons/vector/XEH_preInit.sqf index c3c3576797..68acfa6390 100644 --- a/addons/vector/XEH_preInit.sqf +++ b/addons/vector/XEH_preInit.sqf @@ -11,24 +11,25 @@ PREP(tabDistanceKey); PREP(clearDisplay); PREP(convertToTexturesDegree); PREP(convertToTexturesDistance); +PREP(showCenter); +PREP(showP1); + +PREP(onKeyDown); +PREP(onKeyHold); +PREP(onKeyUp); PREP(getDirection); PREP(getDistance); PREP(getHeightDistance); PREP(getRelativeAzimuthDistance); - -PREP(onKeyDown); -PREP(onKeyHold); -PREP(onKeyUp); +PREP(getRelativeDistance); PREP(showAzimuth); PREP(showAzimuthInclination); PREP(showHeightDistance); PREP(showDistance); PREP(showRelativeAzimuthDistance); - -PREP(showCenter); -PREP(showP1); +PREP(showRelativeDistance); GVAR(holdKeyHandler) = -1; GVAR(isKeyDownAzimuth) = false; diff --git a/addons/vector/functions/fnc_getHeightDistance.sqf b/addons/vector/functions/fnc_getHeightDistance.sqf index d7efa900be..9ec0919917 100644 --- a/addons/vector/functions/fnc_getHeightDistance.sqf +++ b/addons/vector/functions/fnc_getHeightDistance.sqf @@ -10,7 +10,7 @@ _azimuth = _direction select 0; _inclination = _direction select 1; if (_distance < -999) exitWith { - [-1000,-1000] // return + [-1000, -1000] // return }; [sin _inclination * _distance, cos _inclination * _distance] diff --git a/addons/vector/functions/fnc_getRelativeAzimuthDistance.sqf b/addons/vector/functions/fnc_getRelativeAzimuthDistance.sqf index 328650ec41..765d3d6ec4 100644 --- a/addons/vector/functions/fnc_getRelativeAzimuthDistance.sqf +++ b/addons/vector/functions/fnc_getRelativeAzimuthDistance.sqf @@ -1,53 +1,32 @@ // by commy2 #include "script_component.hpp" -_distanceP1 = call AGM_Vector_fnc_getDistance; -_directionP1 = call AGM_Vector_fnc_getDirection; +private ["_distanceP1", "_directionP1", "_azimuthP1", "_inclinationP1", "_distanceP2", "_directionP2", "_azimuthP2", "_inclinationP2"]; + +_distanceP1 = GVAR(pData) select 0; +_directionP1 = GVAR(pData) select 1; _azimuthP1 = _directionP1 select 0; _inclinationP1 = _directionP1 select 1; -_ctrlDigitE1 ctrlSetText "\AGM_Vector\rsc\d1.paa"; -_ctrlDigitE2 ctrlSetText "\AGM_Vector\rsc\d-.paa"; -_ctrlDigitE3 ctrlSetText "\AGM_Vector\rsc\dP.paa"; - -waitUntil {!(AGM_vectorKey select 0)}; - -_distanceP2 = call AGM_Vector_fnc_getDistance; -_directionP2 = call AGM_Vector_fnc_getDirection; +_distanceP2 = call FUNC(getDistance); +_directionP2 = call FUNC(getDirection); _azimuthP2 = _directionP2 select 0; _inclinationP2 = _directionP2 select 1; -_relDirection = sqrt ((_azimuthP1 - _azimuthP2)^2 + (_inclinationP1 - _inclinationP2)^2); -_relDistance = sqrt (_distanceP1^2 + _distanceP2^2 - 2 * _distanceP1 * _distanceP2 * cos _relDirection); +private ["_relDirection", "_relDistance", "_relHeight", "_relLength", "_lenghtP1", "_lenghtP2", "_relAzimuth"]; + +_relDirection = sqrt ((_azimuthP1 - _azimuthP2) ^ 2 + (_inclinationP1 - _inclinationP2) ^ 2); +_relDistance = sqrt (_distanceP1 ^ 2 + _distanceP2 ^ 2 - 2 * _distanceP1 * _distanceP2 * cos _relDirection); _relHeight = (sin _inclinationP1 * _distanceP1) - (sin _inclinationP2 * _distanceP2); -_relLenght = sqrt (_relDistance^2 - _relHeight^2); if (str(_relLenght) == "-1.#IND") then {_relLenght = 0}; +_relLength = sqrt (_relDistance ^ 2 - _relHeight ^ 2); if (str(_relLength) == "-1.#IND") then {_relLength = 0}; _lenghtP1 = cos _inclinationP1 * _distanceP1; _lenghtP2 = cos _inclinationP2 * _distanceP2; _relAzimuth = (sin _azimuthP2 * _lenghtP2 - sin _azimuthP1 * _lenghtP1) atan2 (cos _azimuthP2 * _lenghtP2 - cos _azimuthP1 * _lenghtP1); if (_relAzimuth < 0) then {_relAzimuth = _relAzimuth + 360}; -if (_distanceP1 == -9999 || {_distanceP2 == -9999}) then { - _relDistance = -9999; - _relAzimuth = -9999; +if (_distanceP1 < -999 || {_distanceP2 < -999}) exitWith { + [-1000, -1000] // return }; -_digits = _relLenght call AGM_Vector_fnc_convertDistance; -_ctrlDigit1 ctrlSetText (_digits select 0); -_ctrlDigit2 ctrlSetText (_digits select 1); -_ctrlDigit3 ctrlSetText (_digits select 2); -_ctrlDigit4 ctrlSetText (_digits select 3); - -_digits = _relAzimuth call AGM_Vector_fnc_convertDegree; -_ctrlDigit5 ctrlSetText (_digits select 0); -_ctrlDigit6 ctrlSetText (_digits select 1); -_ctrlDigit7 ctrlSetText (_digits select 2); -_ctrlDigit8 ctrlSetText (_digits select 3); - -_ctrlVectorCenter ctrlShow false; - -_ctrlDigitE1 ctrlShow false; -_ctrlDigitE2 ctrlShow false; -_ctrlDigitE3 ctrlShow false; - -AGM_isVectorReady = true; +[_relAzimuth, _relLength] diff --git a/addons/vector/functions/fnc_getRelativeDistance.sqf b/addons/vector/functions/fnc_getRelativeDistance.sqf new file mode 100644 index 0000000000..9c6dc38943 --- /dev/null +++ b/addons/vector/functions/fnc_getRelativeDistance.sqf @@ -0,0 +1,25 @@ +// by commy2 +#include "script_component.hpp" + +private ["_distanceP1", "_directionP1", "_azimuthP1", "_inclinationP1", "_distanceP2", "_directionP2", "_azimuthP2", "_inclinationP2"]; + +_distanceP1 = GVAR(pData) select 0; +_directionP1 = GVAR(pData) select 1; +_azimuthP1 = _directionP1 select 0; +_inclinationP1 = _directionP1 select 1; + +_distanceP2 = call FUNC(getDistance); +_directionP2 = call FUNC(getDirection); +_azimuthP2 = _directionP2 select 0; +_inclinationP2 = _directionP2 select 1; + +private ["_relDirection", "_relDistance"]; + +_relDirection = sqrt ((_azimuthP1 - _azimuthP2) ^ 2 + (_inclinationP1 - _inclinationP2) ^ 2); +_relDistance = sqrt (_distanceP1 ^ 2 + _distanceP2 ^ 2 - 2 * _distanceP1 * _distanceP2 * cos _relDirection); + +if (_distanceP1 < -999 || {_distanceP2 < -999}) exitWith { + -1000 // return +}; + +_relDistance diff --git a/addons/vector/functions/fnc_modeRelativeAzimuthDistance.sqf b/addons/vector/functions/fnc_modeRelativeAzimuthDistance.sqf deleted file mode 100644 index 283af8f395..0000000000 --- a/addons/vector/functions/fnc_modeRelativeAzimuthDistance.sqf +++ /dev/null @@ -1,72 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -private["_dlgVector", "_ctrlVectorCenter", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8", "_ctrlDigitE1", "_ctrlDigitE2", "_ctrlDigitE3", "_distanceP1", "_directionP1", "_azimuthP1", "_inclinationP1", "_directionP2", "_azimuthP2", "_distanceP2", "_inclinationP2", "_digits", "_relDirection", "_relDistance", "_relHeight", "_relLenght", "_digits0", "_digits1", "_digits2", "_lenghtP1", "_lenghtP2", "_relAzimuth"]; - -disableSerialization; -_dlgVector = uiNamespace getVariable "AGM_dlgVector"; -_ctrlVectorCenter = _dlgVector displayCtrl 1; -_ctrlDigit1 = _dlgVector displayCtrl 11; -_ctrlDigit2 = _dlgVector displayCtrl 12; -_ctrlDigit3 = _dlgVector displayCtrl 13; -_ctrlDigit4 = _dlgVector displayCtrl 14; -_ctrlDigit5 = _dlgVector displayCtrl 15; -_ctrlDigit6 = _dlgVector displayCtrl 16; -_ctrlDigit7 = _dlgVector displayCtrl 17; -_ctrlDigit8 = _dlgVector displayCtrl 18; -_ctrlDigitE1 = _dlgVector displayCtrl 21; -_ctrlDigitE2 = _dlgVector displayCtrl 22; -_ctrlDigitE3 = _dlgVector displayCtrl 23; - -_ctrlVectorCenter ctrlSetText "\AGM_Vector\rsc\Vector_Center.paa"; - -_distanceP1 = call AGM_Vector_fnc_getDistance; -_directionP1 = call AGM_Vector_fnc_getDirection; -_azimuthP1 = _directionP1 select 0; -_inclinationP1 = _directionP1 select 1; - -_ctrlDigitE1 ctrlSetText "\AGM_Vector\rsc\d1.paa"; -_ctrlDigitE2 ctrlSetText "\AGM_Vector\rsc\d-.paa"; -_ctrlDigitE3 ctrlSetText "\AGM_Vector\rsc\dP.paa"; - -waitUntil {!(AGM_vectorKey select 0)}; - -_distanceP2 = call AGM_Vector_fnc_getDistance; -_directionP2 = call AGM_Vector_fnc_getDirection; -_azimuthP2 = _directionP2 select 0; -_inclinationP2 = _directionP2 select 1; - -_relDirection = sqrt ((_azimuthP1 - _azimuthP2)^2 + (_inclinationP1 - _inclinationP2)^2); -_relDistance = sqrt (_distanceP1^2 + _distanceP2^2 - 2 * _distanceP1 * _distanceP2 * cos _relDirection); -_relHeight = (sin _inclinationP1 * _distanceP1) - (sin _inclinationP2 * _distanceP2); -_relLenght = sqrt (_relDistance^2 - _relHeight^2); if (str(_relLenght) == "-1.#IND") then {_relLenght = 0}; - -_lenghtP1 = cos _inclinationP1 * _distanceP1; -_lenghtP2 = cos _inclinationP2 * _distanceP2; -_relAzimuth = (sin _azimuthP2 * _lenghtP2 - sin _azimuthP1 * _lenghtP1) atan2 (cos _azimuthP2 * _lenghtP2 - cos _azimuthP1 * _lenghtP1); -if (_relAzimuth < 0) then {_relAzimuth = _relAzimuth + 360}; - -if (_distanceP1 == -9999 || {_distanceP2 == -9999}) then { - _relDistance = -9999; - _relAzimuth = -9999; -}; - -_digits = _relLenght call AGM_Vector_fnc_convertDistance; -_ctrlDigit1 ctrlSetText (_digits select 0); -_ctrlDigit2 ctrlSetText (_digits select 1); -_ctrlDigit3 ctrlSetText (_digits select 2); -_ctrlDigit4 ctrlSetText (_digits select 3); - -_digits = _relAzimuth call AGM_Vector_fnc_convertDegree; -_ctrlDigit5 ctrlSetText (_digits select 0); -_ctrlDigit6 ctrlSetText (_digits select 1); -_ctrlDigit7 ctrlSetText (_digits select 2); -_ctrlDigit8 ctrlSetText (_digits select 3); - -_ctrlVectorCenter ctrlShow false; - -_ctrlDigitE1 ctrlShow false; -_ctrlDigitE2 ctrlShow false; -_ctrlDigitE3 ctrlShow false; - -AGM_isVectorReady = true; diff --git a/addons/vector/functions/fnc_modeRelativeDistance.sqf b/addons/vector/functions/fnc_modeRelativeDistance.sqf deleted file mode 100644 index 0fa073a389..0000000000 --- a/addons/vector/functions/fnc_modeRelativeDistance.sqf +++ /dev/null @@ -1,58 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -private["_dlgVector", "_ctrlVectorCenter", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8", "_ctrlDigitE1", "_ctrlDigitE2", "_ctrlDigitE3", "_distanceP1", "_directionP1", "_azimuthP1", "_inclinationP1", "_directionP2", "_azimuthP2", "_distanceP2", "_inclinationP2", "_relDirection", "_relDistance", "_distance", "_digits"]; - -disableSerialization; -_dlgVector = uiNamespace getVariable "AGM_dlgVector"; -_ctrlVectorCenter = _dlgVector displayCtrl 1; -_ctrlDigit1 = _dlgVector displayCtrl 11; -_ctrlDigit2 = _dlgVector displayCtrl 12; -_ctrlDigit3 = _dlgVector displayCtrl 13; -_ctrlDigit4 = _dlgVector displayCtrl 14; -_ctrlDigit5 = _dlgVector displayCtrl 15; -_ctrlDigit6 = _dlgVector displayCtrl 16; -_ctrlDigit7 = _dlgVector displayCtrl 17; -_ctrlDigit8 = _dlgVector displayCtrl 18; -_ctrlDigitE1 = _dlgVector displayCtrl 21; -_ctrlDigitE2 = _dlgVector displayCtrl 22; -_ctrlDigitE3 = _dlgVector displayCtrl 23; - -_ctrlVectorCenter ctrlSetText "\AGM_Vector\rsc\Vector_Center.paa"; - -_distanceP1 = call AGM_Vector_fnc_getDistance; -_directionP1 = call AGM_Vector_fnc_getDirection; -_azimuthP1 = _directionP1 select 0; -_inclinationP1 = _directionP1 select 1; - -_ctrlDigitE1 ctrlSetText "\AGM_Vector\rsc\d1.paa"; -_ctrlDigitE2 ctrlSetText "\AGM_Vector\rsc\d-.paa"; -_ctrlDigitE3 ctrlSetText "\AGM_Vector\rsc\dP.paa"; - -waitUntil {!(AGM_vectorKey select 1)}; - -_distanceP2 = call AGM_Vector_fnc_getDistance; -_directionP2 = call AGM_Vector_fnc_getDirection; -_azimuthP2 = _directionP2 select 0; -_inclinationP2 = _directionP2 select 1; - -_relDirection = sqrt ((_azimuthP1 - _azimuthP2)^2 + (_inclinationP1 - _inclinationP2)^2); -_relDistance = sqrt (_distanceP1^2 + _distanceP2^2 - 2 * _distanceP1 * _distanceP2 * cos _relDirection); - -if (_distanceP1 == -9999 || {_distanceP2 == -9999}) then { - _relDistance = -9999; -}; - -_digits = _relDistance call AGM_Vector_fnc_convertDistance; -_ctrlDigit1 ctrlSetText (_digits select 0); -_ctrlDigit2 ctrlSetText (_digits select 1); -_ctrlDigit3 ctrlSetText (_digits select 2); -_ctrlDigit4 ctrlSetText (_digits select 3); - -_ctrlVectorCenter ctrlShow false; - -_ctrlDigitE1 ctrlShow false; -_ctrlDigitE2 ctrlShow false; -_ctrlDigitE3 ctrlShow false; - -AGM_isVectorReady = true; diff --git a/addons/vector/functions/fnc_onKeyDown.sqf b/addons/vector/functions/fnc_onKeyDown.sqf index d27024cd9c..f1c1a4c77f 100644 --- a/addons/vector/functions/fnc_onKeyDown.sqf +++ b/addons/vector/functions/fnc_onKeyDown.sqf @@ -14,15 +14,19 @@ _fnc_setPFH = { GVAR(holdKeyHandler) = -1; }; + GVAR(currentMode) = _this;// GVAR(holdKeyHandler) = [FUNC(onKeyHold), 0, _this] call CBA_fnc_addPerFrameHandler; }; switch (_this select 0) do { case ("azimuth"): { + if (GETGVAR(isKeyDownDistance,false) && {GETGVAR(currentMode,"") in ["relative_distance"]}) exitWith {}; + ["azimuth"] call FUNC(clearDisplay); GVAR(isKeyDownAzimuth) = true; + [false] call FUNC(showP1); if (diag_tickTime < GVAR(keyDownTimeAzimuth) + 0.5) exitWith { "azimuth+inclination" call _fnc_setPFH; @@ -31,12 +35,10 @@ switch (_this select 0) do { GVAR(keyDownTimeAzimuth) = diag_tickTime; if (diag_tickTime > GVAR(keyDownTimeDistance) + 0.5) then { - if (GETGVAR(isKeyDownDistance,false)) exitWith { - hint "P1 relative distance mode"; + if !(GETGVAR(isKeyDownDistance,false)) then { + ["distance"] call FUNC(clearDisplay); + "azimuth" call _fnc_setPFH; }; - - ["distance"] call FUNC(clearDisplay); - "azimuth" call _fnc_setPFH; } else { "azimuth+distance" call _fnc_setPFH; }; @@ -45,9 +47,12 @@ switch (_this select 0) do { case ("distance"): { + if (GETGVAR(isKeyDownAzimuth,false) && {GETGVAR(currentMode,"") in ["relative_azimuth+distance"]}) exitWith {}; + ["distance"] call FUNC(clearDisplay); GVAR(isKeyDownDistance) = true; + [false] call FUNC(showP1); if (diag_tickTime < GVAR(keyDownTimeDistance) + 0.5) exitWith { "height+distance" call _fnc_setPFH; @@ -56,12 +61,10 @@ switch (_this select 0) do { GVAR(keyDownTimeDistance) = diag_tickTime; if (diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5) then { - if (GETGVAR(isKeyDownAzimuth,false)) exitWith { - hint "P1 relative azimuth + non-slope distance mode"; + if !(GETGVAR(isKeyDownAzimuth,false)) then { + ["azimuth"] call FUNC(clearDisplay); + "distance" call _fnc_setPFH; }; - - ["azimuth"] call FUNC(clearDisplay); - "distance" call _fnc_setPFH; } else { "azimuth+distance" call _fnc_setPFH; }; diff --git a/addons/vector/functions/fnc_onKeyHold.sqf b/addons/vector/functions/fnc_onKeyHold.sqf index 255c9acc4e..97b1574a7f 100644 --- a/addons/vector/functions/fnc_onKeyHold.sqf +++ b/addons/vector/functions/fnc_onKeyHold.sqf @@ -56,8 +56,10 @@ switch (_this select 0) do { [_isReady] call FUNC(showCenter); if (!GVAR(isKeyDownAzimuth) && {!GVAR(isKeyDownDistance)}) then { - call FUNC(showDistance); - [false] call FUNC(showCenter); + if (_isReady) then { + call FUNC(showDistance); + [false] call FUNC(showCenter); + }; [_this select 1] call CBA_fnc_removePerFrameHandler; @@ -106,6 +108,52 @@ switch (_this select 0) do { }; + case ("relative_distance"): { + + private "_isReady"; + _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; + }; + }; + + }; + + case ("relative_azimuth+distance"): { + + private "_isReady"; + _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; + }; + }; + + }; + }; systemChat str (_this select 0);// diff --git a/addons/vector/functions/fnc_onKeyUp.sqf b/addons/vector/functions/fnc_onKeyUp.sqf index 0079680f19..4a86e6bc0d 100644 --- a/addons/vector/functions/fnc_onKeyUp.sqf +++ b/addons/vector/functions/fnc_onKeyUp.sqf @@ -7,16 +7,45 @@ Handles releasing 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(currentMode) = _this;// + GVAR(holdKeyHandler) = [FUNC(onKeyHold), 0, _this] call CBA_fnc_addPerFrameHandler; +}; + switch (_this select 0) do { case ("azimuth"): { GVAR(isKeyDownAzimuth) = false; + if (GVAR(isKeyDownDistance)) then { + if (GVAR(currentMode) == "distance") then { + ["azimuth"] call FUNC(clearDisplay); + [true] call FUNC(showP1); + GVAR(pData) = [call FUNC(getDistance), call FUNC(getDirection)]; + "relative_distance" call _fnc_setPFH; + }; + }; + }; case ("distance"): { GVAR(isKeyDownDistance) = false; + if (GVAR(isKeyDownAzimuth)) then { + if (GVAR(currentMode) == "azimuth") then { + ["distance"] call FUNC(clearDisplay); + [true] call FUNC(showP1); + GVAR(pData) = [call FUNC(getDistance), call FUNC(getDirection)]; + "relative_azimuth+distance" call _fnc_setPFH; + }; + }; + }; }; diff --git a/addons/vector/functions/fnc_showAzimuth.sqf b/addons/vector/functions/fnc_showAzimuth.sqf index 7f6ead037f..d4b5421cc3 100644 --- a/addons/vector/functions/fnc_showAzimuth.sqf +++ b/addons/vector/functions/fnc_showAzimuth.sqf @@ -1,23 +1,18 @@ // by commy2 #include "script_component.hpp" -private ["_dlgVector", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8"]; +private "_dlgVector"; disableSerialization; _dlgVector = GETUVAR(ACE_dlgVector,displayNull); -_ctrlDigit5 = _dlgVector displayCtrl 1315; -_ctrlDigit6 = _dlgVector displayCtrl 1316; -_ctrlDigit7 = _dlgVector displayCtrl 1317; -_ctrlDigit8 = _dlgVector displayCtrl 1318; - private ["_direction", "_digits"]; _direction = call FUNC(getDirection); _digits = _direction call FUNC(convertToTexturesDegree); -_ctrlDigit5 ctrlSetText (_digits select 0); -_ctrlDigit6 ctrlSetText (_digits select 1); -_ctrlDigit7 ctrlSetText (_digits select 2); -_ctrlDigit8 ctrlSetText (_digits select 3); +(_dlgVector displayCtrl 1315) ctrlSetText (_digits select 0); +(_dlgVector displayCtrl 1316) ctrlSetText (_digits select 1); +(_dlgVector displayCtrl 1317) ctrlSetText (_digits select 2); +(_dlgVector displayCtrl 1318) ctrlSetText (_digits select 3); diff --git a/addons/vector/functions/fnc_showAzimuthInclination.sqf b/addons/vector/functions/fnc_showAzimuthInclination.sqf index 207927f8ac..9d5bb82506 100644 --- a/addons/vector/functions/fnc_showAzimuthInclination.sqf +++ b/addons/vector/functions/fnc_showAzimuthInclination.sqf @@ -1,20 +1,11 @@ // by commy2 #include "script_component.hpp" -private ["_dlgVector", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8"]; +private "_dlgVector"; disableSerialization; _dlgVector = GETUVAR(ACE_dlgVector,displayNull); -_ctrlDigit1 = _dlgVector displayCtrl 1311; -_ctrlDigit2 = _dlgVector displayCtrl 1312; -_ctrlDigit3 = _dlgVector displayCtrl 1313; -_ctrlDigit4 = _dlgVector displayCtrl 1314; -_ctrlDigit5 = _dlgVector displayCtrl 1315; -_ctrlDigit6 = _dlgVector displayCtrl 1316; -_ctrlDigit7 = _dlgVector displayCtrl 1317; -_ctrlDigit8 = _dlgVector displayCtrl 1318; - private ["_direction", "_digits"]; _direction = call FUNC(getDirection); @@ -22,15 +13,15 @@ _direction = call FUNC(getDirection); // azimuth _digits = [_direction select 0] call FUNC(convertToTexturesDegree); -_ctrlDigit5 ctrlSetText (_digits select 0); -_ctrlDigit6 ctrlSetText (_digits select 1); -_ctrlDigit7 ctrlSetText (_digits select 2); -_ctrlDigit8 ctrlSetText (_digits select 3); +(_dlgVector displayCtrl 1315) ctrlSetText (_digits select 0); +(_dlgVector displayCtrl 1316) ctrlSetText (_digits select 1); +(_dlgVector displayCtrl 1317) ctrlSetText (_digits select 2); +(_dlgVector displayCtrl 1318) ctrlSetText (_digits select 3); // inclination _digits = [_direction select 1] call FUNC(convertToTexturesDegree); -_ctrlDigit1 ctrlSetText (_digits select 0); -_ctrlDigit2 ctrlSetText (_digits select 1); -_ctrlDigit3 ctrlSetText (_digits select 2); -_ctrlDigit4 ctrlSetText (_digits select 3); +(_dlgVector displayCtrl 1311) ctrlSetText (_digits select 0); +(_dlgVector displayCtrl 1312) ctrlSetText (_digits select 1); +(_dlgVector displayCtrl 1313) ctrlSetText (_digits select 2); +(_dlgVector displayCtrl 1314) ctrlSetText (_digits select 3); diff --git a/addons/vector/functions/fnc_showDistance.sqf b/addons/vector/functions/fnc_showDistance.sqf index bc802302fd..69d17faa9e 100644 --- a/addons/vector/functions/fnc_showDistance.sqf +++ b/addons/vector/functions/fnc_showDistance.sqf @@ -1,23 +1,18 @@ // by commy2 #include "script_component.hpp" -private ["_dlgVector", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4"]; +private "_dlgVector"; disableSerialization; _dlgVector = GETUVAR(ACE_dlgVector,displayNull); -_ctrlDigit1 = _dlgVector displayCtrl 1311; -_ctrlDigit2 = _dlgVector displayCtrl 1312; -_ctrlDigit3 = _dlgVector displayCtrl 1313; -_ctrlDigit4 = _dlgVector displayCtrl 1314; - private ["_distance", "_digits"]; _distance = call FUNC(getDistance); _digits = [_distance] call FUNC(convertToTexturesDistance); -_ctrlDigit1 ctrlSetText (_digits select 0); -_ctrlDigit2 ctrlSetText (_digits select 1); -_ctrlDigit3 ctrlSetText (_digits select 2); -_ctrlDigit4 ctrlSetText (_digits select 3); +(_dlgVector displayCtrl 1311) ctrlSetText (_digits select 0); +(_dlgVector displayCtrl 1312) ctrlSetText (_digits select 1); +(_dlgVector displayCtrl 1313) ctrlSetText (_digits select 2); +(_dlgVector displayCtrl 1314) ctrlSetText (_digits select 3); diff --git a/addons/vector/functions/fnc_showHeightDistance.sqf b/addons/vector/functions/fnc_showHeightDistance.sqf index 05d28bcf87..cc563ae11d 100644 --- a/addons/vector/functions/fnc_showHeightDistance.sqf +++ b/addons/vector/functions/fnc_showHeightDistance.sqf @@ -1,20 +1,11 @@ // by commy2 #include "script_component.hpp" -private ["_dlgVector", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8"]; +private "_dlgVector"; disableSerialization; _dlgVector = GETUVAR(ACE_dlgVector,displayNull); -_ctrlDigit1 = _dlgVector displayCtrl 1311; -_ctrlDigit2 = _dlgVector displayCtrl 1312; -_ctrlDigit3 = _dlgVector displayCtrl 1313; -_ctrlDigit4 = _dlgVector displayCtrl 1314; -_ctrlDigit5 = _dlgVector displayCtrl 1315; -_ctrlDigit6 = _dlgVector displayCtrl 1316; -_ctrlDigit7 = _dlgVector displayCtrl 1317; -_ctrlDigit8 = _dlgVector displayCtrl 1318; - private ["_heightDistance", "_digits"]; _heightDistance = call FUNC(getHeightDistance); @@ -22,15 +13,15 @@ _heightDistance = call FUNC(getHeightDistance); // height _digits = [_heightDistance select 0] call FUNC(convertToTexturesDistance); -_ctrlDigit1 ctrlSetText (_digits select 0); -_ctrlDigit2 ctrlSetText (_digits select 1); -_ctrlDigit3 ctrlSetText (_digits select 2); -_ctrlDigit4 ctrlSetText (_digits select 3); +(_dlgVector displayCtrl 1311) ctrlSetText (_digits select 0); +(_dlgVector displayCtrl 1312) ctrlSetText (_digits select 1); +(_dlgVector displayCtrl 1313) ctrlSetText (_digits select 2); +(_dlgVector displayCtrl 1314) ctrlSetText (_digits select 3); // non-slope distance _digits = [_heightDistance select 1] call FUNC(convertToTexturesDistance); -_ctrlDigit5 ctrlSetText (_digits select 0); -_ctrlDigit6 ctrlSetText (_digits select 1); -_ctrlDigit7 ctrlSetText (_digits select 2); -_ctrlDigit8 ctrlSetText (_digits select 3); +(_dlgVector displayCtrl 1315) ctrlSetText (_digits select 0); +(_dlgVector displayCtrl 1316) ctrlSetText (_digits select 1); +(_dlgVector displayCtrl 1317) ctrlSetText (_digits select 2); +(_dlgVector displayCtrl 1318) ctrlSetText (_digits select 3); diff --git a/addons/vector/functions/fnc_showP1.sqf b/addons/vector/functions/fnc_showP1.sqf index 0e9f6b0bcd..54cbd203f4 100644 --- a/addons/vector/functions/fnc_showP1.sqf +++ b/addons/vector/functions/fnc_showP1.sqf @@ -2,7 +2,7 @@ by commy2 -Shows or hides the vectors center square thingy. +Shows or hides the 1-P text line. */ #include "script_component.hpp" diff --git a/addons/vector/functions/fnc_showRelativeAzimuthDistance.sqf b/addons/vector/functions/fnc_showRelativeAzimuthDistance.sqf index 051c21abfb..7dfc157571 100644 --- a/addons/vector/functions/fnc_showRelativeAzimuthDistance.sqf +++ b/addons/vector/functions/fnc_showRelativeAzimuthDistance.sqf @@ -1,74 +1,27 @@ - - // by commy2 #include "script_component.hpp" -private["_dlgVector", "_ctrlVectorCenter", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8", "_ctrlDigitE1", "_ctrlDigitE2", "_ctrlDigitE3", "_distanceP1", "_directionP1", "_azimuthP1", "_inclinationP1", "_directionP2", "_azimuthP2", "_distanceP2", "_inclinationP2", "_digits", "_relDirection", "_relDistance", "_relHeight", "_relLenght", "_digits0", "_digits1", "_digits2", "_lenghtP1", "_lenghtP2", "_relAzimuth"]; +private "_dlgVector"; disableSerialization; -_dlgVector = uiNamespace getVariable "AGM_dlgVector"; -_ctrlVectorCenter = _dlgVector displayCtrl 1; -_ctrlDigit1 = _dlgVector displayCtrl 11; -_ctrlDigit2 = _dlgVector displayCtrl 12; -_ctrlDigit3 = _dlgVector displayCtrl 13; -_ctrlDigit4 = _dlgVector displayCtrl 14; -_ctrlDigit5 = _dlgVector displayCtrl 15; -_ctrlDigit6 = _dlgVector displayCtrl 16; -_ctrlDigit7 = _dlgVector displayCtrl 17; -_ctrlDigit8 = _dlgVector displayCtrl 18; -_ctrlDigitE1 = _dlgVector displayCtrl 21; -_ctrlDigitE2 = _dlgVector displayCtrl 22; -_ctrlDigitE3 = _dlgVector displayCtrl 23; +_dlgVector = GETUVAR(ACE_dlgVector,displayNull); -_ctrlVectorCenter ctrlSetText "\AGM_Vector\rsc\Vector_Center.paa"; +private ["_azimuthDistance", "_digits"]; -_distanceP1 = call AGM_Vector_fnc_getDistance; -_directionP1 = call AGM_Vector_fnc_getDirection; -_azimuthP1 = _directionP1 select 0; -_inclinationP1 = _directionP1 select 1; +_azimuthDistance = call FUNC(getRelativeAzimuthDistance); -_ctrlDigitE1 ctrlSetText "\AGM_Vector\rsc\d1.paa"; -_ctrlDigitE2 ctrlSetText "\AGM_Vector\rsc\d-.paa"; -_ctrlDigitE3 ctrlSetText "\AGM_Vector\rsc\dP.paa"; +// relative azimuth +_digits = [_azimuthDistance select 0] call FUNC(convertToTexturesDegree); -waitUntil {!(AGM_vectorKey select 0)}; +(_dlgVector displayCtrl 1315) ctrlSetText (_digits select 0); +(_dlgVector displayCtrl 1316) ctrlSetText (_digits select 1); +(_dlgVector displayCtrl 1317) ctrlSetText (_digits select 2); +(_dlgVector displayCtrl 1318) ctrlSetText (_digits select 3); -_distanceP2 = call AGM_Vector_fnc_getDistance; -_directionP2 = call AGM_Vector_fnc_getDirection; -_azimuthP2 = _directionP2 select 0; -_inclinationP2 = _directionP2 select 1; +// relative non-slope distance +_digits = [_azimuthDistance select 1] call FUNC(convertToTexturesDistance); -_relDirection = sqrt ((_azimuthP1 - _azimuthP2)^2 + (_inclinationP1 - _inclinationP2)^2); -_relDistance = sqrt (_distanceP1^2 + _distanceP2^2 - 2 * _distanceP1 * _distanceP2 * cos _relDirection); -_relHeight = (sin _inclinationP1 * _distanceP1) - (sin _inclinationP2 * _distanceP2); -_relLenght = sqrt (_relDistance^2 - _relHeight^2); if (str(_relLenght) == "-1.#IND") then {_relLenght = 0}; - -_lenghtP1 = cos _inclinationP1 * _distanceP1; -_lenghtP2 = cos _inclinationP2 * _distanceP2; -_relAzimuth = (sin _azimuthP2 * _lenghtP2 - sin _azimuthP1 * _lenghtP1) atan2 (cos _azimuthP2 * _lenghtP2 - cos _azimuthP1 * _lenghtP1); -if (_relAzimuth < 0) then {_relAzimuth = _relAzimuth + 360}; - -if (_distanceP1 == -9999 || {_distanceP2 == -9999}) then { - _relDistance = -9999; - _relAzimuth = -9999; -}; - -_digits = _relLenght call AGM_Vector_fnc_convertDistance; -_ctrlDigit1 ctrlSetText (_digits select 0); -_ctrlDigit2 ctrlSetText (_digits select 1); -_ctrlDigit3 ctrlSetText (_digits select 2); -_ctrlDigit4 ctrlSetText (_digits select 3); - -_digits = _relAzimuth call AGM_Vector_fnc_convertDegree; -_ctrlDigit5 ctrlSetText (_digits select 0); -_ctrlDigit6 ctrlSetText (_digits select 1); -_ctrlDigit7 ctrlSetText (_digits select 2); -_ctrlDigit8 ctrlSetText (_digits select 3); - -_ctrlVectorCenter ctrlShow false; - -_ctrlDigitE1 ctrlShow false; -_ctrlDigitE2 ctrlShow false; -_ctrlDigitE3 ctrlShow false; - -AGM_isVectorReady = true; +(_dlgVector displayCtrl 1311) ctrlSetText (_digits select 0); +(_dlgVector displayCtrl 1312) ctrlSetText (_digits select 1); +(_dlgVector displayCtrl 1313) ctrlSetText (_digits select 2); +(_dlgVector displayCtrl 1314) ctrlSetText (_digits select 3); diff --git a/addons/vector/functions/fnc_showRelativeDistance.sqf b/addons/vector/functions/fnc_showRelativeDistance.sqf new file mode 100644 index 0000000000..cda17623f9 --- /dev/null +++ b/addons/vector/functions/fnc_showRelativeDistance.sqf @@ -0,0 +1,19 @@ +// by commy2 +#include "script_component.hpp" + +private "_dlgVector"; + +disableSerialization; +_dlgVector = GETUVAR(ACE_dlgVector,displayNull); + +private ["_distance", "_digits"]; + +_distance = call FUNC(getRelativeDistance); + +// relative slope distance +_digits = [_distance] call FUNC(convertToTexturesDistance); + +(_dlgVector displayCtrl 1311) ctrlSetText (_digits select 0); +(_dlgVector displayCtrl 1312) ctrlSetText (_digits select 1); +(_dlgVector displayCtrl 1313) ctrlSetText (_digits select 2); +(_dlgVector displayCtrl 1314) ctrlSetText (_digits select 3);