diff --git a/addons/main/script_macros.hpp b/addons/main/script_macros.hpp index 36f95d8938..9b243c54a5 100644 --- a/addons/main/script_macros.hpp +++ b/addons/main/script_macros.hpp @@ -189,14 +189,14 @@ #define SETVAR_SYS(var1,var2) setVariable [ARR_2(QUOTE(var1),var2)] #define SETPVAR_SYS(var1,var2) setVariable [ARR_3(QUOTE(var1),var2,true)] -#define GETVAR(var1,var2,var3) (var1 GETVAR_SYS(var2,var3)) -#define GETMVAR(var1,var2) (missionNamespace GETVAR_SYS(var1,var2)) -#define GETUVAR(var1,var2) (uiNamespace GETVAR_SYS(var1,var2)) +#define GETVAR(var1,var2,var3) var1 GETVAR_SYS(var2,var3) +#define GETMVAR(var1,var2) missionNamespace GETVAR_SYS(var1,var2) +#define GETUVAR(var1,var2) uiNamespace GETVAR_SYS(var1,var2) -#define SETVAR(var1,var2,var3) (var1 SETVAR_SYS(var2,var3)) -#define SETPVAR(var1,var2,var3) (var1 SETPVAR_SYS(var2,var3)) -#define SETMVAR(var1,var2) (missionNamespace SETVAR_SYS(var1,var2)) -#define SETUVAR(var1,var2) (uiNamespace SETVAR_SYS(var1,var2)) +#define SETVAR(var1,var2,var3) var1 SETVAR_SYS(var2,var3) +#define SETPVAR(var1,var2,var3) var1 SETPVAR_SYS(var2,var3) +#define SETMVAR(var1,var2) missionNamespace SETVAR_SYS(var1,var2) +#define SETUVAR(var1,var2) uiNamespace SETVAR_SYS(var1,var2) #ifdef DISABLE_COMPILE_CACHE diff --git a/addons/vector/RscInGameUI.hpp b/addons/vector/RscInGameUI.hpp index 0a2398b179..dea9d98419 100644 --- a/addons/vector/RscInGameUI.hpp +++ b/addons/vector/RscInGameUI.hpp @@ -11,7 +11,7 @@ class RscControlsGroup { class RscInGameUI { class RscUnitInfo; class ACE_RscOptics_vector: RscUnitInfo { - onLoad = "[""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable ['ACE_dlgVectorOptics', _this select 0];"; + onLoad = "[""onLoad"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf""; uiNamespace setVariable ['ACE_dlgVector', _this select 0];"; onUnload = "[""onUnload"",_this,""RscUnitInfo"",'IGUI'] call compile preprocessfilelinenumbers ""A3\ui_f\scripts\initDisplay.sqf"""; idd = 300; controls[] = {"CA_Distance","CA_Heading","CA_OpticsPitch","CA_Elev","CA_OpticsZoom","CA_VisionMode","ACE_ScriptedDisplayControlsGroup"}; diff --git a/addons/vector/XEH_preInit.sqf b/addons/vector/XEH_preInit.sqf index 9656fd6e5a..16235cae2d 100644 --- a/addons/vector/XEH_preInit.sqf +++ b/addons/vector/XEH_preInit.sqf @@ -2,14 +2,7 @@ PREP(abort); PREP(config); -PREP(convertDegree); -PREP(convertDistance); PREP(convertFOS); -PREP(getDirection); -PREP(getDistance); -PREP(modeAzimuth); -PREP(modeAzimuthInclination); -PREP(modeDistance); PREP(modeDistanceAzimuth); PREP(modeDistanceHeight); PREP(modeFallOfShort); @@ -19,3 +12,22 @@ PREP(modeRelativeDistanceHeight); PREP(settings); PREP(tabAzimuthKey); PREP(tabDistanceKey); + +PREP(clearDisplay); +PREP(convertToTexturesDegree); +PREP(convertToTexturesDistance); +PREP(getDirection); +PREP(getDistance); +PREP(onKeyDown); +PREP(onKeyHold); +PREP(onKeyUp); +PREP(showAzimuth); +PREP(showCenter); +PREP(showDistance); + +GVAR(isKeyDownAzimuth) = false; +GVAR(isKeyDownDistance) = false; +GVAR(keyDownTimeAzimuth) = -1; +GVAR(keyDownTimeDistance) = -1; +GVAR(useMil) = false; +GVAR(useFeet) = false; diff --git a/addons/vector/config.cpp b/addons/vector/config.cpp index 798d7ce7de..4837ca0001 100644 --- a/addons/vector/config.cpp +++ b/addons/vector/config.cpp @@ -16,29 +16,30 @@ class CfgPatches { #include "CfgVehicles.hpp" #include "CfgWeapons.hpp" -/*class AGM_Default_Keys { +class ACE_Default_Keys { class vectorAzimuth { - displayName = "$STR_AGM_Vector_AzimuthKey"; - condition = "currentWeapon player == 'AGM_Vector' && {_vehicle == player} && {cameraView == 'Gunner'}"; - statement = "AGM_vectorKey set [0, true]; if (AGM_isVectorReady) then {AGM_isVectorReady = false; AGM_Vector_scriptHandle = 0 spawn AGM_Vector_fnc_tabAzimuthKey; 0 spawn AGM_Vector_fnc_abort;};"; - conditionUp = "true"; - statementUp = "AGM_vectorKey set [0, false];"; + displayName = "$STR_ACE_Vector_AzimuthKey"; + condition = QUOTE(currentWeapon player == 'ACE_Vector' && {_vehicle == player} && {cameraView == 'GUNNER'}); + statement = QUOTE(['azimuth'] call FUNC(onKeyDown)); + conditionUp = QUOTE(true); + statementUp = QUOTE(['azimuth'] call FUNC(onKeyUp)); key = 15; shift = 0; control = 0; alt = 0; }; + class vectorDistance { - displayName = "$STR_AGM_Vector_DistanceKey"; - condition = "currentWeapon player == 'AGM_Vector' && {_vehicle == player} && {cameraView == 'Gunner'}"; - statement = "AGM_vectorKey set [1, true]; if (AGM_isVectorReady) then {AGM_isVectorReady = false; AGM_Vector_scriptHandle = 0 spawn AGM_Vector_fnc_tabDistanceKey; 0 spawn AGM_Vector_fnc_abort;};"; - conditionUp = "true"; - statementUp = "AGM_vectorKey set [1, false];"; + displayName = "$STR_ACE_Vector_DistanceKey"; + condition = QUOTE(currentWeapon player == 'ACE_Vector' && {_vehicle == player} && {cameraView == 'GUNNER'}); + statement = QUOTE(['distance'] call FUNC(onKeyDown)); + conditionUp = QUOTE(true); + statementUp = QUOTE(['distance'] call FUNC(onKeyUp)); key = 19; shift = 0; control = 0; alt = 0; }; -};*/ +}; #include "RscInGameUI.hpp" diff --git a/addons/vector/functions/fnc_clearDisplay.sqf b/addons/vector/functions/fnc_clearDisplay.sqf new file mode 100644 index 0000000000..5a42461cb7 --- /dev/null +++ b/addons/vector/functions/fnc_clearDisplay.sqf @@ -0,0 +1,43 @@ +/* + +by commy2 + +Clears the vectors control items. + +*/ +#include "script_component.hpp" + +private "_dlgVector"; + +disableSerialization; +_dlgVector = GETUVAR(ACE_dlgVector,displayNull); + +switch (_this select 0) do { + case ("azimuth"): { + private ["_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8"]; + + _ctrlDigit5 = _dlgVector displayCtrl 1315; + _ctrlDigit6 = _dlgVector displayCtrl 1316; + _ctrlDigit7 = _dlgVector displayCtrl 1317; + _ctrlDigit8 = _dlgVector displayCtrl 1318; + + _ctrlDigit5 ctrlSetText ""; + _ctrlDigit6 ctrlSetText ""; + _ctrlDigit7 ctrlSetText ""; + _ctrlDigit8 ctrlSetText ""; + }; + + case ("distance"): { + private ["_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4"]; + + _ctrlDigit1 = _dlgVector displayCtrl 1311; + _ctrlDigit2 = _dlgVector displayCtrl 1312; + _ctrlDigit3 = _dlgVector displayCtrl 1313; + _ctrlDigit4 = _dlgVector displayCtrl 1314; + + _ctrlDigit1 ctrlSetText ""; + _ctrlDigit2 ctrlSetText ""; + _ctrlDigit3 ctrlSetText ""; + _ctrlDigit4 ctrlSetText ""; + }; +}; diff --git a/addons/vector/functions/fnc_convertDegree.sqf b/addons/vector/functions/fnc_convertDegree.sqf deleted file mode 100644 index 894541c2da..0000000000 --- a/addons/vector/functions/fnc_convertDegree.sqf +++ /dev/null @@ -1,67 +0,0 @@ -/* -BWA3 script, by commy2 -this code is property of the ArmA 3 Bundeswehr modification -ask us nicely at http://www.bwmod.de/ if you want to re-use any of this script -we don't support changed code based on this work -*/ -#include "script_component.hpp" - -private["_number", "_return", "_isNegative", "_digit1", "_digit2", "_digit3", "_digit4"]; - -_number = _this; - -_return = []; -if (AGM_vectorSettings select 2) then { - _number = round (6400 / 360 * _number); - if (_number == 6400) then {_number = 0}; - - _return = _number call AGM_Vector_fnc_convertDistance; -} else { - _number = round _number; - _isNegative = if (_number < 0) then {true} else {false}; - _number = abs _number; - if (_number == 360) then {_number = 0}; - - _digit1 = floor (_number / 100); - _digit2 = floor (_number / 10) - _digit1 * 10; - _digit3 = _number mod 10; - _digit4 = "\AGM_Vector\rsc\do.paa"; - - if (_isNegative) then { - if (_digit1 == 0) then { - if (_digit2 == 0) then { - _digit1 = ""; - _digit2 = "\AGM_Vector\rsc\d-.paa"; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - } else { - _digit1 = "\AGM_Vector\rsc\d-.paa"; - _digit2 = format["\AGM_Vector\rsc\d%1.paa", _digit2]; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - }; - } else { - _digit1 = "\AGM_Vector\rsc\d-.paa"; - _digit2 = "\AGM_Vector\rsc\d-.paa"; - _digit3 = "\AGM_Vector\rsc\d-.paa"; - _digit4 = "\AGM_Vector\rsc\d-.paa"; - }; - } else { - if (_digit1 == 0) then { - if (_digit2 == 0) then { - _digit1 = ""; - _digit2 = ""; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - } else { - _digit1 = ""; - _digit2 = format["\AGM_Vector\rsc\d%1.paa", _digit2]; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - }; - } else { - _digit1 = format["\AGM_Vector\rsc\d%1.paa", _digit1]; - _digit2 = format["\AGM_Vector\rsc\d%1.paa", _digit2]; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - }; - }; - _return = [_digit1, _digit2, _digit3, _digit4]; -}; - -_return diff --git a/addons/vector/functions/fnc_convertDistance.sqf b/addons/vector/functions/fnc_convertDistance.sqf deleted file mode 100644 index e595d9a1cc..0000000000 --- a/addons/vector/functions/fnc_convertDistance.sqf +++ /dev/null @@ -1,85 +0,0 @@ -/* -BWA3 script, by commy2 -this code is property of the ArmA 3 Bundeswehr modification -ask us nicely at http://www.bwmod.de/ if you want to re-use any of this script -we don't support changed code based on this work -*/ -#include "script_component.hpp" - -private["_number", "_isNegative", "_digit1", "_digit2", "_digit3", "_digit4"]; - -_number = _this; - -_number = round _number; -_isNegative = if (_number < 0) then {true} else {false}; -_number = abs _number; - -if (_number >= 10000) exitWith { - [ - "\AGM_Vector\rsc\d-.paa", - "\AGM_Vector\rsc\d-.paa", - "\AGM_Vector\rsc\d-.paa", - "\AGM_Vector\rsc\d-.paa" - ] -}; - -_digit1 = floor (_number / 1000); -_digit2 = floor (_number / 100) - _digit1 * 10; -_digit3 = floor (_number / 10) - _digit1 * 100 - _digit2 * 10; -_digit4 = _number mod 10; - -if (_isNegative) then { - if (_digit1 == 0) then { - if (_digit2 == 0) then { - if (_digit3 == 0) then { - _digit1 = ""; - _digit2 = ""; - _digit3 = "\AGM_Vector\rsc\d-.paa"; - _digit4 = format["\AGM_Vector\rsc\d%1.paa", _digit4]; - } else { - _digit1 = ""; - _digit2 = "\AGM_Vector\rsc\d-.paa"; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - _digit4 = format["\AGM_Vector\rsc\d%1.paa", _digit4]; - }; - } else { - _digit1 = "\AGM_Vector\rsc\d-.paa"; - _digit2 = format["\AGM_Vector\rsc\d%1.paa", _digit2]; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - _digit4 = format["\AGM_Vector\rsc\d%1.paa", _digit4]; - }; - } else { - _digit1 = "\AGM_Vector\rsc\d-.paa"; - _digit2 = "\AGM_Vector\rsc\d-.paa"; - _digit3 = "\AGM_Vector\rsc\d-.paa"; - _digit4 = "\AGM_Vector\rsc\d-.paa"; - }; -} else { - if (_digit1 == 0) then { - if (_digit2 == 0) then { - if (_digit3 == 0) then { - _digit1 = ""; - _digit2 = ""; - _digit3 = ""; - _digit4 = format["\AGM_Vector\rsc\d%1.paa", _digit4]; - } else { - _digit1 = ""; - _digit2 = ""; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - _digit4 = format["\AGM_Vector\rsc\d%1.paa", _digit4]; - }; - } else { - _digit1 = ""; - _digit2 = format["\AGM_Vector\rsc\d%1.paa", _digit2]; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - _digit4 = format["\AGM_Vector\rsc\d%1.paa", _digit4]; - }; - } else { - _digit1 = format["\AGM_Vector\rsc\d%1.paa", _digit1]; - _digit2 = format["\AGM_Vector\rsc\d%1.paa", _digit2]; - _digit3 = format["\AGM_Vector\rsc\d%1.paa", _digit3]; - _digit4 = format["\AGM_Vector\rsc\d%1.paa", _digit4]; - }; -}; - -[_digit1, _digit2, _digit3, _digit4] diff --git a/addons/vector/functions/fnc_convertMeterToFeet.sqf b/addons/vector/functions/fnc_convertMeterToFeet.sqf deleted file mode 100644 index a0e6cb034c..0000000000 --- a/addons/vector/functions/fnc_convertMeterToFeet.sqf +++ /dev/null @@ -1,3 +0,0 @@ -// by commy2 - -3.28084 * (_this select 0) diff --git a/addons/vector/functions/fnc_convertToTexturesDegree.sqf b/addons/vector/functions/fnc_convertToTexturesDegree.sqf new file mode 100644 index 0000000000..a028012cec --- /dev/null +++ b/addons/vector/functions/fnc_convertToTexturesDegree.sqf @@ -0,0 +1,77 @@ +/* by commy2 + +converts azimuth into array of textures for the vectors scripted info control + +*/ + +#include "script_component.hpp" + +private "_number"; + +_number = _this select 0; + +if (GVAR(useMil)) then { + + _number = round (6400 / 360 * _number); + if (_number == 6400) then {_number = 0}; + + [_number] call FUNC(convertToTexturesDistance) // return + +} else { + + _number = round _number; + + private "_isNegative"; + _isNegative = _number < 0; + + _number = abs _number; + if (_number == 360) then {_number = 0}; + + private ["_digit1", "_digit2", "_digit3", "_digit4"]; + + _digit1 = floor (_number / 100); + _digit2 = floor (_number / 10) - _digit1 * 10; + _digit3 = _number mod 10; + _digit4 = QUOTE(PATHTOF(rsc\vector_degree.paa)); + + if (_isNegative) then { + + if (_digit1 == 0) then { + if (_digit2 == 0) then { + _digit1 = ""; + _digit2 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + } else { + _digit1 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit2 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit2]; + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + }; + } else { + _digit1 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit2 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit3 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit4 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + }; + + } else { + + if (_digit1 == 0) then { + if (_digit2 == 0) then { + _digit1 = ""; + _digit2 = ""; + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + } else { + _digit1 = ""; + _digit2 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit2]; + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + }; + } else { + _digit1 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit1]; + _digit2 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit2]; + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + }; + + }; + + [_digit1, _digit2, _digit3, _digit4] // return +} diff --git a/addons/vector/functions/fnc_convertToTexturesDistance.sqf b/addons/vector/functions/fnc_convertToTexturesDistance.sqf new file mode 100644 index 0000000000..ea0d054e5e --- /dev/null +++ b/addons/vector/functions/fnc_convertToTexturesDistance.sqf @@ -0,0 +1,86 @@ +/* by commy2 + +converts rangefinder distance into array of textures for the vectors scripted info control + +*/ + +#include "script_component.hpp" + +private ["_number", "_isNegative"]; + +_number = _this select 0; + +_number = round _number; +_isNegative = _number < 0; +_number = abs _number; + +if (_number >= 10000) exitWith { + [QUOTE(PATHTOF(rsc\vector_minus.paa)), QUOTE(PATHTOF(rsc\vector_minus.paa)), QUOTE(PATHTOF(rsc\vector_minus.paa)), QUOTE(PATHTOF(rsc\vector_minus.paa))] // return +}; + +private ["_digit1", "_digit2", "_digit3", "_digit4"]; + +_digit1 = floor (_number / 1000); +_digit2 = floor (_number / 100) - _digit1 * 10; +_digit3 = floor (_number / 10) - _digit1 * 100 - _digit2 * 10; +_digit4 = _number mod 10; + +if (_isNegative) then { + + if (_digit1 == 0) then { + if (_digit2 == 0) then { + if (_digit3 == 0) then { + _digit1 = ""; + _digit2 = ""; + _digit3 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit4 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit4]; + } else { + _digit1 = ""; + _digit2 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + _digit4 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit4]; + }; + } else { + _digit1 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit2 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit2]; + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + _digit4 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit4]; + }; + } else { + _digit1 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit2 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit3 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + _digit4 = QUOTE(PATHTOF(rsc\vector_minus.paa)); + }; + +} else { + + if (_digit1 == 0) then { + if (_digit2 == 0) then { + if (_digit3 == 0) then { + _digit1 = ""; + _digit2 = ""; + _digit3 = ""; + _digit4 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit4]; + } else { + _digit1 = ""; + _digit2 = ""; + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + _digit4 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit4]; + }; + } else { + _digit1 = ""; + _digit2 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit2]; + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + _digit4 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit4]; + }; + } else { + _digit1 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit1]; + _digit2 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit2]; + _digit3 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit3]; + _digit4 = format [QUOTE(PATHTOF(rsc\vector_%1.paa)), _digit4]; + }; + +}; + +[_digit1, _digit2, _digit3, _digit4] diff --git a/addons/vector/functions/fnc_getDirection.sqf b/addons/vector/functions/fnc_getDirection.sqf index 625e8fe34d..50858f6d0c 100644 --- a/addons/vector/functions/fnc_getDirection.sqf +++ b/addons/vector/functions/fnc_getDirection.sqf @@ -1,12 +1,26 @@ // by commy2 #include "script_component.hpp" +/* private "_dlgVector"; disableSerialization; -_dlgVector = uiNamespace getVariable ["AGM_dlgVector", displayNull]; +_dlgVector = GETUVAR(ACE_dlgVector, displayNull); [ - round parseNumber ctrlText (_dlgVector displayCtrl 156), - round parseNumber ctrlText (_dlgVector displayCtrl 182) + round parseNumber ctrlText (_dlgVector displayCtrl 156), + round parseNumber ctrlText (_dlgVector displayCtrl 182) ] +*/ + +private ["_position", "_direction", "_azimuth", "_inclination"]; + +_position = ATLToASL positionCameraToWorld [0,0,0]; +_direction = ATLToASL positionCameraToWorld [0,0,1]; + +_azimuth = ((_direction select 0) - (_position select 0)) atan2 ((_direction select 1) - (_position select 1)); +_inclination = asin ((_direction select 2) - (_position select 2)); + +if (_azimuth < 0) then {_azimuth = _azimuth + 360}; + +[_azimuth, _inclination] diff --git a/addons/vector/functions/fnc_getDistance.sqf b/addons/vector/functions/fnc_getDistance.sqf index 9658b16348..6aacaa1b57 100644 --- a/addons/vector/functions/fnc_getDistance.sqf +++ b/addons/vector/functions/fnc_getDistance.sqf @@ -2,12 +2,12 @@ #include "script_component.hpp" #define MIN_DISTANCE 10 -#define MAX_DISTANCE ([6000, 9000] select GVAR(useFeet)) +#define MAX_DISTANCE [6000, 9000] select GVAR(useFeet) private ["_dlgVector", "_distance"]; disableSerialization; -_dlgVector = GETUVAR(AGM_dlgVector,displayNull); +_dlgVector = GETUVAR(ACE_dlgVector,displayNull); _distance = ctrlText (_dlgVector displayCtrl 151); @@ -16,7 +16,7 @@ if (_distance == "----") exitWith {-1}; _distance = round parseNumber _distance; if (GVAR(useFeet)) then { - _distance = 3.28084 * _distance; + _distance = 3.28084 * _distance; }; if (_distance > MAX_DISTANCE) exitWith {-1}; diff --git a/addons/vector/functions/fnc_modeAzimuth.sqf b/addons/vector/functions/fnc_modeAzimuth.sqf deleted file mode 100644 index 7a6ab71497..0000000000 --- a/addons/vector/functions/fnc_modeAzimuth.sqf +++ /dev/null @@ -1,62 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -private["_dlgVector", "_ctrlVectorCenter", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8", "_exit", "_time"]; - -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; - -_ctrlVectorCenter ctrlSetText "\AGM_Vector\rsc\Vector_Center.paa"; - -_time = -1; -_exit = false; -waitUntil { - if (time > _time + 0.5) then { - _direction = call AGM_Vector_fnc_getDirection; - _azimuth = _direction select 0; - - _digits = _azimuth 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); - - _time = time; - }; - if (AGM_vectorKey select 1) then {_exit = true}; - !(AGM_vectorKey select 0) || {_exit} -}; -if (_exit) exitWith { - waitUntil { - if (time > _time + 0.5) then { - _direction = call AGM_Vector_fnc_getDirection; - _azimuth = _direction select 0; - - _digits = _azimuth 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); - - _time = time; - }; - !(AGM_vectorKey select 1) - }; - _ctrlDigit5 ctrlSetText ""; - _ctrlDigit6 ctrlSetText ""; - _ctrlDigit7 ctrlSetText ""; - _ctrlDigit8 ctrlSetText ""; - AGM_Vector_scriptHandle = 0 spawn AGM_Vector_fnc_modeRelativeAzimuthDistance; -}; -_ctrlVectorCenter ctrlShow false; - -AGM_isVectorReady = true; diff --git a/addons/vector/functions/fnc_modeAzimuthInclination.sqf b/addons/vector/functions/fnc_modeAzimuthInclination.sqf deleted file mode 100644 index 7c97de572a..0000000000 --- a/addons/vector/functions/fnc_modeAzimuthInclination.sqf +++ /dev/null @@ -1,84 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -private["_dlgVector", "_ctrlVectorCenter", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8", "_exit", "_time", "_direction", "_azimuth", "_inclination", "_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; - -_ctrlVectorCenter ctrlSetText "\AGM_Vector\rsc\Vector_Center.paa"; - -_time = -1; -_exit = false; -waitUntil { - if (time > _time + 0.5) then { - _direction = call AGM_Vector_fnc_getDirection; - _azimuth = _direction select 0; - _inclination = _direction select 1; - - _digits = _azimuth 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); - - if (_inclination > 45 || {_inclination < -45}) then {_inclination = -9999}; - - _digits = _inclination call AGM_Vector_fnc_convertDegree; - _ctrlDigit1 ctrlSetText (_digits select 0); - _ctrlDigit2 ctrlSetText (_digits select 1); - _ctrlDigit3 ctrlSetText (_digits select 2); - _ctrlDigit4 ctrlSetText (_digits select 3); - - _time = time; - }; - if (AGM_vectorKey select 1) then {_exit = true}; - !(AGM_vectorKey select 0) || {_exit} -}; -if (_exit) exitWith { - waitUntil { - if (time > _time + 0.5) then { - _direction = call AGM_Vector_fnc_getDirection; - _azimuth = _direction select 0; - _inclination = _direction select 1; - - _digits = _azimuth 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); - - if (_inclination > 45 || {_inclination < -45}) then {_inclination = -9999}; - - _digits = _inclination call AGM_Vector_fnc_convertDegree; - _ctrlDigit1 ctrlSetText (_digits select 0); - _ctrlDigit2 ctrlSetText (_digits select 1); - _ctrlDigit3 ctrlSetText (_digits select 2); - _ctrlDigit4 ctrlSetText (_digits select 3); - - _time = time; - }; - !(AGM_vectorKey select 1) - }; - _ctrlDigit1 ctrlSetText ""; - _ctrlDigit2 ctrlSetText ""; - _ctrlDigit3 ctrlSetText ""; - _ctrlDigit4 ctrlSetText ""; - _ctrlDigit5 ctrlSetText ""; - _ctrlDigit6 ctrlSetText ""; - _ctrlDigit7 ctrlSetText ""; - _ctrlDigit8 ctrlSetText ""; - AGM_Vector_scriptHandle = 0 spawn AGM_Vector_fnc_modeFallOfShort; -}; -_ctrlVectorCenter ctrlShow false; - -AGM_isVectorReady = true; diff --git a/addons/vector/functions/fnc_modeDistance.sqf b/addons/vector/functions/fnc_modeDistance.sqf deleted file mode 100644 index 62fd9deb0a..0000000000 --- a/addons/vector/functions/fnc_modeDistance.sqf +++ /dev/null @@ -1,40 +0,0 @@ -// by commy2 -#include "script_component.hpp" - -private["_dlgVector", "_ctrlVectorCenter", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8", "_exit", "_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; - -_ctrlVectorCenter ctrlSetText "\AGM_Vector\rsc\Vector_Center.paa"; - -_exit = false; -waitUntil { - if (AGM_vectorKey select 0) then {_exit = true}; - !(AGM_vectorKey select 1) || {_exit} -}; -if (_exit) exitWith { - waitUntil {!(AGM_vectorKey select 0)}; - AGM_Vector_scriptHandle = 0 spawn AGM_Vector_fnc_modeRelativeDistance; -}; - -_distance = call AGM_Vector_fnc_getDistance; - -_digits = _distance 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; - -AGM_isVectorReady = true; diff --git a/addons/vector/functions/fnc_onKeyDown.sqf b/addons/vector/functions/fnc_onKeyDown.sqf new file mode 100644 index 0000000000..8f8f2c457a --- /dev/null +++ b/addons/vector/functions/fnc_onKeyDown.sqf @@ -0,0 +1,34 @@ +/* + +by commy2 + +Handles pressing the special vector keys. + +*/ +#include "script_component.hpp" + +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; + }; + + 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; + }; +}; diff --git a/addons/vector/functions/fnc_onKeyHold.sqf b/addons/vector/functions/fnc_onKeyHold.sqf new file mode 100644 index 0000000000..79c7a5dfe6 --- /dev/null +++ b/addons/vector/functions/fnc_onKeyHold.sqf @@ -0,0 +1,39 @@ +/* + +by commy2 + +PFH executed while holding a vector key down. + +*/ +#include "script_component.hpp" + +switch (_this select 0) do { + case ("azimuth"): { + + if (diag_tickTime > GVAR(keyDownTimeAzimuth) + 0.5) then { + call FUNC(showAzimuth); + }; + + if (!GVAR(isKeyDownAzimuth)) then { + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; + + }; + + case ("distance"): { + + private "_isReady"; + _isReady = diag_tickTime > GVAR(keyDownTimeDistance) + 0.5; + + [_isReady] call FUNC(showCenter); + + if (!GVAR(isKeyDownDistance)) then { + if (_isReady) then { + call FUNC(showDistance); + }; + + [_this select 1] call CBA_fnc_removePerFrameHandler; + }; + + }; +}; diff --git a/addons/vector/functions/fnc_onKeyUp.sqf b/addons/vector/functions/fnc_onKeyUp.sqf new file mode 100644 index 0000000000..0079680f19 --- /dev/null +++ b/addons/vector/functions/fnc_onKeyUp.sqf @@ -0,0 +1,22 @@ +/* + +by commy2 + +Handles releasing the special vector keys. + +*/ +#include "script_component.hpp" + +switch (_this select 0) do { + case ("azimuth"): { + + GVAR(isKeyDownAzimuth) = false; + + }; + + case ("distance"): { + + GVAR(isKeyDownDistance) = false; + + }; +}; diff --git a/addons/vector/functions/fnc_showAzimuth.sqf b/addons/vector/functions/fnc_showAzimuth.sqf new file mode 100644 index 0000000000..7f6ead037f --- /dev/null +++ b/addons/vector/functions/fnc_showAzimuth.sqf @@ -0,0 +1,23 @@ +// by commy2 +#include "script_component.hpp" + +private ["_dlgVector", "_ctrlDigit5", "_ctrlDigit6", "_ctrlDigit7", "_ctrlDigit8"]; + +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); diff --git a/addons/vector/functions/fnc_showCenter.sqf b/addons/vector/functions/fnc_showCenter.sqf new file mode 100644 index 0000000000..58899ff1e7 --- /dev/null +++ b/addons/vector/functions/fnc_showCenter.sqf @@ -0,0 +1,10 @@ +/* + +by commy2 + +Shows or hides the vectors center square thingy. + +*/ +#include "script_component.hpp" + +((GETUVAR(ACE_dlgVector,displayNull)) displayCtrl 1301) ctrlSetText (["", QUOTE(PATHTOF(rsc\vector_center.paa))] select (_this select 0)); diff --git a/addons/vector/functions/fnc_showDistance.sqf b/addons/vector/functions/fnc_showDistance.sqf new file mode 100644 index 0000000000..bc802302fd --- /dev/null +++ b/addons/vector/functions/fnc_showDistance.sqf @@ -0,0 +1,23 @@ +// by commy2 +#include "script_component.hpp" + +private ["_dlgVector", "_ctrlDigit1", "_ctrlDigit2", "_ctrlDigit3", "_ctrlDigit4"]; + +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); diff --git a/addons/vector/rsc/debug_crosshair.paa b/addons/vector/rsc/_debug_crosshair.paa similarity index 100% rename from addons/vector/rsc/debug_crosshair.paa rename to addons/vector/rsc/_debug_crosshair.paa diff --git a/addons/vector/rsc/d0.paa b/addons/vector/rsc/vector_0.paa similarity index 100% rename from addons/vector/rsc/d0.paa rename to addons/vector/rsc/vector_0.paa diff --git a/addons/vector/rsc/d1.paa b/addons/vector/rsc/vector_1.paa similarity index 100% rename from addons/vector/rsc/d1.paa rename to addons/vector/rsc/vector_1.paa diff --git a/addons/vector/rsc/d2.paa b/addons/vector/rsc/vector_2.paa similarity index 100% rename from addons/vector/rsc/d2.paa rename to addons/vector/rsc/vector_2.paa diff --git a/addons/vector/rsc/d3.paa b/addons/vector/rsc/vector_3.paa similarity index 100% rename from addons/vector/rsc/d3.paa rename to addons/vector/rsc/vector_3.paa diff --git a/addons/vector/rsc/d4.paa b/addons/vector/rsc/vector_4.paa similarity index 100% rename from addons/vector/rsc/d4.paa rename to addons/vector/rsc/vector_4.paa diff --git a/addons/vector/rsc/d5.paa b/addons/vector/rsc/vector_5.paa similarity index 100% rename from addons/vector/rsc/d5.paa rename to addons/vector/rsc/vector_5.paa diff --git a/addons/vector/rsc/d6.paa b/addons/vector/rsc/vector_6.paa similarity index 100% rename from addons/vector/rsc/d6.paa rename to addons/vector/rsc/vector_6.paa diff --git a/addons/vector/rsc/d7.paa b/addons/vector/rsc/vector_7.paa similarity index 100% rename from addons/vector/rsc/d7.paa rename to addons/vector/rsc/vector_7.paa diff --git a/addons/vector/rsc/d8.paa b/addons/vector/rsc/vector_8.paa similarity index 100% rename from addons/vector/rsc/d8.paa rename to addons/vector/rsc/vector_8.paa diff --git a/addons/vector/rsc/d9.paa b/addons/vector/rsc/vector_9.paa similarity index 100% rename from addons/vector/rsc/d9.paa rename to addons/vector/rsc/vector_9.paa diff --git a/addons/vector/rsc/dA.paa b/addons/vector/rsc/vector_a.paa similarity index 100% rename from addons/vector/rsc/dA.paa rename to addons/vector/rsc/vector_a.paa diff --git a/addons/vector/rsc/db.paa b/addons/vector/rsc/vector_b.paa similarity index 100% rename from addons/vector/rsc/db.paa rename to addons/vector/rsc/vector_b.paa diff --git a/addons/vector/rsc/dC.paa b/addons/vector/rsc/vector_c.paa similarity index 100% rename from addons/vector/rsc/dC.paa rename to addons/vector/rsc/vector_c.paa diff --git a/addons/vector/rsc/dd.paa b/addons/vector/rsc/vector_d.paa similarity index 100% rename from addons/vector/rsc/dd.paa rename to addons/vector/rsc/vector_d.paa diff --git a/addons/vector/rsc/do.paa b/addons/vector/rsc/vector_degree.paa similarity index 100% rename from addons/vector/rsc/do.paa rename to addons/vector/rsc/vector_degree.paa diff --git a/addons/vector/rsc/dE.paa b/addons/vector/rsc/vector_e.paa similarity index 100% rename from addons/vector/rsc/dE.paa rename to addons/vector/rsc/vector_e.paa diff --git a/addons/vector/rsc/dF.paa b/addons/vector/rsc/vector_f.paa similarity index 100% rename from addons/vector/rsc/dF.paa rename to addons/vector/rsc/vector_f.paa diff --git a/addons/vector/rsc/dG.paa b/addons/vector/rsc/vector_g.paa similarity index 100% rename from addons/vector/rsc/dG.paa rename to addons/vector/rsc/vector_g.paa diff --git a/addons/vector/rsc/d-.paa b/addons/vector/rsc/vector_minus.paa similarity index 100% rename from addons/vector/rsc/d-.paa rename to addons/vector/rsc/vector_minus.paa diff --git a/addons/vector/rsc/d+.paa b/addons/vector/rsc/vector_plus.paa similarity index 100% rename from addons/vector/rsc/d+.paa rename to addons/vector/rsc/vector_plus.paa