void CHudChatLine::PerformFadeout( void ) { // Flash + Extra bright when new float curtime = gpGlobals->curtime; int lr = m_clrText[0]; int lg = m_clrText[1]; int lb = m_clrText[2]; //CSPort chat only fades out, no blinking. if ( curtime <= m_flExpireTime && curtime > m_flExpireTime - CHATLINE_FADE_TIME ) { float frac = ( m_flExpireTime - curtime ) / CHATLINE_FADE_TIME; int alpha = frac * 255; alpha = clamp( alpha, 0, 255 ); wchar_t wbuf[4096]; GetText(0, wbuf, sizeof(wbuf)); SetText( "" ); if ( m_iNameLength > 0 ) { wchar_t wText[4096]; // draw the first x characters in the player color wcsncpy( wText, wbuf, min( m_iNameLength + 1, MAX_PLAYER_NAME_LENGTH+32) ); wText[ min( m_iNameLength, MAX_PLAYER_NAME_LENGTH+31) ] = 0; m_clrNameColor[3] = alpha; InsertColorChange( m_clrNameColor ); InsertString( wText ); wcsncpy( wText, wbuf + ( m_iNameLength ), wcslen( wbuf + m_iNameLength ) ); wText[ wcslen( wbuf + m_iNameLength ) ] = '\0'; InsertColorChange( Color( g_ColorYellow[0], g_ColorYellow[1], g_ColorYellow[2], alpha ) ); InsertString( wText ); InvalidateLayout( true ); } else { InsertColorChange( Color( lr, lg, lb, alpha ) ); InsertString( wbuf ); } } OnThink(); }
void CBaseHudChatLine::PerformFadeout( void ) { // Flash + Extra bright when new float curtime = gpGlobals->curtime; int lr = m_clrText[0]; int lg = m_clrText[1]; int lb = m_clrText[2]; if ( curtime >= m_flStartTime && curtime < m_flStartTime + CHATLINE_FLASH_TIME ) { float frac1 = ( curtime - m_flStartTime ) / CHATLINE_FLASH_TIME; float frac = frac1; frac *= CHATLINE_NUM_FLASHES; frac *= 2 * M_PI; frac = cos( frac ); frac = clamp( frac, 0.0f, 1.0f ); frac *= (1.0f-frac1); int r = lr, g = lg, b = lb; r = r + ( 255 - r ) * frac; g = g + ( 255 - g ) * frac; b = b + ( 255 - b ) * frac; // Draw a right facing triangle in red, faded out over time int alpha = 63 + 192 * (1.0f - frac1 ); alpha = clamp( alpha, 0, 255 ); wchar_t wbuf[4096]; GetText(0, wbuf, sizeof(wbuf)); SetText( "" ); InsertColorChange( Color( r, g, b, 255 ) ); InsertString( wbuf ); } else if ( curtime <= m_flExpireTime && curtime > m_flExpireTime - CHATLINE_FADE_TIME ) { float frac = ( m_flExpireTime - curtime ) / CHATLINE_FADE_TIME; int alpha = frac * 255; alpha = clamp( alpha, 0, 255 ); wchar_t wbuf[4096]; GetText(0, wbuf, sizeof(wbuf)); SetText( "" ); InsertColorChange( Color( lr * frac, lg * frac, lb * frac, alpha ) ); InsertString( wbuf ); } else { wchar_t wbuf[4096]; GetText(0, wbuf, sizeof(wbuf)); SetText( "" ); InsertColorChange( Color( lr, lg, lb, 255 ) ); InsertString( wbuf ); } OnThink(); }