@@ -15,82 +15,121 @@ public class Main : Script
1515 bool leftIndicator , rightIndicator ;
1616
1717 Keys sirenToggleKey , beamToggleKey , interiorLightToggleKey , leftIndicatorKey , rightIndicatorKey ;
18+ GTA . Control sirenToggleButton , beamToggleButton , leftIndicatorButton , rightIndicatorButton ;
1819
1920 public Main ( )
2021 {
2122 this . Tick += OnTick ;
2223 this . KeyDown += OnKeyDown ;
2324
2425 ScriptSettings config = ScriptSettings . Load ( "scripts\\ EVLC_Settings.ini" ) ;
25-
26+
27+ #region Keys
2628 sirenToggleKey = config . GetValue < Keys > ( "Emergency Vehicles" , "Siren_Toggle_Key" , Keys . Tab ) ;
2729 beamToggleKey = config . GetValue < Keys > ( "All" , "Beam_Toggle_Key" , Keys . CapsLock ) ;
2830 interiorLightToggleKey = config . GetValue < Keys > ( "All" , "Interior_Light_Toggle_Key" , Keys . I ) ;
2931 leftIndicatorKey = config . GetValue < Keys > ( "All" , "Left_Indicator_key" , Keys . Left ) ;
3032 rightIndicatorKey = config . GetValue < Keys > ( "All" , "Right_Indicator_key" , Keys . Right ) ;
31-
33+ #endregion
34+
35+ #region Buttons
36+ sirenToggleButton = config . GetValue < GTA . Control > ( "Emergency Vehicles" , "Siren_Toggle_Button" , GTA . Control . ScriptPadDown ) ;
37+ beamToggleButton = config . GetValue < GTA . Control > ( "All" , "Beam_Toggle_Button" , GTA . Control . ScriptRLeft ) ;
38+ leftIndicatorButton = config . GetValue < GTA . Control > ( "All" , "Left_Indicator_Button" , GTA . Control . ScriptPadLeft ) ;
39+ rightIndicatorButton = config . GetValue < GTA . Control > ( "All" , "Right_Indicator_Button" , GTA . Control . ScriptPadRight ) ;
40+ #endregion
3241 }
3342
3443 private void OnTick ( object sender , EventArgs e )
3544 {
3645 string modName = "Enhanced Vehicle Lighting Controls" ;
37- string version = "PreRelease v0.2.0 " ;
46+ string version = "PreRelease v0.2.3 " ;
3847 string developer = "MccDev260" ;
3948
4049 if ( firstTime )
4150 {
4251 Notification . Show ( NotificationIcon . Blocked , modName , developer , version + " " + "loaded!!" , false , true ) ;
4352 firstTime = false ;
4453 }
54+
55+ if ( Game . LastInputMethod == InputMethod . GamePad && playerCharacter . CurrentVehicle != null )
56+ GamePad ( ) ;
4557 }
4658
4759 private void OnKeyDown ( object sender , KeyEventArgs e )
48- {
49-
60+ {
5061 if ( playerCharacter . CurrentVehicle != null )
5162 {
52- if ( playerCharacter . CurrentVehicle . HasSiren )
53- {
54- if ( e . KeyCode == sirenToggleKey )
55- {
56- isSirenSilent = ! isSirenSilent ;
57- playerCharacter . CurrentVehicle . IsSirenSilent = isSirenSilent ;
58- }
59- }
60-
61- if ( playerCharacter . CurrentVehicle . AreLightsOn )
62- {
63- if ( e . KeyCode == beamToggleKey )
64- playerCharacter . CurrentVehicle . AreHighBeamsOn = ! playerCharacter . CurrentVehicle . AreHighBeamsOn ;
65- }
63+ if ( e . KeyCode == sirenToggleKey )
64+ ToggleSiren ( ) ;
65+
66+ if ( e . KeyCode == beamToggleKey )
67+ ToggleFullBeams ( ) ;
6668
6769 if ( e . KeyCode == interiorLightToggleKey )
68- playerCharacter . CurrentVehicle . IsInteriorLightOn = ! playerCharacter . CurrentVehicle . IsInteriorLightOn ;
70+ ToggleInteriorLights ( ) ;
6971
7072 if ( e . KeyCode == rightIndicatorKey )
71- {
72- rightIndicator = ! rightIndicator ;
73- playerCharacter . CurrentVehicle . IsRightIndicatorLightOn = rightIndicator ;
74-
75- if ( leftIndicator )
76- {
77- leftIndicator = ! leftIndicator ;
78- playerCharacter . CurrentVehicle . IsLeftIndicatorLightOn = leftIndicator ;
79- }
80- }
73+ ToggleRightIndicator ( ) ;
8174
8275 if ( e . KeyCode == leftIndicatorKey )
83- {
84- leftIndicator = ! leftIndicator ;
85- playerCharacter . CurrentVehicle . IsLeftIndicatorLightOn = leftIndicator ;
86-
87- if ( rightIndicator )
88- {
89- rightIndicator = ! rightIndicator ;
90- playerCharacter . CurrentVehicle . IsRightIndicatorLightOn = rightIndicator ;
91- }
92- }
76+ ToggleLeftIndicator ( ) ;
77+ }
78+ }
79+
80+ private void GamePad ( )
81+ {
82+ if ( Game . IsControlJustReleased ( sirenToggleButton ) )
83+ ToggleSiren ( ) ;
84+
85+ if ( Game . IsControlJustReleased ( beamToggleButton ) )
86+ ToggleFullBeams ( ) ;
87+
88+ if ( Game . IsControlJustPressed ( leftIndicatorButton ) )
89+ ToggleLeftIndicator ( ) ;
90+
91+ if ( Game . IsControlJustPressed ( rightIndicatorButton ) )
92+ ToggleRightIndicator ( ) ;
93+ }
94+
95+ private void ToggleSiren ( )
96+ {
97+ if ( playerCharacter . CurrentVehicle . HasSiren )
98+ {
99+ isSirenSilent = ! isSirenSilent ;
100+ playerCharacter . CurrentVehicle . IsSirenSilent = isSirenSilent ;
93101 }
94102 }
103+
104+ private void ToggleFullBeams ( )
105+ {
106+ if ( playerCharacter . CurrentVehicle . AreLightsOn )
107+ {
108+ playerCharacter . CurrentVehicle . AreHighBeamsOn = ! playerCharacter . CurrentVehicle . AreHighBeamsOn ;
109+ }
110+ }
111+
112+ private void ToggleInteriorLights ( )
113+ {
114+ playerCharacter . CurrentVehicle . IsInteriorLightOn = ! playerCharacter . CurrentVehicle . IsInteriorLightOn ;
115+ }
116+
117+ private void ToggleRightIndicator ( )
118+ {
119+ rightIndicator = ! rightIndicator ;
120+ playerCharacter . CurrentVehicle . IsRightIndicatorLightOn = rightIndicator ;
121+
122+ if ( leftIndicator )
123+ ToggleLeftIndicator ( ) ;
124+ }
125+
126+ private void ToggleLeftIndicator ( )
127+ {
128+ leftIndicator = ! leftIndicator ;
129+ playerCharacter . CurrentVehicle . IsLeftIndicatorLightOn = leftIndicator ;
130+
131+ if ( rightIndicator )
132+ ToggleRightIndicator ( ) ;
133+ }
95134 }
96135}
0 commit comments