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