コード例 #1
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 );
		}
	}
コード例 #2
0
ファイル: slowmotion.cpp プロジェクト: suXinjke/HalfPayne
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;
}
コード例 #3
0
ファイル: cdll_int.cpp プロジェクト: Arkshine/NS
void UIDrawVariableBarSpriteHoles(int inSprite, int inX, int inY, float inPercentage)
{
	// Assumes that frame 0 is the empty sprite, frame 1 is full sprite
	const int kEmptyFrame = 0;
	const int kFullFrame = 1;
	
	int theSpriteWidth = SPR_Width(inSprite, kFullFrame);
	int theSpriteHeight = SPR_Height(inSprite, kFullFrame);
	
	int theColorComponent = 255;
	
	// Draw empty sprite
	SPR_Set(inSprite, theColorComponent, theColorComponent, theColorComponent);
	SPR_DrawHoles(kEmptyFrame, inX, inY, NULL);
	
	// Draw secondary level if specified, at half brightness
	int theFilledHeight = theSpriteHeight*inPercentage;
	theFilledHeight = theSpriteHeight*inPercentage;
	
	// Draw partially full sprite.  Enable scissor so it's not all drawn.
	SPR_EnableScissor(inX, inY + (theSpriteHeight - theFilledHeight), theSpriteWidth, theFilledHeight);
	
	SPR_Set(inSprite, theColorComponent, theColorComponent, theColorComponent);
	SPR_DrawHoles(kFullFrame, inX, inY, NULL);
	
	SPR_DisableScissor();
}
コード例 #4
0
int CHudBackground::Draw(float flTime)
{
	int r = 0, g = 0, b = 0, x = 0, y = 0;
	int x_length = 0, y_length = 0;      // positions of the spots

	y_length = gHUD.GetSpriteRect(m_HUD_back).bottom - gHUD.GetSpriteRect(m_HUD_back).top;
	x_length = gHUD.GetSpriteRect(m_HUD_back).right - gHUD.GetSpriteRect(m_HUD_back).left;

	UnpackRGB(r, g, b, RGB_WHITEISH);
	ScaleColors(r, g, b, 255);
	// position the sprite in the upper right corner of display...
	x = XRES(0);

	y = (YRES(480) - y_length);

	if (g_iWaterLevel != 3)
	{
		y_length = gHUD.GetSpriteRect(m_HUD_back).bottom - gHUD.GetSpriteRect(m_HUD_back).top;
		x_length = gHUD.GetSpriteRect(m_HUD_back).right - gHUD.GetSpriteRect(m_HUD_back).left;

		SPR_Set(m_hSprite, r, g, b);
		SPR_DrawHoles(0, x, y, m_SpriteArea);
		return 1;
	}
	else
	{
		y_length = gHUD.GetSpriteRect(m_HUD_water).bottom - gHUD.GetSpriteRect(m_HUD_water).top;
		x_length = gHUD.GetSpriteRect(m_HUD_water).right - gHUD.GetSpriteRect(m_HUD_water).left;

		SPR_Set(gHUD.GetSprite(m_HUD_water), r, g, b);
		SPR_DrawHoles((((int)(flTime*14))%24), x, y, m_SpriteArea);
		return 0;
	}
}
コード例 #5
0
ファイル: hud_redraw.cpp プロジェクト: XashDev/XashXT
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;
}
コード例 #6
0
ファイル: flashlight.cpp プロジェクト: Arkshine/NS
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;
}
コード例 #7
0
ファイル: CHudFlashlight.cpp プロジェクト: oskarlh/HLEnhanced
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;
}
コード例 #8
0
ファイル: hud_Timer_icon.cpp プロジェクト: mittorn/hlwe_src
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;
}
コード例 #9
0
ファイル: health.cpp プロジェクト: 6779660/halflife
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;
}
コード例 #10
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;
}
コード例 #11
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);
}
コード例 #12
0
ファイル: ammo_secondary.cpp プロジェクト: FWGS/hlsdk-xash3d
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;
}
コード例 #13
0
ファイル: hud_redraw.cpp プロジェクト: 6779660/halflife
// 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;
}
コード例 #14
0
ファイル: money.cpp プロジェクト: AlexCSilva/cs16-client
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)
コード例 #15
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;
}
コード例 #16
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;
}
コード例 #17
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;
}
コード例 #18
0
ファイル: hud_cloak_icon.cpp プロジェクト: mittorn/hlwe_src
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;
}
コード例 #19
0
// Draw node lines
void PieNode::paintBackground()
{
    // For each child
    for(int i = 0; i < kNumNodes; i++)
    {
        PieNode* theCurrentPieNode = this->mArray[i];
        if(theCurrentPieNode)
        {
            // Draw line from us to them indicating pie node in that direction
            if(theCurrentPieNode->GetValveAlpha() < 255)
            {
                // If node above us isn't highlighted, don't draw line to us
                //if(theCurrentPieNode->HasSelectedNodeAbove() || theCurrentPieNode->HasSelectedNodeBelow())
				
				// All those lines are getting confusing.  Only draw the lines around this pie node that
				// connect to a selected parent or selected child
                if(theCurrentPieNode->HasSelectedNodeBelow() || this->GetDrawSelected())
                {
                    // Find correct line to draw from center of edge of source pie node to center
                    // of edge of dest pie node
                    int theRelativeLineX0, theRelativeLineY0, theRelativeLineX1, theRelativeLineY1;
                    if(this->ComputeRelativeConnectorCoordinates(theCurrentPieNode, theRelativeLineX0, theRelativeLineY0, theRelativeLineX1, theRelativeLineY1))
                    {
                        // What color to draw the line in?
                        //vgui::Color theCurrentColor = this->GetColor();
                        vgui::Color theCurrentColor;
						//theCurrentPieNode->getBgColor(theCurrentColor);
						
						if(this->mEnabled)
						{
							theCurrentPieNode->getFgColor(theCurrentColor);
						}
						else
						{
							theCurrentPieNode->getBgColor(theCurrentColor);
						}
						
                        int r, g, b, a;
                        theCurrentColor.getColor(r, g, b, a);

						// Take gamma into account
						//r *= this->mColorBias;
						//g *= this->mColorBias;
						//b *= this->mColorBias;
						a = this->GetValveAlpha();

//						//if(theCurrentPieNode->GetEnabled())
//						//{
//						g = (theCurrentPieNode->HasSelectedNodeBelow() ? 255 : kDarkGreenColor);
//						//g = (theCurrentPieNode->HasSelectedNodeAbove() ? 255 : kDarkGreenColor);
//						//}
//						// ...else this will draw lines in disabled color too, using current fade alpha
                        
                        // Stupid Valve-alpha, vguiSimpleLine wants normal alpha of course
						a = 255 - a;
						a *= this->mColorBias;
						
						// Only draw if child isn't invisible.  Draw line
						// relative from current node.

						if(this->mConnectorSprite == 0 && (this->mConnectorSpriteName != ""))
						{
							this->mConnectorSprite = Safe_SPR_Load(this->mConnectorSpriteName.c_str());
						}

						if(this->mConnectorSprite > 0)
						{
							// Approximate alpha
							float theAlpha = a/255.0f;
							int theSpriteRed = theAlpha*r;
							int theSpriteGreen = theAlpha*g;
							int theSpriteBlue = theAlpha*b;
							
							SPR_Set(this->mConnectorSprite, theSpriteRed, theSpriteGreen, theSpriteBlue);
							int theLineWidth = abs(theRelativeLineX1 - theRelativeLineX0);
							int theLineHeight = abs(theRelativeLineY1 - theRelativeLineY0);
							
							// Use second frame if vertical
							int theConnectorFrame = 0;
							if(theLineHeight > 0)							
							{
								theConnectorFrame = 1;
							}
							
							int theConnectorSpriteWidth = SPR_Width(this->mConnectorSprite, theConnectorFrame);
							int theConnectorSpriteHeight = SPR_Height(this->mConnectorSprite, theConnectorFrame);

							int thePieNodeWidth, thePieNodeHeight;
							this->getContentSize(thePieNodeWidth, thePieNodeHeight);
							
							int thePieNodeX, thePieNodeY;
							this->getPos(thePieNodeX, thePieNodeY);
							
							int theStartX = 0;
							int theStartY = 0;

							if(theConnectorFrame == 0)
							{
								int theXOffset = (theLineWidth - theConnectorSpriteWidth)/2;
								//if(theXOffset < 0)
								//	theXOffset = 0;
								
								theStartX = min(theRelativeLineX0, theRelativeLineX1) + theXOffset;
								theStartY = min(theRelativeLineY0, theRelativeLineY1) - theConnectorSpriteHeight/2;

//								int theScissorStartX = thePieNodeX + min(theRelativeLineX0, theRelativeLineX1) + thePieNodeWidth/2;
//								int theScissorStartY = thePieNodeY + theStartY;
//								int theScissorEndX = theScissorStartX + theLineWidth - thePieNodeWidth/2;
//								int theScissorEndY = theScissorStartY + theConnectorSpriteHeight;
								
								//vguiSimpleBox(theScissorStartX - thePieNodeX, theScissorStartY - thePieNodeY, theScissorEndX - thePieNodeX, theScissorEndY - thePieNodeY, 255, 255, 0, 128);

//								SPR_EnableScissor(theScissorStartX, theScissorStartY, theLineWidth, theConnectorSpriteHeight);
							}
							else
							{
								int theYOffset = (theLineHeight - theConnectorSpriteHeight)/2;
								//if(theYOffset < 0)
								//	theYOffset = 0;

								theStartX = min(theRelativeLineX0, theRelativeLineX1) - theConnectorSpriteWidth/2;
								theStartY = min(theRelativeLineY0, theRelativeLineY1) + theYOffset;

//								int theScissorStartX = thePieNodeX + theStartX;
//								int theScissorStartY = thePieNodeY + min(theRelativeLineY0, theRelativeLineY1);
//								int theScissorEndX = theScissorStartX + theConnectorSpriteWidth;
//								int theScissorEndY = theScissorStartY + theLineHeight - thePieNodeHeight;
								
								//vguiSimpleBox(theScissorStartX - thePieNodeX, theScissorStartY - thePieNodeY, theScissorEndX - thePieNodeX, theScissorEndY - thePieNodeY, 255, 255, 0, 128);

//								SPR_EnableScissor(theScissorStartX, theScissorStartY, theConnectorSpriteWidth, theLineHeight);
							}

							// Take into account our position, including our parent(s), when drawing
//							Panel* theParent = this->getParent();
//							while(theParent)
//							{
//								int theX, theY;
//								theParent->getPos(theX, theY);
//								theStartX += theX;
//								theStartY += theY;
//								theParent = theParent->getParent();
//							}

							// Draw it
							//SPR_DrawAdditive(theConnectorFrame, theStartX, theStartY, NULL);
							SPR_DrawHoles(theConnectorFrame, theStartX, theStartY, NULL);
//							gEngfuncs.pfnSPR_DisableScissor();
							
						}
						else
						{
							vguiSimpleLine(theRelativeLineX0, theRelativeLineY0, theRelativeLineX1, theRelativeLineY1, r, g, b, a);
						}

						vguiSimpleBox(theRelativeLineX0, theRelativeLineY0, theRelativeLineX1, theRelativeLineY1, 255, 255, 0, 128);
					}
				}
			}
		}
	}
}
コード例 #20
0
ファイル: hud_firemode.cpp プロジェクト: mittorn/hlwe_src
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;
}
コード例 #21
0
ファイル: CHudBattery.cpp プロジェクト: swmpdg/HLEnhanced
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;
}
コード例 #22
0
ファイル: battery.cpp プロジェクト: Avatarchik/cs16-client
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;
}
コード例 #23
0
ファイル: hud_redraw.cpp プロジェクト: ET-NiK/amxxgroup
// 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;
}
コード例 #24
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;
}
コード例 #25
0
ファイル: ammo.cpp プロジェクト: Sh1ft0x0EF/HLSDKRevamp
//
// 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
void FadingImageLabel::DoPaint()
{
	//const float thePercentToChopOffXEdge = .1f;
	//const float thePercentToChopOffYEdge = 0.0f;

	int theX, theY;
	this->getPos(theX, theY);

	//if(!IEngineStudio.IsHardware())
	//{
	//	theX += ScreenWidth/2;
	//	theY += ScreenHeight/2;
	//}
	
	int theWidth, theHeight;
	this->getSize(theWidth, theHeight);

	//ASSERT(this->mVisibleWidth <= theWidth);
	//ASSERT(this->mVisibleHeight <= theHeight);

	if((this->mVisibleWidth <= theWidth) && (this->mVisibleHeight <= theHeight))
	{
		int r, g, b, a;
		this->getBgColor(r, g, b, a);

		float theGammaSlope = gHUD.GetGammaSlope();
		r = r/theGammaSlope;
		g = g/theGammaSlope;
		b = b/theGammaSlope;
		
		// Don't take gamma slope into account for alpha
		a = 255 - a;

		////int theXBorder = thePercentToChopOffXEdge*ScreenWidth;
		////int theYBorder = thePercentToChopOffYEdge*ScreenHeight;
		int theXBorder = (theWidth - this->mVisibleWidth)/2;
		int theYBorder = (theHeight - this->mVisibleHeight)/2;

		//vguiSimpleBox(theXBorder, theYBorder, theWidth - theXBorder*2 + theXBorder, theHeight - theYBorder*2 + theYBorder, r, g, b, a);
		
		if(!this->mImageMode)
		{
			//FillRGBA(theXBorder, theYBorder, theWidth - theXBorder*2, theHeight - theYBorder*2, r, g, b, a);

			//int theSprite = Safe_SPR_Load("sprites/marinenode.spr");
			//DrawScaledHUDSprite(theSprite, kRenderTransAdd, 1, theX, theY, theWidth, theHeight, 0);
			
			gEngfuncs.pTriAPI->RenderMode(kRenderTransAlpha);
			gEngfuncs.pTriAPI->CullFace(TRI_NONE);
			//gEngfuncs.pTriAPI->Brightness(1);
			theX = theXBorder;
			theY = theYBorder;
			theWidth = theWidth - theXBorder*2;
			theHeight = theHeight - theYBorder*2;

			// 0 = selectable, valid
			// 1 = selectable, valid, current
			// 2 = selectable, invalid
			// 3 = selectable, invalid, current
			int theFrame = 0;

			if(this->GetEnabled() && this->GetDrawHighlighted())
			{
				theFrame = 1;
			}
			else if(!this->GetEnabled())
			{
				theFrame = this->GetFadeState() ? 3 : 2;
			}

			//char theFrameNumber[64];
			//sprintf(theFrameNumber, "Frame %d", theFrame);
			//this->mTextImage.setText(theFrameNumber);

			if(!this->mSprite)
			{
				this->mSprite = Safe_SPR_Load(this->mImageName.c_str());
				this->mSpriteWidth = SPR_Width(this->mSprite, this->mSpriteFrame);
				this->mSpriteHeight = SPR_Height(this->mSprite, this->mSpriteFrame);
				ASSERT(this->mSprite > 0);
			}
			
			if(this->mSprite && gEngfuncs.pTriAPI->SpriteTexture((struct model_s*)gEngfuncs.GetSpritePointer(this->mSprite), theFrame))
			{
				gEngfuncs.pTriAPI->Begin(TRI_TRIANGLE_STRIP);
			
				vec3_t theVertex;
			
				gEngfuncs.pTriAPI->TexCoord2f(0, 1);
				theVertex.x = theX;
				theVertex.y = theY + theHeight;
				theVertex.z = 0;
				//gEngfuncs.pTriAPI->Color4ub(255, 255, 255, a);
				gEngfuncs.pTriAPI->Vertex3fv((float*)&theVertex);
			
				gEngfuncs.pTriAPI->TexCoord2f(0, 0);
				theVertex.x = theX;
				theVertex.y = theY;
				//gEngfuncs.pTriAPI->Color4ub(255, 255, 255, a);
				gEngfuncs.pTriAPI->Vertex3fv((float*)&theVertex);
			
				gEngfuncs.pTriAPI->TexCoord2f(1, 1);
				theVertex.x = theX + theWidth;
				theVertex.y = theY + theHeight;
				//gEngfuncs.pTriAPI->Color4ub(255, 255, 255, a);
				gEngfuncs.pTriAPI->Vertex3fv((float*)&theVertex);
			
				gEngfuncs.pTriAPI->TexCoord2f(1, 0);
				theVertex.x = theX + theWidth;
				theVertex.y = theY;
				//gEngfuncs.pTriAPI->Color4ub(255, 255, 255, a);
				gEngfuncs.pTriAPI->Vertex3fv((float*)&theVertex);
			
				gEngfuncs.pTriAPI->End();
			}

			gEngfuncs.pTriAPI->RenderMode(kRenderNormal);
		}	
		else
		{
			SPR_Set(this->mSprite, a, a, a);
			
			int theSpriteWidth = SPR_Width(this->mSprite, this->mSpriteFrame);
			int theSpriteHeight = SPR_Height(this->mSprite, this->mSpriteFrame);
			
			//SPR_DrawAdditive(theFrame, (theWidth - theSpriteWidth)/2, (theHeight - theSpriteHeight)/2, NULL);
			SPR_DrawHoles(this->mSpriteFrame, (theWidth - theSpriteWidth)/2, (theHeight - theSpriteHeight)/2, NULL);
		}
	}
}
コード例 #27
0
ファイル: battery.cpp プロジェクト: jlecorre/hlinvasion
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;
}
コード例 #28
0
ファイル: HudHealth.cpp プロジェクト: Sh1ft0x0EF/HLSDKRevamp
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
ファイル: message.cpp プロジェクト: 6779660/halflife
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;
}
コード例 #30
0
ファイル: ammo.cpp プロジェクト: Sh1ft0x0EF/HLSDKRevamp
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;
}