//----------------------------------------------------------------------------- // Purpose: Return true if the passed in sections of the HUD shouldn't be drawn //----------------------------------------------------------------------------- bool CHud::IsHidden(int iHudFlags) { // Not in game? if (!engine->IsInGame()) return true; // No local player yet? C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if (!pPlayer) return true; // Get current hidden flags int iHideHud = pPlayer->m_Local.m_iHideHUD; if (hidehud.GetInt()) { iHideHud = hidehud.GetInt(); } // Everything hidden? if (iHideHud & HIDEHUD_ALL) return true; // Local player dead? if ((iHudFlags & HIDEHUD_PLAYERDEAD) && (pPlayer->GetHealth() <= 0 && !pPlayer->IsAlive())) return true; // Need the HEV suit ( HL2 ) if ((iHudFlags & HIDEHUD_NEEDSUIT) && (!pPlayer->IsSuitEquipped())) return true; return ((iHudFlags & iHideHud) != 0); }
//----------------------------------------------------------------------------- // Purpose: Save CPU cycles by letting the HUD system early cull // costly traversal. Called per frame, return true if thinking and // painting need to occur. //----------------------------------------------------------------------------- bool CHudCrosshair::ShouldDraw( void ) { bool bNeedsDraw; C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return false; // draw a crosshair only if alive or spectating in eye if ( IsXbox() ) { bNeedsDraw = m_pCrosshair && !engine->IsDrawingLoadingImage() && !engine->IsPaused() && !pPlayer->IsSuitEquipped() && g_pClientMode->ShouldDrawCrosshair() && !( pPlayer->GetFlags() & FL_FROZEN ) && ( pPlayer->entindex() == render->GetViewEntity() ) && ( pPlayer->IsAlive() || ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) ); } else { bNeedsDraw = m_pCrosshair && crosshair.GetInt() && !engine->IsDrawingLoadingImage() && !engine->IsPaused() && g_pClientMode->ShouldDrawCrosshair() && !( pPlayer->GetFlags() & FL_FROZEN ) && ( pPlayer->entindex() == render->GetViewEntity() ) && ( pPlayer->IsAlive() || ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) ); } return ( bNeedsDraw && CHudElement::ShouldDraw() ); }
//----------------------------------------------------------------------------- // Purpose: Save CPU cycles by letting the HUD system early cull // costly traversal. Called per frame, return true if thinking and // painting need to occur. //----------------------------------------------------------------------------- bool CHudCrosshair::ShouldDraw( void ) { bool bNeedsDraw; if ( m_bHideCrosshair ) return false; C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return false; C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon(); if ( pWeapon && !pWeapon->ShouldDrawCrosshair() ) return false; #ifdef PORTAL C_Portal_Player *portalPlayer = ToPortalPlayer(pPlayer); if ( portalPlayer && portalPlayer->IsSuppressingCrosshair() ) return false; #endif // PORTAL /* disabled to avoid assuming it's an HL2 player. // suppress crosshair in zoom. if ( pPlayer->m_HL2Local.m_bZooming ) return false; */ // draw a crosshair only if alive or spectating in eye if ( IsX360() ) { bNeedsDraw = m_pCrosshair && !engine->IsDrawingLoadingImage() && !engine->IsPaused() && ( !pPlayer->IsSuitEquipped() || g_pGameRules->IsMultiplayer() ) && g_pClientMode->ShouldDrawCrosshair() && !( pPlayer->GetFlags() & FL_FROZEN ) && ( pPlayer->entindex() == render->GetViewEntity() ) && ( pPlayer->IsAlive() || ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) ); } else { bNeedsDraw = m_pCrosshair && crosshair.GetInt() && !engine->IsDrawingLoadingImage() && !engine->IsPaused() && g_pClientMode->ShouldDrawCrosshair() && !( pPlayer->GetFlags() & FL_FROZEN ) && ( pPlayer->entindex() == render->GetViewEntity() ) && !pPlayer->IsInVGuiInputMode() && ( pPlayer->IsAlive() || ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) ); } return ( bNeedsDraw && CHudElement::ShouldDraw() ); }
//----------------------------------------------------------------------------- // Purpose: Return true if the passed in sections of the HUD shouldn't be drawn //----------------------------------------------------------------------------- bool CHud::IsHidden( int iHudFlags, HUDRENDERSTAGE_t stage ) // GSTRINGMIGRATION { // GSTRINGMIGRATION const bool bDrawAll = m_iRenderingStage == HUDRENDERSTAGE_ALL; if ( !bDrawAll && stage != m_iRenderingStage ) return true; // END GSTRINGMIGRATION // Not in game? if ( !engine->IsInGame() ) return true; // No local player yet? C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return true; // Get current hidden flags int iHideHud = pPlayer->m_Local.m_iHideHUD; if ( hidehud.GetInt() ) { iHideHud = hidehud.GetInt(); } // Everything hidden? if ( iHideHud & HIDEHUD_ALL ) return true; // Local player dead? if ( ( iHudFlags & HIDEHUD_PLAYERDEAD ) && ( pPlayer->GetHealth() <= 0 && !pPlayer->IsAlive() ) ) return true; // Need the HEV suit ( HL2 ) if ( ( iHudFlags & HIDEHUD_NEEDSUIT ) && ( !pPlayer->IsSuitEquipped() ) ) return true; // Hide all HUD elements during screenshot if the user's set hud_freezecamhide ( TF2 ) #if defined( TF_CLIENT_DLL ) extern bool IsTakingAFreezecamScreenshot(); extern ConVar hud_freezecamhide; if ( IsTakingAFreezecamScreenshot() && hud_freezecamhide.GetBool() ) return true; #endif return ( ( iHudFlags & iHideHud ) != 0); }
//----------------------------------------------------------------------------- // Purpose: Save CPU cycles by letting the HUD system early cull // costly traversal. Called per frame, return true if thinking and // painting need to occur. //----------------------------------------------------------------------------- bool CDAHudCrosshair::ShouldDraw( void ) { // OnThink isn't called when the thing isn't visible so force it to update. CalculateCrosshair(); bool bNeedsDraw; if ( m_bHideCrosshair ) return false; C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return false; C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon(); if ( pWeapon && !pWeapon->ShouldDrawCrosshair() ) return false; ConVarRef cl_observercrosshair("cl_observercrosshair"); // draw a crosshair only if alive or spectating in eye if ( IsX360() ) { bNeedsDraw = m_pCrosshair && !engine->IsDrawingLoadingImage() && !engine->IsPaused() && ( !pPlayer->IsSuitEquipped() || g_pGameRules->IsMultiplayer() ) && g_pClientMode->ShouldDrawCrosshair() && !( pPlayer->GetFlags() & FL_FROZEN ) && ( pPlayer->entindex() == render->GetViewEntity() ) && ( pPlayer->IsAlive() || ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) ); } else { bNeedsDraw = m_pCrosshair && da_crosshair.GetInt() && !engine->IsDrawingLoadingImage() && !engine->IsPaused() && g_pClientMode->ShouldDrawCrosshair() && !( pPlayer->GetFlags() & FL_FROZEN ) && ( pPlayer->entindex() == render->GetViewEntity() ) && !pPlayer->IsInVGuiInputMode() && ( pPlayer->IsAlive() || ( pPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) || ( cl_observercrosshair.GetBool() && pPlayer->GetObserverMode() == OBS_MODE_ROAMING ) ); } return ( bNeedsDraw && CHudElement::ShouldDraw() ); }
//----------------------------------------------------------------------------- // Purpose: Return true if the passed in sections of the HUD shouldn't be drawn //----------------------------------------------------------------------------- bool CHud::IsHidden( int iHudFlags ) { // Not in game? if ( !m_bEngineIsInGame ) return true; // No local player yet? C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer( m_nSplitScreenSlot ); if ( !pPlayer ) return true; // Get current hidden flags int iHideHud = pPlayer->m_Local.m_iHideHUD; if ( hidehud.GetInt() ) { iHideHud = hidehud.GetInt(); } // Hide all hud elements if we're blurring the background, since they don't blur properly if ( GetClientMode()->GetBlurFade() ) return true; // Everything hidden? if ( iHideHud & HIDEHUD_ALL ) return true; // Don't show hud elements when we're at the mainmenu with a background map running if (engine->IsLevelMainMenuBackground()) return true; // Local player dead? if ( ( iHudFlags & HIDEHUD_PLAYERDEAD ) && ( pPlayer->GetHealth() <= 0 ) ) return true; // Need the HEV suit ( HL2 ) if ( ( iHudFlags & HIDEHUD_NEEDSUIT ) && ( !pPlayer->IsSuitEquipped() ) ) return true; return ( ( iHudFlags & iHideHud ) != 0); }