Advertisement
Guest User

Untitled

a guest
Aug 19th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.81 KB | None | 0 0
  1. /*
  2. ===============
  3. idPlayer::DrawHUD
  4. ===============
  5. */
  6. void idPlayer::DrawHUD( idUserInterface *_hud ) {
  7.  
  8. // Draw the cinematic hud when in a cinematic
  9. if ( IsInCinematic() && gameLocal.GetCamera( ) ) {
  10. if ( cinematicHud && !(gameLocal.editors & EDITOR_MODVIEW) ) {
  11. cinematicHud->Redraw( gameLocal.time );
  12. }
  13. return;
  14. }
  15.  
  16. if ( screenshotmode ) {
  17. return;
  18. }
  19.  
  20. /*
  21. idUserInterface * hud = idPlayer::hud;
  22. idUserInterface * mphud = idPlayer::mphud;
  23. idUserInterface * cursor = idPlayer::cursor;
  24. */
  25.  
  26. idPlayer* player;
  27.  
  28. if ( team != gameLocal.GetLocalPlayer()->hudTeam && _hud ) {
  29. _hud->HandleNamedEvent( (team ? "setTeam_strogg" : "setTeam_marine") );
  30. gameLocal.GetLocalPlayer()->hudTeam = team;
  31. }
  32.  
  33. if ( !gameLocal.GetLocalPlayer() ) {
  34. // server netdemo
  35. if ( gameLocal.GetDemoState() == DEMO_PLAYING && gameLocal.IsServerDemoPlaying() && gameLocal.GetDemoFollowClient() == entityNumber ) {
  36. _hud = gameLocal.GetDemoHud();
  37. mphud = gameLocal.GetDemoMphud();
  38. cursor = gameLocal.GetDemoCursor();
  39. }
  40.  
  41. } else if ( IsLocalSpectator( spectator ) ) {
  42.  
  43. idPlayer *p = gameLocal.GetLocalPlayer();
  44. if ( p && p->spectating && p->spectator == entityNumber ) {
  45. _hud = p->hud;
  46. mphud = p->mphud;
  47. cursor = p->GetCursorGUI();
  48. }
  49.  
  50.  
  51. //if ( gameLocal.entities[ spectator ] ) {
  52. /*
  53. player = static_cast< idPlayer * >( gameLocal.entities[ spectator ] );
  54. if ( player ) {
  55. //idPlayer *p = gameLocal.GetLocalPlayer();
  56. assert( player->hud && player->mphud );
  57. _hud = player->hud;
  58. mphud = player->mphud;
  59. cursor = player->GetCursorGUI();
  60.  
  61. if ( player->team != gameLocal.GetLocalPlayer()->hudTeam && hud ) {
  62. hud->HandleNamedEvent( (player->team ? "setTeam_strogg" : "setTeam_marine") );
  63. gameLocal.GetLocalPlayer()->hudTeam = player->team;
  64. }
  65.  
  66. }
  67. */
  68.  
  69. }
  70.  
  71. /*
  72. if ( winnerCam && g_showNamesMP.GetBool() ) {
  73.  
  74. for( int i = 0; i < MAX_GENTITIES; i++ ) {
  75. idEntity *ent = gameLocal.entities[ i ];
  76. if ( !ent || !ent->IsType( idPlayer::GetClassType() ) || !gameLocal.InPlayerPVS( ent ) ) {
  77. continue;
  78. }
  79.  
  80. //winnerCam->GetPVSAreas()
  81. //!gameLocal.InPlayerPVS( player ) ||
  82. //!gameLocal.InPlayerPVS( ent ) ||
  83. idPlayer* player = static_cast< idPlayer* >(ent);
  84. if ( !gameLocal.mpGame.GetPlayerState( player->entityNumber ).ingame || player->health <= 0 || !player->head.IsValid() || player->spectating || player->IsHidden() ) {
  85. continue;
  86. }
  87.  
  88. gameRenderWorld->DrawText( gameLocal.userInfo[ player->entityNumber ].GetString( "ui_name" ), player->GetHead()->GetPhysics()->GetOrigin() + idVec3( 0.0f, 0.0f, 30.0f ), 0.2f, colorWhite, winnerCam->GetRenderView()->viewaxis, 1 );
  89.  
  90. }
  91.  
  92. }
  93. */
  94.  
  95. if ( _hud ) {
  96. _hud->SetStateBool( "systemTimeShow", g_showSystemClock.GetBool() );
  97. _hud->SetStateString( "systemTime", gameLocal.GetSystemTime() );
  98. }
  99.  
  100. if ( gameLocal.isMultiplayer && arenaCam && ( winnerCam || spectating || pfl.dead && pm_thirdPersonDeath.GetBool() ) ) {
  101.  
  102. //update frag/team winner name
  103. if ( winningEnt && winningEnt.IsValid() ) {
  104.  
  105. bool showName = true;
  106.  
  107. if ( winningEnt.GetEntityNum() == entityNumber && spectating ) {
  108. showName = false;
  109. }
  110.  
  111. if ( gameLocal.IsTeamGame() ) {
  112.  
  113. arenaCam->SetStateString( "viewWinnerTitle", common->GetLocalizedString( "#str_108082" ) );
  114.  
  115. if ( winningTeam != TEAM_NONE ) {
  116. arenaCam->SetStateString( "viewWinnerTeamName", gameLocal.GetTeamName( winningTeam ) );
  117. } else if ( winningTeam == TEAM_NONE ) {
  118. arenaCam->SetStateString( "viewWinnerTeamName", common->GetLocalizedString( "#str_108087" ) );
  119. }
  120.  
  121. arenaCam->HandleNamedEvent( "viewTeamLeader" );
  122.  
  123. } else if ( !gameLocal.IsTeamGame() && !gameLocal.IsDuelGameType() && showName ) {
  124.  
  125. arenaCam->SetStateString( "viewWinnerTitle", common->GetLocalizedString( "#str_108081" ) );
  126.  
  127. player = winningEnt->GetStaticPlayer();
  128. arenaCam->SetStateString( "viewWinnerName", player->GetUserInfo()->GetString( "ui_name" ) );
  129. arenaCam->HandleNamedEvent( "viewFragLeader" );
  130.  
  131. } else if ( gameLocal.IsDuelGameType() && showName ) {
  132.  
  133. player = winningEnt->GetStaticPlayer();
  134.  
  135. if ( !gameLocal.mpGame.ConcededWin( entityNumber ) ) {
  136. arenaCam->SetStateString( "viewWinnerTitle", common->GetLocalizedString( "#str_108092" ) );
  137. } else if ( gameLocal.mpGame.ConcededWin( entityNumber ) ) {
  138. arenaCam->SetStateString( "viewWinnerTitle", common->GetLocalizedString( "#str_108093" ) );
  139. }
  140.  
  141. arenaCam->SetStateString( "viewWinnerName", player->GetUserInfo()->GetString( "ui_name" ) );
  142. arenaCam->HandleNamedEvent( "viewDuelLeader" );
  143.  
  144. }
  145.  
  146. arenaCam->HandleNamedEvent( "nextGameBegins" );
  147. arenaCam->SetStateString( "gamebegins", va( common->GetLocalizedString( "#str_108058" ), Max( (( gameLocal.mpGame.GetGameState()->GetNextMPGameStateTime() - gameLocal.time) / 1000) + 1, 0 ) ) );
  148.  
  149. }
  150.  
  151. //add smash effect material
  152. if ( ( pfl.dead && pm_thirdPersonDeath.GetBool() || spectating ) && gameLocal.GetLocalPlayer() ) {
  153.  
  154. if ( ( g_spectateHudfx.GetInteger() >= 1 && g_spectateHudfx.GetInteger() <= 2 ) && !pfl.arenaCam ) {
  155.  
  156. pfl.arenaCam = true;
  157.  
  158. arenaCam->SetStateInt( "showline", GetLimitRandomInt( 0, 1 ) );
  159. arenaCam->SetStateInt( "showstatic3", GetLimitRandomInt( 0, 1 ) );
  160. arenaCam->SetStateInt( "showstatic2", GetLimitRandomInt( 0, 1 ) );
  161. arenaCam->SetStateInt( "showstatic1", GetLimitRandomInt( 0, 1 ) );
  162. arenaCam->SetStateInt( "showtopreflect", GetLimitRandomInt( 0, 1 ) );
  163. arenaCam->SetStateInt( "showbroken_glass", false );
  164.  
  165. if ( gameLocal.IsMPGameState( GAMEON ) && pfl.dead && !spectating && g_spectateHudfx.GetInteger() == 2 && GetLimitRandomInt( 0, 6 ) == 4 ) {
  166. arenaCam->SetStateInt( "showbroken_glass", true );
  167. }
  168.  
  169. }
  170.  
  171. }
  172.  
  173. arenaCam->Redraw( gameLocal.realClientTime );
  174.  
  175. if ( winnerCam || pfl.dead ) {
  176. return;
  177. }
  178.  
  179. }
  180.  
  181. if ( !_hud || disableHud || influenceActive != INFLUENCE_NONE || privateCameraView || !g_showHud.GetBool() ) {
  182. return;
  183. }
  184.  
  185. if ( pfl.attackerDeathView ) {
  186.  
  187. aiVisionhud->Redraw( gameLocal.realClientTime );
  188.  
  189. } else if ( IsGuidingProjectile() ) {
  190.  
  191. guidedProjectilehud = uiManager->FindGui( GetGuideEnt()->spawnArgs.GetString( "guidehud" ), true, false, true );
  192.  
  193. if ( guidedProjectilehud ) {
  194. guidedProjectilehud->SetStateString ( "guiderange", va( "%s %i [%i]", common->GetLocalizedString( "#str_108096" ), (int)guiderange, GetGuideEnt()->spawnArgs.GetInt( "guideRange" ) ) );
  195. guidedProjectilehud->Redraw( gameLocal.realClientTime );
  196. }
  197.  
  198. } else if ( GetDriverHud() ) {
  199.  
  200. _hud = GetDriverHud();
  201.  
  202. // Boss bar
  203. if ( _hud && _hud->State().GetInt( "boss_health", "-1" ) != (bossEnemy ? bossEnemy->health : -1) ) {
  204.  
  205. if ( !bossEnemy || bossEnemy->health <= 0 ) {
  206. bossEnemy = NULL;
  207. _hud->SetStateInt( "boss_health", -1 );
  208. _hud->HandleNamedEvent( "hideBossBar" );
  209. _hud->HandleNamedEvent( "hideBossShieldBar" ); // grrr, for boss buddy..but maybe other bosses will have shields?
  210. } else {
  211. _hud->SetStateInt( "boss_health", bossEnemy->health );
  212. _hud->HandleNamedEvent( "updateBossBar" );
  213. }
  214.  
  215. }
  216.  
  217. if ( cursor ) {
  218. cursor->SetStateBool( "vehiclecursor", false );
  219. }
  220.  
  221. if ( !gameDebug.IsHudActive( DBGHUD_ANY ) ) {
  222.  
  223. if ( cursor && health > 0 ) {
  224. // mekberg: adjustable crosshair size.
  225. int crossSize = cvarSystem->GetCVarInteger( "g_crosshairSize" );
  226. crossSize = crossSize - crossSize % 8;
  227. cvarSystem->SetCVarInteger( "g_crosshairSize", crossSize );
  228. cursor->SetStateInt( "g_crosshairSize", crossSize );
  229.  
  230. vehicleController.UpdateCursorGUI( cursor );
  231. cursor->Redraw( gameLocal.realClientTime );
  232. }
  233.  
  234. vehicleController.DrawHUD( );
  235. }
  236.  
  237. } else if ( objectiveSystemOpen && IsLocalClient() ) {
  238.  
  239. if ( !GuiActive() ) {
  240. // showing weapon zoom gui when objectives are open because that's the way I'z told to make it werkz
  241. if ( HasWeapon() && weapon->GetZoomGui( ) && IsZoomed() ) {
  242. weapon->GetZoomGui( )->Redraw( gameLocal.realClientTime );
  243. }
  244. }
  245.  
  246. } else {
  247.  
  248. // FIXME: this is temp to allow the sound meter to show up in the hud
  249. // it should be commented out before shipping but the code can remain
  250. // for mod developers to enable for the same functionality
  251. if ( _hud ) {
  252. _hud->SetStateBool( "weaponEnabled", weaponEnabled );
  253. _hud->SetStateBool( "mp", gameLocal.isMultiplayer );
  254. _hud->SetStateInt( "s_debug", cvarSystem->GetCVarInteger( "s_showLevelMeter" ) );
  255.  
  256. if ( team != gameLocal.GetLocalPlayer()->hudTeam ) {
  257. for( int i = 0; i < TEAM_MAX; i++ ) {
  258. if ( team != i ) {
  259. continue;
  260. }
  261. _hud->HandleNamedEvent( va( "setTeam_%d", i ) );
  262. }
  263. gameLocal.GetLocalPlayer()->hudTeam = team;
  264. }
  265. }
  266.  
  267. if ( g_showZoomHud.GetBool() && HasWeapon() && weapon->GetZoomGui() && IsZoomed() ) {
  268. weapon->GetZoomGui( )->Redraw( gameLocal.realClientTime );
  269. }
  270.  
  271. // don't draw main hud in spectator (only mphud)
  272. if ( !spectating && !gameDebug.IsHudActive( DBGHUD_ANY ) ) {
  273.  
  274. // weapon targeting crosshair
  275. if ( !GuiActive() ) {
  276.  
  277. if ( cursor && health > 0 ) {
  278. // Pass the current weapon to the cursor gui for custom crosshairs
  279. // mekberg: adjustable crosshair size.
  280. int crossSize = cvarSystem->GetCVarInteger( "g_crosshairSize" );
  281. crossSize = crossSize - crossSize % 8;
  282. cvarSystem->SetCVarInteger( "g_crosshairSize", crossSize );
  283. cursor->SetStateInt( "g_crosshairSize", crossSize );
  284. cursor->Redraw( gameLocal.realClientTime );
  285. }
  286. }
  287.  
  288. if ( focusBrackets ) {
  289. // If 2d_calc is still true then the gui didnt render so we can abandon it
  290. if ( focusBrackets->State().GetBool( "2d_calc" ) ) {
  291. focusBrackets->SetStateBool( "2d_calc", false );
  292. focusBrackets = NULL;
  293. focusBracketsTime = 0;
  294. _hud->HandleNamedEvent( "hideBrackets" );
  295. } else {
  296. _hud->SetStateString( "bracket_left", focusBrackets->State().GetString( "2d_min_x" ) );
  297. _hud->SetStateString( "bracket_top", focusBrackets->State().GetString( "2d_min_y" ) );
  298. _hud->SetStateFloat( "bracket_width", focusBrackets->State().GetFloat( "2d_max_x" ) - focusBrackets->State().GetFloat( "2d_min_x" ) );
  299. _hud->SetStateFloat( "bracket_height", focusBrackets->State().GetFloat( "2d_max_y" ) - focusBrackets->State().GetFloat( "2d_min_y" ) );
  300. // TODO: Find a way to get bracket text from gui to hud
  301. }
  302. }
  303.  
  304. //draw
  305. UpdateHud( _hud );
  306. }
  307.  
  308. }
  309.  
  310. UpdatePauseHud();
  311.  
  312. if ( gameLocal.isMultiplayer ) {
  313.  
  314. if ( mphud ) {
  315. gameLocal.mpGame.UpdateHud( mphud );
  316. mphud->Redraw( gameLocal.realClientTime );
  317. }
  318.  
  319. if ( overlayHud && overlayHudTime > gameLocal.time && overlayHudTime != 0 ) {
  320. overlayHud->Redraw( gameLocal.realClientTime );
  321. } else {
  322. overlayHud = NULL;
  323. overlayHudTime = 0;
  324. }
  325.  
  326. }
  327.  
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement