示例#1
0
int CHudSlowMotion::Draw(float flTime)
{
	if ( !( gHUD.m_iWeaponBits & ( 1 << ( WEAPON_SUIT ) ) )
		|| ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
		|| gEngfuncs.IsSpectateOnly()
		|| std::string( gEngfuncs.pfnGetLevelName() ) == "maps/nightmare.bsp" ) {
		
		return 1;
	}

	wrect_t hourglassRect = gHUD.GetSpriteRect( hourglassStrokeSprite );
	int hourglassRectHeight = hourglassRect.bottom - hourglassRect.top;

	int x = CORNER_OFFSET + HEALTH_SPRITE_WIDTH;
	int y = ScreenHeight - hourglassRectHeight - CORNER_OFFSET;

	SPR_Set( gHUD.GetSprite( hourglassStrokeSprite ), 20, 20, 20 );
	SPR_DrawAdditive( 0, x, y, &hourglassRect );

	float slowmotionPercent = ( slowMotionCharge / 100.0f );
	float slowmotionLackPercent = 1.0f - slowmotionPercent;
	
	if ( slowmotionPercent > 0.0f ) {
		hourglassRect = gHUD.GetSpriteRect( hourglassFillSprite );
		int hourglassHeight = hourglassRectHeight * slowmotionLackPercent;
		hourglassRect.top = hourglassHeight;
		
		SPR_Set( gHUD.GetSprite( hourglassStrokeSprite ), 180, 180, 180 );
		SPR_DrawAdditive( 0, x, y + hourglassHeight, &hourglassRect );
	}

	return 1;
}
示例#2
0
int CHud :: DrawHudNumber( int x, int y, int iFlags, int iNumber, int r, int g, int b )
{
	int iWidth = GetSpriteRect( m_HUD_number_0 ).right - GetSpriteRect( m_HUD_number_0 ).left;
	int k;
	
	if( iNumber > 0 )
	{
		// SPR_Draw 100's
		if( iNumber >= 100 )
		{
			k = iNumber/100;
			SPR_Set( GetSprite( m_HUD_number_0 + k ), r, g, b );
			SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 + k ));
			x += iWidth;
		}
		else if( iFlags & ( DHN_3DIGITS ))
		{
			x += iWidth;
		}

		// SPR_Draw 10's
		if( iNumber >= 10 )
		{
			k = (iNumber % 100) / 10;
			SPR_Set( GetSprite( m_HUD_number_0 + k ), r, g, b );
			SPR_DrawAdditive( 0, x, y, &GetSpriteRect( m_HUD_number_0 + k ));
			x += iWidth;
		}
		else if( iFlags & ( DHN_3DIGITS | DHN_2DIGITS ))
		{
			x += iWidth;
		}

		// SPR_Draw ones
		k = iNumber % 10;
		SPR_Set( GetSprite( m_HUD_number_0 + k ), r, g, b );
		SPR_DrawAdditive( 0,  x, y, &GetSpriteRect( m_HUD_number_0 + k ));
		x += iWidth;
	} 
	else if( iFlags & DHN_DRAWZERO ) 
	{
		SPR_Set( GetSprite( m_HUD_number_0 ), r, g, b );

		// SPR_Draw 100's
		if( iFlags & ( DHN_3DIGITS ))
		{
			x += iWidth;
		}

		if( iFlags & ( DHN_3DIGITS|DHN_2DIGITS ))
			x += iWidth;

		SPR_DrawAdditive( 0,  x, y, &GetSpriteRect( m_HUD_number_0 ));
		x += iWidth;
	}
	return x;
}
示例#3
0
int CHudFlashlight::Draw(float flTime)
{
	if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
		return 1;

	int r, g, b, x, y, a;
	wrect_t rc;

	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
		return 1;

	if (m_fOn)
		a = 225;
	else
		a = MIN_ALPHA;

	if (m_flBat < 0.20)
		UnpackRGB(r,g,b, RGB_REDISH);
	else
	{
		gHUD.GetPrimaryHudColor(r, g, b);
	}

	ScaleColors(r, g, b, a);

	y = (m_prc1->bottom - m_prc2->top)/2;
	x = ScreenWidth() - m_iWidth - m_iWidth/2 ;

	// Draw the flashlight casing
	SPR_Set(m_hSprite1, r, g, b );
	SPR_DrawAdditive( 0,  x, y, m_prc1);

	if ( m_fOn )
	{  // draw the flashlight beam
		x = ScreenWidth() - m_iWidth/2;

		SPR_Set( m_hBeam, r, g, b );
		SPR_DrawAdditive( 0, x, y, m_prcBeam );
	}

	// draw the flashlight energy level
	x = ScreenWidth() - m_iWidth - m_iWidth/2 ;
	int iOffset = m_iWidth * (1.0 - m_flBat);
	if (iOffset < m_iWidth)
	{
		rc = *m_prc2;
		rc.left += iOffset;

		SPR_Set(m_hSprite2, r, g, b );
		SPR_DrawAdditive( 0, x + iOffset, y, &rc);
	}


	return 1;
}
示例#4
0
bool CHudFlashlight::Draw(float flTime)
{
	if ( GetHud().GetHideHudBits().Any( HIDEHUD_FLASHLIGHT | HIDEHUD_ALL ) )
		return true;

	int r, g, b, x, y, a;
	wrect_t rc;

	if (!( Hud().GetWeaponBits() & (1<<(WEAPON_SUIT)) ))
		return true;

	if (m_fOn)
		a = 225;
	else
		a = MIN_ALPHA;

	if (m_flBat < 0.20)
		GetHud().GetEmptyItemColor().UnpackRGB(r,g,b);
	else
		GetHud().GetPrimaryColor().UnpackRGB(r,g,b);

	ScaleColors(r, g, b, a);

	y = (m_prc1->bottom - m_prc2->top)/2;
	x = ScreenWidth - m_iWidth - m_iWidth/2 ;

	// Draw the flashlight casing
	SPR_Set(m_hSprite1, r, g, b );
	SPR_DrawAdditive( 0,  x, y, m_prc1);

	if ( m_fOn )
	{  // draw the flashlight beam
		x = ScreenWidth - m_iWidth/2;

		SPR_Set( m_hBeam, r, g, b );
		SPR_DrawAdditive( 0, x, y, m_prcBeam );
	}

	// draw the flashlight energy level
	x = ScreenWidth - m_iWidth - m_iWidth/2 ;
	int iOffset = m_iWidth * (1.0 - m_flBat);
	if (iOffset < m_iWidth)
	{
		rc = *m_prc2;
		rc.left += iOffset;

		SPR_Set(m_hSprite2, r, g, b );
		SPR_DrawAdditive( 0, x + iOffset, y, &rc);
	}


	return true;
}
示例#5
0
int CHudTimer::Draw(float flTime)
{
	if (!Inited)
	{
		Inited = true;
		Time += flTime;
	}

	if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_ALL ) )
		return 1;

	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
		return 1;

	int diff = Time - flTime;

	if (diff < 0)
	{
		diff = 0;
		return 1;
	}

	int r,g,b,x,y;
	r = (diff > 10) ? 255 : 200;
	g = (diff > 10) ? 140 : 0;
	b = 0;
      
	y = (m_prc1->bottom - m_prc1->top);
	x = ScreenWidth/2 - 80;

	// Draw the icon
	SPR_Set(m_hSprite1, r, g, b );
	SPR_DrawAdditive( 0,  x, y, m_prc1);

	x += 35;
	y -= 2;

	int min = diff /60;
	int sec = diff %60;

	int sec_exp1 = sec/10;
	int sec_exp0 = sec%10;

	x = gHUD.DrawHudNumberLarge(x, y, DHN_2DIGITS | DHN_DRAWZERO, min, r, g, b);

	SPR_Set(m_hSprite2, r, g, b );
	SPR_DrawAdditive( 0,  x + 7, y, m_prc2);

	x = gHUD.DrawHudNumberLarge(x, y, DHN_2DIGITS | DHN_DRAWZERO, sec_exp1, r, g, b);
	gHUD.DrawHudNumberLarge(x, y, DHN_DRAWZERO, sec_exp0, r, g, b);

	return 1;
}
示例#6
0
int CHudHealth::DrawDamage(float flTime)
{
	int r, g, b, a;
	DAMAGE_IMAGE *pdmg;

	if (!m_bitsDamage)
		return 1;

	UnpackRGB(r,g,b, RGB_YELLOWISH);
	
	a = (int)( fabs(sin(flTime*2)) * 256.0);

	ScaleColors(r, g, b, a);

	// Draw all the items
	int i;
	for (i = 0; i < NUM_DMG_TYPES; i++)
	{
		if (m_bitsDamage & giDmgFlags[i])
		{
			pdmg = &m_dmg[i];
			SPR_Set(gHUD.GetSprite(m_HUD_dmg_bio + i), r, g, b );
			SPR_DrawAdditive(0, pdmg->x, pdmg->y, &gHUD.GetSpriteRect(m_HUD_dmg_bio + i));
		}
	}


	// check for bits that should be expired
	for ( i = 0; i < NUM_DMG_TYPES; i++ )
	{
		DAMAGE_IMAGE *pdmg = &m_dmg[i];

		if ( m_bitsDamage & giDmgFlags[i] )
		{
			pdmg->fExpire = min( flTime + DMG_IMAGE_LIFE, pdmg->fExpire );

			if ( pdmg->fExpire <= flTime		// when the time has expired
				&& a < 40 )						// and the flash is at the low point of the cycle
			{
				pdmg->fExpire = 0;

				int y = pdmg->y;
				pdmg->x = pdmg->y = 0;

				// move everyone above down
				for (int j = 0; j < NUM_DMG_TYPES; j++)
				{
					pdmg = &m_dmg[j];
					if ((pdmg->y) && (pdmg->y < y))
						pdmg->y += giDmgHeight;

				}

				m_bitsDamage &= ~giDmgFlags[i];  // clear the bits
			}
		}
	}

	return 1;
}
示例#7
0
int CHudRedeemer :: Draw( float flTime )
{
	int x, y, w, h;
	wrect_t rc;
	int frame;

	// setup screen rectangle
	rc.left = rc.top = 0;
	rc.right = ScreenWidth;
	rc.bottom = ScreenHeight;

	if( m_iHudMode == 1 ) // draw warhead screen (controllable rocket)
	{
		y = (ScreenWidth - GUIDE_S) / 2;
		x = (ScreenHeight - GUIDE_S) / 2;

		SPR_Set( m_hCrosshair, 255, 128, 128 );
		SPR_DrawAdditive( 0,  y, x, NULL);

		int yOffset = ScreenHeight;
		yOffset -= ((int)(flTime * 650) % READOUT_S) - READOUT_S;
		SPR_Set( m_hSprite, 255, 128, 128 );
		while( yOffset > -READOUT_S )
		{
			SPR_DrawAdditive( 0, 0, yOffset, READOUT_S>>1, READOUT_S );
			yOffset -= READOUT_S;
		}

		if( m_iOldHudMode != m_iHudMode )
		{
			// enable red fade
			SetScreenFade( Vector( 255, 0, 0 ), 64, 0, 0, FFADE_STAYOUT );
		}
	}
示例#8
0
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 );

		// 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 )
				gEngfuncs.pfnDrawSetTextColor( 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 )
				gEngfuncs.pfnDrawSetTextColor( rgDeathNoticeList[i].VictimColor[0], rgDeathNoticeList[i].VictimColor[1], rgDeathNoticeList[i].VictimColor[2] );
			x = DrawConsoleString( x, y, rgDeathNoticeList[i].szVictim );
		}
	}

	return 1;
}
示例#9
0
文件: health.cpp 项目: mittorn/csdm
int CHudHealth::Draw(float flTime)
{
	int r, g, b;
	int a = 0, x, y;
	int HealthWidth;

	if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() )
		return 1;

	if ( !m_HSPRITE )
		m_HSPRITE = LoadSprite(PAIN_NAME);
	
	// Has health changed? Flash the health #
	if (m_fFade)
	{
		m_fFade -= (gHUD.m_flTimeDelta * 20);
		if (m_fFade <= 0)
		{
			a = MIN_ALPHA;
			m_fFade = 0;
		}

		// Fade the health number back to dim

		a = MIN_ALPHA +  (m_fFade/FADE_TIME) * 128;

	}
	else
		a = MIN_ALPHA;

	// If health is getting low, make it bright red
	if (m_iHealth <= 15)
		a = 255;
		
	GetPainColor( r, g, b );
	ScaleColors(r, g, b, a );

	// Only draw health if we have the suit.
	if (gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)))
	{
		HealthWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;
		int CrossWidth = gHUD.GetSpriteRect(m_HUD_cross).right - gHUD.GetSpriteRect(m_HUD_cross).left;

		y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
		x = CrossWidth /2;

		SPR_Set(gHUD.GetSprite(m_HUD_cross), r, g, b);
		SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_cross));

		x = CrossWidth + HealthWidth / 2;

		//x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iHealth, r, g, b);
		gHUD.DrawHudNumber2( x, y, false, 3, m_iHealth, r, g, b);
	}

	DrawDamage(flTime);
	return DrawPain(flTime);
}
示例#10
0
int CHudAmmoSecondary::Draw( float flTime )
{
	if( ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL ) ) )
		return 1;

	// draw secondary ammo icons above normal ammo readout
	int a, x, y, r, g, b, AmmoWidth;
	UnpackRGB( r, g, b, RGB_YELLOWISH );
	a = (int)max( MIN_ALPHA, m_fFade );
	if( m_fFade > 0 )
		m_fFade -= ( gHUD.m_flTimeDelta * 20 );  // slowly lower alpha to fade out icons
	ScaleColors( r, g, b, a );

	AmmoWidth = gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).right - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).left;

	y = ScreenHeight - ( gHUD.m_iFontHeight * 4 );  // this is one font height higher than the weapon ammo values
	x = ScreenWidth - AmmoWidth;

	if( m_HUD_ammoicon )
	{
		// Draw the ammo icon
		x -= ( gHUD.GetSpriteRect( m_HUD_ammoicon ).right - gHUD.GetSpriteRect( m_HUD_ammoicon ).left );
		y -= ( gHUD.GetSpriteRect( m_HUD_ammoicon ).top - gHUD.GetSpriteRect( m_HUD_ammoicon ).bottom );

		SPR_Set( gHUD.GetSprite( m_HUD_ammoicon ), r, g, b );
		SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect( m_HUD_ammoicon ) );
	}
	else
	{
		// move the cursor by the '0' char instead, since we don't have an icon to work with
		x -= AmmoWidth;
		y -= ( gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).top - gHUD.GetSpriteRect( gHUD.m_HUD_number_0 ).bottom );
	}

	// draw the ammo counts, in reverse order, from right to left
	for( int i = MAX_SEC_AMMO_VALUES-1; i >= 0; i-- )
	{
		if( m_iAmmoAmounts[i] < 0 )
			continue; // negative ammo amounts imply that they shouldn't be drawn

		// half a char gap between the ammo number and the previous pic
		x -= ( AmmoWidth / 2 );

		// draw the number, right-aligned
		x -= ( gHUD.GetNumWidth( m_iAmmoAmounts[i], DHN_DRAWZERO ) * AmmoWidth );
		gHUD.DrawHudNumber( x, y, DHN_DRAWZERO, m_iAmmoAmounts[i], r, g, b );

		if( i != 0 )
		{
			// draw the divider bar
			x -= ( AmmoWidth / 2 );
			FillRGBA( x, y, ( AmmoWidth/10 ), gHUD.m_iFontHeight, r, g, b, a );
		}
	}

	return 1;
}
示例#11
0
// Redraw
// step through the local data,  placing the appropriate graphics & text as appropriate
// returns 1 if they've changed, 0 otherwise
int CHud :: Redraw( float flTime, int intermission )
{
	m_fOldTime = m_flTime;	// save time of previous redraw
	m_flTime = flTime;
	m_flTimeDelta = (double)m_flTime - m_fOldTime;
	
	// Clock was reset, reset delta
	if ( m_flTimeDelta < 0 )
		m_flTimeDelta = 0;

	m_iIntermission = intermission;

	// if no redrawing is necessary
	// return 0;
	
	HUDLIST *pList = m_pHudList;

	while (pList)
	{
		if ( !intermission )
		{
			if ((pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL))
				pList->p->Draw(flTime);
		}
		else
		{  // it's an intermission,  so only draw hud elements that are set to draw during intermissions
			if ( pList->p->m_iFlags & HUD_INTERMISSION )
				pList->p->Draw( flTime );
		}

		pList = pList->pNext;
	}

	// are we in demo mode? do we need to draw the logo in the top corner?
	if (m_iLogo)
	{
		int x, y, i;

		if (m_hsprLogo == 0)
			m_hsprLogo = LoadSprite("sprites/%d_logo.spr");

		SPR_Set(m_hsprLogo, 250, 250, 250 );
		
		x = SPR_Width(m_hsprLogo, 0);
		x = ScreenWidth - x;
		y = SPR_Height(m_hsprLogo, 0)/2;

		// Draw the logo at 20 fps
		int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
		i = grgLogoFrame[iFrame] - 1;

		SPR_DrawAdditive(i, x, y, NULL);
	}

	return 1;
}
示例#12
0
int CHudMoney::Draw(float flTime)
{
	if(( gHUD.m_iHideHUDDisplay & ( HIDEHUD_HEALTH ) ))
		return 1;

	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT))))
		return 1;

	int r, g, b, alphaBalance;
	m_fFade -= gHUD.m_flTimeDelta;
	if( m_fFade < 0)
	{
		m_fFade = 0.0f;
		m_iDelta = 0;
	}
	float interpolate = ( 5 - m_fFade ) / 5;

	int iDollarWidth = m_hDollar.rect.right - m_hDollar.rect.left;

	int x = ScreenWidth - iDollarWidth * 7;
	int y = MONEY_YPOS;

	if( m_iBlinkAmt )
	{
		m_fBlinkTime += gHUD.m_flTimeDelta;
		DrawUtils::UnpackRGB( r, g, b, m_fBlinkTime > 0.5f? RGB_REDISH : RGB_YELLOWISH );

		if( m_fBlinkTime > 1.0f )
		{
			m_fBlinkTime = 0.0f;
			--m_iBlinkAmt;
		}
	}
	else
	{
		if( m_iDelta != 0 )
		{
			int iDeltaR, iDeltaG, iDeltaB;
			int iDollarHeight = m_hDollar.rect.bottom - m_hDollar.rect.top;
			int iDeltaAlpha = 255 - interpolate * (255);

			DrawUtils::UnpackRGB  (iDeltaR, iDeltaG, iDeltaB, m_iDelta < 0 ? RGB_REDISH : RGB_GREENISH);
			DrawUtils::ScaleColors(iDeltaR, iDeltaG, iDeltaB, iDeltaAlpha);

			if( m_iDelta > 0 )
			{
				r = interpolate * ((RGB_YELLOWISH & 0xFF0000) >> 16);
				g = (RGB_GREENISH & 0xFF00) >> 8;
				b = (RGB_GREENISH & 0xFF);

				// draw delta
				SPR_Set(m_hPlus.spr, iDeltaR, iDeltaG, iDeltaB );
				SPR_DrawAdditive(0, x, y - iDollarHeight * 1.5, &m_hPlus.rect );
			}
			else if( m_iDelta < 0)
示例#13
0
// Draw status icons along the left-hand side of the screen
int CHudStatusIcons::Draw( float flTime )
{
	// find starting position to draw from, along right-hand side of screen
	int x = 5;
	int y = ScreenHeight / 2;
	
	// loop through icon list, and draw any valid icons drawing up from the middle of screen
	for( int i = 0; i < MAX_ICONSPRITES; i++ )
	{
		if ( m_IconList[i].spr )
		{
			y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5;
			
			SPR_Set( m_IconList[i].spr, m_IconList[i].r, m_IconList[i].g, m_IconList[i].b );
			SPR_DrawAdditive( 0, x, y, &m_IconList[i].rc );
		}
	}
	return 1;
}
示例#14
0
文件: train.cpp 项目: FWGS/XashXT
int CHudTrain::Draw( float fTime )
{
	if( !m_hSprite )
		m_hSprite = LoadSprite( "sprites/640_train.spr" );

	if( m_iPos )
	{
		int r, g, b, x, y;

		UnpackRGB( r, g, b, gHUD.m_iHUDColor );
		SPR_Set( m_hSprite, r, g, b );

		// This should show up to the right and part way up the armor number
		y = ScreenHeight - SPR_Height( m_hSprite, 0 ) - gHUD.m_iFontHeight;
		x = ScreenWidth / 3 + SPR_Width( m_hSprite, 0 ) / 4;

		SPR_DrawAdditive( m_iPos - 1,  x, y, NULL );
	}
	return 1;
}
示例#15
0
int CHudCloak::Draw(float flTime)
{
	if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_ALL ) )
	return 1;

	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
		return 1;

	int r,g,b,x,y;
	r = 250;
	g = 0;
	b = 0;
      
	y = (m_prc1->bottom - m_prc1->top)+85;
	x = ScreenWidth - m_iWidth - m_iWidth/2;

	// Draw the icon
	SPR_Set(m_hSprite1, r, g, b );
	SPR_DrawAdditive( 0,  x, y, m_prc1);

return 1;
}
示例#16
0
// Draw status icons along the left-hand side of the screen
int CHudStatusIcons::Draw( float flTime )
{
	if (gEngfuncs.IsSpectateOnly())
		return 1;
	// find starting position to draw from, along right-hand side of screen
	int x = 5;
	int y = ScreenHeight / 2;

	// loop through icon list, and draw any valid icons drawing up from the middle of screen
	for ( int i = 0; i < MAX_ICONSPRITES; i++ )
	{
		if ( m_IconList[i].spr )
		{
			y -= ( m_IconList[i].rc.bottom - m_IconList[i].rc.top ) + 5;
			
			if( g_bInBombZone && !strcmp(m_IconList[i].szSpriteName, "c4") && ((int)(flTime * 10) % 2))
				SPR_Set( m_IconList[i].spr, 255, 16, 16 );
			else SPR_Set( m_IconList[i].spr, m_IconList[i].r, m_IconList[i].g, m_IconList[i].b );
			SPR_DrawAdditive( 0, x, y, &m_IconList[i].rc );
		}
	}
	
	return 1;
}
示例#17
0
int CHudBattery::Draw( float flTime )
{
	if( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
		return 1;

	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
		return 1;

	int r, g, b, x, y, a;
	wrect_t rc;

	rc = *m_prc2;

	// battery can go from 0 to 100 so * 0.01 goes from 0 to 1
	rc.top += m_iHeight * ((float)( 100 - ( min( 100, m_iBat ))) * 0.01f );

	UnpackRGB( r, g, b, RGB_YELLOWISH );

	// Has health changed? Flash the health #
	if( m_fFade )
	{
		if( m_fFade > FADE_TIME )
			m_fFade = FADE_TIME;

		m_fFade -= (gHUD.m_flTimeDelta * 20);

		if( m_fFade <= 0 )
		{
			a = 128;
			m_fFade = 0;
		}

		// Fade the health number back to dim
		a = MIN_ALPHA +  (m_fFade / FADE_TIME) * 128;

	}
	else
	{
		a = MIN_ALPHA;
	}

	ScaleColors( r, g, b, a );
	
	int iOffset = (m_prc1->bottom - m_prc1->top) / 6;

	y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
	x = ScreenWidth / 5;

	// make sure we have the right sprite handles
	if( !m_hSprite1 )
		m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ));

	if( !m_hSprite2 )
		m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ));

	if( !m_hSprite1Helmet )
		m_hSprite1Helmet = gHUD.GetSprite( gHUD.GetSpriteIndex( "suithelmet_empty" ));

	if( !m_hSprite2Helmet )
		m_hSprite2Helmet = gHUD.GetSprite( gHUD.GetSpriteIndex( "suithelmet_full" ));

	if( m_enArmorType == Vest )
		SPR_Set( m_hSprite1, r, g, b );
	else
		SPR_Set( m_hSprite1Helmet, r, g, b );
	SPR_DrawAdditive( 0,  x, y - iOffset, m_prc1 );

	if( rc.bottom > rc.top )
	{
		if( m_enArmorType == Vest )
			SPR_Set( m_hSprite2, r, g, b );
		else
			SPR_Set( m_hSprite2Helmet, r, g, b );
		SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc );
	}

	x += (m_prc1->right - m_prc1->left);
	x = gHUD.DrawHudNumber( x, y, DHN_3DIGITS|DHN_DRAWZERO, m_iBat, r, g, b );

	return 1;
}
示例#18
0
// Redraw
// step through the local data,  placing the appropriate graphics & text as appropriate
// returns 1 if they've changed, 0 otherwise
int CHud :: Redraw( float flTime, int intermission )
{
	m_fOldTime = m_flTime;	// save time of previous redraw
	m_flTime = flTime;
	m_flTimeDelta = (double)m_flTime - m_fOldTime;
	static m_flShotTime = 0;
	
	// Clock was reset, reset delta
	if ( m_flTimeDelta < 0 )
		m_flTimeDelta = 0;

	// Bring up the scoreboard during intermission
	if (gViewPort)
	{
		if ( m_iIntermission && !intermission )
		{
			// Have to do this here so the scoreboard goes away
			m_iIntermission = intermission;
			gViewPort->HideCommandMenu();
			gViewPort->HideScoreBoard();
			gViewPort->UpdateSpectatorPanel();
		}
		else if ( !m_iIntermission && intermission )
		{
			m_iIntermission = intermission;
			gViewPort->HideCommandMenu();
			gViewPort->HideVGUIMenu();
			gViewPort->ShowScoreBoard();
			gViewPort->UpdateSpectatorPanel();

			// Take a screenshot if the client's got the cvar set
			if ( CVAR_GET_FLOAT( "hud_takesshots" ) != 0 )
				m_flShotTime = flTime + 1.0;	// Take a screenshot in a second
		}
	}

	if (m_flShotTime && m_flShotTime < flTime)
	{
		gEngfuncs.pfnClientCmd("snapshot\n");
		m_flShotTime = 0;
	}
	// if no redrawing is necessary
	// return 0;
	
	// draw all registered HUD elements
	if ( m_pCvarDraw->value )
	{
		HUDLIST *pList = m_pHudList;

		while (pList)
		{
			if ( !intermission )
			{
				if ((pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL))
					pList->p->Draw(flTime);
			}
			else
			{  // it's an intermission,  so only draw hud elements that are set to draw during intermissions
				if ( pList->p->m_iFlags & HUD_INTERMISSION )
					pList->p->Draw( flTime );
			}

			pList = pList->pNext;
		}
	}

	// are we in demo mode? do we need to draw the logo in the top corner?
	if (m_iLogo)
	{
		int x, y, i;

		if (m_hsprLogo == 0)
			m_hsprLogo = LoadSprite("sprites/%d_logo.spr");

		SPR_Set(m_hsprLogo, 250, 250, 250 );
		
		x = SPR_Width(m_hsprLogo, 0);
		x = ScreenWidth - x;
		y = SPR_Height(m_hsprLogo, 0)/2;

		// Draw the logo at 20 fps
		int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
		i = grgLogoFrame[iFrame] - 1;

		SPR_DrawAdditive(i, x, y, NULL);
	}
	

	return 1;
}
示例#19
0
// Redraw
// step through the local data,  placing the appropriate graphics & text as appropriate
// returns 1 if they've changed, 0 otherwise
int CHud :: Redraw( float flTime, int intermission )
{
	m_fOldTime = m_flTime;	// save time of previous redraw
	m_flTime = flTime;
	m_flTimeDelta = (double)m_flTime - m_fOldTime;
	static float m_flShotTime = 0;
	
	// Clock was reset, reset delta
	if ( m_flTimeDelta < 0 )
		m_flTimeDelta = 0;


	if (m_flShotTime && m_flShotTime < flTime)
	{
		gEngfuncs.pfnClientCmd("snapshot\n");
		m_flShotTime = 0;
	}

	m_iIntermission = intermission;

	// if no redrawing is necessary
	// return 0;
	
	if ( m_pCvarDraw->value )
	{
		HUDLIST *pList = m_pHudList;

		while (pList)
		{
			if ( !intermission )
			{
				if ( (pList->p->m_iFlags & HUD_ACTIVE) && !(m_iHideHUDDisplay & HIDEHUD_ALL) )
					pList->p->Draw(flTime);
			}
			else
			{  // it's an intermission,  so only draw hud elements that are set to draw during intermissions
				if ( pList->p->m_iFlags & HUD_INTERMISSION )
					pList->p->Draw( flTime );
			}

			pList = pList->pNext;
		}
	}

	// are we in demo mode? do we need to draw the logo in the top corner?
	if (m_iLogo)
	{
		int x, y, i;

		if (m_hsprLogo == 0)
			m_hsprLogo = LoadSprite("sprites/%d_logo.spr");

		SPR_Set(m_hsprLogo, 250, 250, 250 );
		
		x = SPR_Width(m_hsprLogo, 0);
		x = ScreenWidth - x;
		y = SPR_Height(m_hsprLogo, 0)/2;

		// Draw the logo at 20 fps
		int iFrame = (int)(flTime * 20) % MAX_LOGO_FRAMES;
		i = grgLogoFrame[iFrame] - 1;

		SPR_DrawAdditive(i, x, y, NULL);
	}

	/*
	if ( g_iVisibleMouse )
	{
		void IN_GetMousePos( int *mx, int *my );
		int mx, my;

		IN_GetMousePos( &mx, &my );
		
		if (m_hsprCursor == 0)
		{
			char sz[256];
			sprintf( sz, "sprites/cursor.spr" );
			m_hsprCursor = SPR_Load( sz );
		}

		SPR_Set(m_hsprCursor, 250, 250, 250 );
		
		// Draw the logo at 20 fps
		SPR_DrawAdditive( 0, mx, my, NULL );
	}
	*/

	return 1;
}
示例#20
0
int CHudMessage::Draw( float fTime )
{
	int i, drawn;
	client_textmessage_t *pMessage;
	float endTime;

	drawn = 0;

	if ( m_gameTitleTime > 0 )
	{
		float localTime = gHUD.m_flTime - m_gameTitleTime;
		float brightness;

		// Maybe timer isn't set yet
		if ( m_gameTitleTime > gHUD.m_flTime )
			m_gameTitleTime = gHUD.m_flTime;

		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 = gHUD.GetSpriteRect(m_HUD_title_half).right - gHUD.GetSpriteRect(m_HUD_title_half).left;
			int fullWidth = halfWidth + gHUD.GetSpriteRect(m_HUD_title_life).right - gHUD.GetSpriteRect(m_HUD_title_life).left;
			int fullHeight = gHUD.GetSpriteRect(m_HUD_title_half).bottom - gHUD.GetSpriteRect(m_HUD_title_half).top;

			int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth );
			int y = YPosition( m_pGameTitle->y, fullHeight );


			SPR_Set( gHUD.GetSprite(m_HUD_title_half), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
			SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_title_half) );

			SPR_Set( gHUD.GetSprite(m_HUD_title_life), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
			SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect(m_HUD_title_life) );

			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] > gHUD.m_flTime )
				m_startTime[i] = gHUD.m_flTime + 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;
			}

			if ( fTime <= endTime )
			{
				float messageTime = fTime - 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 = gHUD.m_flTime;
	// Don't call until we get another message
	if ( !drawn )
		m_iFlags &= ~HUD_ACTIVE;

	return 1;
}
示例#21
0
文件: message.cpp 项目: puzl/NS3.2
int CHudMessage::Draw( float fTime )
{
	int i, drawn;
	client_textmessage_t *pMessage;
	
	drawn = 0;

	if ( m_gameTitleTime > 0 )
	{
		float localTime = gHUD.m_flTime - m_gameTitleTime;
		float brightness;

		// Maybe timer isn't set yet
		if ( m_gameTitleTime > gHUD.m_flTime )
			m_gameTitleTime = gHUD.m_flTime;

		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 = gHUD.GetSpriteRect(m_HUD_title_half).right - gHUD.GetSpriteRect(m_HUD_title_half).left;
			int fullWidth = halfWidth + gHUD.GetSpriteRect(m_HUD_title_life).right - gHUD.GetSpriteRect(m_HUD_title_life).left;
			int fullHeight = gHUD.GetSpriteRect(m_HUD_title_half).bottom - gHUD.GetSpriteRect(m_HUD_title_half).top;

			int x = XPosition( m_pGameTitle->x, fullWidth, fullWidth );
			int y = YPosition( m_pGameTitle->y, fullHeight );


			SPR_Set( gHUD.GetSprite(m_HUD_title_half), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
			SPR_DrawAdditive( 0, x, y, &gHUD.GetSpriteRect(m_HUD_title_half) );

			SPR_Set( gHUD.GetSprite(m_HUD_title_life), brightness * m_pGameTitle->r1, brightness * m_pGameTitle->g1, brightness * m_pGameTitle->b1 );
			SPR_DrawAdditive( 0, x + halfWidth, y, &gHUD.GetSpriteRect(m_HUD_title_life) );

			drawn++;
		}
	}

	// Draw player id
//	if(this->mPlayerIDTime > 0)
//	{
//		float localTime = gHUD.m_flTime - this->mPlayerIDTime;
//		//float brightness;
//		
//		// Maybe timer isn't set yet
//		if ( this->mPlayerIDTime > gHUD.m_flTime )
//			this->mPlayerIDTime = gHUD.m_flTime;
//		
//		if ( localTime > (this->mPlayerIDMessage.fadein + this->mPlayerIDMessage.holdtime + this->mPlayerIDMessage.fadeout) )
//		{
//			this->mPlayerIDTime = 0;
//			this->mPlayerIDMessage.pName = NULL;
//			this->mPlayerIDMessage.pMessage = NULL;
//		}
//		else
//		{
//			drawn++;
//		}
//	}
	
	// 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] > gHUD.m_flTime )
				m_startTime[i] = gHUD.m_flTime + m_parms.time - m_startTime[i] + 0.2;	// Server takes 0.2 seconds to spawn, adjust for this
		}
	}
	
	for ( i = 0; i < maxHUDMessages; i++ )
	{
		client_textmessage_t* theMessage = this->m_pMessages[i];
		if(theMessage)
		{
			if(this->DrawMessage(theMessage, this->m_startTime[i], fTime))
			{
				drawn++;
			}
			else
			{
				// The message is over
				this->m_pMessages[i] = NULL;
			}
		}
	}

	if(this->DrawMessage(&this->mPlayerIDMessage, this->mPlayerIDTime, fTime))
	{
		drawn++;
	}
	else
	{
		this->mPlayerIDMessage.pName = NULL;
		this->mPlayerIDMessage.pMessage = NULL;
	}
		
	
	// Remember the time -- to fix up level transitions
	m_parms.time = gHUD.m_flTime;
	// Don't call until we get another message
	if ( !drawn )
		m_iFlags &= ~HUD_ACTIVE;
	
	return 1;
}
示例#22
0
int CHudBattery::Draw(float flTime)
{
	if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
		return 1;

	// modif de jUlien
	if ( !(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)))  )
		return 1;

