11/*
22 ASG_fnc_initEarPro
3- by: Diffusion9
4-
5- Adds a keyDown eventHandler that watched the 'End' key, or UserAction 1 in the Custom Action menu.
3+ by: Diffusion9 and jmlane
4+
5+ Adds a keyDown eventHandler that watched the 'End' key (0xCF) , or UserAction 1 in the Custom Action menu.
66 This should be run locally on the player.
7-
7+
88 EXEC TYPE: Call
99 INPUT: Nothing
1010 OUTPUT: Nothing
1111*/
12+ if ! (isNull (uiNamespace getVariable [' ASG_earPro_ctrl' , controlNull ])) exitWith {};
1213
1314#include " \A3\Ui_F\hpp\defineDIKCodes.inc"
1415
15- if (! isNil " earPro_handler" ) exitWith {true };
16+ waitUntil {! (isNull findDisplay 46 )};
17+
18+ call {
19+ disableSerialization;
1620
17- earPro_handler = findDisplay 46 displayAddEventHandler [" keyDown" , {
18- params [' _display' , ' _key' , ' _shift' , ' _ctrl' ,' _alt' ];
21+ private _earProCtrl = findDisplay 46 ctrlCreate [' RscPictureKeepAspect' , - 1 ];
22+ _earProCtrl ctrlShow FALSE ;
23+ _earProCtrl ctrlSetText ' functions\earPro\earplugs_ca.paa' ;
24+ _earProCtrl ctrlSetPosition [
25+ ((0.95 * safezoneW) + safezoneX),
26+ ((0.39 * safezoneH) + safezoneY),
27+ 0.075 ,
28+ 0.075
29+ ];
30+ _earProCtrl ctrlSetTextColor [0.8 ,0.8 ,0.8 ,1 ];
31+ _earProCtrl ctrlCommit 0 ;
32+ uiNamespace setVariable [' ASG_earPro_ctrl' , _earProCtrl ];
33+ };
34+
35+ findDisplay 46 displayAddEventHandler [" keyDown" , {
36+ params [' _display' , ' _key' , ' _shift' , ' _ctrl' , ' _alt' ];
1937 private [' _conditions' ];
2038 // IF CUSTOM KEY IS UNDEFINED
2139 if (actionKeys ' User1' isEqualTo []) then {
@@ -24,14 +42,18 @@ earPro_handler = findDisplay 46 displayAddEventHandler ["keyDown", {
2442 _conditions = (_key in actionKeys ' User1' )
2543 };
2644 // ENABLE / DISABLE EARPLUGS
27- if _conditions then {
28- if (missionNamespace getVariable [' earPlugs_state' , false ]) then {
29- .1 fadeSound 1 ;
30- earPlugs_state = false ;
31- } else {
32- 1 fadeSound .04 ;
33- earPlugs_state = true ;
34- };
35- };
45+ if _conditions then {
46+ if (missionNamespace getVariable [' ASG_earPro_active' , false ]) then {
47+ .1 fadeSound 1 ;
48+ ASG_earPro_active = false ;
49+ uiNamespace getVariable [' ASG_earPro_ctrl' , controlNull ] ctrlShow false ;
50+ } else {
51+ if ! (isStreamFriendlyUIEnabled) then {
52+ uiNamespace getVariable [' ASG_earPro_ctrl' , controlNull ] ctrlShow true ;
53+ };
54+ 1 fadeSound .04 ;
55+ ASG_earPro_active = true ;
56+ };
57+ };
58+ false
3659}];
37- earPro_handler
0 commit comments