Laser - Cleanup laser designator config and code (#9289)

* cleanup laser designator code

* condition

* use macro for IDC

Co-authored-by: PabstMirror <pabstmirror@gmail.com>

* IDC to macro

* switch to _currentShooter

* hide CA_Distance even if fade fails

---------

Co-authored-by: PabstMirror <pabstmirror@gmail.com>
This commit is contained in:
Grim 2023-07-30 04:41:46 +03:00 committed by GitHub
parent 14e92dfb7f
commit 628d62d329
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 124 deletions

View File

@ -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};

View File

@ -20,8 +20,6 @@ class CfgPatches {
class RscControlsGroup;
class VScrollbar;
class HScrollbar;
class RscText;
class RscMapControl;
class RscControlsGroupNoScrollbars;

View File

@ -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));

View File

@ -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