/*
	int r, g, b, x, y, a;
	wrect_t rc;

	rc = *m_prc2;
	rc.top  += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01);	// battery can go from 0 to 100 so * 0.01 goes from 0 to 1

	UnpackRGB(r,g,b, RGB_YELLOWISH);

	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
		return 1;

	// Has health changed? Flash the health #
	if (m_fFade)
	{
		if (m_fFade > FADE_TIME)
			m_fFade = FADE_TIME;

		m_fFade -= (gHUD.m_flTimeDelta * 20);
		if (m_fFade <= 0)
		{
			a = 128;
			m_fFade = 0;
		}

		// Fade the health number back to dim

		a = MIN_ALPHA +  (m_fFade/FADE_TIME) * 128;

	}
	else
		a = MIN_ALPHA;

	ScaleColors(r, g, b, a );
	
	int iOffset = (m_prc1->bottom - m_prc1->top)/6;

	y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
	x = ScreenWidth/5;

	// make sure we have the right sprite handles
	if ( !m_hSprite1 )
		m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
	if ( !m_hSprite2 )
		m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );

	SPR_Set(m_hSprite1, r, g, b );
	SPR_DrawAdditive( 0,  x, y - iOffset, m_prc1);

	if (rc.bottom > rc.top)
	{
		SPR_Set(m_hSprite2, r, g, b );
		SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
	}

	x += (m_prc1->right - m_prc1->left);
	x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);
*/


	// modif de Julien
	// affichage du nouveau hud
	
	for ( int i = 0; i < 7; i++ )
	{
		// couleurs précalculées
		int r = m_flArmor[i][0], g = m_flArmor[i][1], b = m_flArmor[i][2];

		// brillance pour les dommages
		if ( m_flPain[i] > 0 )
		{
			// blanc
			r = r + ( m_flPain[i] / ARMOR_PAIN_TIME ) * ( 255 - r );
			g = g + ( m_flPain[i] / ARMOR_PAIN_TIME ) * ( 255 - g );
			b = b + ( m_flPain[i] / ARMOR_PAIN_TIME ) * ( 255 - b );

			m_flPain[i] = max ( 0, m_flPain[i] - gHUD.m_flTimeDelta );
		}

		if ( m_flPain[i] < 0 )
		{
			// rouge
			r = r + ( -m_flPain[i] / ARMOR_PAIN_TIME ) * ( 255 - r );
			g = g + ( -m_flPain[i] / ARMOR_PAIN_TIME ) * ( 0 - g );
			b = b + ( -m_flPain[i] / ARMOR_PAIN_TIME ) * ( 0 - b );

			m_flPain[i] = min ( 0, m_flPain[i] + gHUD.m_flTimeDelta );
		}

		ScaleColors ( r,g,b, 200 );

		SPR_Set( m_sprCorps, r, g, b );
		SPR_DrawAdditive(i, 0, 0, &m_wrcCorps);
	}

	//-----------------------

	return 1;
}
示例#23
0
int CHudRadar::Draw(float flTime)
{	if ( (gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH) || gEngfuncs.IsSpectateOnly() || !(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT))))
	{	return 1;
	}

	cl_entity_t *pLocal = gEngfuncs.GetLocalPlayer();
	if(!pLocal)
	{	return 1;
	}

	float flPlayerAngles, flLength, flAngle, flRadians, pos_x, pos_y;
	vec3_t vecViewAngles, v_right, vecPlayerOrigin, vecOtherOrigin, vecDifference, vecAngles;

	/*
	* Draw Background radar
	*/

	// Get origin for radar
	int x = ScreenWidth;
	int y = 0;

	int iRadarWidth = gHUD.GetSpriteRect(m_HUD_radar).right - gHUD.GetSpriteRect(m_HUD_radar).left;
	int iRadarHeight = gHUD.GetSpriteRect(m_HUD_radar).bottom - gHUD.GetSpriteRect(m_HUD_radar).top;

	int infox = ScreenWidth - INFO_WIDTH;
	int infoy = iRadarHeight;
	int infoheight = gHUD.GetSpriteRect(m_HUD_radar_info).bottom - gHUD.GetSpriteRect(m_HUD_radar_info).top;

	x -= iRadarWidth;
	
	// Slide radar + info bar in/out when we enable/disable
	if(m_blPrevRadar != m_blRadar && !m_blSliding)
	{	m_blSliding = true;
		m_flSlideTime = flTime;
	}
	// We switched the radar on/off while in the middle of sliding
	else if(m_blPrevRadar == m_blRadar && m_blSliding)
	{	m_blPrevRadar = !m_blPrevRadar;
		// Invert time
		float flSlideTime = flTime - m_flSlideTime;
		flSlideTime = SLIDETIME - flSlideTime;
		m_flSlideTime = flTime - flSlideTime;
	}

	if(m_blSliding)
	{	// Sliding is done, disable
		if((m_flSlideTime + SLIDETIME) < flTime)
		{	m_blSliding = false;
			m_flSlideTime = 0;
			m_blPrevRadar = m_blRadar;

			// Done sliding and radar is off, disable
			if(!m_blRadar)
			{	return 1;
			}
		}
		// we're still sliding
		else
		{	float flPercent;
			if(m_blRadar)
				flPercent = (SLIDETIME-(flTime - m_flSlideTime))/SLIDETIME;
			else
				flPercent = (flTime - m_flSlideTime)/SLIDETIME;
			
			// Slide Radar
			y = -iRadarHeight * flPercent;
			// Slide Infobox
			infox += INFO_WIDTH * flPercent;
		}
	}

	// Done sliding and radar is off, disable
	if(!m_blRadar && !m_blSliding)
	{	return 1;
	}
	// Draw Radar
	SPR_Set(gHUD.GetSprite(m_HUD_radar), 255, 255, 255);
	SPR_DrawHoles(0, x,y, &gHUD.GetSpriteRect(m_HUD_radar));

	// Draw info box
	SPR_Set(gHUD.GetSprite(m_HUD_radar_info), 255,255,255);
	SPR_DrawHoles(0, infox,infoy, &gHUD.GetSpriteRect(m_HUD_radar_info));

	if(m_blSliding)
		m_iyBottomRadar = y + iRadarHeight;
	else
		m_iyBottomRadar = infoy + infoheight;

	// Sliding or radar is just off, dont display information
	if(m_blSliding || !m_blRadar)
	{	return 1;
	}
	/*
	* Get Player Angles
	*/

	// Setting player angles
	gEngfuncs.GetViewAngles((float *)vecViewAngles);
	AngleVectors(vecViewAngles, NULL, v_right, NULL );
	// Inverse vector
	VectorInverse(v_right);
	v_right.z = 0;

	// Get angles
	VectorAngles(v_right,vecAngles);
	flPlayerAngles = vecAngles.y;

	// strictly 0 to 360
	if(flPlayerAngles < 0)
		flPlayerAngles += 360;

	// Move x and y to the middle of the radar
	x += OFFSET_RAD_WIDTH;
	y += OFFSET_RAD_HEIGHT;

	/*
	* Loop and draw dots
	*/
	for(int i=0; i<MAX_PLAYERS; i++)
	{	int r=255,g=255,b=255;
		bool blDrawInfo = false;
		cl_entity_t *pPlayer = gEngfuncs.GetEntityByIndex(i);
		// Invalid
		if(!pPlayer)
		{	continue;
		}

		// Not player
		if(!pPlayer->player)
		{	continue;
		}

		// Render check, make sure player is being rendered
		if(!g_RenderCheck[i].blRendered)
		{	continue;
		}

		// Draw yourself as a orange dot
		if(pPlayer == pLocal)
		{	r=255;
			g=255;
			b=0;
		}

		// Get Origins
		vecPlayerOrigin = pLocal->origin;
		vecOtherOrigin = pPlayer->origin;
		vecPlayerOrigin.z = 0;
		vecOtherOrigin.z = 0;
		vecDifference = vecPlayerOrigin - vecOtherOrigin;

		flLength = vecDifference.Length();

		// Player is too far away, dont draw
		if(flLength > MAX_RADAR_DIST)
			continue;

		vecDifference = vecDifference.Normalize();

		// Set 0 to 360
		VectorAngles(vecDifference, vecAngles);
		flAngle = vecAngles.y;

		if(flAngle < 0)
			flAngle += 360;

		// Subtract Angles
		flAngle = flPlayerAngles - flAngle;

		// Set length according to the size of the radar
		flLength = (flLength/(float)MAX_RADAR_DIST) * RAD_DIAM;

		// Angles to radians
		flRadians = flAngle * PI_180;
		pos_x = int(cos(flRadians)*flLength);
		pos_y = int(sin(flRadians)*flLength);

		// Set positions + draw radar
		pos_x += x;
		pos_y += y;

		// Shift dot over so it's drawn in the correct position
		int iDotWidth = (gHUD.GetSpriteRect(m_HUD_radardot).right - gHUD.GetSpriteRect(m_HUD_radardot).left)/2;
		int iDotHeight = (gHUD.GetSpriteRect(m_HUD_radardot).bottom - gHUD.GetSpriteRect(m_HUD_radardot).top)/2;
		pos_x -= iDotWidth;
		pos_y -= iDotHeight;

		// Person is targeted by our missles, color them red
		if( gHUD.m_Lockon.FindLock( pPlayer->index ) != -1 )
		{	r=255;
			g=0;
			b=0;
		}

		// Yellow if our crosshair is/was over the player
		if(	gHUD.m_Crosshair.m_iMouseOverEnt == pPlayer->index && ((flTime - gHUD.m_Crosshair.m_flMouseOverTime) < 3) )
		{	UnpackRGB(r,g,b, RGB_YELLOWISH);
			blDrawInfo = true;
		}

		// Draw
		SPR_Set(gHUD.GetSprite(m_HUD_radardot), r,g,b);
		SPR_DrawAdditive(0, pos_x,pos_y, &gHUD.GetSpriteRect(m_HUD_radardot));

		// Draw information if specified
		if(blDrawInfo)
		{	int line_height=0,line_width=0;
			pos_x = ScreenWidth - INFO_WIDTH + INFO_OFFSET_WIDTH;
			pos_y = iRadarHeight + INFO_OFFSET_HEIGHT;

			hud_player_info_t *pl_info = &g_PlayerInfoList[i];
			char szName[128];

			// Get colors
			float flTeamR,flTeamG,flTeamB;
			if((g_PlayerExtraInfo[i].teamnumber == g_PlayerExtraInfo[pLocal->index].teamnumber) && gHUD.m_Teamplay)
			{	flTeamR=0;
				flTeamG=0.9;
				flTeamB=0;
			}
			else
			{	flTeamR=1.0;
				flTeamG=0.2;
				flTeamB=0.2;
			}
			
			// Draw player name
			strcpy(szName,"Name: ");
			int iNameX = DrawConsoleString( pos_x, pos_y, szName );
			// Draw name in color, depending if player is on your team
			strcpy(szName, pl_info->name);
			// Set color
			gEngfuncs.pfnDrawSetTextColor(flTeamR,flTeamG,flTeamB);
			// Draw
			DrawConsoleString( iNameX, pos_y, szName );


			// Adjust offset
			GetConsoleStringSize( szName, &line_width, &line_height );
			pos_y += line_height + INFO_OFFSET_LINE;
			// Draw Label
			strcpy(szName,"Mech: ");
			iNameX = DrawConsoleString( pos_x, pos_y, szName );
			// Get Mech Name
			int iClass = g_PlayerExtraInfo[i].playerclass;
			if(iClass < 0)
				iClass = 0;
			else if(iClass >= PC_LASTCLASS)
				iClass = PC_LASTCLASS-1;
			strcpy(szName, szClassNames[iClass] );
			// Set Color
			gEngfuncs.pfnDrawSetTextColor(flTeamR,flTeamG,flTeamB);
			// Draw Mech Name
			DrawConsoleString( iNameX, pos_y, szName );
		}
	}

	return 1;
}
示例#24
0
int CHudAmmo::Draw(float flTime)
{
	int a, x, y, r, g, b;
	int AmmoWidth;

	int   iCrossX;
	int   iCrossY;
	int   iCrossLength;
	char *chCrossHair = "+"; // Heh

	/*if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
		return 1;*/

	if((gHUD.m_iHideHUDDisplay & (HIDEHUD_WEAPONS | HIDEHUD_ALL)))
		return 1;

	// Draw Weapon Menu
	DrawWList(flTime);

	// Draw ammo pickup history
	gHR.DrawAmmoHistory(flTime);

	if(!(m_iFlags & HUD_ACTIVE))
		return 0;

	if(!m_pWeapon)
		return 0;

	WEAPON *pw = m_pWeapon; // shorthand

	// SPR_Draw Ammo
	if((pw->iAmmoType < 0) && (pw->iAmmo2Type < 0))
		return 0;

	int iFlags = DHN_DRAWZERO; // draw 0 values

	AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;

	a = (int)max(MIN_ALPHA, m_fFade);

	if(m_fFade > 0)
		m_fFade -= (gHUD.m_flTimeDelta * 20);

	UnpackRGB(r, g, b, RGB_YELLOWISH);

	ScaleColors(r, g, b, a);

	// Does this weapon have a clip?
	y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;

	/******************* DRAW CROSSHAIR *********************/
	iCrossLength = gHUD.m_scrinfo.charWidths[*chCrossHair];
	iCrossY      = ScreenHeight / 2 - gHUD.m_scrinfo.iCharHeight / 2;
	iCrossX      = ScreenWidth / 2 - iCrossLength / 2;

	gHUD.DrawHudString(iCrossX, iCrossY, iCrossX + 50, chCrossHair, 170, 170, 170);
	/******************* DRAW CROSSHAIR *********************/

	// Does weapon have any ammo at all?
	if(m_pWeapon->iAmmoType > 0)
	{
		int iIconWidth = m_pWeapon->rcAmmo.right - m_pWeapon->rcAmmo.left;

		if(pw->iClip >= 0)
		{
			x = ScreenWidth - (8 * AmmoWidth) - iIconWidth;

			UnpackRGB(r, g, b, RGB_YELLOWISH);
			// GL Seems to need this
			ScaleColors(r, g, b, a);
			m_iNumberXPosition = x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, gWR.CountAmmo(pw->iAmmoType), r, g, b);
		}

		// Draw the ammo Icon
		int iOffset = (m_pWeapon->rcAmmo.bottom - m_pWeapon->rcAmmo.top) / 8;
		SPR_Set(m_pWeapon->hAmmo, r, g, b);
		SPR_DrawAdditive(0, x, y - iOffset, &m_pWeapon->rcAmmo);

		m_iXPosition = x;
	}

	return 1;
}
示例#25
0
//
// Draw Weapon Menu
//
int CHudAmmo::DrawWList(float flTime)
{
	int r, g, b, x, y, a, i;

	if(!gpActiveSel)
		return 0;

	int iActiveSlot;

	if(gpActiveSel == (WEAPON *)1)
		iActiveSlot = -1; // current slot has no weapons
	else
		iActiveSlot = gpActiveSel->iSlot;

	x = 10; //!!!
	y = 10; //!!!

	// Ensure that there are available choices in the active slot
	if(iActiveSlot > 0)
	{
		if(!gWR.GetFirstPos(iActiveSlot))
		{
			gpActiveSel = (WEAPON *)1;
			iActiveSlot = -1;
		}
	}

	// Draw top line
	for(i = 0; i < MAX_WEAPON_SLOTS; i++)
	{
		int iWidth;

		UnpackRGB(r, g, b, RGB_YELLOWISH);

		if(iActiveSlot == i)
			a = 255;
		else
			a = 192;

		ScaleColors(r, g, b, 255);
		SPR_Set(gHUD.GetSprite(m_HUD_bucket0 + i), r, g, b);

		// make active slot wide enough to accomodate gun pictures
		if(i == iActiveSlot)
		{
			WEAPON *p = gWR.GetFirstPos(iActiveSlot);

			if(p)
				iWidth = p->rcActive.right - p->rcActive.left;
		}
		else
			iWidth = giBucketWidth;

		if(i == iActiveSlot)
			SPR_DrawAdditive(0, x + 104, y, &gHUD.GetSpriteRect(m_HUD_bucket0 + i));
		else
			SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_bucket0 + i));

		x += iWidth + 5;
	}

	a = 128; //!!!
	x = 10;

	// Draw all of the buckets
	for(i = 1; i < MAX_WEAPON_SLOTS + 1; i++)
	{
		y = giBucketHeight + 10;

		// If this is the active slot, draw the bigger pictures,
		// otherwise just draw boxes
		if(i == iActiveSlot)
		{
			WEAPON *p      = gWR.GetFirstPos(i);
			int     iWidth = giBucketWidth;
			if(p)
				iWidth = p->rcActive.right - p->rcActive.left;

			for(int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++)
			{
				p = gWR.GetWeaponSlot(i, iPos);

				if(!p || !p->iId)
					continue;

				UnpackRGB(r, g, b, RGB_YELLOWISH);

				// if active, then we must have ammo.

				if(gpActiveSel == p)
				{
					if(gWR.HasAmmo(p))
						ScaleColors(r, g, b, 192);
					else
					{
						UnpackRGB(r, g, b, RGB_REDISH);
						ScaleColors(r, g, b, 128);
					}

					SPR_Set(p->hActive, r, g, b);
					SPR_DrawAdditive(0, x, y, &p->rcActive);
				}
				else
				{
					// Draw Weapon if Red if no ammo

					if(gWR.HasAmmo(p))
						ScaleColors(r, g, b, 192);
					else
					{
						UnpackRGB(r, g, b, RGB_REDISH);
						ScaleColors(r, g, b, 128);
					}

					SPR_Set(p->hInactive, r, g, b);
					SPR_DrawAdditive(0, x, y, &p->rcInactive);
				}

				// Draw Ammo Bar

				DrawAmmoBar(p, x + giABWidth / 2, y, giABWidth, giABHeight);

				y += p->rcActive.bottom - p->rcActive.top + 5;
			}

			x += iWidth + 5;
		}
		else
		{
			// Draw Row of weapons.

			UnpackRGB(r, g, b, RGB_YELLOWISH);

			for(int iPos = 0; iPos < MAX_WEAPON_POSITIONS; iPos++)
			{
				WEAPON *p = gWR.GetWeaponSlot(i, iPos);

				if(!p || !p->iId)
					continue;

				if(gWR.HasAmmo(p))
				{
					UnpackRGB(r, g, b, RGB_YELLOWISH);
					a = 128;
				}
				else
				{
					UnpackRGB(r, g, b, RGB_REDISH);
					a = 96;
				}

				FillRGBA(x, y, giBucketWidth, giBucketHeight, r, g, b, a);

				y += giBucketHeight + 5;
			}

			x += giBucketWidth + 5;
		}
	}

	return 1;
}
示例#26
0
bool CHudAmmo::Draw(float flTime)
{
	int a, x, y, r, g, b;
	int AmmoWidth;

	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
		return true;

	if ( (gHUD.m_iHideHUDDisplay & ( HIDEHUD_WEAPONS | HIDEHUD_ALL )) )
		return true;

	// Draw Weapon Menu
	DrawWList(flTime);

	// Draw ammo pickup history
	gHR.DrawAmmoHistory( flTime );

	if (!(m_iFlags & HUD_ACTIVE))
		return false;

	if (!m_pWeapon)
		return false;

	if( m_pCrosshair->value != 0 && m_hCrosshair != INVALID_HSPRITE )
	{
		float flScale;

		switch( static_cast<int>( m_pCrosshairMode->value ) )
		{
		default:
		case CROSS_NATIVESCALE:
			flScale = 1;
			break;

		case CROSS_RESSCALE:
			flScale = max( ( ScreenWidth / 640.0 ) * 0.75, 1.0 );
			break;

		case CROSS_USERSCALE:
			flScale = abs( m_pCrosshairScale->value );
			break;
		}

		class CCrosshairTriCallback : public ITriCoordFallback
		{
		public:
			void Calculate( HSPRITE hSprite, const int frame, const wrect_t& rect, const float flScale, int& x, int& y ) override
			{
				x = ( ScreenWidth - ( ( rect.right - rect.left ) ) ) / 2;
				y = ( ScreenHeight - ( ( rect.bottom - rect.top ) ) ) / 2;
			}
		};

		CCrosshairTriCallback callback;

		Tri_DrawScaledSprite( m_hCrosshair, 0, m_iR, m_iG, m_iB, 255, kRenderTransTexture, flScale, callback, &m_CrosshairRC );
	}

	CBasePlayerWeapon *pw = m_pWeapon; // shorthand

	// SPR_Draw Ammo
	if( !pw->GetWeaponInfo()->GetPrimaryAmmo() && !pw->GetWeaponInfo()->GetSecondaryAmmo() )
		return false;

	int iFlags = DHN_DRAWZERO; // draw 0 values

	AmmoWidth = gHUD.GetSpriteRect(gHUD.m_HUD_number_0).right - gHUD.GetSpriteRect(gHUD.m_HUD_number_0).left;

	a = (int) max( static_cast<float>( MIN_ALPHA ), m_fFade );

	if (m_fFade > 0)
		m_fFade -= (gHUD.m_flTimeDelta * 20);

	gHUD.GetPrimaryColor().UnpackRGB(r,g,b);

	ScaleColors(r, g, b, a );

	// Does this weapon have a clip?
	y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight/2;

	CBasePlayer* pPlayer = g_Prediction.GetLocalPlayer();

	// Does weapon have any ammo at all?
	if ( auto pAmmo = pw->GetWeaponInfo()->GetPrimaryAmmo() )
	{
		const auto& ammo = m_pWeapon->GetWeaponInfo()->GetHUDInfo()->GetPrimaryAmmo();

		int iIconWidth = ammo.rect.right - ammo.rect.left;
		
		if (pw->m_iClientClip >= 0)
		{
			// room for the number and the '|' and the current ammo
			
			x = ScreenWidth - (8 * AmmoWidth) - iIconWidth;
			x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pw->m_iClientClip, r, g, b);

			wrect_t rc;
			rc.top = 0;
			rc.left = 0;
			rc.right = AmmoWidth;
			rc.bottom = 100;

			int iBarWidth =  AmmoWidth/10;

			x += AmmoWidth/2;

			gHUD.GetPrimaryColor().UnpackRGB(r,g,b);

			// draw the | bar
			FillRGBA(x, y, iBarWidth, gHUD.m_iFontHeight, r, g, b, a);

			x += iBarWidth + AmmoWidth/2;;

			// GL Seems to need this
			ScaleColors(r, g, b, a );
			x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pPlayer->CountAmmo( pAmmo->GetID() ), r, g, b);


		}
		else
		{
			// SPR_Draw a bullets only line
			x = ScreenWidth - 4 * AmmoWidth - iIconWidth;
			x = gHUD.DrawHudNumber(x, y, iFlags | DHN_3DIGITS, pPlayer->CountAmmo( pAmmo->GetID() ), r, g, b);
		}

		// Draw the ammo Icon
		int iOffset = ( ammo.rect.bottom - ammo.rect.top)/8;
		SPR_Set( ammo.hSprite, r, g, b);
		SPR_DrawAdditive(0, x, y - iOffset, &ammo.rect );
	}

	// Does weapon have seconday ammo?
	if ( auto pAmmo = pw->GetWeaponInfo()->GetSecondaryAmmo() )
	{
		const auto& ammo2 = m_pWeapon->GetWeaponInfo()->GetHUDInfo()->GetSecondaryAmmo();

		int iIconWidth = ammo2.rect.right - ammo2.rect.left;

		// Do we have secondary ammo?
		if ( pPlayer->CountAmmo( pAmmo->GetID() ) > 0 )
		{
			y -= gHUD.m_iFontHeight + gHUD.m_iFontHeight/4;
			x = ScreenWidth - 4 * AmmoWidth - iIconWidth;
			x = gHUD.DrawHudNumber(x, y, iFlags|DHN_3DIGITS, pPlayer->CountAmmo( pAmmo->GetID() ), r, g, b);

			// Draw the ammo Icon
			SPR_Set( ammo2.hSprite, r, g, b);
			int iOffset = ( ammo2.rect.bottom - ammo2.rect.top)/8;
			SPR_DrawAdditive(0, x, y - iOffset, &ammo2.rect );
		}
	}
	return true;
}
示例#27
0
bool CHudBattery::Draw(float flTime)
{
	if ( gHUD.m_iHideHUDDisplay & HIDEHUD_HEALTH )
		return true;

	wrect_t rc;

	rc = *m_prc2;

#if defined( _TFC )
	float fScale = 0.0;
	
	if ( m_iBatMax > 0 )
		fScale = 1.0 / (float)m_iBatMax;

	rc.top  += m_iHeight * ((float)(m_iBatMax-(min(m_iBatMax,m_iBat))) * fScale); // battery can go from 0 to m_iBatMax so * fScale goes from 0 to 1
#else
	rc.top  += m_iHeight * ((float)(100-(min(100,m_iBat))) * 0.01);	// battery can go from 0 to 100 so * 0.01 goes from 0 to 1
#endif

	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
		return true;

	int r, g, b, x, y, a = MIN_ALPHA;

	gHUD.GetPrimaryColor().UnpackRGB( r, g, b );

	// Has health changed? Flash the health #
	if (m_fFade)
	{
		if (m_fFade > FADE_TIME)
			m_fFade = FADE_TIME;

		m_fFade -= (gHUD.m_flTimeDelta * 20);
		if (m_fFade <= 0)
		{
			m_fFade = 0;
		}

		// Fade the health number back to dim

		a += ( m_fFade / FADE_TIME ) * 128;

	}

	ScaleColors(r, g, b, a );
	
	int iOffset = (m_prc1->bottom - m_prc1->top)/6;

	y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
	x = ScreenWidth/5;

	// make sure we have the right sprite handles
	if ( !m_hSprite1 )
		m_hSprite1 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_empty" ) );
	if ( !m_hSprite2 )
		m_hSprite2 = gHUD.GetSprite( gHUD.GetSpriteIndex( "suit_full" ) );

	SPR_Set(m_hSprite1, r, g, b );
	SPR_DrawAdditive( 0,  x, y - iOffset, m_prc1);

	if (rc.bottom > rc.top)
	{
		SPR_Set(m_hSprite2, r, g, b );
		SPR_DrawAdditive( 0, x, y - iOffset + (rc.top - m_prc2->top), &rc);
	}

	x += (m_prc1->right - m_prc1->left);
	x = gHUD.DrawHudNumber(x, y, DHN_3DIGITS | DHN_DRAWZERO, m_iBat, r, g, b);

	return true;
}
示例#28
0
int CHudHealth::DrawPain(float flTime)
{
	if(!(m_fAttackFront || m_fAttackRear || m_fAttackLeft || m_fAttackRight))
		return 1;

	int r, g, b;
	int x, y, a, shade;

	// TODO:  get the shift value of the health
	a = 255; // max brightness until then

	float fFade = gHUD.m_flTimeDelta * 2;

	// SPR_Draw top
	if(m_fAttackFront > 0.4)
	{
		GetPainColor(r, g, b);
		shade = a * max(m_fAttackFront, 0.5);
		ScaleColors(r, g, b, shade);
		SPR_Set(m_hSprite, r, g, b);

		x = ScreenWidth / 2 - SPR_Width(m_hSprite, 0) / 2;
		y = ScreenHeight / 2 - SPR_Height(m_hSprite, 0) * 3;
		SPR_DrawAdditive(0, x, y, NULL);
		m_fAttackFront = max(0, m_fAttackFront - fFade);
	}
	else
		m_fAttackFront = 0;

	if(m_fAttackRight > 0.4)
	{
		GetPainColor(r, g, b);
		shade = a * max(m_fAttackRight, 0.5);
		ScaleColors(r, g, b, shade);
		SPR_Set(m_hSprite, r, g, b);

		x = ScreenWidth / 2 + SPR_Width(m_hSprite, 1) * 2;
		y = ScreenHeight / 2 - SPR_Height(m_hSprite, 1) / 2;
		SPR_DrawAdditive(1, x, y, NULL);
		m_fAttackRight = max(0, m_fAttackRight - fFade);
	}
	else
		m_fAttackRight = 0;

	if(m_fAttackRear > 0.4)
	{
		GetPainColor(r, g, b);
		shade = a * max(m_fAttackRear, 0.5);
		ScaleColors(r, g, b, shade);
		SPR_Set(m_hSprite, r, g, b);

		x = ScreenWidth / 2 - SPR_Width(m_hSprite, 2) / 2;
		y = ScreenHeight / 2 + SPR_Height(m_hSprite, 2) * 2;
		SPR_DrawAdditive(2, x, y, NULL);
		m_fAttackRear = max(0, m_fAttackRear - fFade);
	}
	else
		m_fAttackRear = 0;

	if(m_fAttackLeft > 0.4)
	{
		GetPainColor(r, g, b);
		shade = a * max(m_fAttackLeft, 0.5);
		ScaleColors(r, g, b, shade);
		SPR_Set(m_hSprite, r, g, b);

		x = ScreenWidth / 2 - SPR_Width(m_hSprite, 3) * 3;
		y = ScreenHeight / 2 - SPR_Height(m_hSprite, 3) / 2;
		SPR_DrawAdditive(3, x, y, NULL);

		m_fAttackLeft = max(0, m_fAttackLeft - fFade);
	}
	else
		m_fAttackLeft = 0;

	return 1;
}
示例#29
0
int CHudFiremode::Draw(float flTime)
{
	if ( gHUD.m_iHideHUDDisplay & ( HIDEHUD_ALL ) )
	return 1;

	if (!(gHUD.m_iWeaponBits & (1<<(WEAPON_SUIT)) ))
		return 1;

	int r,g,b,x,y,x2;
	r = 200;
	g = 140;
	b = 0;

	y = ScreenHeight - gHUD.m_iFontHeight - gHUD.m_iFontHeight / 2;
	x = ScreenWidth/2;
	x2 = ScreenWidth/1.6;

	if (m_iType!=0)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE), r, g, b);
		SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_FIREMODE));
	}

		if (m_iType==FIREMODE_GLAUNCHER)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_GLAUNCHER), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_GLAUNCHER));
	}
		else if (m_iType==FIREMODE_QUAD)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_QUAD), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_QUAD));
	}
		else if (m_iType==FIREMODE_SCOPE)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_SCOPE), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_SCOPE));
	}
		else if (m_iType==FIREMODE_CHARGE)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_CHARGE), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_CHARGE));
	}
		else if (m_iType==FIREMODE_PULSE)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_PULSE), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_PULSE));
	}
		else if (m_iType==FIREMODE_BEAM)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_BEAM), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_BEAM));
	}
		else if (m_iType==FIREMODE_NARROW)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_NARROW), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_NARROW));
	}
		else if (m_iType==FIREMODE_WIDE)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_WIDE), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_WIDE));
	}
		else if (m_iType==FIREMODE_BOLT)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_BOLT), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_BOLT));
	}
		else if (m_iType==FIREMODE_ACCELBOLT)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_ACCELBOLT), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_ACCELBOLT));
	}
		else if (m_iType==FIREMODE_EXPBOLT)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_EXPBOLT), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_EXPBOLT));
	}
		else if (m_iType==FIREMODE_HALF)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_HALF), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_HALF));
	}
		else if (m_iType==FIREMODE_FULL)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_FULL), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_FULL));
	}
		else if (m_iType==FIREMODE_SHOOT)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_SHOOT), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_SHOOT));
	}
		else if (m_iType==FIREMODE_KNIFE)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_KNIFE), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_KNIFE));
	}
		else if (m_iType==FIREMODE_SENTRYTURRET)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_SENTRYTURRET), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_SENTRYTURRET));
	}
		else if (m_iType==FIREMODE_MISSILETURRET)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_MISSILETURRET), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_MISSILETURRET));
	}
		else if (m_iType==FIREMODE_IONTURRET)
	{
		SPR_Set(gHUD.GetSprite(m_FIREMODE_IONTURRET), r, g, b);
		SPR_DrawAdditive(0, x2, y, &gHUD.GetSpriteRect(m_FIREMODE_IONTURRET));
	}
