Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ===============
- idPlayer::DrawHUD
- ===============
- */
- void idPlayer::DrawHUD( idUserInterface *_hud ) {
- // Draw the cinematic hud when in a cinematic
- if ( IsInCinematic() && gameLocal.GetCamera( ) ) {
- if ( cinematicHud && !(gameLocal.editors & EDITOR_MODVIEW) ) {
- cinematicHud->Redraw( gameLocal.time );
- }
- return;
- }
- if ( screenshotmode ) {
- return;
- }
- /*
- idUserInterface * hud = idPlayer::hud;
- idUserInterface * mphud = idPlayer::mphud;
- idUserInterface * cursor = idPlayer::cursor;
- */
- idPlayer* player;
- if ( team != gameLocal.GetLocalPlayer()->hudTeam && _hud ) {
- _hud->HandleNamedEvent( (team ? "setTeam_strogg" : "setTeam_marine") );
- gameLocal.GetLocalPlayer()->hudTeam = team;
- }
- if ( !gameLocal.GetLocalPlayer() ) {
- // server netdemo
- if ( gameLocal.GetDemoState() == DEMO_PLAYING && gameLocal.IsServerDemoPlaying() && gameLocal.GetDemoFollowClient() == entityNumber ) {
- _hud = gameLocal.GetDemoHud();
- mphud = gameLocal.GetDemoMphud();
- cursor = gameLocal.GetDemoCursor();
- }
- } else if ( IsLocalSpectator( spectator ) ) {
- idPlayer *p = gameLocal.GetLocalPlayer();
- if ( p && p->spectating && p->spectator == entityNumber ) {
- _hud = p->hud;
- mphud = p->mphud;
- cursor = p->GetCursorGUI();
- }
- //if ( gameLocal.entities[ spectator ] ) {
- /*
- player = static_cast< idPlayer * >( gameLocal.entities[ spectator ] );
- if ( player ) {
- //idPlayer *p = gameLocal.GetLocalPlayer();
- assert( player->hud && player->mphud );
- _hud = player->hud;
- mphud = player->mphud;
- cursor = player->GetCursorGUI();
- if ( player->team != gameLocal.GetLocalPlayer()->hudTeam && hud ) {
- hud->HandleNamedEvent( (player->team ? "setTeam_strogg" : "setTeam_marine") );
- gameLocal.GetLocalPlayer()->hudTeam = player->team;
- }
- }
- */
- }
- /*
- if ( winnerCam && g_showNamesMP.GetBool() ) {
- for( int i = 0; i < MAX_GENTITIES; i++ ) {
- idEntity *ent = gameLocal.entities[ i ];
- if ( !ent || !ent->IsType( idPlayer::GetClassType() ) || !gameLocal.InPlayerPVS( ent ) ) {
- continue;
- }
- //winnerCam->GetPVSAreas()
- //!gameLocal.InPlayerPVS( player ) ||
- //!gameLocal.InPlayerPVS( ent ) ||
- idPlayer* player = static_cast< idPlayer* >(ent);
- if ( !gameLocal.mpGame.GetPlayerState( player->entityNumber ).ingame || player->health <= 0 || !player->head.IsValid() || player->spectating || player->IsHidden() ) {
- continue;
- }
- 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 );
- }
- }
- */
- if ( _hud ) {
- _hud->SetStateBool( "systemTimeShow", g_showSystemClock.GetBool() );
- _hud->SetStateString( "systemTime", gameLocal.GetSystemTime() );
- }
- if ( gameLocal.isMultiplayer && arenaCam && ( winnerCam || spectating || pfl.dead && pm_thirdPersonDeath.GetBool() ) ) {
- //update frag/team winner name
- if ( winningEnt && winningEnt.IsValid() ) {
- bool showName = true;
- if ( winningEnt.GetEntityNum() == entityNumber && spectating ) {
- showName = false;
- }
- if ( gameLocal.IsTeamGame() ) {
- arenaCam->SetStateString( "viewWinnerTitle", common->GetLocalizedString( "#str_108082" ) );
- if ( winningTeam != TEAM_NONE ) {
- arenaCam->SetStateString( "viewWinnerTeamName", gameLocal.GetTeamName( winningTeam ) );
- } else if ( winningTeam == TEAM_NONE ) {
- arenaCam->SetStateString( "viewWinnerTeamName", common->GetLocalizedString( "#str_108087" ) );
- }
- arenaCam->HandleNamedEvent( "viewTeamLeader" );
- } else if ( !gameLocal.IsTeamGame() && !gameLocal.IsDuelGameType() && showName ) {
- arenaCam->SetStateString( "viewWinnerTitle", common->GetLocalizedString( "#str_108081" ) );
- player = winningEnt->GetStaticPlayer();
- arenaCam->SetStateString( "viewWinnerName", player->GetUserInfo()->GetString( "ui_name" ) );
- arenaCam->HandleNamedEvent( "viewFragLeader" );
- } else if ( gameLocal.IsDuelGameType() && showName ) {
- player = winningEnt->GetStaticPlayer();
- if ( !gameLocal.mpGame.ConcededWin( entityNumber ) ) {
- arenaCam->SetStateString( "viewWinnerTitle", common->GetLocalizedString( "#str_108092" ) );
- } else if ( gameLocal.mpGame.ConcededWin( entityNumber ) ) {
- arenaCam->SetStateString( "viewWinnerTitle", common->GetLocalizedString( "#str_108093" ) );
- }
- arenaCam->SetStateString( "viewWinnerName", player->GetUserInfo()->GetString( "ui_name" ) );
- arenaCam->HandleNamedEvent( "viewDuelLeader" );
- }
- arenaCam->HandleNamedEvent( "nextGameBegins" );
- arenaCam->SetStateString( "gamebegins", va( common->GetLocalizedString( "#str_108058" ), Max( (( gameLocal.mpGame.GetGameState()->GetNextMPGameStateTime() - gameLocal.time) / 1000) + 1, 0 ) ) );
- }
- //add smash effect material
- if ( ( pfl.dead && pm_thirdPersonDeath.GetBool() || spectating ) && gameLocal.GetLocalPlayer() ) {
- if ( ( g_spectateHudfx.GetInteger() >= 1 && g_spectateHudfx.GetInteger() <= 2 ) && !pfl.arenaCam ) {
- pfl.arenaCam = true;
- arenaCam->SetStateInt( "showline", GetLimitRandomInt( 0, 1 ) );
- arenaCam->SetStateInt( "showstatic3", GetLimitRandomInt( 0, 1 ) );
- arenaCam->SetStateInt( "showstatic2", GetLimitRandomInt( 0, 1 ) );
- arenaCam->SetStateInt( "showstatic1", GetLimitRandomInt( 0, 1 ) );
- arenaCam->SetStateInt( "showtopreflect", GetLimitRandomInt( 0, 1 ) );
- arenaCam->SetStateInt( "showbroken_glass", false );
- if ( gameLocal.IsMPGameState( GAMEON ) && pfl.dead && !spectating && g_spectateHudfx.GetInteger() == 2 && GetLimitRandomInt( 0, 6 ) == 4 ) {
- arenaCam->SetStateInt( "showbroken_glass", true );
- }
- }
- }
- arenaCam->Redraw( gameLocal.realClientTime );
- if ( winnerCam || pfl.dead ) {
- return;
- }
- }
- if ( !_hud || disableHud || influenceActive != INFLUENCE_NONE || privateCameraView || !g_showHud.GetBool() ) {
- return;
- }
- if ( pfl.attackerDeathView ) {
- aiVisionhud->Redraw( gameLocal.realClientTime );
- } else if ( IsGuidingProjectile() ) {
- guidedProjectilehud = uiManager->FindGui( GetGuideEnt()->spawnArgs.GetString( "guidehud" ), true, false, true );
- if ( guidedProjectilehud ) {
- guidedProjectilehud->SetStateString ( "guiderange", va( "%s %i [%i]", common->GetLocalizedString( "#str_108096" ), (int)guiderange, GetGuideEnt()->spawnArgs.GetInt( "guideRange" ) ) );
- guidedProjectilehud->Redraw( gameLocal.realClientTime );
- }
- } else if ( GetDriverHud() ) {
- _hud = GetDriverHud();
- // Boss bar
- if ( _hud && _hud->State().GetInt( "boss_health", "-1" ) != (bossEnemy ? bossEnemy->health : -1) ) {
- if ( !bossEnemy || bossEnemy->health <= 0 ) {
- bossEnemy = NULL;
- _hud->SetStateInt( "boss_health", -1 );
- _hud->HandleNamedEvent( "hideBossBar" );
- _hud->HandleNamedEvent( "hideBossShieldBar" ); // grrr, for boss buddy..but maybe other bosses will have shields?
- } else {
- _hud->SetStateInt( "boss_health", bossEnemy->health );
- _hud->HandleNamedEvent( "updateBossBar" );
- }
- }
- if ( cursor ) {
- cursor->SetStateBool( "vehiclecursor", false );
- }
- if ( !gameDebug.IsHudActive( DBGHUD_ANY ) ) {
- if ( cursor && health > 0 ) {
- // mekberg: adjustable crosshair size.
- int crossSize = cvarSystem->GetCVarInteger( "g_crosshairSize" );
- crossSize = crossSize - crossSize % 8;
- cvarSystem->SetCVarInteger( "g_crosshairSize", crossSize );
- cursor->SetStateInt( "g_crosshairSize", crossSize );
- vehicleController.UpdateCursorGUI( cursor );
- cursor->Redraw( gameLocal.realClientTime );
- }
- vehicleController.DrawHUD( );
- }
- } else if ( objectiveSystemOpen && IsLocalClient() ) {
- if ( !GuiActive() ) {
- // showing weapon zoom gui when objectives are open because that's the way I'z told to make it werkz
- if ( HasWeapon() && weapon->GetZoomGui( ) && IsZoomed() ) {
- weapon->GetZoomGui( )->Redraw( gameLocal.realClientTime );
- }
- }
- } else {
- // FIXME: this is temp to allow the sound meter to show up in the hud
- // it should be commented out before shipping but the code can remain
- // for mod developers to enable for the same functionality
- if ( _hud ) {
- _hud->SetStateBool( "weaponEnabled", weaponEnabled );
- _hud->SetStateBool( "mp", gameLocal.isMultiplayer );
- _hud->SetStateInt( "s_debug", cvarSystem->GetCVarInteger( "s_showLevelMeter" ) );
- if ( team != gameLocal.GetLocalPlayer()->hudTeam ) {
- for( int i = 0; i < TEAM_MAX; i++ ) {
- if ( team != i ) {
- continue;
- }
- _hud->HandleNamedEvent( va( "setTeam_%d", i ) );
- }
- gameLocal.GetLocalPlayer()->hudTeam = team;
- }
- }
- if ( g_showZoomHud.GetBool() && HasWeapon() && weapon->GetZoomGui() && IsZoomed() ) {
- weapon->GetZoomGui( )->Redraw( gameLocal.realClientTime );
- }
- // don't draw main hud in spectator (only mphud)
- if ( !spectating && !gameDebug.IsHudActive( DBGHUD_ANY ) ) {
- // weapon targeting crosshair
- if ( !GuiActive() ) {
- if ( cursor && health > 0 ) {
- // Pass the current weapon to the cursor gui for custom crosshairs
- // mekberg: adjustable crosshair size.
- int crossSize = cvarSystem->GetCVarInteger( "g_crosshairSize" );
- crossSize = crossSize - crossSize % 8;
- cvarSystem->SetCVarInteger( "g_crosshairSize", crossSize );
- cursor->SetStateInt( "g_crosshairSize", crossSize );
- cursor->Redraw( gameLocal.realClientTime );
- }
- }
- if ( focusBrackets ) {
- // If 2d_calc is still true then the gui didnt render so we can abandon it
- if ( focusBrackets->State().GetBool( "2d_calc" ) ) {
- focusBrackets->SetStateBool( "2d_calc", false );
- focusBrackets = NULL;
- focusBracketsTime = 0;
- _hud->HandleNamedEvent( "hideBrackets" );
- } else {
- _hud->SetStateString( "bracket_left", focusBrackets->State().GetString( "2d_min_x" ) );
- _hud->SetStateString( "bracket_top", focusBrackets->State().GetString( "2d_min_y" ) );
- _hud->SetStateFloat( "bracket_width", focusBrackets->State().GetFloat( "2d_max_x" ) - focusBrackets->State().GetFloat( "2d_min_x" ) );
- _hud->SetStateFloat( "bracket_height", focusBrackets->State().GetFloat( "2d_max_y" ) - focusBrackets->State().GetFloat( "2d_min_y" ) );
- // TODO: Find a way to get bracket text from gui to hud
- }
- }
- //draw
- UpdateHud( _hud );
- }
- }
- UpdatePauseHud();
- if ( gameLocal.isMultiplayer ) {
- if ( mphud ) {
- gameLocal.mpGame.UpdateHud( mphud );
- mphud->Redraw( gameLocal.realClientTime );
- }
- if ( overlayHud && overlayHudTime > gameLocal.time && overlayHudTime != 0 ) {
- overlayHud->Redraw( gameLocal.realClientTime );
- } else {
- overlayHud = NULL;
- overlayHudTime = 0;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement