//----------------------------------------------------------------------------- // 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 ); }
//----------------------------------------------------------------------------- // 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 CTFHudKothTimeStatus::Think( void ) { if ( !TFGameRules() ) return; // check for an active timer and turn the time panel on or off if we need to if ( m_pBlueKothTimer && m_pRedKothTimer ) { // Don't draw in freezecam, or when the game's not running C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); bool bDisplayTimers = !( pPlayer && pPlayer->GetObserverMode() == OBS_MODE_FREEZECAM ); if ( bDisplayTimers ) { bool bDisplayBlueTimer = false; bool bDisplayRedTimer = false; bool bDisplayGreenTimer = false; bool bDisplayYellowTimer = false; // is the time panel still pointing at an active timer? CTeamRoundTimer *pTimer = dynamic_cast< CTeamRoundTimer* >( ClientEntityList().GetEnt( m_pBlueKothTimer->GetTimerIndex() ) ); // Check for the current active timer (used for the pulsating HUD animation) CTFHudTimeStatus *pActiveKothTimerPanel = NULL; if ( !pTimer ) { pTimer = TFGameRules()->GetBlueKothRoundTimer(); if ( pTimer && m_pBlueKothTimer->GetTimerIndex() != pTimer->index ) m_pBlueKothTimer->SetTimerIndex( pTimer->index ); } if ( pTimer && !pTimer->IsDormant() && !pTimer->IsDisabled() ) { // the current timer is fine, make sure the panel is visible bDisplayBlueTimer = true; if ( !pTimer->IsTimerPaused() ) pActiveKothTimerPanel = m_pBlueKothTimer; } // And now let's check the other timer // is the time panel still pointing at an active timer? pTimer = dynamic_cast< CTeamRoundTimer* >( ClientEntityList().GetEnt( m_pRedKothTimer->GetTimerIndex() ) ); if ( !pTimer ) { pTimer = TFGameRules()->GetRedKothRoundTimer(); if ( pTimer && m_pRedKothTimer->GetTimerIndex() != pTimer->index ) m_pRedKothTimer->SetTimerIndex( pTimer->index ); } if ( pTimer && !pTimer->IsDormant() && !pTimer->IsDisabled() ) { // the current timer is fine, make sure the panel is visible bDisplayRedTimer = true; if ( !pTimer->IsTimerPaused() ) pActiveKothTimerPanel = m_pRedKothTimer; } if ( TFGameRules()->IsFourTeamGame() ) { // Check GRN timer pTimer = dynamic_cast< CTeamRoundTimer* >( ClientEntityList().GetEnt( m_pGreenKothTimer->GetTimerIndex() ) ); if ( !pTimer ) { pTimer = TFGameRules()->GetGreenKothRoundTimer(); if ( pTimer ) m_pGreenKothTimer->SetTimerIndex( pTimer->index ); } if ( pTimer && !pTimer->IsDormant() && !pTimer->IsDisabled() ) { // the current timer is fine, make sure the panel is visible bDisplayGreenTimer = true; if ( !pTimer->IsTimerPaused() ) pActiveKothTimerPanel = m_pGreenKothTimer; } // Check YLW timer pTimer = dynamic_cast< CTeamRoundTimer* >( ClientEntityList().GetEnt( m_pYellowKothTimer->GetTimerIndex() ) ); if ( !pTimer ) { pTimer = TFGameRules()->GetYellowKothRoundTimer(); if ( pTimer ) m_pYellowKothTimer->SetTimerIndex( pTimer->index ); } if ( pTimer && !pTimer->IsDormant() && !pTimer->IsDisabled() ) { // the current timer is fine, make sure the panel is visible bDisplayYellowTimer = true; if ( !pTimer->IsTimerPaused() ) pActiveKothTimerPanel = m_pYellowKothTimer; } } if ( !m_pBlueKothTimer->IsVisible() || !m_pRedKothTimer->IsVisible() ) { m_pBlueKothTimer->SetVisible( true ); // bDisplayBlueTimer m_pRedKothTimer->SetVisible( true ); // bDisplayRedTimer // If our spectator GUI is visible, invalidate its layout so that it moves the reinforcement label if ( g_pSpectatorGUI ) { g_pSpectatorGUI->InvalidateLayout(); } } if ( TFGameRules()->IsFourTeamGame() ) { if ( !m_pGreenKothTimer->IsVisible() || !m_pYellowKothTimer->IsVisible() ) { m_pGreenKothTimer->SetVisible( true ); m_pYellowKothTimer->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 { m_pGreenKothTimer->SetVisible( false ); m_pYellowKothTimer->SetVisible( false ); } // Set overtime panels active on our active panel (if needed) if ( m_pActiveKothTimerPanel ) m_pActiveKothTimerPanel->SetExtraTimePanels(); // Do NOT put a null check here, otherwise the white active timer BG will linger around after a round end if ( pActiveKothTimerPanel != m_pActiveKothTimerPanel ) { m_pActiveKothTimerPanel = pActiveKothTimerPanel; UpdateActiveTeam(); } } else { m_pBlueKothTimer->SetVisible( false ); m_pRedKothTimer->SetVisible( false ); m_pGreenKothTimer->SetVisible( false ); m_pYellowKothTimer->SetVisible( false ); m_pActiveTimerBG->SetVisible( false ); } } }