Beispiel #1
0
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();
}
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;
	}
}
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);
		}
	}
}
Beispiel #4
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);
					}
				}
			}
		}
	}
}
Beispiel #5
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;
}
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);
}
Beispiel #7
0
int CHudStatusBar::Draw(float fTime)
{
	int r, g, b, a, name_r, name_g, name_b;

	if(m_bReparseString)
	{
		for(int i = 0; i < MAX_STATUSBAR_LINES; i++)
			ParseStatusString(i);
		m_bReparseString = FALSE;
	}

	//Not Watching anyone
	if(m_iStatusValues[1] == 0)
	{
		m_iFlags &= ~HUD_ACTIVE;
		return 1;
	}

	// Draw the status bar lines
	for(int i = 0; i < MAX_STATUSBAR_LINES; i++)
	{
		int TextHeight     = 0;
		int TotalTextWidth = 0;

		//Ugly way to get
		if(m_iTeamMate[i])
		{
			TotalTextWidth += gHUD.ReturnStringPixelLength(m_szName[i]);
			TotalTextWidth += gHUD.ReturnStringPixelLength(m_szHealth[i]);
			TotalTextWidth += gHUD.ReturnStringPixelLength(m_szArmor[i]);
			TotalTextWidth += 48;
			TextHeight = gHUD.m_scrinfo.iCharHeight;
		}
		else
			TotalTextWidth += gHUD.ReturnStringPixelLength(m_szName[i]);

		TextHeight = gHUD.m_scrinfo.iCharHeight;

		if(g_iNameColors == 1)
		{
			name_r = 255;
			name_g = 50;
			name_b = 50;
		}
		else if(g_iNameColors == 2)
		{
			name_r = 50;
			name_g = 50;
			name_b = 255;
		}
		else
			name_r = name_g = name_b = 255;

		int Y_START;
		if(ScreenHeight >= 480)
			Y_START = ScreenHeight - 55;
		else
			Y_START = ScreenHeight - 45;

		int x = gHUD.m_Ammo.m_iNumberXPosition;
		int y = Y_START; // = ( ScreenHeight / 2 ) + ( TextHeight * 3 );

		int x_offset;
		a = 200;

		UnpackRGB(r, g, b, RGB_NORMAL);
		ScaleColors(r, g, b, a);
		ScaleColors(name_r, name_g, name_b, 125);

		//Draw the name First
		gHUD.DrawHudString(x, y, 1024, m_szName[i], name_r, name_g, name_b);

		if(!m_iTeamMate[i])
			continue;

		//Get the length in pixels for the name
		x_offset = gHUD.ReturnStringPixelLength(m_szName[i]);

		//Add the offset
		x += (x_offset + 8);

		//Now draw the Sprite for the health
		SPR_Set(m_hHealth, r, g, b);
		SPR_DrawHoles(0, x, y, &gHUD.GetSpriteRect(m_iHealthSpriteIndex));

		//Add the sprite width size
		x += 16;

		//Draw the health value ( x + offset for the name lenght + width of the sprite )
		gHUD.DrawHudString(x, y, 1024, m_szHealth[i], name_r, name_g, name_b);

		//Get the length in pixels for the health
		x_offset = gHUD.ReturnStringPixelLength(m_szHealth[i]);

		//Add the offset
		x += (x_offset + 8);

		//Now draw the Sprite for the Armor
		SPR_Set(m_hArmor, r, g, b);
		SPR_DrawHoles(0, x, y, &gHUD.GetSpriteRect(m_iArmorSpriteIndex));

		x += 16;

		//Draw the armor value ( x + offset for the name lenght + width of the sprite )
		gHUD.DrawHudString(x, y, 1024, m_szArmor[i], name_r, name_g, name_b);
	}

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

	int iTeamNumber = g_PlayerExtraInfo[ gHUD.m_Scoreboard.m_iPlayerNum ].teamnumber;
	int r, g, b;

	if( cl_radartype->value )
	{
		SPR_Set(m_hRadarOpaque.spr, 200, 200, 200);
		SPR_DrawHoles(0, 0, 0, &m_hRadarOpaque.rect);
	}
	else
	{
		SPR_Set( m_hRadar.spr, 25, 75, 25 );
		SPR_DrawAdditive( 0, 0, 0, &m_hRadarOpaque.rect );
	}

	if( bUseRenderAPI )
	{
		gEngfuncs.pTriAPI->RenderMode( kRenderTransAdd );
		gEngfuncs.pTriAPI->CullFace( TRI_NONE );
		gEngfuncs.pTriAPI->Brightness( 1 );
		gRenderAPI.GL_SelectTexture( 0 );
	}

	for(int i = 0; i < 33; i++)
	{
		// skip local player and dead players
		if( i == gHUD.m_Scoreboard.m_iPlayerNum || g_PlayerExtraInfo[i].dead )
			continue;

		// skip non-teammates
		if( g_PlayerExtraInfo[i].teamnumber != iTeamNumber )
			continue;

		// decide should player draw at this time. For flashing.
		// Always true for non-flashing players
		if( !FlashTime( flTime, &g_PlayerExtraInfo[i]) )
			continue;

		// player with C4 must be red
		if( g_PlayerExtraInfo[i].has_c4 )
		{
			DrawUtils::UnpackRGB( r, g, b, RGB_REDISH );
		}
		else
		{
			// white
			DrawUtils::UnpackRGB( r, g, b, RGB_WHITE );
		}

		// calc radar position
		Vector pos = WorldToRadar(gHUD.m_vecOrigin, g_PlayerExtraInfo[i].origin, gHUD.m_vecAngles);

		DrawZAxis( pos, r, g, b, 255 );
	}

	// Terrorist specific code( C4 Bomb )
	if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_TERRORIST )
	{
		if ( !g_PlayerExtraInfo[33].dead &&
			 g_PlayerExtraInfo[33].radarflashes &&
			 FlashTime( flTime, &g_PlayerExtraInfo[33] ))
		{
			Vector pos = WorldToRadar(gHUD.m_vecOrigin, g_PlayerExtraInfo[33].origin, gHUD.m_vecAngles);
			if( g_PlayerExtraInfo[33].playerclass ) // bomb planted
			{
				DrawCross( pos.x, pos.y, 255, 0, 0, 255 );
			}
			else
			{
				DrawZAxis( pos, 255, 0, 0, 255 );
			}
		}
	}
	// Counter-Terrorist specific code( hostages )
	else if( g_PlayerExtraInfo[gHUD.m_Scoreboard.m_iPlayerNum].teamnumber == TEAM_CT )
	{
		// draw hostages for CT
		for( int i = 0; i < MAX_HOSTAGES; i++ )
		{
			if( !HostageFlashTime( flTime, g_HostageInfo + i ) )
			{
				continue;
			}

			Vector pos = WorldToRadar(gHUD.m_vecOrigin, g_HostageInfo[i].origin, gHUD.m_vecAngles);
			if( g_HostageInfo[i].dead )
			{
				DrawZAxis( pos, 255, 0, 0, 255 );
			}
			else
			{
				DrawZAxis( pos, 4, 25, 110, 255 );
			}
		}
	}

	return 0;
}
Beispiel #9
0
//
// Draw Weapon Menu
//
int CHudAmmo::DrawWList(float flTime)
{
//	int r,g,b,x,y,a,i;
	int baseX, baseY, x,y;
	bool blFakeActive = false;

	// Check if sliding is finished
	if(m_blSliding)
	{	if(m_flSlideTime + SLIDETIME < gHUD.m_flTime)
		{	m_blSliding = false;
			m_blSlideIn = false;
			m_flSlideTime = 0;
		}
	}

	// "Fake" active weapon so we can slide the weapon bar out with the correct information
	if ( !gpActiveSel )
	{	// start sliding
		if(m_blPrevStatus)
		{	m_blPrevStatus = false;

			SlideIn();

			blFakeActive = true;
			gpActiveSel = gpLastSel;
			if(!gpActiveSel)
				return 0;
		}
		else if(m_blSliding)
		{	blFakeActive = true;
			gpActiveSel = gpLastSel;
			if(!gpActiveSel)
				return 0;
		}
		else
		{	m_blPrevStatus = false;
			return 0;
		}
	}
	else
	{	if(!m_blPrevStatus)
		{	SlideOut();
		}
		m_blPrevStatus = true;
	}

	int iActiveSlot;

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

	baseX=x=0;
	baseY=y=GetYBase(m_iweapcenterHeight);

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

	// Draw left bar edge
	SPR_Set(gHUD.GetSprite(m_HUD_wpleft), 255, 255, 255 );
	SPR_DrawHoles(0,x,y, &gHUD.GetSpriteRect(m_HUD_wpleft));

	// Move over drawing position to the end of the left bar
	x+=m_iweapedgeWidth;

	// Draw all of the buckets
	for (int i = 0; i < MAX_WEAPON_SLOTS; i++)
	{
		// Set bucket rect
		wrect_t bucketrect;
		bucketrect.top = 0;
		bucketrect.left = 0;
		bucketrect.bottom = BUCKET_HEIGHT;
		bucketrect.right = BUCKET_WIDTH;

		// If this is the active slot, draw the bigger pictures,
		WEAPON *p = gWR.GetFirstPos( i );
	/*	int iWidth = BUCKET_WIDTH;
		int iHeight = BUCKET_HEIGHT;*/
		if ( p )
		{/*	iWidth = p->rcActive.right - p->rcActive.left;
			iHeight = p->rcActive.bottom - p->rcActive.top;*/
		}

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

			if ( !p || !p->iId )
				continue;
		
			// Draw bucket
			SPR_Set(gHUD.GetSprite(m_HUD_wpcenter), 255, 255, 255 );
			SPR_DrawHoles(0, x, y, &gHUD.GetSpriteRect(m_HUD_wpcenter));

			// Active weapon
			if ( gpActiveSel == p )
			{	SPR_Set(p->hActive, 255, 255, 255 );
				SPR_Draw(0, x+OFFSETBUCKET_X, y+OFFSETBUCKET_Y, &bucketrect);
			}
			// Unactive weapon
			else
			{	SPR_Set(p->hInactive, 255, 255, 255 );
				SPR_Draw(0, x+OFFSETBUCKET_X, y+OFFSETBUCKET_Y, &bucketrect);
			}
			x+=m_iweapcenterWidth;
		}
	}
	
	// Draw right bar edge
	SPR_Set(gHUD.GetSprite(m_HUD_wpright), 255, 255, 255 );
	SPR_DrawHoles(0,x,y, &gHUD.GetSpriteRect(m_HUD_wpright));

	// Set active back to NULL
	if(blFakeActive)
	{	gpActiveSel = NULL;
	}

	// Redone by Pcjoe
/*
	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;
		}
		else
			iWidth = giBucketWidth;

		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 < MAX_WEAPON_SLOTS; 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 )
				{
					SPR_Set(p->hActive, r, g, b );
					SPR_DrawAdditive(0, x, y, &p->rcActive);

					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 ( 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;

}