//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTFHudObjectiveStatus::Think() { if ( !TeamplayRoundBasedRules() ) return; SetVisiblePanels(); // check for an active timer and turn the time panel on or off if we need to if ( m_pTimePanel ) { // Don't draw in freezecam, or when the game's not running C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); bool bDisplayTimer = !( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM ); if ( bDisplayTimer ) { // is the time panel still pointing at an active timer? int iCurrentTimer = m_pTimePanel->GetTimerIndex(); CTeamRoundTimer *pTimer = dynamic_cast< CTeamRoundTimer* >( ClientEntityList().GetEnt( iCurrentTimer ) ); if ( pTimer && !pTimer->IsDormant() && !pTimer->IsDisabled() && pTimer->ShowInHud() ) { // the current timer is fine, make sure the panel is visible bDisplayTimer = true; } else if ( ObjectiveResource() ) { // check for a different timer int iActiveTimer = ObjectiveResource()->GetTimerToShowInHUD(); pTimer = dynamic_cast< CTeamRoundTimer* >( ClientEntityList().GetEnt( iActiveTimer ) ); bDisplayTimer = ( iActiveTimer != 0 && pTimer && !pTimer->IsDormant() && pTimer->ShowInHud() ); if ( bDisplayTimer ) m_pTimePanel->SetTimerIndex( iActiveTimer ); } } if ( bDisplayTimer ) { if ( !m_pTimePanel->IsVisible() ) { m_pTimePanel->SetVisible( true ); // If our spectator GUI is visible, invalidate its layout so that it moves the reinforcement label if ( g_pSpectatorGUI ) { g_pSpectatorGUI->InvalidateLayout(); } } } else if ( m_pTimePanel->IsVisible() ) { m_pTimePanel->SetVisible( false ); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CTeamRoundTimer::SetActiveTimer( CTeamRoundTimer *pNewlyActive ) { CBaseEntity *pChosenTimer = pNewlyActive; // Ensure all other timers are off. CBaseEntity *pEntity = NULL; while ((pEntity = gEntList.FindEntityByClassname( pEntity, "team_round_timer" )) != NULL) { if ( pEntity == pNewlyActive ) continue; CTeamRoundTimer *pTimer = assert_cast< CTeamRoundTimer* >( pEntity ); if ( !pTimer->IsDisabled() && pTimer->ShowInHud() ) { if ( pChosenTimer ) { // Turn off all other hud timers pTimer->SetShowInHud( false ); } else { // Found a timer. Use it. pChosenTimer = pTimer; } } } ObjectiveResource()->SetTimerInHUD( pChosenTimer ); }