int CHudStatusBar :: Draw( float fTime ) { this->ReparseStringIfNeeded(); // Draw the status bar lines for ( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) { int TextHeight, TextWidth; GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight ); int Y_START; if ( ScreenHeight() >= 480 ) Y_START = ScreenHeight() - 55; else Y_START = ScreenHeight() - 45; int x = 5; int y = Y_START - ( TextHeight * i ); // draw along bottom of screen // let user set status ID bar centering if ( (i == STATUSBAR_ID_LINE) && CVAR_GET_FLOAT("hud_centerid") ) { x = max( 0, max(2, (ScreenWidth() - TextWidth)) / 2 ); y = (ScreenHeight() / 2) + (TextHeight*CVAR_GET_FLOAT("hud_centerid")); } if ( m_pflNameColors[i] ) DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] ); DrawConsoleString( x, y, m_szStatusBar[i] ); } return 1; }
int CHudSayText :: Draw( float flTime ) { if( !m_HUD_saytext->value ) return 1; int y = Y_START; // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value ); // make sure the scrolltime is within reasonable bounds, to guard against the clock being reset flScrollTime = min( flScrollTime, flTime + m_HUD_saytext_time->value ); if( flScrollTime <= flTime ) { if( *g_szLineBuffer[0] ) { flScrollTime = flTime + m_HUD_saytext_time->value; // push the console up ScrollTextUp(); } else { // buffer is empty, just disable drawing of this section m_iFlags &= ~HUD_ACTIVE; } } for( int i = 0; i < MAX_LINES; i++ ) { if( *g_szLineBuffer[i] ) { if( *g_szLineBuffer[i] == 2 && g_pflNameColors[i] ) { // it's a saytext string static char buf[MAX_PLAYER_NAME_LENGTH+32]; // draw the first x characters in the player color Q_strncpy( buf, g_szLineBuffer[i], sizeof( buf )); buf[min( g_iNameLengths[i], MAX_PLAYER_NAME_LENGTH+31)] = 0; DrawSetTextColor( g_pflNameColors[i][0], g_pflNameColors[i][1], g_pflNameColors[i][2] ); int x = DrawConsoleString( LINE_START, y, buf ); // color is reset after each string draw DrawConsoleString( x, y, g_szLineBuffer[i] + g_iNameLengths[i] ); } else { // normal draw DrawConsoleString( LINE_START, y, g_szLineBuffer[i] ); } } y += line_height; } return 1; }
int CHudStatusBar :: Draw( float fTime ) { if( m_bReparseString ) { for( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) { m_pflNameColors[i] = g_ColorYellow; ParseStatusString( i ); } m_bReparseString = FALSE; } int Y_START = ScreenHeight - YRES( 32 + 4 ); // Draw the status bar lines for( int i = 0; i < MAX_STATUSBAR_LINES; i++ ) { int TextHeight, TextWidth; GetConsoleStringSize( m_szStatusBar[i], &TextWidth, &TextHeight ); int x = 4; int y = Y_START - ( 4 + TextHeight * i ); // draw along bottom of screen // let user set status ID bar centering if(( i == STATUSBAR_ID_LINE ) && CVAR_GET_FLOAT( "hud_centerid" )) { x = max( 0, max( 2, (ScreenWidth - TextWidth)) / 2 ); y = (ScreenHeight / 2) + (TextHeight * CVAR_GET_FLOAT( "hud_centerid" )); } if( m_pflNameColors[i] ) DrawSetTextColor( m_pflNameColors[i][0], m_pflNameColors[i][1], m_pflNameColors[i][2] ); DrawConsoleString( x, y, m_szStatusBar[i] ); } return 1; }
int CHudDeathNotice::Draw( float flTime ) { int x, y, r, g, b; for( int i = 0; i < MAX_DEATHNOTICES; i++ ) { if( rgDeathNoticeList[i].iId == 0 ) break; // we've gone through them all if( rgDeathNoticeList[i].flDisplayTime < flTime ) { // display time has expired // remove the current item from the list memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i + 1], sizeof(DeathNoticeItem) * ( MAX_DEATHNOTICES - i ) ); i--; // continue on the next item; stop the counter getting incremented continue; } rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME ); // Only draw if the viewport will let me // vgui dropped out //if( gViewPort && gViewPort->AllowedToPrintText() ) { // Draw the death notice y = YRES( DEATHNOTICE_TOP ) + 2 + ( 20 * i ); //!!! int id = ( rgDeathNoticeList[i].iId == -1 ) ? m_HUD_d_skull : rgDeathNoticeList[i].iId; x = ScreenWidth - ConsoleStringLen( rgDeathNoticeList[i].szVictim ) - ( gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left ); if( !rgDeathNoticeList[i].iSuicide ) { x -= ( 5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) ); // Draw killers name if( rgDeathNoticeList[i].KillerColor ) DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] ); x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller ); } r = 255; g = 80; b = 0; if( rgDeathNoticeList[i].iTeamKill ) { r = 10; g = 240; b = 10; // display it in sickly green } // Draw death weapon SPR_Set( gHUD.GetSprite(id), r, g, b ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) ); x += ( gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left ); // Draw victims name (if it was a player that was killed) if( rgDeathNoticeList[i].iNonPlayerKill == FALSE ) { if( rgDeathNoticeList[i].VictimColor ) DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] ); x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim ); } } } return 1; }
int CHudDeathNotice :: Draw( float flTime ) { int x, y, r, g, b; for ( int i = 0; i < MAX_DEATHNOTICES; i++ ) { if ( rgDeathNoticeList[i].iId == 0 ) break; // we've gone through them all if ( rgDeathNoticeList[i].flDisplayTime < flTime ) { // display time has expired // remove the current item from the list memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) ); i--; // continue on the next item; stop the counter getting incremented continue; } rgDeathNoticeList[i].flDisplayTime = min( rgDeathNoticeList[i].flDisplayTime, gHUD.m_flTime + DEATHNOTICE_DISPLAY_TIME ); // Only draw if the viewport will let me if ( gViewPort && gViewPort->AllowedToPrintText() ) { // Draw the death notice //y = DEATHNOTICE_TOP + (20 * i); //!!! int theBaseY = DEATHNOTICE_TOP; // Bring down death messages when in top down or when we're drawing letter box if(gHUD.m_Spectator.IsInOverviewMode()) { // No HUD elements to compensate for } else if(gHUD.GetInTopDownMode()) { theBaseY = .10*ScreenHeight(); } else if(gHUD.GetIsMarine()) { theBaseY = .26*ScreenHeight(); } else if(gHUD.GetIsAlien()) { theBaseY = kHiveNormScreenY*ScreenHeight() + (kMaxHives-1)*((kHiveNormScreenHeight + kHiveNormScreenVerticalSpacing)*ScreenHeight()); } // Lower death messages more when spectating so they don't overlap (due to letterbox) if(g_iUser1 != OBS_NONE) { theBaseY += .06*ScreenHeight(); } y = theBaseY + (20 * i); //!!! int id = (rgDeathNoticeList[i].iId == -1) ? m_HUD_d_skull : rgDeathNoticeList[i].iId; x = ScreenWidth() - ConsoleStringLen(rgDeathNoticeList[i].szVictim) - (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); if ( !rgDeathNoticeList[i].iSuicide ) { x -= (5 + ConsoleStringLen( rgDeathNoticeList[i].szKiller ) ); // Draw killers name if ( rgDeathNoticeList[i].KillerColor ) DrawSetTextColor( rgDeathNoticeList[i].KillerColor[0], rgDeathNoticeList[i].KillerColor[1], rgDeathNoticeList[i].KillerColor[2] ); x = 5 + DrawConsoleString( x, y, rgDeathNoticeList[i].szKiller ); } r = 255; g = 80; b = 0; if ( rgDeathNoticeList[i].iTeamKill ) { r = 10; g = 240; b = 10; // display it in sickly green } // Draw death weapon SPR_Set( gHUD.GetSprite(id), r, g, b ); SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(id) ); x += (gHUD.GetSpriteRect(id).right - gHUD.GetSpriteRect(id).left); // Draw victims name (if it was a player that was killed) if (rgDeathNoticeList[i].iNonPlayerKill == FALSE) { if ( rgDeathNoticeList[i].VictimColor ) DrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] ); x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim ); } } } return 1; }