DayZ 1.24
Loading...
Searching...
No Matches
Backlit.c
Go to the documentation of this file.
1
2// Purpose of this file is to encapsulate Backlit Effects
3// Basic implementatoin is for Razer Chroma devices, but API is made to remain universal for future purposes
4//
5// for specific method - watch UAInputAPI/ UAInput class
6//
7//
8
9
10//-----------------------------------------------------------------------------
12const int EUABLAYER_ALL = 0; // all layers
13const int EUABLAYER_HINTKEY = 1; // showing hints
14const int EUABLAYER_VISKEY = 2; // visualisation
15const int EUABLAYER_3 = 3; //
16const int EUABLAYER_CAR = 4; //
17const int EUABLAYER_HUMAN = 5; //
18const int EUABLAYER_6 = 6; //
19const int EUABLAYER_CUSTOM = 7; // custom
20const int EUABLAYER_LOADING = 8; // keys during loading sequence
21const int EUABLAYER_MENU = 9; // keys during menu
22
23
24//-----------------------------------------------------------------------------
26const int EUABACKLIT_NONE = 0; // turn off
27const int EUABACKLIT_ON = 1; // permanent ilumination
28const int EUABACKLIT_2 = 2;
29const int EUABACKLIT_3 = 3;
30const int EUABACKLIT_FADEOUT_SLOW = 4; // slow fadeout
31const int EUABACKLIT_FADEOUT_FAST = 5; // fast fadeout
32const int EUABACKLIT_FADEIN_SLOW = 6; // slow in -> then stay on
33const int EUABACKLIT_FADEIN_FAST = 7; // fast in -> then stay on
34
35
36// note: there should be states like:
37//
38//
39// LOADING/ MAIN MENU/ CONNECTING/ KEYBINDING/ OPTIONS - continuous
40// CHARACTER/ CAR/ "HELI"/ SPECTATOR/ INFECTED - continuous BASE
41// SWIMMING/ CRAWLING/ SPRINTING/ FIGHTING/ FLARE/ FLASHLIGHT - continuous CHARACTER
42//
43// DoorOpen/ HitTaken/ CarCrashed/ etc. - event based
44//
45
46
47const int EUAB_OFF = 0; // all off
48
49// logos :: anims
50const int EUAB_LOGO_DAYZ = 10;
51const int EUAB_LOGO_CONNECTING = 11;
52
53// menus :: anims
54const int EUAB_MENU_BROWSER = 20;
55const int EUAB_MENU_MAIN = 21;
56const int EUAB_MENU_KEYBINDING = 22;
57const int EUAB_MENU_OPTIONS = 23;
58
59// car :: basic background colour + overlay + transition anims
60const int EUAB_CAR_OFF = 100; // sitting in car with engine off
61const int EUAB_CAR_ON_NOLIGHTS = 101; // driving w/o lights (day)
62const int EUAB_CAR_ON_LIGHTS = 102; // driving with headlights (night)
63const int EUAB_CAR_STARTING = 103; // short starting animation
64const int EUAB_CAR_ENTER = 104; // entering car
65const int EUAB_CAR_LEAVE = 105; // leaving car
66const int EUAB_CAR_CRASH = 106; // crashed
67
68// character :: basic background colour + overlay + transition anims
69const int EUAB_PLR_WALK = 200;
70const int EUAB_PLR_RUN = 201;
71const int EUAB_PLR_SPRINT = 202;
72const int EUAB_PLR_SWIM = 203;
73const int EUAB_PLR_HITBY = 204;
74const int EUAB_PLR_CONSUME = 205;
75const int EUAB_PLR_CRAFTING = 206;
76const int EUAB_PLR_EMOTE = 207; // playing emote
77const int EUAB_PLR_UNCONSCIOUS = 208;
78const int EUAB_PLR_DEAD = 209;
79
80// modes :: these are set of background colours
81const int EUAB_MODE_NIGHT = 300;
82const int EUAB_MODE_MORNING_BAD = 301;
83const int EUAB_MODE_MORNING_GOOD = 302;
84const int EUAB_MODE_DAY_FOGGY = 303;
85const int EUAB_MODE_DAY_OVERCAST = 304;
86const int EUAB_MODE_DAY_NICE = 305;
87const int EUAB_MODE_EVENING_BAD = 306;
88const int EUAB_MODE_EVENING_GOOD = 307;
89
90const int EUAB_MODE_FLASHLIGHT = 320;
91const int EUAB_MODE_CHEMLIGHT = 321;
92
93
94// overlay types
95const int EUAB_OVERLAY_NONE = 400; // no overlay
96const int EUAB_OVERLAY_CONTROLS = 401; // highlighted controls
97const int EUAB_OVERLAY_STATUS = 402; // numpad + mouse used for health/ blood level visualisation
98const int EUAB_OVERLAY_VON = 403; // VON status
99
100
101//-----------------------------------------------------------------------------
103
105{
106 // private void ~Backlit(); // raist todo: turn lights off there?
107
109
110 void OnInit(DayZGame game)
111 {
112 // enable only on client/ standalone!
113 if (game.IsClient() || !game.IsMultiplayer())
114 m_BacklitActive = true;
115
116 if (m_BacklitActive)
117 Print("... Backlit Effects Enabled");
118 }
119
120 // start infinite loading animation
122 {
123 if (!m_BacklitActive)
124 return; // always return when backlit not present!
125
126 // lighten up your desktop
127 GetUApi().Backlit_KeyByName("kD", EUABLAYER_LOADING, EUABACKLIT_ON, 0xffff0000);
128 GetUApi().Backlit_KeyByName("kA", EUABLAYER_LOADING, EUABACKLIT_ON, 0xffcf0000);
129 GetUApi().Backlit_KeyByName("kY", EUABLAYER_LOADING, EUABACKLIT_ON, 0xffaf0000);
130 GetUApi().Backlit_KeyByName("kZ", EUABLAYER_LOADING, EUABACKLIT_ON, 0xff8f0000);
131 GetUApi().Backlit_Animation("Loading/", 2, 0xffc8c8c8, 0xff080808);
132 GetUApi().Backlit_ForceUpdate();
133 }
134
135 // ...
137 {
138 if (!m_BacklitActive)
139 return; // always return when backlit not present!
140
141 // lighten up your desktop
142 GetUApi().Backlit_Remove(EUABLAYER_ALL);
143 GetUApi().Backlit_Animation("MainMenu/", 2, 0xffff0000, 0xff080000);
144 GetUApi().Backlit_ForceUpdate();
145 }
146
147 // ...
149 {
150 if (!m_BacklitActive)
151 return; // always return when backlit not present!
152
153 GetUApi().Backlit_Remove(EUABLAYER_ALL);
154 GetUApi().Backlit_Background(0, 0xff220000, 0xff222222);
155 }
156
157 // ...
159 {
160 if (!m_BacklitActive)
161 return; // always return when backlit not present!
162
163 GetUApi().Backlit_Remove(EUABLAYER_ALL);
164 GetUApi().Backlit_Background(0, 0xff211202, 0xff110800);
165 }
166
167 // ...
169 {
170 if (!m_BacklitActive)
171 return; // always return when backlit not present!
172
173 // force update player
174 if (GetGame().GetMission().GetHud())
175 {
176 GetUApi().Backlit_Remove(EUABLAYER_ALL);
177 GetUApi().Backlit_Background(0, 0xff220000, 0xff222222);
178
179 UpdatePlayer(true);
180 }
181 }
182
183 // ...
185 {
186 if (!m_BacklitActive)
187 return; // always return when backlit not present!
188
189 // reset queue
190 GetUApi().Backlit_EmptyQueue();
191 // play hit animation
192 GetUApi().Backlit_Animation("Water/", 0, 0xff00ffff, 0xffffffff);
193 }
194
195 // ...
197 {
198 if (!m_BacklitActive)
199 return; // always return when backlit not present!
200
201 if (GetGame().GetMission().GetHud())
202 {
203 // enqueue background
204 GetUApi().Backlit_Background(0, 0xff220000, 0xff222222);
205 // force update player
206 UpdatePlayer(true);
207 }
208 }
209
210 // clear tutorial/ hint keys
212 {
213 if (!m_BacklitActive)
214 return; // always return when backlit not present!
215
216 // remove previous backlit
217 GetUApi().Backlit_Remove(EUABLAYER_HINTKEY);
218 }
219
220 // highlight tutorial/ hint keys
222 {
223 if (!m_BacklitActive)
224 return; // always return when backlit not present!
225
226 action.Backlit_Override(EUABLAYER_HINTKEY, 0xffafafff);
227 }
228
229 // clear keybinding keys
231 {
232 if (!m_BacklitActive)
233 return; // always return when backlit not present!
234
235 GetUApi().Backlit_Remove(EUABLAYER_ALL);
236 }
237
238 // clear keybinding keys
240 {
241 if (!m_BacklitActive)
242 return; // always return when backlit not present!
243
244 GetUApi().Backlit_KeyByHash(keyHash, EUABLAYER_VISKEY, EUABACKLIT_FADEOUT_SLOW, 0xff0000ff);
245 }
246
247
249 {
251
252 int aColor = 0xff1fff1f;
253 int dColor = 0xff001f00;
254
255 if (iLevel > 0)
256 ua_api.Backlit_KeyByName("kF1", EUABLAYER_HUMAN, EUABACKLIT_ON, aColor);
257 else
258 ua_api.Backlit_KeyByName("kF1", EUABLAYER_HUMAN, EUABACKLIT_ON, dColor);
259 if (iLevel > 1)
260 ua_api.Backlit_KeyByName("kF2", EUABLAYER_HUMAN, EUABACKLIT_ON, aColor);
261 else
262 ua_api.Backlit_KeyByName("kF2", EUABLAYER_HUMAN, EUABACKLIT_ON, dColor);
263 if (iLevel > 2)
264 ua_api.Backlit_KeyByName("kF3", EUABLAYER_HUMAN, EUABACKLIT_ON, aColor);
265 else
266 ua_api.Backlit_KeyByName("kF3", EUABLAYER_HUMAN, EUABACKLIT_ON, dColor);
267 if (iLevel > 3)
268 ua_api.Backlit_KeyByName("kF4", EUABLAYER_HUMAN, EUABACKLIT_ON, aColor);
269 else
270 ua_api.Backlit_KeyByName("kF4", EUABLAYER_HUMAN, EUABACKLIT_ON, dColor);
271
272 /* int lc = 0xff001f00;
273 if( iLevel > 0 )
274 lc = 0xff003f00;
275 else if( iLevel > 1 )
276 lc = 0xff007f00;
277 else if( iLevel > 2 )
278 lc = 0xff00af00;
279 else if( iLevel > 3 )
280 lc = 0xff00ff00;
281
282 ua_api.Backlit_KeyByName("mBMiddle",EUABLAYER_HUMAN,EUABACKLIT_ON,lc);*/
283
284 }
285
287 {
289
290 int aColor = 0xffff1f1f;
291 int dColor = 0xff1f0000;
292
293 if (iLevel > 0)
294 ua_api.Backlit_KeyByName("kF5", EUABLAYER_HUMAN, EUABACKLIT_ON, aColor);
295 else
296 ua_api.Backlit_KeyByName("kF5", EUABLAYER_HUMAN, EUABACKLIT_ON, dColor);
297 if (iLevel > 1)
298 ua_api.Backlit_KeyByName("kF6", EUABLAYER_HUMAN, EUABACKLIT_ON, aColor);
299 else
300 ua_api.Backlit_KeyByName("kF6", EUABLAYER_HUMAN, EUABACKLIT_ON, dColor);
301 if (iLevel > 2)
302 ua_api.Backlit_KeyByName("kF7", EUABLAYER_HUMAN, EUABACKLIT_ON, aColor);
303 else
304 ua_api.Backlit_KeyByName("kF7", EUABLAYER_HUMAN, EUABACKLIT_ON, dColor);
305 if (iLevel > 3)
306 ua_api.Backlit_KeyByName("kF8", EUABLAYER_HUMAN, EUABACKLIT_ON, aColor);
307 else
308 ua_api.Backlit_KeyByName("kF8", EUABLAYER_HUMAN, EUABACKLIT_ON, dColor);
309
310 /* int lc = 0xff1f0000;
311 if( iLevel > 0 )
312 lc = 0xff3f0000;
313 else if( iLevel > 1 )
314 lc = 0xff7f0000;
315 else if( iLevel > 2 )
316 lc = 0xffaf0000;
317 else if( iLevel > 3 )
318 lc = iLevel;
319
320 ua_api.Backlit_KeyByName("mBRight",EUABLAYER_HUMAN,EUABACKLIT_ON,lc);*/
321
322 }
323
326
327 int m_HealthNew = 0;
328 int m_BloodNew = 0;
329
330 void SetHealth(float fHealth) // range 0 .. 100
331 {
332 float health = fHealth * 0.01; // div 100
333 m_HealthNew = health * 4; // 4 stages
334 }
335
336 void SetBlood(float fBlood) // range 0 .. 5000
337 {
338 float blood = fBlood * 0.0002; // div 5000
339 m_BloodNew = blood * 4; // 4 stages
340 }
341
343 {
344 if (!m_BacklitActive)
345 return; // always return when backlit not present!
346
347 // force update
348 if (bForce)
349 {
350 m_HealthBefore = -1;
351 m_BloodBefore = -1;
352 }
353
354 // do not update
356 return;
357
358 // remove previous layers
359 GetUApi().Backlit_Remove(EUABLAYER_ALL);
360
361 // set keys to layer CUSTOM
362 GetUApi().Backlit_KeyByName("kW", EUABLAYER_CUSTOM, EUABACKLIT_ON, 0xff0000ff);
363 GetUApi().Backlit_KeyByName("kA", EUABLAYER_CUSTOM, EUABACKLIT_ON, 0xff0000cf);
364 GetUApi().Backlit_KeyByName("kS", EUABLAYER_CUSTOM, EUABACKLIT_ON, 0xff0000af);
365 GetUApi().Backlit_KeyByName("kD", EUABLAYER_CUSTOM, EUABACKLIT_ON, 0xff00008f);
366
367 GetUApi().Backlit_KeyByName("kX", EUABLAYER_CUSTOM, EUABACKLIT_ON, 0xff3f3f3f);
368 GetUApi().Backlit_KeyByName("kC", EUABLAYER_CUSTOM, EUABACKLIT_ON, 0xff3f3f3f);
369
370 GetUApi().Backlit_KeyByName("kQ", EUABLAYER_CUSTOM, EUABACKLIT_ON, 0xff7f7f0f);
371 GetUApi().Backlit_KeyByName("kE", EUABLAYER_CUSTOM, EUABACKLIT_ON, 0xff7f7f0f);
372
373 // health
375 // blood
377
378 // animation
379 GetUApi().Backlit_Background(0, 0xff220000, 0xff222222);
380
381 // save level
384 }
385
386
388 bool m_CELBefore = false;
389
391 {
392 if (!m_BacklitActive)
393 return; // always return when backlit not present!
394
396
397 if (m_GearBefore != iGear)
398 {
400
401 int activeColor = 0xff3fff3f;
402 int dimmColor = 0xff0f3f0f;
403
404 if (iGear == CarGear.REVERSE)
405 ua_api.Backlit_KeyByName("kR", EUABLAYER_CAR, EUABACKLIT_ON, activeColor);
406 else
407 ua_api.Backlit_KeyByName("kR", EUABLAYER_CAR, EUABACKLIT_ON, dimmColor);
408
409 if (iGear == CarGear.NEUTRAL)
410 ua_api.Backlit_KeyByName("kN", EUABLAYER_CAR, EUABACKLIT_ON, activeColor);
411 else
412 ua_api.Backlit_KeyByName("kN", EUABLAYER_CAR, EUABACKLIT_ON, dimmColor);
413
414 if (iGear == CarGear.FIRST)
415 ua_api.Backlit_KeyByName("k1", EUABLAYER_CAR, EUABACKLIT_ON, activeColor);
416 else
417 ua_api.Backlit_KeyByName("k1", EUABLAYER_CAR, EUABACKLIT_ON, dimmColor);
418
419 if (iGear == CarGear.SECOND)
420 ua_api.Backlit_KeyByName("k2", EUABLAYER_CAR, EUABACKLIT_ON, activeColor);
421 else
422 ua_api.Backlit_KeyByName("k2", EUABLAYER_CAR, EUABACKLIT_ON, dimmColor);
423
424 if (iGear == CarGear.THIRD)
425 ua_api.Backlit_KeyByName("k3", EUABLAYER_CAR, EUABACKLIT_ON, activeColor);
426 else
427 ua_api.Backlit_KeyByName("k3", EUABLAYER_CAR, EUABACKLIT_ON, dimmColor);
428
429 if (iGear == CarGear.FOURTH)
430 ua_api.Backlit_KeyByName("k4", EUABLAYER_CAR, EUABACKLIT_ON, activeColor);
431 else
432 ua_api.Backlit_KeyByName("k4", EUABLAYER_CAR, EUABACKLIT_ON, dimmColor);
433
434 if (iGear == CarGear.FIFTH)
435 ua_api.Backlit_KeyByName("k5", EUABLAYER_CAR, EUABACKLIT_ON, activeColor);
436 else
437 ua_api.Backlit_KeyByName("k5", EUABLAYER_CAR, EUABACKLIT_ON, dimmColor);
438
439 }
440
441 if (bCEL != m_CELBefore)
442 {
444
445 if (bCEL)
446 ua_api.Backlit_KeyByName("kC", EUABLAYER_CAR, EUABACKLIT_ON, 0xffff0f0f);
447 else
448 ua_api.Backlit_KeyByName("kC", EUABLAYER_CAR, EUABACKLIT_NONE, 0xff000000);
449 }
450
451 }
452
453};
454
const int EUAB_PLR_DEAD
Definition Backlit.c:78
const int EUABLAYER_CUSTOM
Definition Backlit.c:19
const int EUABACKLIT_NONE
Input backlit type.
Definition Backlit.c:26
const int EUABLAYER_6
Definition Backlit.c:18
const int EUABACKLIT_3
Definition Backlit.c:29
const int EUAB_MODE_DAY_OVERCAST
Definition Backlit.c:85
const int EUAB_MENU_BROWSER
Definition Backlit.c:54
const int EUAB_PLR_HITBY
Definition Backlit.c:73
const int EUAB_MODE_DAY_NICE
Definition Backlit.c:86
const int EUABLAYER_HUMAN
Definition Backlit.c:17
const int EUABLAYER_VISKEY
Definition Backlit.c:14
const int EUAB_PLR_CONSUME
Definition Backlit.c:74
const int EUAB_MODE_EVENING_GOOD
Definition Backlit.c:88
const int EUAB_PLR_SPRINT
Definition Backlit.c:71
const int EUAB_OVERLAY_STATUS
Definition Backlit.c:97
const int EUAB_CAR_OFF
Definition Backlit.c:60
const int EUABLAYER_CAR
Definition Backlit.c:16
const int EUAB_MODE_NIGHT
Definition Backlit.c:81
const int EUAB_CAR_ON_LIGHTS
Definition Backlit.c:62
const int EUABACKLIT_FADEOUT_SLOW
Definition Backlit.c:30
const int EUAB_CAR_CRASH
Definition Backlit.c:66
const int EUAB_OFF
Definition Backlit.c:47
const int EUAB_MODE_CHEMLIGHT
Definition Backlit.c:91
const int EUAB_OVERLAY_CONTROLS
Definition Backlit.c:96
const int EUAB_PLR_UNCONSCIOUS
Definition Backlit.c:77
const int EUABACKLIT_FADEOUT_FAST
Definition Backlit.c:31
const int EUABLAYER_MENU
Definition Backlit.c:21
const int EUABLAYER_LOADING
Definition Backlit.c:20
const int EUAB_MODE_FLASHLIGHT
Definition Backlit.c:90
const int EUAB_PLR_RUN
Definition Backlit.c:70
const int EUAB_MENU_KEYBINDING
Definition Backlit.c:56
const int EUAB_PLR_EMOTE
Definition Backlit.c:76
const int EUAB_MODE_MORNING_GOOD
Definition Backlit.c:83
const int EUAB_MODE_DAY_FOGGY
Definition Backlit.c:84
const int EUAB_PLR_CRAFTING
Definition Backlit.c:75
const int EUAB_PLR_WALK
Definition Backlit.c:69
const int EUAB_CAR_ENTER
Definition Backlit.c:64
const int EUAB_CAR_ON_NOLIGHTS
Definition Backlit.c:61
const int EUAB_MENU_MAIN
Definition Backlit.c:55
const int EUABACKLIT_FADEIN_SLOW
Definition Backlit.c:32
const int EUABACKLIT_ON
Definition Backlit.c:27
const int EUAB_LOGO_DAYZ
Definition Backlit.c:50
const int EUABLAYER_ALL
Input layer type.
Definition Backlit.c:12
const int EUABLAYER_3
Definition Backlit.c:15
const int EUAB_CAR_LEAVE
Definition Backlit.c:65
const int EUAB_MENU_OPTIONS
Definition Backlit.c:57
const int EUAB_MODE_EVENING_BAD
Definition Backlit.c:87
const int EUAB_MODE_MORNING_BAD
Definition Backlit.c:82
const int EUABACKLIT_2
Definition Backlit.c:28
const int EUAB_OVERLAY_VON
Definition Backlit.c:98
const int EUABACKLIT_FADEIN_FAST
Definition Backlit.c:33
const int EUAB_PLR_SWIM
Definition Backlit.c:72
const int EUAB_LOGO_CONNECTING
Definition Backlit.c:51
const int EUABLAYER_HINTKEY
Definition Backlit.c:13
const int EUAB_OVERLAY_NONE
Definition Backlit.c:95
const int EUAB_CAR_STARTING
Definition Backlit.c:63
proto native UAInputAPI GetUApi()
Backlit effect class.
Definition Backlit.c:105
void SetBlood(float fBlood)
Definition Backlit.c:336
void KeybindingShow(int keyHash)
Definition Backlit.c:239
void OnSwimmingStart()
Definition Backlit.c:184
void KeybindingClear()
Definition Backlit.c:230
void UpdatePlayer(bool bForce)
Definition Backlit.c:342
void OnEnterCar()
Definition Backlit.c:158
int m_HealthBefore
Definition Backlit.c:324
void MainMenu_OnHide()
Definition Backlit.c:148
void OnSwimmingStop()
Definition Backlit.c:196
void OnInit(DayZGame game)
Definition Backlit.c:110
void LoadingAnim()
Definition Backlit.c:121
void HintShow(UAInput action)
Definition Backlit.c:221
void OnLeaveCar()
Definition Backlit.c:168
void VisualiseBlood(int iLevel)
Definition Backlit.c:286
bool m_BacklitActive
Definition Backlit.c:108
int m_HealthNew
Definition Backlit.c:327
void MainMenu_OnShow()
Definition Backlit.c:136
void SetHealth(float fHealth)
Definition Backlit.c:330
int m_BloodBefore
Definition Backlit.c:325
bool m_CELBefore
Definition Backlit.c:388
void VisualiseHealth(int iLevel)
Definition Backlit.c:248
void RefreshVehicleLayout(int iGear, bool bCEL)
Definition Backlit.c:390
int m_BloodNew
Definition Backlit.c:328
void HintClear()
Definition Backlit.c:211
int m_GearBefore
Definition Backlit.c:387
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.