diff --git a/addons/laser/RscInGameUI.hpp b/addons/laser/RscInGameUI.hpp index 49ce3fdf5b..753564385c 100644 --- a/addons/laser/RscInGameUI.hpp +++ b/addons/laser/RscInGameUI.hpp @@ -1,117 +1,18 @@ class RscInGameUI { class RscOptics_LaserDesignator { - idd = 300; - controls[] = {"CA_IGUI_elements_group"}; - - onLoad = "uiNameSpace setVariable ['ACE_RscOptics_LaserDesignator',(_this select 0)];"; - onUnload = "uiNameSpace setVariable ['ACE_RscOptics_LaserDesignator',nil];"; - class CA_IGUI_elements_group: RscControlsGroup { - idc = 170; - - x = "0 * (0.01875 * SafezoneH) + (SafezoneX + ((SafezoneW - SafezoneH) / 2))"; - y = "0 * (0.025 * SafezoneH) + (SafezoneY)"; - w = "53.5 * (0.01875 * SafezoneH)"; - h = "40 * (0.025 * SafezoneH)"; - class VScrollbar: VScrollbar { - width = 0; - }; - class HScrollbar: HScrollbar { - height = 0; - }; class controls { - class CA_OpticsZoom: RscText { - idc = 180; - style = 1; - colorText[] = {0.706,0.0745,0.0196,1}; - sizeEx = "0.038*SafezoneH"; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "4.5"; - x = "43.85 * (0.01875 * SafezoneH)"; - y = "19.6 * (0.025 * SafezoneH)"; - w = "4.5 * (0.01875 * SafezoneH)"; - h = "1.1 * (0.025 * SafezoneH)"; - }; - class ACE_Distance: RscText { - idc = 123002; - style = 0; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "2456"; - x = "24.6 * (0.01875 * SafezoneH)"; - y = "3 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.5 * (0.025 * SafezoneH)"; - }; + // Hide the vanilla distance display class CA_Distance: RscText { - idc = 151; - style = 0; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "2456"; - x = 0; - y = 0; - w = 0; - h = 0; + idc = IDC_LASERDESIGNATOR_DISTANCE; // Purposeful overwrite, makes range update constantly, do not remove + fade = 1; + colorText[] = {0,0,0,0}; // fade doesn't work in some cases (e.g. controlling remote designator uav) }; - class CA_Elev: RscText { - idc = 175; - style = 1; - sizeEx = "0.038*SafezoneH"; + class ACE_Distance: CA_Distance { + idc = IDC_LASERDESIGNATOR_ACEDISTANCE; + fade = 0; colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "80.5"; - x = "32.7 * (0.01875 * SafezoneH)"; - y = "3 * (0.025 * SafezoneH)"; - w = "5 * (0.01875 * SafezoneH)"; - h = "1.5 * (0.025 * SafezoneH)"; }; - class CA_VisionMode: RscText { - idc = 179; - style = 0; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "VIS"; - x = "6.5 * (0.01875 * SafezoneH)"; - y = "19.6 * (0.025 * SafezoneH)"; - w = "4 * (0.01875 * SafezoneH)"; - h = "1.1 * (0.025 * SafezoneH)"; - }; - class CA_Laser: RscText { - idc = 158; - style = "0x30 + 0x800"; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "\A3\ui_f\data\igui\rscingameui\rscoptics\laser_designator_iconLaserOn.paa"; - x = "29.2 * (0.01875 * SafezoneH)"; - y = "3 * (0.025 * SafezoneH)"; - w = "3.5 * (0.01875 * SafezoneH)"; - h = "1.5 * (0.025 * SafezoneH)"; - }; - class CA_Heading: RscText { - idc = 156; - style = 0; - sizeEx = "0.038*SafezoneH"; - colorText[] = {0.706,0.0745,0.0196,1}; - shadow = 0; - font = "EtelkaMonospacePro"; - text = "023"; - x = "16.1 * (0.01875 * SafezoneH)"; - y = "3 * (0.025 * SafezoneH)"; - w = "3.5 * (0.01875 * SafezoneH)"; - h = "1.6 * (0.025 * SafezoneH)"; - }; - class ACE_LaserCode_Helper: RscMapControl { idc = -1; onDraw = QUOTE(_this call FUNC(onLaserDesignatorDraw)); @@ -119,7 +20,7 @@ class RscInGameUI { h = 0; }; class ACE_LaserCode: RscText { - idc = 123001; + idc = IDC_LASERDESIGNATOR_LASERCODE; style = 0; sizeEx = "0.038*SafezoneH"; colorText[] = {0.706,0.0745,0.0196,1}; diff --git a/addons/laser/config.cpp b/addons/laser/config.cpp index 2d59a177de..5bd8bf8548 100644 --- a/addons/laser/config.cpp +++ b/addons/laser/config.cpp @@ -20,8 +20,6 @@ class CfgPatches { class RscControlsGroup; -class VScrollbar; -class HScrollbar; class RscText; class RscMapControl; class RscControlsGroupNoScrollbars; diff --git a/addons/laser/functions/fnc_onLaserDesignatorDraw.sqf b/addons/laser/functions/fnc_onLaserDesignatorDraw.sqf index e7a4994ce2..9c85689f4a 100644 --- a/addons/laser/functions/fnc_onLaserDesignatorDraw.sqf +++ b/addons/laser/functions/fnc_onLaserDesignatorDraw.sqf @@ -15,14 +15,26 @@ * Public: No */ -private _laserCode = ACE_player getVariable[QGVAR(code), ACE_DEFAULT_LASER_CODE]; -if (!isNil "_laserCode") then { - __LaserDesignatorIGUI_LaserCode ctrlSetText format["Code: %1", [_laserCode, 4, 0, false] call CBA_fnc_formatNumber]; +params ["_ctrl"]; + +private _display = ctrlParent _ctrl; + +private _currentShooter = ACE_controlledUAV param [0, objNull]; +if (isNull _currentShooter) then { + if (ACE_player call CBA_fnc_canUseWeapon) then { + _currentShooter = ACE_player; + } else { + _currentShooter = objectParent ACE_player; + }; }; -if (! (ctrlShown __LaserDesignatorIGUI_LaserOn) ) then { - // TODO: hide distance - __LaserDesignatorIGUI_ACE_Distance ctrlSetText "----"; -} else { - __LaserDesignatorIGUI_ACE_Distance ctrlSetText (ctrlText __LaserDesignatorIGUI_CA_Distance); +private _laserCode = _currentShooter getVariable [QGVAR(code), ACE_DEFAULT_LASER_CODE]; +private _ctrlLaserCode = _display displayCtrl IDC_LASERDESIGNATOR_LASERCODE; +_ctrlLaserCode ctrlSetText format ["Code: %1", [_laserCode, 4, 0, false] call CBA_fnc_formatNumber]; + +private _ctrlDistanceACE = _display displayCtrl IDC_LASERDESIGNATOR_ACEDISTANCE; +if (!isLaserOn _currentShooter) exitWith { + _ctrlDistanceACE ctrlSetText "----"; }; + +_ctrlDistanceACE ctrlSetText (ctrlText (_display displayCtrl IDC_LASERDESIGNATOR_DISTANCE)); diff --git a/addons/laser/script_component.hpp b/addons/laser/script_component.hpp index b0d9951bf3..64a9a85f13 100644 --- a/addons/laser/script_component.hpp +++ b/addons/laser/script_component.hpp @@ -17,14 +17,11 @@ #include "\z\ace\addons\main\script_macros.hpp" - -#define __LaserDesignatorIGUI (uiNamespace getVariable ["ACE_RscOptics_LaserDesignator", nil]) -#define __LaserDesignatorIGUI_LaserCode (__LaserDesignatorIGUI displayCtrl 123001) -#define __LaserDesignatorIGUI_ACE_Distance (__LaserDesignatorIGUI displayCtrl 123002) -#define __LaserDesignatorIGUI_CA_Distance (__LaserDesignatorIGUI displayCtrl 151) -#define __LaserDesignatorIGUI_LaserOn (__LaserDesignatorIGUI displayCtrl 158) - #define IDC_MODECONTROLGROUP 1000 #define IDC_ATTACKMODE 1001 #define IDC_LASERCODE 1002 #define IDC_LASERICON 1003 + +#define IDC_LASERDESIGNATOR_LASERCODE 123001 +#define IDC_LASERDESIGNATOR_ACEDISTANCE 123002 +#define IDC_LASERDESIGNATOR_DISTANCE 151