return 1;
}
示例#30
0
//
// Draw Weapon Menu
//
int CHudAmmo::DrawWList(float flTime)
{
	int r,g,b,x,y,a,i;

	if ( !m_pActiveSel )
		return 0;

	int iActiveSlot;

	if ( m_pActiveSel == ( CBasePlayerWeapon *)1 )
		iActiveSlot = -1;	// current slot has no weapons
	else 
		iActiveSlot = m_pActiveSel->GetWeaponInfo()->GetBucket();

	x = 10; //!!!
	y = 10; //!!!
	
	CBasePlayer* pPlayer = g_Prediction.GetLocalPlayer();

	// Ensure that there are available choices in the active slot
	if ( iActiveSlot > 0 )
	{
		if ( !pPlayer->GetFirstPos( iActiveSlot ) )
		{
			m_pActiveSel = ( CBasePlayerWeapon *)1;
			iActiveSlot = -1;
		}
	}

	// Shepard : determine how many buckets we should draw
	int iBucketsToDraw = 0;
	for ( i = 0; i < MAX_WEAPON_SLOTS; i++ )
	{
		for ( int j = 0; j < MAX_WEAPONS; j++ )
		{
			CBasePlayerWeapon *pWeapon = pPlayer->GetWeapon( i, j );
			if ( pWeapon && pWeapon->GetWeaponInfo() && pWeapon->GetWeaponInfo()->GetBucket() > iBucketsToDraw )
				iBucketsToDraw = pWeapon->GetWeaponInfo()->GetBucket();
		}
	}
	iBucketsToDraw++;

	// Draw top line
	for ( i = 0; i < iBucketsToDraw; i++ )
	{
		int iWidth;

		gHUD.GetPrimaryColor().UnpackRGB(r,g,b);
	
		if ( iActiveSlot == i )
			a = 255;
		else
			a = 192;

		ScaleColors(r, g, b, 255);
		SPR_Set(gHUD.GetSprite(m_HUD_bucket0 + i), r, g, b );

		// make active slot wide enough to accomodate gun pictures
		if ( i == iActiveSlot )
		{
			CBasePlayerWeapon *p = pPlayer->GetFirstPos(iActiveSlot);
			if ( p )
				iWidth = p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.right - p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.left;
			else
				iWidth = m_iBucketWidth;
		}
		else
			iWidth = m_iBucketWidth;

		SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_bucket0 + i));
		
		x += iWidth + 5;
	}


	a = 128; //!!!
	x = 10;

	// Draw all of the buckets
	for (i = 0; i < iBucketsToDraw; i++)
	{
		y = m_iBucketHeight + 10;

		// If this is the active slot, draw the bigger pictures,
		// otherwise just draw boxes
		if ( i == iActiveSlot )
		{
			CBasePlayerWeapon *p = pPlayer->GetFirstPos( i );
			int iWidth = m_iBucketWidth;
			if ( p )
				iWidth = p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.right - p->GetWeaponInfo()->GetHUDInfo()->GetActive().rect.left;

			for ( int iPos = 0; iPos < MAX_WEAPONS; iPos++ )
			{
				p = pPlayer->GetWeapon( i, iPos );

				if ( !p || !p->GetWeaponInfo() )
					continue;

				auto pHUDInfo = p->GetWeaponInfo()->GetHUDInfo();

				gHUD.GetPrimaryColor().UnpackRGB( r,g,b );
			
				// if active, then we must have ammo.

				if ( m_pActiveSel == p )
				{
					SPR_Set( pHUDInfo->GetActive().hSprite, r, g, b );
					SPR_DrawAdditive(0, x, y, &pHUDInfo->GetActive().rect );

					SPR_Set(gHUD.GetSprite(m_HUD_selection), r, g, b );
					SPR_DrawAdditive(0, x, y, &gHUD.GetSpriteRect(m_HUD_selection));
				}
				else
				{
					// Draw Weapon if Red if no ammo

					if ( pPlayer->HasAmmo(p) )
						ScaleColors(r, g, b, 192);
					else
					{
						gHUD.GetEmptyItemColor().UnpackRGB(r,g,b);
						ScaleColors(r, g, b, 128);
					}

					SPR_Set( pHUDInfo->GetInactive().hSprite, r, g, b );
					SPR_DrawAdditive( 0, x, y, &pHUDInfo->GetInactive().rect );
				}

				// Draw Ammo Bar

				DrawAmmoBar(p, x + m_iABWidth/2, y, m_iABWidth, m_iABHeight);
				
				y += pHUDInfo->GetActive().rect.bottom - pHUDInfo->GetActive().rect.top + 5;
			}

			x += iWidth + 5;

		}
		else
		{
			// Draw Row of weapons.

			gHUD.GetPrimaryColor().UnpackRGB(r,g,b);

			for ( int iPos = 0; iPos < MAX_WEAPONS; iPos++ )
			{
				CBasePlayerWeapon *p = pPlayer->GetWeapon( i, iPos );
				
				if ( !p || !p->GetWeaponInfo() )
					continue;

				if ( pPlayer->HasAmmo(p) )
				{
					gHUD.GetPrimaryColor().UnpackRGB(r,g,b);
					a = 128;
				}
				else
				{
					gHUD.GetEmptyItemColor().UnpackRGB(r,g,b);
					a = 96;
				}

				FillRGBA( x, y, m_iBucketWidth, m_iBucketHeight, r, g, b, a );

				y += m_iBucketHeight + 5;
			}

			x += m_iBucketWidth + 5;
		}
	}	

	return 1;

}