示例#1
0
文件: overview.cpp 项目: puzl/NS3.2
//-----------------------------------------------------------------------------
// Purpose: Loads new icons
//-----------------------------------------------------------------------------
int CHudOverview::VidInit()
{
	m_hsprPlayer = Safe_SPR_Load("sprites/ring.spr");
	m_hsprViewcone = Safe_SPR_Load("sprites/camera.spr");

	return 1;
}
// Takes texture name, and optional frame, sets the current texture.  Returns true or false.
static int triSpriteTexture(lua_State* inState)
{
	bool theSuccess = false;
	
	int theNumArgs = lua_gettop(inState);
	if(theNumArgs >= 1)
	{
		string theSpriteName = lua_tostring(inState, 1);
		int theSpriteHandle = Safe_SPR_Load(theSpriteName.c_str());
		if(theSpriteHandle)
		{
			int theSpriteFrame = 0;
			if(theNumArgs >= 2)
			{
				theSpriteFrame = lua_tonumber(inState, 2);
			}
			
			if(gEngfuncs.pTriAPI->SpriteTexture((struct model_s *)gEngfuncs.GetSpritePointer(theSpriteHandle), theSpriteFrame))
			{
				theSuccess = true;
			}
		}
	}
	
	lua_pushnumber(inState, theSuccess);
	
	return 1;
}
// string spriteName, int inMode, int x0, int y0, int theWidth, int theHeight, optional frame
static int drawScaledHUDSprite(lua_State* inState)
{
	bool theSuccess = false;

	int theNumArgs = lua_gettop(inState);
	if(theNumArgs >= 6)
	{
		string theSpriteName = lua_tostring(inState, 1);
		int theRenderMode = lua_tonumber(inState, 2);
		int theStartX = lua_tonumber(inState, 3);
		int theStartY = lua_tonumber(inState, 4);
		int theWidth = lua_tonumber(inState, 5);
		int theHeight = lua_tonumber(inState, 6);
		int theFrame = 0;
		
		// Read optional frame
		if(theNumArgs >= 7)
		{
			theFrame = lua_tonumber(inState, 7);
		}
		
		int theSpriteHandle = Safe_SPR_Load(theSpriteName.c_str());
		if(theSpriteHandle)
		{
			DrawScaledHUDSprite(theSpriteHandle, theRenderMode, 1, theStartX, theStartY, theWidth, theHeight, theFrame);
			theSuccess = true;
		}
	}
	
	lua_pushnumber(inState, theSuccess);
	
	return 1;
}
示例#4
0
文件: AvHFont.cpp 项目: Arkshine/NS
bool AvHFont::Load(const char* inFileName)
{
    
    std::string theSpriteFileName;
    theSpriteFileName  = inFileName;
    theSpriteFileName += ".spr";

    std::string theWidthFileName;
    theWidthFileName  = getModDirectory();
    theWidthFileName += "/";
    theWidthFileName += inFileName;
    theWidthFileName += ".dat";
    
    FILE* file = fopen(theWidthFileName.c_str(), "rb");

    if (file != NULL)
    {

        struct LABC
        {
            long a;
            long b;
            long c;
        };

        LABC labc[256];
        fread(labc, sizeof(LABC), 256, file);

        for (int i = 0; i < 256; ++i)
        {
            mCharWidth[i].a = labc[i].a;
            mCharWidth[i].b = labc[i].b;
            mCharWidth[i].c = labc[i].c;
        }
        
        fclose(file);
    }
    else
    {
        return false;
    }

    mSprite = Safe_SPR_Load(theSpriteFileName.c_str());

    if (mSprite != 0)
    {
        mSpriteWidth  = SPR_Width(mSprite, 0);
        mSpriteHeight = SPR_Height(mSprite, 0);
    }
    
    return mSprite != 0;

}
示例#5
0
文件: cdll_int.cpp 项目: Arkshine/NS
// Demonstrates black lines around the edge of sprites (both using tri API and SPR_* calls)
// Demonstrates scissor not working properly
void Direct3DTest()
{
	static int theSprite = 0;
	
	if(!theSprite)
	{
		theSprite = Safe_SPR_Load("sprites/640a-energy.spr");
	}

	// Draw alien energy
	if(theSprite)
	{
		int theFrame = 0;
		
		int theX = ScreenWidth() - SPR_Width(theSprite, theFrame);
		int theY = ScreenHeight() - SPR_Height(theSprite, theFrame);

		// 0-1, depending how much to draw
		float theFactor = .5f;
		UIDrawVariableBarSpriteHoles(theSprite, theX, theY, theFactor);
	}
}
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);
		}
	}
}
示例#7
0
文件: tri.cpp 项目: Arkshine/NS
void DrawHitBox(const OBBox& inBox)
{

    HSPRITE sprite = Safe_SPR_Load("sprites/white.spr");

    vec3_t theBoxPoint[8];

    for (int i = 0; i < 8; ++i)
    {

        vec3_t xAmount;
        vec3_t yAmount;
        vec3_t zAmount;

        if (i & 1)
        {
            VectorScale(inBox.mAxis[0],  inBox.mExtents[0], xAmount);
        }
        else
        {
            VectorScale(inBox.mAxis[0], -inBox.mExtents[0], xAmount);
        }
        
        if (i & 2)
        {
            VectorScale(inBox.mAxis[1],  inBox.mExtents[1], yAmount);
        }
        else
        {
            VectorScale(inBox.mAxis[1], -inBox.mExtents[1], yAmount);
        }
        
        if (i & 4)
        {
            VectorScale(inBox.mAxis[2],  inBox.mExtents[2], zAmount);
        }
        else
        {
            VectorScale(inBox.mAxis[2], -inBox.mExtents[2], zAmount);
        }
        
        VectorAdd(inBox.mOrigin,  xAmount, theBoxPoint[i]);
        VectorAdd(theBoxPoint[i], yAmount, theBoxPoint[i]);
        VectorAdd(theBoxPoint[i], zAmount, theBoxPoint[i]);
        
    }
    
    struct model_s* spritePtr = (struct model_s*)(gEngfuncs.GetSpritePointer(sprite));
    gEngfuncs.pTriAPI->SpriteTexture(spritePtr, 0);

    gEngfuncs.pTriAPI->Begin(TRI_LINES);

    gEngfuncs.pTriAPI->Color4f(1, 1, 1, 1);

    // Bottom.
        
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[0]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[1]);
    
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[1]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[3]);
    
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[3]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[2]);

    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[2]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[0]);

    // Top.

    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[4]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[6]);
    
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[6]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[7]);
    
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[7]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[5]);

    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[5]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[4]);

    // Sides.

    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[0]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[4]);
    
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[2]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[6]);
    
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[3]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[7]);

    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[1]);
    gEngfuncs.pTriAPI->Vertex3fv(theBoxPoint[5]);

    gEngfuncs.pTriAPI->End();

}
示例#8
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);
					}
				}
			}
		}
	}
}
void AvHVisibleBlipList::Draw(const pVector& inView, int kDefaultStatus)
{
	//bool theIsEnemy = this->GetType() == BLIP_TYPE_ENEMY;
	
	// Now draw the thing!
	for(int theCurrentBlip = 0; theCurrentBlip < this->mNumBlips; theCurrentBlip++)
	{
		int theStatus = this->mBlipStatus[theCurrentBlip];
		ASSERT(theStatus >= 0);
		ASSERT(theStatus < kNumBlipTypes);

		// This has to be reloaded too
		if(!this->mSprite[theStatus])
		{
			string theSpriteName = string(kSpriteDirectory) + string("/") + string(kBlipSprite) + MakeStringFromInt(theStatus) + string(".spr");
			this->mSprite[theStatus] = Safe_SPR_Load(theSpriteName.c_str());
		}

		int theSprite = this->mSprite[theStatus];
		if(!theSprite)
		{
			theSprite = this->mSprite[kDefaultStatus];
		}

		if(theSprite > 0)
		{
			int theNumFrames = SPR_Frames(theSprite);
			const int kFrameRate = 12;
			const float theCurrentTime = gEngfuncs.GetClientTime();
			int theFrame = (int)((theCurrentTime - this->mTimeBlipsReceived)*kFrameRate) % theNumFrames;
			
			if(gEngfuncs.pTriAPI->SpriteTexture((struct model_s *)gEngfuncs.GetSpritePointer(theSprite), theFrame))
			{
				//gEngfuncs.pTriAPI->RenderMode(kRenderTransTexture);
				gEngfuncs.pTriAPI->RenderMode(kRenderTransAdd);
			
				pVector up(0, 0, 1);
				pVector right = inView ^ up;
				right.normalize();
				pVector nup = right ^ inView;
				
				int theScale = kWorldBlipScale;
				right *= theScale/2.0f;
				nup *= theScale/2.0f;
				
				// Quad draws v0, v1, v2, v3
				pVector V0 = -(right + nup);
				pVector V1 = -(right - nup);
				pVector V2 = right + nup;
				pVector V3 = right - nup;
				
				pVector sV0 = V0;
				pVector sV1 = V1;
				pVector sV2 = V2;
				pVector sV3 = V3;
			
				gEngfuncs.pTriAPI->CullFace( TRI_NONE );
				
				gEngfuncs.pTriAPI->Begin( TRI_TRIANGLE_STRIP );
			
				gEngfuncs.pTriAPI->Brightness(1.0f);
				
					pVector p;
					p.x = this->mBlipPositions[theCurrentBlip][0];
					p.y = this->mBlipPositions[theCurrentBlip][1];
					p.z = this->mBlipPositions[theCurrentBlip][2];
					
					gEngfuncs.pTriAPI->TexCoord2f(0, 0);
					pVector ver = p + sV0;
					gEngfuncs.pTriAPI->Vertex3fv((float*)&ver);
			
					gEngfuncs.pTriAPI->TexCoord2f(0, 1);
					ver = p + sV1;
					gEngfuncs.pTriAPI->Vertex3fv((float*)&ver);
			
					gEngfuncs.pTriAPI->TexCoord2f(1, 0);
					ver = p + sV3;
					gEngfuncs.pTriAPI->Vertex3fv((float*)&ver);

					gEngfuncs.pTriAPI->TexCoord2f(1, 1);
					ver = p + sV2;
					gEngfuncs.pTriAPI->Vertex3fv((float*)&ver);
				
				gEngfuncs.pTriAPI->End();
			
				gEngfuncs.pTriAPI->RenderMode( kRenderNormal );
			}
		}
	}
}
示例#10
0
AvHOverviewControl::AvHOverviewControl()
{
    m_hsprWhite = Safe_SPR_Load(kWhiteSprite);
    addInputSignal(new AvHOverviewInputSignal(this));
}
示例#11
0
文件: hud.cpp 项目: Arkshine/NS
void CHud :: VidInit( void )
{
	m_scrinfo.iSize = sizeof(m_scrinfo);
	GetScreenInfo(&m_scrinfo);

	// The NS viewport isn't set up yet
	int theViewPort[4];
	theViewPort[0] = theViewPort[1] = 0;
	theViewPort[2] = this->m_scrinfo.iWidth;
	theViewPort[3] = this->m_scrinfo.iHeight;

	gHUD.SetViewport(theViewPort);

    mFont.Load("sprites/font_arial");
    mSmallFont.Load("sprites/font_arialsmall");

	// ----------
	// Load Sprites
	// ---------
//	m_hsprFont = LoadSprite("sprites/%d_font.spr");
	
	m_hsprLogo = 0;	
	m_hsprCursor = 0;

	if (ScreenWidth() < 640)
		m_iRes = 320;
	else
		m_iRes = 640;

	// Only load this once
	if ( !m_pSpriteList )
	{
		// we need to load the hud.txt, and all sprites within
		m_pSpriteList = SPR_GetList("sprites/hud.txt", &m_iSpriteCountAllRes);

		if (m_pSpriteList)
		{
			// count the number of sprites of the appropriate res
			m_iSpriteCount = 0;
			client_sprite_t *p = m_pSpriteList;
			for ( int j = 0; j < m_iSpriteCountAllRes; j++ )
			{
				if ( p->iRes == m_iRes )
					m_iSpriteCount++;
				p++;
			}

			// allocated memory for sprite handle arrays
 			m_rghSprites = new HSPRITE[m_iSpriteCount];
			m_rgrcRects = new wrect_t[m_iSpriteCount];
			m_rgszSpriteNames = new char[m_iSpriteCount * MAX_SPRITE_NAME_LENGTH];

			p = m_pSpriteList;
			int index = 0;
			for ( j = 0; j < m_iSpriteCountAllRes; j++ )
			{
				if ( p->iRes == m_iRes )
				{
					char sz[256];
					sprintf(sz, "sprites/%s.spr", p->szSprite);
					m_rghSprites[index] = Safe_SPR_Load(sz);
					m_rgrcRects[index] = p->rc;
					strncpy( &m_rgszSpriteNames[index * MAX_SPRITE_NAME_LENGTH], p->szName, MAX_SPRITE_NAME_LENGTH );

					index++;
				}

				p++;
			}
		}
	}
	else
	{
		// we have already have loaded the sprite reference from hud.txt, but
		// we need to make sure all the sprites have been loaded (we've gone through a transition, or loaded a save game)
		client_sprite_t *p = m_pSpriteList;
		int index = 0;
		for ( int j = 0; j < m_iSpriteCountAllRes; j++ )
		{
			if ( p->iRes == m_iRes )
			{
				char sz[256];
				sprintf( sz, "sprites/%s.spr", p->szSprite );
				m_rghSprites[index] = Safe_SPR_Load(sz);
				index++;
			}

			p++;
		}
	}

	// assumption: number_1, number_2, etc, are all listed and loaded sequentially
	m_HUD_number_0 = GetSpriteIndex( "number_0" );

	m_iFontHeight = m_rgrcRects[m_HUD_number_0].bottom - m_rgrcRects[m_HUD_number_0].top;

	m_Ammo.VidInit();
	m_Health.VidInit();
	m_Spectator.VidInit();
	m_Geiger.VidInit();
	m_Train.VidInit();
	m_Battery.VidInit();
	m_Flash.VidInit();
	m_Message.VidInit();
	m_StatusBar.VidInit();
	m_DeathNotice.VidInit();
	m_SayText.VidInit();
	m_Menu.VidInit();
	m_AmmoSecondary.VidInit();
	m_TextMessage.VidInit();
	m_StatusIcons.VidInit();
	GetClientVoiceMgr()->VidInit();
}