//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CHudBaseDeathNotice::Paint() { // Retire any death notices that have expired RetireExpiredDeathNotices(); CBaseViewport *pViewport = dynamic_cast<CBaseViewport *>( GetClientModeNormal()->GetViewport() ); int yStart = pViewport->GetDeathMessageStartHeight(); surface()->DrawSetTextFont( m_hTextFont ); int xMargin = XRES( 10 ); int xSpacing = UTIL_ComputeStringWidth( m_hTextFont, L" " ); int iCount = m_DeathNotices.Count(); for ( int i = 0; i < iCount; i++ ) { DeathNoticeItem &msg = m_DeathNotices[i]; CHudTexture *icon = msg.iconDeath; CHudTexture *iconPrekiller = msg.iconPreKiller; wchar_t victim[256]=L""; wchar_t killer[256]=L""; // TEMP - print the death icon name if we don't have a material for it g_pVGuiLocalize->ConvertANSIToUnicode( msg.Victim.szName, victim, sizeof( victim ) ); g_pVGuiLocalize->ConvertANSIToUnicode( msg.Killer.szName, killer, sizeof( killer ) ); int iVictimTextWide = UTIL_ComputeStringWidth( m_hTextFont, victim ) + xSpacing; int iDeathInfoTextWide= msg.wzInfoText[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzInfoText ) + xSpacing : 0; int iDeathInfoEndTextWide= msg.wzInfoTextEnd[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzInfoTextEnd ) + xSpacing : 0; int iKillerTextWide = killer[0] ? UTIL_ComputeStringWidth( m_hTextFont, killer ) + xSpacing : 0; int iLineTall = m_flLineHeight; int iTextTall = surface()->GetFontTall( m_hTextFont ); int iconWide = 0, iconTall = 0, iDeathInfoOffset = 0, iVictimTextOffset = 0, iconActualWide = 0; int iPreKillerTextWide = msg.wzPreKillerText[0] ? UTIL_ComputeStringWidth( m_hTextFont, msg.wzPreKillerText ) - xSpacing : 0; int iconPrekillerWide = 0, iconPrekillerActualWide = 0, iconPreKillerTall = 0; // Get the local position for this notice if ( icon ) { iconActualWide = icon->EffectiveWidth( 1.0f ); iconWide = iconActualWide + xSpacing; iconTall = icon->EffectiveHeight( 1.0f ); int iconTallDesired = iLineTall-YRES(2); Assert( 0 != iconTallDesired ); float flScale = (float) iconTallDesired / (float) iconTall; iconActualWide *= flScale; iconTall *= flScale; iconWide *= flScale; } if ( iconPrekiller ) { iconPrekillerActualWide = iconPrekiller->EffectiveWidth( 1.0f ); iconPrekillerWide = iconPrekillerActualWide; iconPreKillerTall = iconPrekiller->EffectiveHeight( 1.0f ); int iconTallDesired = iLineTall-YRES(2); Assert( 0 != iconTallDesired ); float flScale = (float) iconTallDesired / (float) iconPreKillerTall; iconPrekillerActualWide *= flScale; iconPreKillerTall *= flScale; iconPrekillerWide *= flScale; } int iTotalWide = iKillerTextWide + iconWide + iVictimTextWide + iDeathInfoTextWide + iDeathInfoEndTextWide + ( xMargin * 2 ); iTotalWide += iconPrekillerWide + iPreKillerTextWide; int y = yStart + ( ( iLineTall + m_flLineSpacing ) * i ); int yText = y + ( ( iLineTall - iTextTall ) / 2 ); int yIcon = y + ( ( iLineTall - iconTall ) / 2 ); int x=0; if ( m_bRightJustify ) { x = GetWide() - iTotalWide; } // draw a background panel for the message Vertex_t vert[NUM_BACKGROUND_COORD]; GetBackgroundPolygonVerts( x, y+1, x+iTotalWide, y+iLineTall-1, ARRAYSIZE( vert ), vert ); surface()->DrawSetTexture( -1 ); surface()->DrawSetColor( GetBackgroundColor ( i ) ); surface()->DrawTexturedPolygon( ARRAYSIZE( vert ), vert ); x += xMargin; if ( killer[0] ) { // Draw killer's name DrawText( x, yText, m_hTextFont, GetTeamColor( msg.Killer.iTeam, msg.bLocalPlayerInvolved ), killer ); x += iKillerTextWide; } // prekiller text if ( msg.wzPreKillerText[0] ) { x += xSpacing; DrawText( x + iDeathInfoOffset, yText, m_hTextFont, GetInfoTextColor( i ), msg.wzPreKillerText ); x += iPreKillerTextWide; } // Prekiller icon if ( iconPrekiller ) { int yPreIconTall = y + ( ( iLineTall - iconPreKillerTall ) / 2 ); iconPrekiller->DrawSelf( x, yPreIconTall, iconPrekillerActualWide, iconPreKillerTall, m_clrIcon ); x += iconPrekillerWide + xSpacing; } // Draw glow behind weapon icon to show it was a crit death if ( msg.bCrit && msg.iconCritDeath ) { msg.iconCritDeath->DrawSelf( x, yIcon, iconActualWide, iconTall, m_clrIcon ); } // Draw death icon if ( icon ) { icon->DrawSelf( x, yIcon, iconActualWide, iconTall, m_clrIcon ); x += iconWide; } // Draw additional info text next to death icon if ( msg.wzInfoText[0] ) { if ( msg.bSelfInflicted ) { iDeathInfoOffset += iVictimTextWide; iVictimTextOffset -= iDeathInfoTextWide; } DrawText( x + iDeathInfoOffset, yText, m_hTextFont, GetInfoTextColor( i ), msg.wzInfoText ); x += iDeathInfoTextWide; } // Draw victims name DrawText( x + iVictimTextOffset, yText, m_hTextFont, GetTeamColor( msg.Victim.iTeam, msg.bLocalPlayerInvolved ), victim ); x += iVictimTextWide; // Draw Additional Text on the end of the victims name if ( msg.wzInfoTextEnd[0] ) { DrawText( x , yText, m_hTextFont, GetInfoTextColor( i ), msg.wzInfoTextEnd ); } } }
void CHUDAutoAim::Paint() { if( hud_draw_active_reticle.GetBool() ) { int xCenter = m_vecPos.x; int yCenter = m_vecPos.y; int width, height; float xMod, yMod; vgui::surface()->DrawSetTexture( m_textureID_ActiveReticle ); vgui::surface()->DrawSetColor( 255, 255, 255, m_alpha ); vgui::surface()->DrawGetTextureSize( m_textureID_ActiveReticle, width, height ); float uv1 = 0.5f / width, uv2 = 1.0f - uv1; vgui::Vertex_t vert[4]; Vector2D uv11( uv1, uv1 ); Vector2D uv12( uv1, uv2 ); Vector2D uv21( uv2, uv1 ); Vector2D uv22( uv2, uv2 ); xMod = width; yMod = height; xMod *= m_scale; yMod *= m_scale; xMod /= 2; yMod /= 2; vert[0].Init( Vector2D( xCenter + xMod, yCenter + yMod ), uv21 ); vert[1].Init( Vector2D( xCenter - xMod, yCenter + yMod ), uv11 ); vert[2].Init( Vector2D( xCenter - xMod, yCenter - yMod ), uv12 ); vert[3].Init( Vector2D( xCenter + xMod, yCenter - yMod ), uv22 ); vgui::surface()->DrawTexturedPolygon( 4, vert ); } if( hud_draw_fixed_reticle.GetBool() ) { CHudTexture *pIcon; pIcon = gHUD.GetIcon( "crosshair_xbox" ); if ( pIcon != NULL ) { float x, y; Vector screen; x = ScreenWidth()/2; y = ScreenHeight()/2; x -= pIcon->Width() / 2; y -= pIcon->Height() / 2; Color clr; clr = gHUD.m_clrNormal; int r,g,b,a; clr.GetColor( r,g,b,a ); C_BaseHLPlayer *pLocalPlayer = (C_BaseHLPlayer *)C_BasePlayer::GetLocalPlayer(); if( pLocalPlayer && pLocalPlayer->m_HL2Local.m_hAutoAimTarget.Get() ) { r = 250; g = 138; b = 4; } clr.SetColor( r,g,b,m_alphaFixed); pIcon->DrawSelf( x, y, clr ); } } }
//============================================== // CHudFlags's Paint // errr... paints the panel //============================================== void CHudCTFFlags::Paint() { int m_iFlagCount = g_CtfFlags.Count(); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if( !pPlayer ) return; //char text[512]; int i;// = 0; int x_offset = 0; //int y_offset = 5; Color ColourWhite( 255, 255, 255, 255 ); i = 0; while (i < MAX_FLAGS) { m_pLabelFlag[i]->SetVisible(false); i++; } //x_offset = ( (ScreenWidth() / 2) - (m_iFlagCount * 74) ); //Always lean to the left from the center. -HairyPotter x_offset = 0; for( i = 0; i < m_iFlagCount; i++ ) { x_offset += 68; float fTimeToCap = gpGlobals->curtime; //switch( g_Flags[i]->m_iLastTeam ) switch( g_CtfFlags[i]->GetTeamNumber() ) { case TEAM_UNASSIGNED: switch( g_CtfFlags[i]->m_iForTeam ) { case 0: m_pIconBlank->DrawSelf( x_offset, 0, ColourWhite ); break; case 1: //This flag is picked up by the brits... so it's actually the american flag. m_pIconBlue->DrawSelf( x_offset, 0, ColourWhite ); break; case 2: //This flag is picked up by the americans... so it's actually the british flag. m_pIconRed->DrawSelf( x_offset, 0, ColourWhite ); break; } break; case TEAM_AMERICANS: m_pIconBlue->DrawSelf( x_offset, 0, ColourWhite ); break; case TEAM_BRITISH: m_pIconRed->DrawSelf( x_offset, 0, ColourWhite ); break; } if ( g_CtfFlags[i]->m_bIsCarried ) { int r=0,g=0,b=0; //Start at blue. r = 0; g = 0; b = 255; //End up at red. r += 255 * (sin(fTimeToCap*4) + 1)/2; //g -= 100 * (sin(gpGlobals->curtime*4) + 1)/2; b -= 255 * (sin(fTimeToCap*4) + 1)/2; m_pLabelFlag[i]->SetText( "Taken" ); m_pLabelFlag[i]->SizeToContents(); //m_pLabelFlag[i]->SetVisible( true ); //center on icon int w,h; m_pLabelFlag[i]->GetSize( w, h ); m_pLabelFlag[i]->SetPos( (x_offset + 32) - w/2, 32 - h/2 ); m_pLabelFlag[i]->SetFgColor( Color(r,g,b,255) ); m_pLabelFlag[i]->SetVisible(true); } if ( g_CtfFlags[i]->GetMoveParent() && g_CtfFlags[i]->GetMoveParent() == pPlayer ) { int ystart = GetTall() - 140; //Place this just above the LMS indicator. int w,h; m_pLabelCarrier->SetText( g_pVGuiLocalize->Find("#CTF")); m_pLabelCarrier->SizeToContents(); m_pLabelCarrier->GetSize( w, h ); m_pLabelCarrier->SetPos( 5, ystart - 1.3*h); m_pLabelCarrier->SetFgColor( ColourWhite ); m_pLabelCarrier->SetVisible( true ); //Msg("You are carrying a flag! \n"); } else m_pLabelCarrier->SetVisible( false ); } }
void CGEObjectives::Paint( void ) { C_GEPlayer *pPlayer = ToGEPlayer( C_BasePlayer::GetLocalPlayer() ); if ( !pPlayer || !m_pCardTexture ) return; Vector myEyePos = pPlayer->EyePosition(); Vector myAbsPos = pPlayer->GetAbsOrigin(); int half_w = ScreenWidth() / 2, half_h = ScreenHeight() / 2, card_w = XRES(20), card_h = XRES(20), buffer = XRES(5), off_upleft_x = m_iInnerBound, off_lowleft_x = m_iInnerBound, off_upright_x = ScreenWidth() - m_iInnerBound - card_w, off_lowright_x = ScreenWidth() - m_iInnerBound - card_w; vgui::HFont text_font = scheme()->GetIScheme( GetScheme() )->GetFont("GETargetID", true); for ( int i=0; i < m_vObjectives.Count(); i++ ) { GEObjective *obj = m_vObjectives[i]; Vector screen; Vector objAbsPos; // Calculate the current position based off of interpolation VectorLerp(obj->last_pos, obj->curr_pos, (gpGlobals->curtime - obj->update_time) / RADAR_THINK_INT, objAbsPos ); // This lets us mess with the objective position without losing our "real" position Vector objPos = objAbsPos; int x = 0, y = 0; float theta = 0; CBaseEntity *pEnt = obj->hEnt.Get(); if ( pEnt ) { // If we aren't dormant use our known position if ( !pEnt->IsDormant() ) { // Try to get our NPC's position if we are really a bot C_GEBotPlayer *pBot = ToGEBotPlayer( pEnt ); if ( pBot && pBot->GetNPC() ) objPos = pBot->GetNPC()->GetAbsOrigin(); else objPos = pEnt->GetAbsOrigin(); } // Add our collision box which (usually) surrounds the entire entity float height = pEnt->CollisionProp()->OBBMaxs().z; // Add additional z for player specific reasons if ( pEnt->IsPlayer() ) objPos.z += height + ToGEPlayer(pEnt)->GetHeadOffset(); else objPos.z += max( height, 40.0f ); } // Calculate parameters Vector toEye = objPos - myEyePos; float dist = toEye.Length(); // Check out min distance parameter float alpha_mod = 1.0f; if ( obj->min_dist > 0 ) alpha_mod = RemapValClamped( dist, obj->min_dist, obj->min_dist + 80, 0, 1.0f ); if ( alpha_mod == 0 ) continue; // Find where on the screen to draw the indicator // Note: we don't draw it behind us if we are really close bool behind = ScreenTransform( objPos, screen ) && dist > OBJ_ABS_MIN_DIST; if ( !behind && screen.x > -1.0 && screen.x < 1.0 ) { x = half_w + screen.x*half_w - card_w/2; y = half_h - screen.y*half_h - card_h; // We are off-screen vertically, flip the card if ( screen.y > 1.0 ) theta = M_PI; } else { bool onLeft = screen.x < 0; // Calculate a new position for our object to make it "on-screen" at the same height Vector forward; pPlayer->EyeVectors( &forward ); Vector newPos; VectorMA( myEyePos, dist, forward, newPos ); newPos.z = objPos.z; if ( abs(toEye.z) > 100.0f ) newPos.z += toEye.z; //debugoverlay->AddBoxOverlay( newPos, Vector(-5), Vector(5), vec3_angle, 255, 0, 0, 200, gpGlobals->frametime ); // Find our new screen coordinates ScreenTransform( newPos, screen ); if ( screen.y > 0.97f ) { // The obj is above us and off-screen y = m_iInnerBound; if ( onLeft ) { x = off_upleft_x; theta = 0.75 * M_PI; off_upleft_x += card_w + buffer; } else { x = off_upright_x; theta = 1.25 * M_PI; off_upright_x -= card_w + buffer; } } else if ( screen.y < -0.97f ) { // The obj is below us and off-screen y = ScreenHeight() - m_iInnerBound; if ( onLeft ) { x = off_lowleft_x; theta = 0.25 * M_PI; off_lowleft_x += card_w + buffer; } else { x = off_lowright_x; theta = -0.25 * M_PI; off_lowright_x -= card_w + buffer; } } else { // The obj is "on-screen" and level with us if ( onLeft ) { x = m_iInnerBound; y = half_h - screen.y*half_h; theta = M_HALFPI; } else { x = ScreenWidth() - m_iInnerBound - card_w; y = half_h - screen.y*half_h; theta = -M_HALFPI; } } } // Default color is white Color c = obj->color; if ( c.a() == 0 ) c = Color( 255, 255, 255, 120 ); // Apply alpha mod if ( (!behind && screen.x > -1.0 && screen.x < 1.0) ) c[3] *= alpha_mod; // Bound our results x = clamp( x, m_iInnerBound, ScreenWidth() - m_iInnerBound - card_w ); y = clamp( y, m_iInnerBound, ScreenHeight() - m_iInnerBound - card_h ); // Draw text (if defined) before applying pulse so we don't affect it's color if ( obj->text[0] ) { // This is where we clamp the size to 16 int txtX, txtY; txtX = clamp( (x + card_w/2) - obj->txtW/2, XRES(3), ScreenWidth() - obj->txtW - XRES(3) ); txtY = y - obj->txtH - YRES(3); if ( txtY < 0 ) txtY = y + card_h + YRES(3); surface()->DrawSetTextColor( c ); surface()->DrawSetTextFont( text_font ); surface()->DrawSetTextPos( txtX, txtY ); surface()->DrawUnicodeString( obj->text ); } // Apply Pulse if ( obj->pulse ) { float blink = SmoothCurve( obj->pulse_mod ); c[0] = c[0] + (blink * (255-c[0]) * 0.15f); c[1] = c[1] + (blink * (255-c[1]) * 0.15f); c[2] = c[2] + (blink * (255-c[2]) * 0.15f); // Modulate the blink obj->pulse_mod += 1.2f * gpGlobals->frametime; if ( obj->pulse_mod > 1.0f ) obj->pulse_mod -= 1.0f; } m_pCardTexture->DrawSelfRotated( x, y, card_w, card_h, theta, c ); } }
void C_PropVehicleDriveable::DrawHudElements( ) { CHudTexture *pIcon; int iIconX, iIconY; if (m_bHasGun) { // draw crosshairs for vehicle gun pIcon = gHUD.GetIcon( "gunhair" ); if ( pIcon != NULL ) { float x, y; if( UseVR() ) { C_BasePlayer *pPlayer = (C_BasePlayer *)GetPassenger( VEHICLE_ROLE_DRIVER ); Vector vecStart, vecDirection; pPlayer->EyePositionAndVectors( &vecStart, &vecDirection, NULL, NULL ); Vector vecEnd = vecStart + vecDirection * MAX_TRACE_LENGTH; trace_t tr; UTIL_TraceLine( vecStart, vecEnd, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); Vector screen; screen.Init(); ScreenTransform(tr.endpos, screen); int vx, vy, vw, vh; vgui::surface()->GetFullscreenViewport( vx, vy, vw, vh ); float screenWidth = vw; float screenHeight = vh; x = 0.5f * ( 1.0f + screen[0] ) * screenWidth + 0.5f; y = 0.5f * ( 1.0f - screen[1] ) * screenHeight + 0.5f; } else { Vector screen; x = ScreenWidth()/2; y = ScreenHeight()/2; #if TRIANGULATED_CROSSHAIR ScreenTransform( m_vecGunCrosshair, screen ); x += 0.5 * screen[0] * ScreenWidth() + 0.5; y -= 0.5 * screen[1] * ScreenHeight() + 0.5; #endif } x -= pIcon->Width() / 2; y -= pIcon->Height() / 2; Color clr = ( m_bUnableToFire ) ? gHUD.m_clrCaution : gHUD.m_clrNormal; pIcon->DrawSelf( x, y, clr ); } if ( m_nScannerDisabledWeapons ) { // Draw icons for scanners "weps disabled" pIcon = gHUD.GetIcon( "dmg_bio" ); if ( pIcon ) { iIconY = 467 - pIcon->Height() / 2; iIconX = 385; if ( !m_bScannerWepIcon ) { pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, 255, 255 ) ); m_bScannerWepIcon = true; m_iScannerWepFlashTimer = 0; m_bScannerWepDim = true; } else { pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, GetFlashColorIntensity(55, 255, m_bScannerWepDim, 10, m_iScannerWepFlashTimer), 255 ) ); m_iScannerWepFlashTimer++; m_iScannerWepFlashTimer %= 20; if(!m_iScannerWepFlashTimer) m_bScannerWepDim ^= 1; } } } } if ( m_nScannerDisabledVehicle ) { // Draw icons for scanners "vehicle disabled" pIcon = gHUD.GetIcon( "dmg_bio" ); if ( pIcon ) { iIconY = 467 - pIcon->Height() / 2; iIconX = 410; if ( !m_bScannerVehicleIcon ) { pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, 255, 255 ) ); m_bScannerVehicleIcon = true; m_iScannerVehicleFlashTimer = 0; m_bScannerVehicleDim = true; } else { pIcon->DrawSelf( XRES(iIconX), YRES(iIconY), Color( 0, 0, GetFlashColorIntensity(55, 255, m_bScannerVehicleDim, 10, m_iScannerVehicleFlashTimer), 255 ) ); m_iScannerVehicleFlashTimer++; m_iScannerVehicleFlashTimer %= 20; if(!m_iScannerVehicleFlashTimer) m_bScannerVehicleDim ^= 1; } } } }
//--------------------------------------------------------- // Purpose: Draw the radar panel. // We're probably doing too much other work in here //--------------------------------------------------------- void CGERadar::Paint() { // Check to make sure we loaded our icons if ( !m_Background ) Init(); // Draw the radar background. int bgAlpha = 225; if ( C_BasePlayer::GetLocalPlayer() && C_BasePlayer::GetLocalPlayer()->IsObserver() ) bgAlpha = 255; m_Background->DrawSelf(m_iSideBuff, m_iSideBuff, m_flRadarDiameter, m_flRadarDiameter, Color(255,255,255,bgAlpha)); // Now go through the list of radar targets and represent them on the radar screen // by drawing their icons on top of the background. for( int i = 0 ; i < m_iNumContacts ; i++ ) { int alpha = 140; CGERadarContact *pContact = &m_radarContacts[ i ]; Color col( 255, 255, 255, 255 ); if ( pContact->m_iType == RADAR_TYPE_PLAYER ) { // Players default to DM color col.SetRawColor( s_ColorDM.GetRawColor() ); if ( GEMPRules()->IsTeamplay() ) { CBasePlayer *pLocalPlayer = CBasePlayer::GetLocalPlayer(); int team = GEPlayerRes()->GetTeam( pContact->GetEntindex() ); // Set the color to their team if ( team == TEAM_MI6 ) col.SetRawColor( s_ColorMI6.GetRawColor() ); else col.SetRawColor( s_ColorJanus.GetRawColor() ); // Enemies are higher opacity so they stand out if ( team != pLocalPlayer->GetTeamNumber() ) alpha = 200; } else { // Calculate our display for campers (only non-teamplay!) if ( pContact->m_iCampingPercent > 0 ) { alpha = RemapValClamped( pContact->m_iCampingPercent, 0, RADAR_CAMP_ALLVIS_PERCENT, alpha, 255 ); if ( pContact->m_iCampingPercent > RADAR_CAMP_ALLVIS_PERCENT ) { // Make the dot more intensely colored green float blink = SmoothCurve( pContact->m_flBlinkMod ); col[1] = col[1] + blink * (255-col[1]); // Modulate the blink pContact->m_flBlinkMod += 0.5f * gpGlobals->frametime; if ( pContact->m_flBlinkMod > 1.0f ) pContact->m_flBlinkMod = 0; } } else { pContact->m_flBlinkMod = 0; } } } col[3] = alpha; // If we have an override color make sure we display it instead of the above if ( pContact->m_ColorOverride[3] != 0 ) col = pContact->m_ColorOverride; DrawIconOnRadar( pContact, col ); } }
//--------------------------------------------------------- // Purpose: Compute the proper position on the radar screen // for this object's position relative to the player. // Then draw the icon in the proper location on the // radar screen. //--------------------------------------------------------- void CGERadar::DrawIconOnRadar( CGERadarContact *contact, Color col ) { float x = contact->m_vScaledPos.x, y = contact->m_vScaledPos.y, z_delta = contact->m_vScaledPos.z; int width, height; float floorheight = GEMPRules()->GetMapFloorHeight(); // Get the correct icon for this type of contact CHudTexture *icon = NULL; if ( contact->m_Icon ) { // We have a custom icon! if (z_delta > floorheight && contact->m_IconAbove) icon = contact->m_IconAbove; else if (z_delta < floorheight * -1 && contact->m_IconBelow) icon = contact->m_IconBelow; else icon = contact->m_Icon; width = max( icon->EffectiveWidth(m_flScaleX), 16 ); height = max( icon->EffectiveHeight(m_flScaleY), 16 ); } else if ( contact->m_iType == RADAR_TYPE_TOKEN ) { if ( z_delta > floorheight ) icon = m_IconTokenAbove; else if ( z_delta < floorheight * -1 ) icon = m_IconTokenBelow; else icon = m_IconToken; width = max( icon->EffectiveWidth(m_flScaleX), 8 ); height = max( icon->EffectiveHeight(m_flScaleY), 8 ); } else { if ( z_delta > floorheight ) icon = m_IconBlipAbove; else if ( z_delta < floorheight * -1 ) icon = m_IconBlipBelow; else icon = m_IconBlip; width = max( icon->EffectiveWidth(m_flScaleX), 8 ); height = max( icon->EffectiveHeight(m_flScaleY), 8 ); } // Double check we are inside the radar bounds if ( x >= m_iSideBuff && y >= m_iSideBuff ) { // Center the icon around its position. x -= (width >> 1); y -= (height >> 1); vgui::surface()->DrawSetColor( col[0], col[1], col[2], col[3]*contact->m_flAlphaMod ); vgui::surface()->DrawSetTexture( icon->textureId ); vgui::surface()->DrawTexturedRect(x, y, x + width, y + height); }
void CHUDQuickInfo::Paint() { C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); if ( player == NULL ) return; C_BaseCombatWeapon *pWeapon = GetActiveWeapon(); if ( pWeapon == NULL ) return; float fX, fY; bool bBehindCamera = false; CHudCrosshair::GetDrawPosition( &fX, &fY, &bBehindCamera ); // if the crosshair is behind the camera, don't draw it if( bBehindCamera ) return; // int xCenter = ( ScreenWidth() - m_icon_c->Width() ) / 2; // int yCenter = ( ScreenHeight() - m_icon_c->Height() ) / 2; int xCenter = (int)fX - m_icon_c->Width() / 2; int yCenter = (int)fY - m_icon_c->Height() / 2; float scalar = 255.0f/255.0f; //138.0f/255.0f; // m_icon_c->DrawSelf( xCenter, yCenter, clrNormal ); // adjust center for the bigger crosshairs // xCenter = ScreenWidth() / 2; // yCenter = ( ScreenHeight() - m_icon_full->Height() ) / 2; Color clrNormal = gHUD.m_clrNormal; clrNormal[3] = 255 * scalar; if( IsX360() ) { // Because the fixed reticle draws on half-texels, this rather unsightly hack really helps // center the appearance of the quickinfo on 360 displays. xCenter += 1; } if ( !hud_quickinfo.GetInt() ) return; int sinScale = (int)( fabs(sin(gpGlobals->curtime*8.0f)) * 128.0f ); Color XhairColor = m_warnXhair ? gHUD.m_clrNormal : gHUD.m_clrNormal;; if ( m_warnXhair ) { XhairColor[3] = 255 * sinScale; } else { XhairColor[3] = 255 * scalar; } if (quickinfo_dynamic.GetBool()) { //ConVar *c_puntgun_highlight= cvar->FindVar( "c_puntgun_highlight" ); if (c_puntgun_highlight.GetBool()) { gHUD.DrawIconProgressBar( xCenter - (m_icon_full->Width() - hud_quickinfo_alignment.GetInt()), yCenter, m_icon_full, m_icon_empty, ( 1.0f - 100.0f ), XhairColor, CHud::HUDPB_VERTICAL ); //gHUD.DrawIconProgressBar( xCenter - (m_icon_lb->Width() * 2), yCenter, m_icon_lb, m_icon_lbe, ( 1.0f - 100.0f ), XhairColor, CHud::HUDPB_VERTICAL ); //gHUD.DrawIconProgressBar( xCenter + m_icon_rb->Width(), yCenter, m_icon_rb, m_icon_rbe, ( 1.0f - 100.0f ), XhairColor, CHud::HUDPB_VERTICAL ); } else { gHUD.DrawIconProgressBar( xCenter - (m_icon_full->Width() - hud_quickinfo_alignment.GetInt()), yCenter, m_icon_full, m_icon_empty, ( 1.0f - 0.0f ), XhairColor, CHud::HUDPB_VERTICAL ); //gHUD.DrawIconProgressBar( xCenter - (m_icon_lb->Width() * 2), yCenter, m_icon_lb, m_icon_lbe, ( 1.0f - 0.0f ), XhairColor, CHud::HUDPB_VERTICAL ); //gHUD.DrawIconProgressBar( xCenter + m_icon_rb->Width(), yCenter, m_icon_rb, m_icon_rbe, ( 1.0f - 0.0f ), XhairColor, CHud::HUDPB_VERTICAL ); } } else { gHUD.DrawIconProgressBar( xCenter - (m_icon_full->Width() - hud_quickinfo_alignment.GetInt()), yCenter, m_icon_full, m_icon_empty, ( 1.0f - 100.0f ), XhairColor, CHud::HUDPB_VERTICAL ); //gHUD.DrawIconProgressBar( xCenter - (m_icon_lb->Width() * 2), yCenter, m_icon_lb, m_icon_lbe, ( 1.0f - 100.0f ), XhairColor, CHud::HUDPB_VERTICAL ); //gHUD.DrawIconProgressBar( xCenter + m_icon_rb->Width(), yCenter, m_icon_rb, m_icon_rbe, ( 1.0f - 100.0f ), XhairColor, CHud::HUDPB_VERTICAL ); } }
void CHUDQuickInfo::Paint() { //BB: KILL THIS CRAP! return; C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); if ( player == NULL ) return; C_BaseCombatWeapon *pWeapon = GetActiveWeapon(); if ( pWeapon == NULL ) return; float fX, fY; bool bBehindCamera = false; CHudCrosshair::GetDrawPosition( &fX, &fY, &bBehindCamera ); // if the crosshair is behind the camera, don't draw it if( bBehindCamera ) return; int xCenter = (int)fX; int yCenter = (int)fY - m_icon_lb->Height() / 2; float scalar = 138.0f/255.0f; // Check our health for a warning int health = player->GetHealth(); if ( health != m_lastHealth ) { UpdateEventTime(); m_lastHealth = health; if ( health <= HEALTH_WARNING_THRESHOLD ) { if ( m_warnHealth == false ) { m_healthFade = 255; m_warnHealth = true; CLocalPlayerFilter filter; C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, "HUDQuickInfo.LowHealth" ); } } else { m_warnHealth = false; } } // Check our ammo for a warning int ammo = pWeapon->Clip1(); if ( ammo != m_lastAmmo ) { UpdateEventTime(); m_lastAmmo = ammo; // Find how far through the current clip we are float ammoPerc = (float) ammo / (float) pWeapon->GetMaxClip1(); // Warn if we're below a certain percentage of our clip's size if (( pWeapon->GetMaxClip1() > 1 ) && ( ammoPerc <= ( 1.0f - CLIP_PERC_THRESHOLD ))) { if ( m_warnAmmo == false ) { m_ammoFade = 255; m_warnAmmo = true; CLocalPlayerFilter filter; C_BaseEntity::EmitSound( filter, SOUND_FROM_LOCAL_PLAYER, "HUDQuickInfo.LowAmmo" ); } } else { m_warnAmmo = false; } } Color clrNormal = gHUD.m_clrNormal; clrNormal[3] = 255 * scalar; m_icon_c->DrawSelf( xCenter, yCenter, clrNormal ); if( IsX360() ) { // Because the fixed reticle draws on half-texels, this rather unsightly hack really helps // center the appearance of the quickinfo on 360 displays. xCenter += 1; } if ( !hud_quickinfo.GetInt() ) return; int sinScale = (int)( fabs(sin(gpGlobals->curtime*8.0f)) * 128.0f ); // Update our health if ( m_healthFade > 0.0f ) { DrawWarning( xCenter - (m_icon_lb->Width() * 2), yCenter, m_icon_lb, m_healthFade ); } else { float healthPerc = (float) health / 100.0f; healthPerc = clamp( healthPerc, 0.0f, 1.0f ); Color healthColor = m_warnHealth ? gHUD.m_clrCaution : gHUD.m_clrNormal; if ( m_warnHealth ) { healthColor[3] = 255 * sinScale; } else { healthColor[3] = 255 * scalar; } gHUD.DrawIconProgressBar( xCenter - (m_icon_lb->Width() * 2), yCenter, m_icon_lb, m_icon_lbe, ( 1.0f - healthPerc ), healthColor, CHud::HUDPB_VERTICAL ); } // Update our ammo if ( m_ammoFade > 0.0f ) { DrawWarning( xCenter + m_icon_rb->Width(), yCenter, m_icon_rb, m_ammoFade ); } else { float ammoPerc; if ( pWeapon->GetMaxClip1() <= 0 ) { ammoPerc = 0.0f; } else { ammoPerc = 1.0f - ( (float) ammo / (float) pWeapon->GetMaxClip1() ); ammoPerc = clamp( ammoPerc, 0.0f, 1.0f ); } Color ammoColor = m_warnAmmo ? gHUD.m_clrCaution : gHUD.m_clrNormal; if ( m_warnAmmo ) { ammoColor[3] = 255 * sinScale; } else { ammoColor[3] = 255 * scalar; } gHUD.DrawIconProgressBar( xCenter + m_icon_rb->Width(), yCenter, m_icon_rb, m_icon_rbe, ammoPerc, ammoColor, CHud::HUDPB_VERTICAL ); } }
void CHudAmmo::Paint() { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return; if (!pPlayer->IsAlive()) return; if (!pPlayer->GetActiveSDKWeapon()) return; int iWidth, iHeight; GetSize(iWidth, iHeight); float flScale = 480.0f/(float)iHeight * hud_ammoscale.GetFloat(); int iGrenades = 0; int iTotalGrenades = GetAmmoDef()->MaxCarry(GetAmmoDef()->Index("grenades")); if (pPlayer->m_Shared.m_iStyleSkill != SKILL_TROLL) iTotalGrenades = ConVarRef("da_max_grenades").GetInt(); CWeaponSDKBase* pGrenade = pPlayer->FindWeapon(SDK_WEAPON_GRENADE); if (pGrenade) iGrenades = pPlayer->GetAmmoCount(pGrenade->GetPrimaryAmmoType()); if (m_pGrenadeIcon) { for (int i = 0; i < iGrenades; i++) { Vector4D vecGrenade = GetGrenadePosition(i); m_pGrenadeIcon->DrawSelf(vecGrenade.x, vecGrenade.y, vecGrenade.z, vecGrenade.w, Color(255, 255, 255, 255)); } } if (m_pGrenadeEmptyIcon) { for (int i = iGrenades; i < iTotalGrenades; i++) { Vector4D vecGrenade = GetGrenadePosition(i); m_pGrenadeEmptyIcon->DrawSelf(vecGrenade.x, vecGrenade.y, vecGrenade.z, vecGrenade.w, Color(255, 255, 255, 255)); } } if (pPlayer->UseVRHUD()) return; CHudTexture* pTexture = GetTexture(); if (!pTexture) return; for (int i = 0; i < m_iAmmo; i++) { Vector2D vecRound = GetRoundPosition(i); pTexture->DrawSelf( vecRound.x, vecRound.y, GetTextureDrawWidth(pTexture, flScale), GetTextureDrawHeight(pTexture, flScale), Color(255, 255, 255, 255) ); } float flFrameTime = gpGlobals->frametime * pPlayer->GetSlowMoMultiplier(); for (int i = 0; i < m_aRounds.Count(); i++) { CFlyingRound& oRound = m_aRounds[i]; if (!oRound.bActive) continue; if (oRound.vecPosition.y > iHeight+1000) { oRound.bActive = false; continue; } if (!oRound.pTexture) { oRound.bActive = false; continue; } oRound.vecPosition += flFrameTime * oRound.vecVelocity; oRound.vecVelocity.y += flFrameTime * 2000; oRound.flAngle += flFrameTime * oRound.flAngularVelocity; SDKViewport::DrawPolygon(oRound.pTexture, oRound.vecPosition.x, oRound.vecPosition.y, GetTextureDrawWidth(oRound.pTexture, flScale), GetTextureDrawHeight(oRound.pTexture, flScale), oRound.flAngle); } wchar_t* pszActivate = g_pVGuiLocalize->Find("#DA_HUD_Ammo_Reload"); if (pszActivate && m_iAmmo == 0 && !pPlayer->GetActiveSDKWeapon()->m_bInReload) { #define WSTRLEN 512 // replace any key references with bound keys wchar_t wszHintLabel[WSTRLEN]; UTIL_ReplaceKeyBindings( pszActivate, 0, wszHintLabel, sizeof( wszHintLabel ) ); int iTextWide, iTextTall; surface()->GetTextSize( m_hHintFont, wszHintLabel, iTextWide, iTextTall ); int iWidth, iHeight; GetSize(iWidth, iHeight); float flRightPadding = scheme()->GetProportionalScaledValueEx(GetScheme(), 40); float flBottomPadding = scheme()->GetProportionalScaledValueEx(GetScheme(), 40); surface()->DrawSetTextPos( iWidth - iTextWide - flRightPadding, iHeight - flBottomPadding - iTextTall ); surface()->DrawSetTextColor( Color(255, 0, 0, Oscillate(gpGlobals->curtime, 1)*255) ); surface()->DrawSetTextFont( m_hHintFont ); surface()->DrawUnicodeString( wszHintLabel, vgui::FONT_DRAW_NONADDITIVE ); }}
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CHudDeathNotice::Paint() { int x, y; surface()->DrawSetTextFont( m_hTextFont ); surface()->DrawSetTextColor( m_clrText ); for ( int i = 0; i < MAX_DEATHNOTICES; i++ ) { // we've gone through them all if ( rgDeathNoticeList[i].iconDeath == NULL ) break; // display time has expired // remove the current item from the list if ( rgDeathNoticeList[i].flDisplayTime < gpGlobals->curtime ) { Q_memmove( &rgDeathNoticeList[i], &rgDeathNoticeList[i+1], sizeof(DeathNoticeItem) * (MAX_DEATHNOTICES - i) ); // continue on the next item; stop the counter getting incremented i--; continue; } rgDeathNoticeList[i].flDisplayTime = MIN( rgDeathNoticeList[i].flDisplayTime, gpGlobals->curtime + DEATHNOTICE_DISPLAY_TIME ); // Draw the death notice y = DEATHNOTICE_TOP + (20 * i) + 100; //!!! CHudTexture *icon = rgDeathNoticeList[i].iconDeath; if ( !icon ) continue; wchar_t victim[ 256 ]; wchar_t killer[ 256 ]; g_pVGuiLocalize->ConvertANSIToUnicode( rgDeathNoticeList[i].szVictim, victim, sizeof( victim ) ); g_pVGuiLocalize->ConvertANSIToUnicode( rgDeathNoticeList[i].szKiller, killer, sizeof( killer ) ); int len = UTIL_ComputeStringWidth( m_hTextFont, victim ); x = ScreenWidth() - len - icon->Width() - 5; if ( !rgDeathNoticeList[i].iSuicide ) { int lenkiller = UTIL_ComputeStringWidth( m_hTextFont, killer ); x -= (5 + lenkiller ); // Draw killer's name surface()->DrawSetTextPos( x, y ); surface()->DrawUnicodeString( killer ); surface()->DrawGetTextPos( x, y ); x += 5; } Color iconColor( 255, 80, 0, 255 ); if ( rgDeathNoticeList[i].iTeamKill ) { // display it in sickly green iconColor = Color( 10, 240, 10, 255 ); } // Draw death weapon icon->DrawSelf( x, y, iconColor ); x += icon->Width(); // Draw victims name surface()->DrawSetTextPos( x, y ); surface()->DrawUnicodeString( victim ); } }
int CDODDeathStatsPanel::DrawDeathNoticeItem( int x, int y ) { // Get the team numbers for the players involved int iKillerTeam = TEAM_UNASSIGNED; int iVictimTeam = TEAM_UNASSIGNED; if( g_PR ) { iKillerTeam = g_PR->GetTeam( m_DeathRecord.Killer.iEntIndex ); iVictimTeam = g_PR->GetTeam( m_DeathRecord.Victim.iEntIndex ); } wchar_t victim[ 256 ]; wchar_t killer[ 256 ]; g_pVGuiLocalize->ConvertANSIToUnicode( m_DeathRecord.Victim.szName, victim, sizeof( victim ) ); g_pVGuiLocalize->ConvertANSIToUnicode( m_DeathRecord.Killer.szName, killer, sizeof( killer ) ); // Get the local position for this notice int len = UTIL_ComputeStringWidth( m_hTextFont, victim ); int iconWide; int iconTall; CHudTexture *icon = m_DeathRecord.iconDeath; Assert( icon ); if ( !icon ) return 0; if( icon->bRenderUsingFont ) { iconWide = surface()->GetCharacterWidth( icon->hFont, icon->cCharacterInFont ); iconTall = surface()->GetFontTall( icon->hFont ); } else { float scale = GetScale( icon->Width(), icon->Height(), XRES(cl_deathicon_width.GetInt()), YRES(cl_deathicon_height.GetInt()) ); iconWide = (int)( scale * (float)icon->Width() ); iconTall = (int)( scale * (float)icon->Height() ); } int spacerX = XRES(5); //int x = xRight - len - spacerX - iconWide - XRES(10); surface()->DrawSetTextFont( m_hTextFont ); int iFontTall = vgui::surface()->GetFontTall( m_hTextFont ); int yText = y + ( iconTall - iFontTall ) / 2; int boxWidth = len + iconWide + spacerX; int boxHeight = min( iconTall, m_flLineHeight ); int boxBorder = XRES(2); // Only draw killers name if it wasn't a suicide if ( !m_DeathRecord.bSuicide ) { int nameWidth = UTIL_ComputeStringWidth( m_hTextFont, killer ) + spacerX; // gap //x -= nameWidth; boxWidth += nameWidth; Panel::DrawBox( x-boxBorder, y-boxBorder, boxWidth+2*boxBorder, boxHeight+2*boxBorder, m_ActiveBackgroundColor, 1.0 ); Color c = g_PR->GetTeamColor( iKillerTeam ); surface()->DrawSetTextColor( c ); // Draw killer's name surface()->DrawSetTextPos( x, yText ); const wchar_t *p = killer; while ( *p ) { surface()->DrawUnicodeChar( *p++ ); } surface()->DrawGetTextPos( x, yText ); x += spacerX; } else { Panel::DrawBox( x-boxBorder, y-boxBorder, boxWidth+2*boxBorder, boxHeight+2*boxBorder, m_ActiveBackgroundColor, 1.0 ); } Color iconColor( 255, 80, 0, 255 ); // Draw death weapon //If we're using a font char, this will ignore iconTall and iconWide icon->DrawSelf( x, y, iconWide, iconTall, iconColor ); x += iconWide + spacerX; Color c = g_PR->GetTeamColor( iVictimTeam ); surface()->DrawSetTextColor( c ); // Draw victims name surface()->DrawSetTextFont( m_hTextFont ); //reset the font, draw icon can change it surface()->DrawSetTextPos( x, yText ); const wchar_t *p = victim; while ( *p ) { surface()->DrawUnicodeChar( *p++ ); } return boxWidth; }
void CHudStyleBar::Paint() { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return; if (!pPlayer->IsAlive()) return; for (int i = 0; i < TOTAL_ANNOUNCEMENTS; i++) { if (!m_apAnnouncements[i]) m_apAnnouncements[i] = gHUD.GetIcon(g_apszAnnouncementTextures[i]); } if (!m_apActiveSkillIcons[SKILL_BOUNCER]) { m_apActiveSkillIcons[SKILL_BOUNCER] = gHUD.GetIcon("bouncer"); m_apActiveSkillIcons[SKILL_ATHLETIC] = gHUD.GetIcon("athletic"); m_apActiveSkillIcons[SKILL_REFLEXES] = gHUD.GetIcon("reflexes"); m_apActiveSkillIcons[SKILL_MARKSMAN] = gHUD.GetIcon("marksman"); m_apActiveSkillIcons[SKILL_TROLL] = gHUD.GetIcon("troll"); m_apActiveSkillIcons[SKILL_SUPER] = gHUD.GetIcon("super"); //m_apActiveSkillIcons[SKILL_RESILIENT] = gHUD.GetIcon("resilient"); m_pGoldStar = gHUD.GetIcon("star_gold"); m_pSilverStar = gHUD.GetIcon("star_silver"); m_pBronzeStar = gHUD.GetIcon("star_bronze"); m_pBriefcase = gHUD.GetIcon("briefcase"); } CHudTexture* pStyleTexture = m_apActiveSkillIcons[pPlayer->m_Shared.m_iStyleSkill]; if (pPlayer->m_Shared.m_bSuperSkill || SDKGameRules()->GetBountyPlayer() == pPlayer) pStyleTexture = m_apActiveSkillIcons[SKILL_SUPER]; float flStyleTextureWidth = 0; float flStyleTextureHeight = 0; if (pStyleTexture) { flStyleTextureWidth = scheme()->GetProportionalScaledValueEx(GetScheme(), pStyleTexture->EffectiveWidth(0.5f)) * 0.8f; flStyleTextureHeight = scheme()->GetProportionalScaledValueEx(GetScheme(), pStyleTexture->EffectiveHeight(0.5f)) * 0.8f; } int iWidth = m_flElementWide; int iHeight = m_flElementTall; int flScreenWide, flScreenTall; surface()->GetScreenSize(flScreenWide, flScreenTall); float flBarLeft = m_flElementXPos + iWidth - flStyleTextureWidth/2 - m_flBarWidth/2; surface()->DrawSetColor( Color(0, 0, 0, 100) ); surface()->DrawFilledRect( flBarLeft, m_flElementYPos, m_flElementXPos + iWidth - flStyleTextureWidth/2 + m_flBarWidth/2, m_flElementYPos + iHeight - flStyleTextureHeight - m_flGap ); Color clrActivated = Color(255, 190, 20, 255); Color clrNormal = Color(170, 140, 33, 255); Color clrZeroStyle = Color(100, 100, 100, 255); wchar_t* pwszStyle = L"Style!"; if (pPlayer->IsStyleSkillActive()) pwszStyle = g_pVGuiLocalize->Find("#DA_Style_Active"); else if (m_flCurrentStyle/da_stylemeteractivationcost.GetFloat() > 0.6) pwszStyle = g_pVGuiLocalize->Find("#DA_Style_High"); else if (m_flCurrentStyle/da_stylemeteractivationcost.GetFloat() > 0.3) pwszStyle = g_pVGuiLocalize->Find("#DA_Style_Med"); else pwszStyle = g_pVGuiLocalize->Find("#DA_Style_Low"); if (!pwszStyle) pwszStyle = L"Style!"; int iStyleTextWide, iStyleTextTall; surface()->GetTextSize(m_hStyleFont, pwszStyle, iStyleTextWide, iStyleTextTall); Color clrStyleText; if (pPlayer->IsStyleSkillActive()) clrStyleText = Color( RemapValClamped(Oscillate(gpGlobals->curtime, 1), 0, 1, clrActivated.r(), clrNormal.r()), RemapValClamped(Oscillate(gpGlobals->curtime, 1), 0, 1, clrActivated.g(), clrNormal.g()), RemapValClamped(Oscillate(gpGlobals->curtime, 1), 0, 1, clrActivated.b(), clrNormal.b()), 255); else clrStyleText = Color( RemapValClamped(m_flCurrentStyle, 0, da_stylemeteractivationcost.GetFloat(), clrZeroStyle.r(), clrNormal.r()), RemapValClamped(m_flCurrentStyle, 0, da_stylemeteractivationcost.GetFloat(), clrZeroStyle.g(), clrNormal.g()), RemapValClamped(m_flCurrentStyle, 0, da_stylemeteractivationcost.GetFloat(), clrZeroStyle.b(), clrNormal.b()), 255); vgui::surface()->DrawSetTextFont( m_hStyleFont ); vgui::surface()->DrawSetTextPos( flBarLeft + m_flBarWidth/2 - iStyleTextWide/2, m_flElementYPos - iStyleTextTall ); vgui::surface()->DrawSetTextColor( clrStyleText ); vgui::surface()->DrawPrintText( pwszStyle, wcslen(pwszStyle) ); Color clrBar; if (pPlayer->IsStyleSkillActive()) { clrBar = clrActivated; clrBar.SetColor(clrBar.r(), clrBar.g(), clrBar.b(), RemapValClamped(Gain(Oscillate(gpGlobals->curtime, 1), 0.7f), 0, 1, 0.1f, 1)*255); } else { int r = Lerp(m_flCurrentStyle/da_stylemeteractivationcost.GetFloat(), clrNormal.r()/2, clrNormal.r()); int g = Lerp(m_flCurrentStyle/da_stylemeteractivationcost.GetFloat(), clrNormal.g()/2, clrNormal.g()); int b = Lerp(m_flCurrentStyle/da_stylemeteractivationcost.GetFloat(), clrNormal.b()/2, clrNormal.b()); clrBar.SetColor(r, g, b, clrNormal.a()); } surface()->DrawSetColor( clrBar ); float flPercent; if (pPlayer->IsStyleSkillActive()) flPercent = min(pPlayer->GetStyleSkillCharge() / 100, 1); else flPercent = m_flCurrentStyle / da_stylemeteractivationcost.GetFloat(); float flBarHeight = iHeight - flStyleTextureHeight - m_flGap*2; int iBarLeft = m_flElementXPos + iWidth - flStyleTextureWidth/2 - m_flBarWidth/2 + m_flGap; int iBarRight = m_flElementXPos + iWidth - flStyleTextureWidth/2 + m_flBarWidth/2 - m_flGap; surface()->DrawFilledRect( iBarLeft, m_flElementYPos + m_flGap + flBarHeight*(1-flPercent), iBarRight, m_flElementYPos + flBarHeight ); float flPulseTime = 0.6f; float flAlphaRamp = RemapValClamped(fmod(gpGlobals->curtime, flPulseTime), 0, flPulseTime, 0, 1); int iPulseAlpha = RemapValClamped(Bias(flAlphaRamp, 0.1f), 0, flPulseTime, 50, 10); surface()->DrawSetColor( Color(255, 255, 255, iPulseAlpha) ); float flWidth = 0.1f; float flBottom = RemapValClamped(fmod(gpGlobals->curtime, flPulseTime), 0, flPulseTime, -flWidth, 1); float flTop = flBottom + flWidth; flBottom = clamp(flBottom, 0, flPercent); flTop = clamp(flTop, 0, flPercent); surface()->DrawFilledRect( iBarLeft + 2, m_flElementYPos + m_flGap + flBarHeight*(1-flTop), iBarRight - 2, m_flElementYPos + flBarHeight*(1-flBottom) ); if (pStyleTexture) { float flAlpha = 1; float flNonRed = 0; float flRed = 0; if (pPlayer->IsStyleSkillActive()) { flAlpha = RemapValClamped(Gain(Oscillate(gpGlobals->curtime, 1), 0.7f), 0, 1, 0.5f, 1); flNonRed = Gain(1-Oscillate(gpGlobals->curtime, 1), 0.7f); flRed = 1; } float flBarIconX = m_flElementXPos + iWidth - flStyleTextureWidth; float flBarIconY = m_flElementYPos + iHeight - flStyleTextureHeight; pStyleTexture->DrawSelf( flBarIconX, flBarIconY, flStyleTextureWidth, flStyleTextureHeight, Color( Lerp(flRed, 255, clrActivated.r()), Lerp(flNonRed, 255, clrActivated.g()), Lerp(flNonRed, 255, clrActivated.b()), 255*flAlpha ) ); float flIconXPos = GetIconX(); float flIconYPos = GetIconY(); float flIconWide = GetIconW(); float flIconTall = GetIconH(); if (pPlayer->IsStyleSkillActive()) { pStyleTexture->DrawSelf( flIconXPos, flIconYPos, flIconWide, flIconTall, Color( 255, 255, 255, 255 ) ); } if (m_pBriefcase && pPlayer->HasBriefcase()) { m_pBriefcase->DrawSelf( flIconXPos + flIconWide + 20, flIconYPos, flIconWide, flIconTall, Color( 255, 255, 255, 255 ) ); } float flLerpTime = 1.0f; float flFadeTime = 1.0f; if (m_flStyleIconLerpStart && gpGlobals->curtime < m_flStyleIconLerpStart + flLerpTime + flFadeTime) { float flRamp = Bias(RemapValClamped(gpGlobals->curtime, m_flStyleIconLerpStart, m_flStyleIconLerpStart + flLerpTime, 0, 1), 0.7f); if (pPlayer->m_Shared.m_iStyleSkill == SKILL_TROLL) { CHudAmmo* pElement = dynamic_cast<CHudAmmo*>(gHUD.FindElement("CHudAmmo")); if (pElement) { Vector4D vecGrenade = pElement->GetGrenadePosition(pPlayer->GetAmmoCount("grenades")-1); flIconXPos = vecGrenade.x; flIconYPos = vecGrenade.y; flIconWide = vecGrenade.z; flIconTall = vecGrenade.w; } } else if (pPlayer->m_Shared.m_iStyleSkill == SKILL_REFLEXES) { CHudNumericDisplay* pElement = dynamic_cast<CHudNumericDisplay*>(gHUD.FindElement("CHudSlowMo")); if (pElement) { int x, y; pElement->GetPos(x, y); flIconXPos = x; flIconYPos = y; int w, h; pElement->GetSize(w, h); flIconWide = flIconTall = (w + h)/2; } } float flAlpha = RemapValClamped(gpGlobals->curtime, m_flStyleIconLerpStart + flLerpTime, m_flStyleIconLerpStart + flLerpTime + flFadeTime, 1, 0); pStyleTexture->DrawSelf( RemapVal(flRamp, 0, 1, flBarIconX, flIconXPos), RemapVal(flRamp, 0, 1, flBarIconY, flIconYPos), RemapVal(flRamp, 0, 1, flStyleTextureWidth, flIconWide), RemapVal(flRamp, 0, 1, flStyleTextureHeight, flIconTall), Color( clrActivated.r(), clrActivated.g(), clrActivated.b(), 255*flAlpha ) ); } } int iNext; for (int i = m_aAnnouncements.Head(); i != m_aAnnouncements.InvalidIndex(); i = iNext) { iNext = m_aAnnouncements.Next( i ); CAnnouncement* pAnnouncement = &m_aAnnouncements[i]; if (pAnnouncement->m_eAnnouncement < 0) continue; if (pAnnouncement->m_eAnnouncement >= TOTAL_ANNOUNCEMENTS) continue; if (!m_apAnnouncements[pAnnouncement->m_eAnnouncement]) continue; if (gpGlobals->curtime < pAnnouncement->m_flStartTime) continue; CHudTexture* pTexture = m_apAnnouncements[pAnnouncement->m_eAnnouncement]; float flScale = 1.2; if (pAnnouncement->m_ePointStyle == STYLE_POINT_LARGE) flScale = 0.8f; else if (pAnnouncement->m_ePointStyle == STYLE_POINT_SMALL) flScale = 0.6f; float flStarWidth = pTexture->EffectiveHeight(flScale); float flSlideInLerp = RemapValClamped(gpGlobals->curtime, pAnnouncement->m_flStartTime, pAnnouncement->m_flStartTime + 0.3f, 0, 1); float flSlideIn = RemapVal(Bias(flSlideInLerp, 0.75), 0, 1, -1000, 0); float flEndTime = pAnnouncement->m_flStartTime + hud_announcementtime.GetFloat(); float flAlpha = 1; if (gpGlobals->curtime < pAnnouncement->m_flStartTime + 0.3f) flAlpha = RemapValClamped(gpGlobals->curtime, pAnnouncement->m_flStartTime, pAnnouncement->m_flStartTime + 0.3f, 0, 1); else if (gpGlobals->curtime > flEndTime-0.5f) flAlpha = RemapValClamped(gpGlobals->curtime, flEndTime-0.5f, flEndTime, 1, 0); pTexture->DrawSelf( flBarLeft - pTexture->EffectiveWidth(flScale) - flStarWidth + flSlideIn, m_flElementYPos + RemapValClamped(pAnnouncement->m_flBarPosition, 0, 1, m_flGap + flBarHeight - pTexture->EffectiveHeight(flScale), m_flGap), pTexture->EffectiveWidth(flScale), pTexture->EffectiveHeight(flScale), Color(255, 255, 255, 255 * flAlpha) ); int iGold, iSilver, iBronze; C_SDKPlayer::GetStyleStars(pAnnouncement->m_flStylePoints, iGold, iSilver, iBronze); CHudTexture* pStarTexture; int iStars; if (iGold) { pStarTexture = m_pGoldStar; iStars = iGold; } else if (iSilver) { pStarTexture = m_pSilverStar; iStars = iSilver; } else { pStarTexture = m_pBronzeStar; iStars = iBronze; } if (pStarTexture) { pStarTexture->DrawSelf( flBarLeft - flStarWidth + flSlideIn, m_flElementYPos + RemapValClamped(pAnnouncement->m_flBarPosition, 0, 1, m_flGap + flBarHeight - pTexture->EffectiveHeight(flScale), m_flGap), flStarWidth, flStarWidth, Color(255, 255, 255, 255 * flAlpha) ); } } }
void CHudHealth::Paint() { Color clrHealth; int a; int x; int y; BaseClass::Paint(); if ( !icon_cross ) { icon_cross = gHUD.GetIcon( "cross" ); } if ( !icon_cross ) { return; } // Has health changed? Flash the health # if ( m_flFade ) { m_flFade -= ( gpGlobals->frametime * 20 ); if ( m_flFade <= 0 ) { a = MIN_ALPHA; m_flFade = 0; } else { // Fade the health number back to dim a = MIN_ALPHA + ( m_flFade / FADE_TIME ) * 128; } } else { a = MIN_ALPHA; } // If health is getting low, make it bright red if ( m_iHealth <= 15 ) a = 255; if (m_iHealth > 25) { int r, g, b, nUnused; (gHUD.m_clrYellowish).GetColor( r, g, b, nUnused ); clrHealth.SetColor( r, g, b, a ); } else { clrHealth.SetColor( 250, 0, 0, a ); } int nFontWidth = GetNumberFontWidth(); int nFontHeight = GetNumberFontHeight(); int nCrossWidth = icon_cross->Width(); x = nCrossWidth / 2; y = GetTall() - ( nFontHeight * 1.5 ); icon_cross->DrawSelf( x, y, clrHealth ); x = nCrossWidth + ( nFontWidth / 2 ); x = DrawHudNumber( x, y, m_iHealth, clrHealth ); x += nFontWidth / 2; int iHeight = nFontHeight; int iWidth = nFontWidth / 10; clrHealth.SetColor( 255, 160, 0, a ); vgui::surface()->DrawSetColor( clrHealth ); vgui::surface()->DrawFilledRect( x, y, x + iWidth, y + iHeight ); }
//============================================== // CHudFlags's Paint // errr... paints the panel //============================================== void CHudFlags::Paint() { int m_iFlagCount = g_Flags.Count(); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if( !pPlayer ) return; char text[512]; int i;// = 0; int x_offset = 5; int y_offset = 5; Color ColourWhite( 255, 255, 255, 255 ); Color ColourRed( 255, 0, 0, 255 ); Color ColourBlue( 0, 0, 255, 255 ); switch (cl_flagstatus.GetInt()) { case 0: // not display anything for( i = 0; i < MAX_FLAGS; i++ ) { m_pLabelFlag[i]->SetVisible(false); } break; case 1: // display flag status as text for( i = 0; i < MAX_FLAGS; i++ ) { m_pLabelFlag[i]->SetVisible(false); } for( i = 0; i < m_iFlagCount && i < 12; i++ ) { if( !g_Flags[i] ) { break; } //BG2 - Tjoppen - obey HUDSlot if( g_Flags[i]->m_iHUDSlot < 0 ) { m_pLabelFlag[i]->SetVisible( false ); continue; } // float iTimeToCap = g_Flags[i]->m_flNextCapture - gpGlobals->curtime; const char *pOLString = NULL; //describes overload status - "Overloaded", "Not overloaded", empty string of not applicable //empty string if.. if( g_Flags[i]->GetTeamNumber() == TEAM_UNASSIGNED || //flag not held by any team g_Flags[i]->m_bNotUncappable || //flag can't be uncapped !g_Flags[i]->m_bUncapOnDeath || //flag doesn't uncap when overloaders die g_Flags[i]->GetTeamNumber() != pPlayer->GetTeamNumber() ) //flag held by other team { pOLString = ""; } else if( g_Flags[i]->m_pOverloading[pPlayer->GetClientIndex()] ) { //player has overloading this flag if( cl_flagstatusdetail.GetInt() <= 1 ) pOLString = "- OL:ed"; else pOLString = "- Overloaded"; } else { //player has not overloaded this flag yet if( cl_flagstatusdetail.GetInt() <= 1 ) pOLString = "- Not OL:ed"; else pOLString = "- Not overloaded"; } //team specific flag? switch( g_Flags[i]->m_iForTeam ) { case 0: //flag can be taken by any team Q_snprintf( text, sizeof(text), "%s", g_Flags[i]->m_sFlagName); switch (cl_flagstatusdetail.GetInt()) { case 0: // No Details if( iTimeToCap > 0.1f ) { char text_add[128]; Q_snprintf( text_add, sizeof(text_add), "- %i", (int)iTimeToCap); strcat( text, text_add); } break; case 1: // Compact Details if( iTimeToCap > 0 ) { char text_add[128]; Q_snprintf( text_add, sizeof(text_add), " - %i/%i - %i", g_Flags[i]->m_iNearbyPlayers, g_Flags[i]->m_iCapturePlayers, (int)iTimeToCap ); strcat( text, text_add); } else { char text_add[128]; Q_snprintf( text_add, sizeof(text_add), " - %i/%i %s", g_Flags[i]->m_iNearbyPlayers, g_Flags[i]->m_iCapturePlayers, pOLString ); strcat( text, text_add); } break; case 2: // Full Details if( iTimeToCap > 0 ) { char text_add[128]; Q_snprintf( text_add, sizeof(text_add), " - %i/%i Players - Time %i", g_Flags[i]->m_iNearbyPlayers, g_Flags[i]->m_iCapturePlayers, (int)iTimeToCap ); strcat( text, text_add); } else { char text_add[128]; Q_snprintf( text_add, sizeof(text_add), " - %i/%i Players %s", g_Flags[i]->m_iNearbyPlayers, g_Flags[i]->m_iCapturePlayers, pOLString ); strcat( text, text_add); } break; } break; case 1: //flag can only be taken by the americans if( iTimeToCap > 0 ) { Q_snprintf( text, sizeof(text), "%s - American Only Target - %i/%i Players - Time %i", g_Flags[i]->m_sFlagName, g_Flags[i]->m_iNearbyPlayers, g_Flags[i]->m_iCapturePlayers, (int)iTimeToCap ); } else { Q_snprintf( text, sizeof(text), "%s - American Only Target - %i/%i Players %s", g_Flags[i]->m_sFlagName, g_Flags[i]->m_iNearbyPlayers, g_Flags[i]->m_iCapturePlayers, pOLString ); } break; case 2: //flag can only be taken by the british if( iTimeToCap > 0 ) { Q_snprintf( text, sizeof(text), "%s - British Only Target - %i/%i Players - Time %i", g_Flags[i]->m_sFlagName, g_Flags[i]->m_iNearbyPlayers, g_Flags[i]->m_iCapturePlayers, (int)iTimeToCap ); } else { Q_snprintf( text, sizeof(text), "%s - British Only Target - %i/%i Players %s", g_Flags[i]->m_sFlagName, g_Flags[i]->m_iNearbyPlayers, g_Flags[i]->m_iCapturePlayers, pOLString ); } break; } //figure out which colors to use float r = 0; float g = 0; float b = 0; /*if( !g_Flags[i]->m_bActive ) //Tweaked. See flag.cpp in server project. -HairyPotter { //BG2 - Tjoppen - inactive flags simply have grey text for now r = g = b = 96; } else*/ switch( g_Flags[i]->m_iLastTeam ) { case TEAM_AMERICANS: r = 66; g = 115; b = 247; r += 188 * (sin(iTimeToCap*4) + 1)/2; g += 139 * (sin(iTimeToCap*4) + 1)/2; b += 7 * (sin(iTimeToCap*4) + 1)/2; break; case TEAM_BRITISH: r = 255; g = 16; b = 16; g += 238 * (sin(iTimeToCap*4) + 1)/2; b += 238 * (sin(iTimeToCap*4) + 1)/2; break; default: case TEAM_UNASSIGNED: switch (g_Flags[i]->GetTeamNumber()) { case TEAM_AMERICANS: r = 66; g = 115; b = 247; break; case TEAM_BRITISH: r = 255; g = 16; b = 16; break; case TEAM_UNASSIGNED: switch (g_Flags[i]->m_iRequestingCappers) { case TEAM_BRITISH: r = 255; g = 16; b = 16; g += 238 * (int)((sin(iTimeToCap*8) + 2.7f)/2); b += 238 * (int)((sin(iTimeToCap*8) + 2.7f)/2); break; case TEAM_AMERICANS: r = 66; g = 115; b = 247; r += 188 * (int)((sin(iTimeToCap*8) + 2.7f)/2); g += 139 * (int)((sin(iTimeToCap*8) + 2.7f)/2); b += 7 * (int)((sin(iTimeToCap*8) + 2.7f)/2); break; case TEAM_UNASSIGNED: switch( g_Flags[i]->m_iForTeam ) { case 0: r = 255; g = 255; b = 255; break; case 1: r = 255; g = 16; b = 16; break; case 2: r = 66; g = 115; b = 247; break; } break; } break; } break; } m_pLabelFlag[i]->SetFgColor(Color(r,g,b,255)); m_pLabelFlag[i]->SetText( text ); m_pLabelFlag[i]->SizeToContents(); //BP hack to widen the label so no cropping can occur m_pLabelFlag[i]->SetWide(m_pLabelFlag[i]->GetWide() + 5); m_pLabelFlag[i]->SetVisible( true ); //BG2 - Tjoppen - obey HUDSlot if( g_Flags[i]->m_iHUDSlot == 0 ) { m_pLabelFlag[i]->SetPos(x_offset,y_offset); y_offset += 20; } else { m_pLabelFlag[i]->SetPos(x_offset, 20*(g_Flags[i]->m_iHUDSlot - 1) + 5 ); } // } break; case 2: // Display Flag status as Icons i = 0; while (i < MAX_FLAGS) { m_pLabelFlag[i]->SetVisible(false); i++; } int xinc = 0; //incremental x.. for old flags for( i = 0; i < m_iFlagCount; i++ ) { int x_offset; if( g_Flags[i]->m_iHUDSlot < 0 ) { m_pLabelFlag[i]->SetVisible( false ); continue; } else if( g_Flags[i]->m_iHUDSlot == 0 ) { x_offset = xinc; xinc += 80; } else x_offset = (g_Flags[i]->m_iHUDSlot - 1) * 80; //BG2 - Tjoppen - first draw the color of the team holding the flag, then progress bar of capture float fTimeToCap = g_Flags[i]->m_flNextCapture - gpGlobals->curtime; int iTimeToCap = (int)fTimeToCap; //switch( g_Flags[i]->m_iLastTeam ) switch( g_Flags[i]->GetTeamNumber() ) { case TEAM_UNASSIGNED: switch( g_Flags[i]->m_iForTeam ) { case 0: m_pIconBlank->DrawSelf( x_offset, 0, ColourWhite ); break; case 1: m_pIconRed->DrawSelf( x_offset, 0, ColourWhite ); break; case 2: m_pIconBlue->DrawSelf( x_offset, 0, ColourWhite ); break; } break; case TEAM_AMERICANS: m_pIconBlue->DrawSelf( x_offset, 0, ColourWhite ); break; case TEAM_BRITISH: m_pIconRed->DrawSelf( x_offset, 0, ColourWhite ); break; } if( iTimeToCap >= 0 ) { //stepwise transition //int coverw = (64 * (iTimeToCap+1)) / (int)(g_Flags[i]->m_flCaptureTime + 1); //dod:s style smooth transition int coverw = (int)(64.f * (fTimeToCap + 1) / (g_Flags[i]->m_flCaptureTime + 1)); if( coverw < 0 ) coverw = 0; switch( g_Flags[i]->m_iLastTeam ) { case TEAM_UNASSIGNED: //is this needed? unassigned can't capture flags.. //m_IconCover[i]->DrawSelfCropped(x_offset, 0, x_offset, 0, 32 - coverw, 32, ColourWhite); m_pIconBlank->DrawSelfCropped(x_offset, 0, 0, 0, 64 - coverw, 64, ColourWhite); break; case TEAM_BRITISH: //m_IconCover[i]->DrawSelfCropped(x_offset, 0, x_offset, 0, 32 - coverw, 32, ColourRed); m_pIconRed->DrawSelfCropped(x_offset, 0, 0, 0, 64 - coverw, 64, ColourWhite); break; case TEAM_AMERICANS: //m_IconCover[i]->DrawSelfCropped(x_offset, 0, x_offset, 0, 32 - coverw, 32, ColourBlue); m_pIconBlue->DrawSelfCropped(x_offset, 0, 0, 0, 64 - coverw, 64, ColourWhite); break; } } int r=0,g=0,b=0; switch( g_Flags[i]->m_iLastTeam ) { case TEAM_AMERICANS: r = 66; g = 115; b = 247; r += 188 * (sin(fTimeToCap*4) + 1)/2; g += 139 * (sin(fTimeToCap*4) + 1)/2; b += 7 * (sin(fTimeToCap*4) + 1)/2; break; case TEAM_BRITISH: r = 255; g = 16; b = 16; g += 238 * (sin(fTimeToCap*4) + 1)/2; b += 238 * (sin(fTimeToCap*4) + 1)/2; break; default: case TEAM_UNASSIGNED: switch (g_Flags[i]->GetTeamNumber()) { case TEAM_AMERICANS: r = 66; g = 115; b = 247; break; case TEAM_BRITISH: r = 255; g = 16; b = 16; break; case TEAM_UNASSIGNED: switch (g_Flags[i]->m_iRequestingCappers) { case TEAM_BRITISH: r = 255; g = 16; b = 16; g += 238 * (int)((sin(fTimeToCap*8) + 2.7f)/2); b += 238 * (int)((sin(fTimeToCap*8) + 2.7f)/2); break; case TEAM_AMERICANS: r = 66; g = 115; b = 247; r += 188 * (int)((sin(fTimeToCap*8) + 2.7f)/2); g += 139 * (int)((sin(fTimeToCap*8) + 2.7f)/2); b += 7 * (int)((sin(fTimeToCap*8) + 2.7f)/2); break; case TEAM_UNASSIGNED: switch( g_Flags[i]->m_iForTeam ) { case 0: r = 255; g = 255; b = 255; break; case 1: r = 255; g = 16; b = 16; break; case 2: r = 66; g = 115; b = 247; break; } break; } break; } break; } Q_snprintf( text, 512, "%i/%i", g_Flags[i]->m_iNearbyPlayers, g_Flags[i]->m_iCapturePlayers ); m_pLabelFlag[i]->SetText( text ); m_pLabelFlag[i]->SizeToContents(); //m_pLabelFlag[i]->SetVisible( true ); //m_pLabelFlag[i]->SetPos( (x_offset + 32), 64 ); //center on icon int w,h; m_pLabelFlag[i]->GetSize( w, h ); m_pLabelFlag[i]->SetPos( (x_offset + 32) - w/2, 32 - h/2 ); m_pLabelFlag[i]->SetFgColor( Color(r,g,b,255) ); m_pLabelFlag[i]->SetVisible(true); //x_offset += 80; } break; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CHudMessage::Paint() { int i, drawn; client_textmessage_t *pMessage; float endTime; drawn = 0; if ( m_gameTitleTime > 0 ) { float localTime = gpGlobals->curtime - m_gameTitleTime; float brightness; // Maybe timer isn't set yet if ( m_gameTitleTime > gpGlobals->curtime ) { m_gameTitleTime = gpGlobals->curtime; } if ( localTime > (m_pGameTitle->fadein + m_pGameTitle->holdtime + m_pGameTitle->fadeout) ) { m_gameTitleTime = 0; } else { brightness = FadeBlend( m_pGameTitle->fadein, m_pGameTitle->fadeout, m_pGameTitle->holdtime, localTime ); int halfWidth = m_iconTitleHalf->Width(); int fullWidth = halfWidth + m_iconTitleLife->Width(); int fullHeight = m_iconTitleHalf->Height(); int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth ); int y = YPosition( m_pGameTitle->y, fullHeight ); m_iconTitleHalf->DrawSelf( x, y, Color( m_pGameTitle->r1, m_pGameTitle->g1, m_pGameTitle->b1, brightness * 255 ) ); m_iconTitleLife->DrawSelf( x + halfWidth, y, Color( m_pGameTitle->r1, m_pGameTitle->g1, m_pGameTitle->b1, brightness * 255 ) ); drawn = 1; } } // Fixup level transitions for ( i = 0; i < maxHUDMessages; i++ ) { // Assume m_parms.time contains last time if ( m_pMessages[i] ) { pMessage = m_pMessages[i]; if ( m_startTime[i] > gpGlobals->curtime ) m_startTime[i] = gpGlobals->curtime + m_parms.time - m_startTime[i] + 0.2; // Server takes 0.2 seconds to spawn, adjust for this } } for ( i = 0; i < maxHUDMessages; i++ ) { if ( m_pMessages[i] ) { pMessage = m_pMessages[i]; // This is when the message is over switch( pMessage->effect ) { case 0: case 1: endTime = m_startTime[i] + pMessage->fadein + pMessage->fadeout + pMessage->holdtime; break; // Fade in is per character in scanning messages case 2: endTime = m_startTime[i] + (pMessage->fadein * strlen( pMessage->pMessage )) + pMessage->fadeout + pMessage->holdtime; break; default: endTime = 0; break; } if ( gpGlobals->curtime <= endTime ) { float messageTime = gpGlobals->curtime - m_startTime[i]; // Draw the message // effect 0 is fade in/fade out // effect 1 is flickery credits // effect 2 is write out (training room) MessageDrawScan( pMessage, messageTime ); drawn++; } else { // The message is over m_pMessages[i] = NULL; } } } // Remember the time -- to fix up level transitions m_parms.time = gpGlobals->curtime; // Did we draw any messages? if ( !drawn ) { m_bHaveMessage = false; } }