Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.98 KB | None | 0 0
  1. /*
  2. ===============
  3. idPlayer::DrawHUD
  4. ===============
  5. */
  6. void idPlayer::DrawHUD( idUserInterface *_hud ) {
  7. idUserInterface * cursor = idPlayer::cursor;
  8.  
  9. if ( !gameLocal.GetLocalPlayer() ) {
  10. // server netdemo
  11. if ( gameLocal.GetDemoState() == DEMO_PLAYING && gameLocal.IsServerDemo() && gameLocal.GetDemoFollowClient() == entityNumber ) {
  12. cursor = gameLocal.GetDemoCursor();
  13. if ( cursor ) {
  14. cursor->HandleNamedEvent( "showCrossCombat" );
  15. }
  16. }
  17. } else {
  18.  
  19. if ( team != gameLocal.GetLocalPlayer()->hudTeam && _hud ) {
  20. _hud->HandleNamedEvent( (team ? "setTeam_strogg" : "setTeam_marine") );
  21. gameLocal.GetLocalPlayer()->hudTeam = team;
  22. }
  23.  
  24. // if updating the hud of a followed client
  25. idPlayer *p = gameLocal.GetLocalPlayer();
  26. if ( p->spectating && p->spectator == entityNumber ) {
  27. cursor = p->GetCursorGUI();
  28. if ( cursor ) {
  29. cursor->HandleNamedEvent( "showCrossCombat" );
  30. }
  31. }
  32. }
  33.  
  34. if ( disableHud || influenceActive != INFLUENCE_NONE || privateCameraView || !_hud || !g_showHud.GetBool() ) {
  35. return;
  36. }
  37.  
  38. if ( objectiveSystemOpen ) {
  39. if ( !GuiActive() ) {
  40. // showing weapon zoom gui when objectives are open because that's the way I'z told to make it werkz
  41. if ( weapon && weapon->GetZoomGui( ) && zoomed ) {
  42. weapon->GetZoomGui( )->Redraw( gameLocal.time );
  43. }
  44. }
  45. return;
  46. }
  47.  
  48. if ( gameLocal.isMultiplayer ) {
  49. _hud->SetStateBool( "mp", true );
  50. } else {
  51. _hud->SetStateBool( "mp", false );
  52. }
  53.  
  54. // Draw the cinematic hud when in a cinematic
  55. if ( gameLocal.GetCamera( ) ) {
  56. if ( cinematicHud && !(gameLocal.editors & EDITOR_MODVIEW) ) {
  57. cinematicHud->Redraw( gameLocal.time );
  58. }
  59. return;
  60. }
  61.  
  62. // Let the vehicle draw the hud instead
  63. if ( vehicleController.IsDriving( ) ) {
  64. if ( !gameDebug.IsHudActive( DBGHUD_ANY ) ) {
  65. vehicleController.DrawHUD( );
  66. if ( cursor && health > 0 ) {
  67. // mekberg: adjustable crosshair size.
  68. int crossSize = cvarSystem->GetCVarInteger( "g_crosshairSize" );
  69. crossSize = crossSize - crossSize % 8;
  70. cvarSystem->SetCVarInteger( "g_crosshairSize", crossSize );
  71. cursor->SetStateInt( "g_crosshairSize", crossSize );
  72. cursor->SetStateBool( "vehiclecursor", true );
  73.  
  74. vehicleController.UpdateCursorGUI( cursor );
  75. cursor->Redraw( gameLocal.time );
  76. }
  77. }
  78. _hud = GetHud();
  79. // Boss bar
  80. if ( _hud && _hud->State().GetInt( "boss_health", "-1" ) != (bossEnemy ? bossEnemy->health : -1) ) {
  81. if ( !bossEnemy || bossEnemy->health <= 0 ) {
  82. bossEnemy = NULL;
  83. _hud->SetStateInt( "boss_health", -1 );
  84. _hud->HandleNamedEvent( "hideBossBar" );
  85. _hud->HandleNamedEvent( "hideBossShieldBar" ); // grrr, for boss buddy..but maybe other bosses will have shields?
  86. } else {
  87. _hud->SetStateInt( "boss_health", bossEnemy->health );
  88. _hud->HandleNamedEvent( "updateBossBar" );
  89. }
  90. }
  91. return;
  92. }
  93.  
  94. if ( cursor ) {
  95. cursor->SetStateBool( "vehiclecursor", false );
  96. }
  97.  
  98. // FIXME: this is temp to allow the sound meter to show up in the hud
  99. // it should be commented out before shipping but the code can remain
  100. // for mod developers to enable for the same functionality
  101. _hud->SetStateInt( "s_debug", cvarSystem->GetCVarInteger( "s_showLevelMeter" ) );
  102.  
  103. // don't draw main hud in spectator (only mphud)
  104. if ( !spectating && !gameDebug.IsHudActive( DBGHUD_ANY ) ) {
  105. // weapon targeting crosshair
  106. if ( !GuiActive() ) {
  107. if ( weapon && weapon->GetZoomGui( ) && zoomed ) {
  108. weapon->GetZoomGui( )->Redraw( gameLocal.time );
  109. }
  110. // RAVEN BEGIN
  111. // mekberg: removed check for weapon->ShowCrosshair.
  112. // we want to show the crosshair regardless for NPC tags
  113. if ( cursor && health > 0 ) {
  114. // Pass the current weapon to the cursor gui for custom crosshairs
  115. // mekberg: adjustable crosshair size.
  116. int crossSize = cvarSystem->GetCVarInteger( "g_crosshairSize" );
  117. crossSize = crossSize - crossSize % 8;
  118. cvarSystem->SetCVarInteger( "g_crosshairSize", crossSize );
  119. cursor->SetStateInt( "g_crosshairSize", crossSize );
  120. // RAVEN END
  121. cursor->Redraw( gameLocal.time );
  122. }
  123. }
  124.  
  125. UpdateHudStats( _hud );
  126.  
  127. if ( focusBrackets ) {
  128. // If 2d_calc is still true then the gui didnt render so we can abandon it
  129. if ( focusBrackets->State().GetBool( "2d_calc" ) ) {
  130. focusBrackets->SetStateBool( "2d_calc", false );
  131. focusBrackets = NULL;
  132. focusBracketsTime = 0;
  133. _hud->HandleNamedEvent( "hideBrackets" );
  134. } else {
  135. _hud->SetStateString( "bracket_left", focusBrackets->State().GetString( "2d_min_x" ) );
  136. _hud->SetStateString( "bracket_top", focusBrackets->State().GetString( "2d_min_y" ) );
  137. _hud->SetStateFloat( "bracket_width", focusBrackets->State().GetFloat( "2d_max_x" ) - focusBrackets->State().GetFloat( "2d_min_x" ) );
  138. _hud->SetStateFloat( "bracket_height", focusBrackets->State().GetFloat( "2d_max_y" ) - focusBrackets->State().GetFloat( "2d_min_y" ) );
  139. // TODO: Find a way to get bracket text from gui to hud
  140. }
  141. }
  142. _hud->Redraw( gameLocal.realClientTime );
  143. }
  144.  
  145. if ( gameLocal.isMultiplayer ) {
  146. idUserInterface* _mphud = mphud;
  147. // server netdemos don't have a local player, grab the right mphud
  148. if ( !gameLocal.GetLocalPlayer() ) {
  149. assert( gameLocal.GetDemoState() == DEMO_PLAYING && gameLocal.IsServerDemo() );
  150. assert( gameLocal.GetDemoFollowClient() >= 0 );
  151. assert( gameLocal.entities[ gameLocal.GetDemoFollowClient() ] && gameLocal.entities[ gameLocal.GetDemoFollowClient() ]->IsType( idPlayer::GetClassType() ) );
  152. _mphud = gameLocal.GetDemoMphud();
  153. } else if ( gameLocal.GetLocalPlayer() != this ) {
  154. // if we're spectating someone else, use our local hud
  155. _mphud = gameLocal.GetLocalPlayer()->mphud;
  156. }
  157. if ( _mphud ) {
  158. gameLocal.mpGame.UpdateHud( _mphud );
  159. _mphud->Redraw( gameLocal.time );
  160. }
  161.  
  162. if ( overlayHud && overlayHudTime > gameLocal.time && overlayHudTime != 0 ) {
  163. overlayHud->Redraw( gameLocal.time );
  164. } else {
  165. overlayHud = NULL;
  166. overlayHudTime = 0;
  167. }
  168. }
  169. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement