//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseHudChat::Clear( void ) { #ifndef _XBOX // Kill input prompt StopMessageMode(); // Expire all messages for ( int i = 0; i < CHAT_INTERFACE_LINES; i++ ) { CBaseHudChatLine *line = m_ChatLines[ i ]; if ( !line ) continue; if ( !line->IsVisible() ) continue; line->Expire(); } #endif }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseHudChat::ExpireOldest( void ) { #ifndef _XBOX float oldestTime = 100000000.0f; CBaseHudChatLine *oldest = NULL; for ( int i = 0; i < CHAT_INTERFACE_LINES; i++ ) { CBaseHudChatLine *line = m_ChatLines[ i ]; if ( !line ) continue; if ( !line->IsVisible() ) continue; if ( !oldest ) { oldest = line; oldestTime = line->GetStartTime(); continue; } if ( line->GetStartTime() < oldestTime ) { oldest = line; oldestTime = line->GetStartTime(); } } if ( !oldest ) { oldest = m_ChatLines[ 0 ]; } oldest->Expire(); #endif }
//----------------------------------------------------------------------------- // Purpose: Do respositioning here to avoid latency due to repositioning of vgui // voice manager icon panel //----------------------------------------------------------------------------- void CBaseHudChat::OnTick( void ) { #ifndef _XBOX int i; for ( i = 0; i < CHAT_INTERFACE_LINES; i++ ) { CBaseHudChatLine *line = m_ChatLines[ i ]; if ( !line ) continue; if ( !line->IsVisible() ) continue; if ( !line->IsReadyToExpire() ) continue; line->Expire(); } int w, h; GetSize( w, h ); CBaseHudChatLine *line = m_ChatLines[ 0 ]; if ( line ) { vgui::HFont font = line->GetFont(); if ( font ) { m_iFontHeight = vgui::surface()->GetFontTall( font ) + 2; // Put input area at bottom int w, h; GetSize( w, h ); m_pChatInput->SetBounds( 1, h - m_iFontHeight - 1, w-2, m_iFontHeight ); } } // Sort chat lines qsort( m_ChatLines, CHAT_INTERFACE_LINES, sizeof( CBaseHudChatLine * ), SortLines ); // Step backward from bottom int currentY = h - m_iFontHeight - 1; int startY = currentY; int ystep = m_iFontHeight; currentY -= GetChatInputOffset(); // Walk backward for ( i = CHAT_INTERFACE_LINES - 1; i >= 0 ; i-- ) { CBaseHudChatLine *line = m_ChatLines[ i ]; if ( !line ) continue; if ( !line->IsVisible() ) { line->SetSize( w, m_iFontHeight ); continue; } line->PerformFadeout(); line->SetSize( w, m_iFontHeight * line->GetNumLines() ); line->SetPos( 0, ( currentY+m_iFontHeight) - m_iFontHeight * line->GetNumLines() ); currentY -= ystep * line->GetNumLines(); } if ( currentY != startY ) { m_nVisibleHeight = startY - currentY + 2; } else { m_nVisibleHeight = 0; } vgui::surface()->MovePopupToBack( GetVPanel() ); #endif }