예제 #1
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();
}
예제 #2
0
int CHudHealth::Draw(float flTime)
{
	int r = 0, g = 0, b = 0;
	int x = 0, y = 0;
	int iDraw = 0;

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

	if(g_iTeamNumber == UNDEFINED || g_iTeamNumber == SPECS )
	{
		gHUD.m_iHideHUDDisplay |= HIDEHUD_HEALTH;
		return 1;
	}

	if(g_iUser1 != 0)
		return 1;

	m_flHealth = g_flHealth;

	if ( !m_hSprite )
		m_hSprite = LoadSprite(PAIN_NAME);

	//hocked on here as this is a good palce as they are related.
	if(IEngineStudio.IsHardware())
		iDraw = gBackground.Draw(flTime);

	if(iDraw == 0)
	{
		gHUD.m_iHideHUDDisplay |= HIDEHUD_HEALTH;
		return 1;
	}
	else
	{
		gHUD.m_iHideHUDDisplay &= ~HIDEHUD_HEALTH;
	}

	gStamina.Draw(flTime);

	if(ScreenWidth >= 640)
		gMiddle.Draw(flTime);
	gHintBox.Draw(flTime);

	UnpackRGB(r, g, b, RGB_WHITEISH);

	HSPRITE m_hSprite = gHUD.GetSprite( m_HUD_health );
	wrect_t *m_SpriteArea = &gHUD.GetSpriteRect( m_HUD_health );

	int x_length, y_length;      // positions of the spots

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

	if(ScreenWidth >= 640)
		x = 5;
	else
		x = 2;	

	y = (YRES(480) - (y_length + ((ScreenWidth >= 640) ? 5 : 3)));

	if(!IEngineStudio.IsHardware())
	{
		UnpackRGB(r, g, b, RGB_WHITEISH);
		gStamina.Draw(flTime);
			
		if(ScreenWidth >= 640)
			x = 5;
		else
			x = 2;	

		y = (YRES(480) - (20 + ((ScreenWidth >= 640) ? 5 : 3)));		

		gHUD.DrawHudNumber(x, y, DHN_2DIGITS | DHN_DRAWZERO, m_flHealth, r, g, b);
		return 1;
	}

	SPR_Set(m_hSprite, r, g, b);

	int iClipLevel = (y_length - ((m_flHealth * y_length) / MAX_HEALTH));
	//clipper starts at the clipping level. its height is the full amount of health take away the mamount clipped
	SPR_EnableScissor(x, y+iClipLevel, 24 , y_length-iClipLevel);
	SPR_DrawHoles(0, x, y, m_SpriteArea);
	SPR_DisableScissor();

	DrawDamage(flTime);
	return DrawPain(flTime);
}