From 4bd489cd966b5711d084aa29c3b4b76e8f9d0dbf Mon Sep 17 00:00:00 2001 From: jaynus Date: Sun, 12 Apr 2015 16:18:39 -0700 Subject: [PATCH] Fixed: Javelin CLU UI should have been a PFH not a draw. Migrated. Closes #531 --- addons/javelin/RscInGameUI.hpp | 9 +---- addons/javelin/functions/fnc_onOpticDraw.sqf | 38 ++++++++++++++------ addons/javelin/functions/fnc_onOpticLoad.sqf | 8 ++++- 3 files changed, 35 insertions(+), 20 deletions(-) diff --git a/addons/javelin/RscInGameUI.hpp b/addons/javelin/RscInGameUI.hpp index e208e18834..8c73f3d8d1 100644 --- a/addons/javelin/RscInGameUI.hpp +++ b/addons/javelin/RscInGameUI.hpp @@ -14,7 +14,7 @@ class RscInGameUI { idd = 300; controls[] = { "ACE_javelin_elements_group", "CA_Distance", "ACE_Targeting" }; //, "ACE_TargetingConstrains", "ACE_TargetingGate", "ACE_TargetingLines"}; onLoad = QUOTE(_this call FUNC(onOpticLoad)); - onUnload = "uiNameSpace setVariable ['ACE_RscOptics_javelin',nil];"; + onUnload = "uiNameSpace setVariable ['ACE_RscOptics_javelin',nil];uiNameSpace setVariable ['ACE_RscOptics_javelin_PFH',nil];"; class CA_Distance: RscOpticsValue { idc = 151; @@ -45,13 +45,6 @@ class RscInGameUI { height = 0.001; }; class Controls { - class JavelinLocking : RscMapControl { - onDraw = QUOTE(_this call FUNC(onOpticDraw)); - idc = -1; - w = 0; - h = 0; - }; - class ACE_javelin_Day_mode_off: RscPicture { idc = 1001; x = "(SafezoneX+(SafezoneW -SafezoneH*3/4)/2)+ (0.03/4)*3*SafezoneH - SafezoneX"; diff --git a/addons/javelin/functions/fnc_onOpticDraw.sqf b/addons/javelin/functions/fnc_onOpticDraw.sqf index a319c61de5..643c12e4c3 100644 --- a/addons/javelin/functions/fnc_onOpticDraw.sqf +++ b/addons/javelin/functions/fnc_onOpticDraw.sqf @@ -1,6 +1,6 @@ -//#define DEBUG_MODE_FULL +#define DEBUG_MODE_FULL #include "script_component.hpp" -//TRACE_1("enter", _this); +TRACE_1("enter", _this); #define __TRACKINTERVAL 0 // how frequent the check should be. #define __LOCKONTIME 3.0 // Lock on won't occur sooner @@ -10,7 +10,19 @@ #define __OffsetX ((ctrlPosition __JavelinIGUITargetingLineV) select 0) - 0.5 #define __OffsetY ((ctrlPosition __JavelinIGUITargetingLineH) select 1) - 0.5 -private["_args", "_lastTick", "_runTime", "_soundTime", "_lockTime", "_newTarget", "_currentTarget", "_range", "_pos", "_targetArray"]; +private["_isJavelin", "_args", "_lastTick", "_runTime", "_soundTime", "_lockTime", "_newTarget", "_currentTarget", "_range", "_pos", "_targetArray"]; + +if( ! ([ (configFile >> "CfgWeapons" >> (currentWeapon (vehicle ACE_player)) ), "launch_Titan_base"] call EFUNC(common,inheritsFrom)) + || { (vehicle ACE_player) != ACE_player } + ) exitWith { + __JavelinIGUITargeting ctrlShow false; + __JavelinIGUITargetingGate ctrlShow false; + __JavelinIGUITargetingLines ctrlShow false; + __JavelinIGUITargetingConstraints ctrlShow false; + + [(_this select 1)] call cba_fnc_removePerFrameHandler; + uiNamespace setVariable["ACE_RscOptics_javelin_PFH", nil]; +}; // Reset arguments if we havnt rendered in over a second _args = uiNamespace getVariable[QGVAR(arguments), [] ]; @@ -21,6 +33,8 @@ if( (count _args) > 0) then { }; }; +TRACE_1("Running", "Running"); + // Pull the arguments _currentTarget = _args select 1; _runTime = _args select 2; @@ -37,9 +51,6 @@ if ((velocity ACE_player) distance [0,0,0] > 0.5 && {cameraView == "GUNNER"} && // Refresh the firemode [] call FUNC(showFireMode); - -// Only start locking on holding tab -if(!GVAR(isLockKeyDown)) exitWith { false }; _range = parseNumber (ctrlText __JavelinIGUIRangefinder); if (_range > 50 && {_range < 2500}) then { @@ -73,8 +84,10 @@ if (isNull _newTarget) then { __JavelinIGUISeek ctrlSetTextColor __ColorGray; __JavelinIGUINFOV ctrlSetTextColor __ColorGreen; + __JavelinIGUITargeting ctrlShow false; __JavelinIGUITargetingGate ctrlShow false; __JavelinIGUITargetingLines ctrlShow false; + __JavelinIGUITargetingConstraints ctrlShow false; ACE_player setVariable ["ace_missileguidance_target",nil, false]; @@ -82,8 +95,9 @@ if (isNull _newTarget) then { //if (ACE_player ammo "Javelin" > 0 || {ACE_player ammo "ACE_Javelin_Direct" > 0}) then {ACE_player setWeaponReloadingTime //[player, "Javelin", 0.2];}; } else { if (_newTarget distance ACE_player < 2500 - // && {(call CBA_fnc_getFoV) select 1 > 7} - // && { (currentVisionMode ACE_player == 2)} + && {(call CBA_fnc_getFoV) select 1 > 9} + && { (currentVisionMode ACE_player == 2)} + && GVAR(isLockKeyDown) ) then { // Lock on after 3 seconds if(_currentTarget != _newTarget) then { @@ -98,8 +112,9 @@ if (isNull _newTarget) then { __JavelinIGUISeek ctrlSetTextColor __ColorGreen; __JavelinIGUINFOV ctrlSetTextColor __ColorNull; + __JavelinIGUITargeting ctrlShow true; - __JavelinIGUITargetingConstrains ctrlShow true; + __JavelinIGUITargetingConstrains ctrlShow false; __JavelinIGUITargetingGate ctrlShow true; __JavelinIGUITargetingLines ctrlShow true; @@ -187,10 +202,11 @@ if (isNull _newTarget) then { } else { // Something is wrong with our seek _currentTarget = objNull; - + ACE_player setVariable["ace_missileguidance_target", nil, false]; + __JavelinIGUISeek ctrlSetTextColor __ColorGray; __JavelinIGUINFOV ctrlSetTextColor __ColorGray; - __JavelinIGUITargetingConstrains ctrlShow false; + __JavelinIGUITargeting ctrlShow false; __JavelinIGUITargetingGate ctrlShow false; __JavelinIGUITargetingLines ctrlShow false; diff --git a/addons/javelin/functions/fnc_onOpticLoad.sqf b/addons/javelin/functions/fnc_onOpticLoad.sqf index 49e9a25e61..a12d0ef176 100644 --- a/addons/javelin/functions/fnc_onOpticLoad.sqf +++ b/addons/javelin/functions/fnc_onOpticLoad.sqf @@ -24,4 +24,10 @@ uiNameSpace setVariable [QGVAR(arguments), 0, // Lock Time 0 // Sound timer ] -]; \ No newline at end of file +]; + +_pfh_handle = uiNamespace getVariable ["ACE_RscOptics_javelin_PFH", nil]; +if(isNil "_pfh_handle") then { + _pfh_handle = [FUNC(onOpticDraw), 0, []] call CBA_fnc_addPerFrameHandler; + uiNamespace setVariable["ACE_RscOptics_javelin_PFH", _pfh_handle]; +}; \ No newline at end of file