Results 1 to 5 of 5
  1. #1
    supercarz1991's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    6,285
    Reputation
    435
    Thanks
    3,715
    My Mood
    Doh

    Custom Classes: DX.h (text, boxes, circle, text highlight and more)

    Diggin through My Documents, found a source code for a menu from none other than Drunken Cheetah himself. Don't know how i got it or from where..But the dip hook works, and the menu is of course sexy as hell...found this in it, figured i'd share because its actually some cool effects for ESP and menus

    DX.h
    Code:
    class CCanvas
    {
    public:
    	//Engine Specific 
    	virtual void Init(void* Pram)=0;
    	virtual void Begin()=0;
    	virtual bool IsValid()=0;
    	virtual void End()=0;
    	virtual void Reset()=0;
    	virtual void Text(char* text,int x, int y, DWORD color)=0;
    	virtual int TextWidth(char* text)=0;
    	virtual int TextHeight(char* text)=0;
    	virtual void Line(float x1,float y1,float x2,float y2,DWORD color)=0;
    	virtual void FillGradient(float x,float y,float w,float h,DWORD color1,DWORD color2,DWORD color3,DWORD color4)=0;
    	virtual void Poly(POINT* points,int count,DWORD color)=0;
    
    	//Extras
    	void Fill(float x,float y,float w,float h,DWORD color)
    	{
    		FillGradient(x,y,w,h,color,color,color,color);
    	}
    	void FillCentered(float x,float y,float w,float h,DWORD color)
    	{
    		FillGradient(x-w/2,y-h/2,w,h,color,color,color,color);
    	}
    	void Textf(int x, int y, DWORD color, const char *fmt, ...)
    	{
    		if (!IsValid()) return;
    		static char buffer[1024];
    		va_list va_alist;
    		va_start (va_alist, fmt);
    		//_vsnprintf(buffer, sizeof(buffer), fmt, va_alist);
    		vsnprintf(buffer, sizeof(buffer), fmt, va_alist);
    		va_end (va_alist);
    		Text(buffer,x,y,color);
    	}
    	void TextCenteredf(int x, int y, DWORD color, const char *fmt, ...)
    	{
    		if (!IsValid()) return;
    		static char buffer[1024];
    		va_list va_alist;
    		va_start (va_alist, fmt);
    		vsnprintf(buffer, sizeof(buffer), fmt, va_alist);
    		va_end (va_alist);
    		Text(buffer,x-TextWidth(buffer)/2,y,color);
    	}
    
    	void Circle(int x, int y, int r, int s, DWORD color)
    	{
    		if (!IsValid()) return;
    		float Step = 3.14159265*2.0/s;
    		for (float a=0; a < 3.14159265*2.0; a += Step)
    		{
    			float x1 = r * cos(a) + x;
    			float y1 = r * sin(a) + y;
    			float x2 = r * cos(a+Step) + x;
    			float y2 = r * sin(a+Step) + y;
    			Line(x1,y1,x2,y2,color);
    		}
    	}
    	void Box(int x, int y, int w, int h, DWORD color)
    	{
    		if (!IsValid()) return;
    		Line(x,y,x+w,y,color);
    		Line(x+w,y,x+w,y+h,color);
    		Line(x+w,y+h,x,y+h,color);
    		Line(x,y+h,x,y,color);
    	}
    	void BoxCentered(int x, int y, int w, int h, DWORD color)
    	{
    		if (!IsValid()) return;
    		Box(x-w/2,y-h/2,w,h,color);
    	}
    
    	int Width,Height;
    };
    extern CCanvas* pCanvas;
    
    class CDX9Canvas : public CCanvas
    {
    	struct CUSTOMVERTEX
    	{
    		FLOAT x, y, z, rhw; // The transformed position for the vertex.
    		DWORD color;        // The vertex color.
    	};
    #define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
    
    	LPD3DXFONT pFont;
    	LPDIRECT3DDEVICE9 pDevice;
    	IDirect3DStateBlock9 *pSB;
    
    	bool bValid;
    
    	CUSTOMVERTEX Line_Batch[5000];
    	CUSTOMVERTEX Fill_Batch[16000];
    	int Line_Index;
    	int Fill_Index;
    
    public:
    	CDX9Canvas()
    	{
    		bValid = false;
    		pDevice = NULL;
    		pFont = NULL;
    		pSB = NULL;
    		Line_Index = 0;
    		Fill_Index = 0;
    	}
    
    	virtual void Init(void* Pram)
    	{
    		pDevice = (LPDIRECT3DDEVICE9)Pram;
    	}
    	virtual void Begin()
    	{
    		bValid = false;
    
    		if (!pDevice)return;
    		if (!pSB)
    		{
    			if (pDevice->CreateStateBlock(D3DSBT_ALL,&pSB) != D3D_OK) return;
    		}
    		if (!pFont)
    		{
    			if (D3DXCreateFont(pDevice,14, 0, FW_NORMAL, 1, FALSE, DEFAULT_CHARSET,OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,"Arial",&pFont) != D3D_OK) return;
    		}
    
    		Line_Index = 0;
    		Fill_Index = 0;
    		pSB->Capture();
    
    		bValid = true;
    	}
    	virtual bool IsValid()
    	{
    		return bValid;
    	}
    	virtual void End()
    	{
    		if (bValid)
    		{
    			SetupDrawing();
    			if (Line_Index>0) pDevice->DrawPrimitiveUP(D3DPT_LINELIST,Line_Index/2,Line_Batch,sizeof(CUSTOMVERTEX));
    			if (Fill_Index>0) pDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST,Fill_Index/3,Fill_Batch,sizeof(CUSTOMVERTEX));
    			pSB->Apply();
    		}
    		bValid = false;
    		Line_Index = 0;
    		Fill_Index = 0;
    	}
    	virtual void Reset()
    	{
    		if (pFont)
    		{
    			pFont->Release();
    			pFont = NULL;
    		}
    		if (pSB)
    		{
    			pSB->Release();
    			pSB = NULL;
    		}
    		bValid = false;
    	}
    
    	void SetupDrawing()
    	{
    		pDevice->SetTexture(0,NULL);  
    		pDevice->SetTexture(1,NULL);  
    
    		pDevice->SetVertexShader(NULL);
    		pDevice->SetPixelShader(NULL);
    
    		//pDevice->SetRenderState( D3DRS_ALPHATESTENABLE ,FALSE );
    		//pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE ,FALSE );
    		pDevice->SetRenderState( D3DRS_ZENABLE,D3DZB_FALSE );
    		pDevice->SetRenderState( D3DRS_FILLMODE,D3DFILL_SOLID );
    		pDevice->SetRenderState( D3DRS_SHADEMODE ,D3DSHADE_GOURAUD );
    		pDevice->SetRenderState( D3DRS_ZWRITEENABLE ,FALSE );
    		pDevice->SetRenderState( D3DRS_SRCBLEND ,D3DBLEND_ONE );
    		pDevice->SetRenderState( D3DRS_DESTBLEND ,D3DBLEND_ZERO );
    		pDevice->SetRenderState( D3DRS_CULLMODE ,D3DCULL_NONE );
    		pDevice->SetRenderState( D3DRS_ZFUNC ,D3DCMP_LESSEQUAL );
    		pDevice->SetRenderState( D3DRS_FOGENABLE ,FALSE );
    		pDevice->SetRenderState( D3DRS_SPECULARENABLE ,FALSE );
    		pDevice->SetRenderState( D3DRS_STENCILENABLE ,FALSE );
    		pDevice->SetRenderState( D3DRS_CLIPPING ,FALSE );
    		pDevice->SetRenderState( D3DRS_LIGHTING ,FALSE );
    		pDevice->SetRenderState( D3DRS_COLORVERTEX ,TRUE );
    		pDevice->SetRenderState( D3DRS_CLIPPLANEENABLE ,0 );
    
    		pDevice->SetFVF(D3DFVF_CUSTOMVERTEX);
    	}
    	virtual void Text(char* text,int x, int y, DWORD color)
    	{
    		if (!IsValid()) return;
    		color |= 0xFF000000;
    		RECT pos;
    		SetRect(&pos,x,y,0,0);
    		pFont->DrawTextA(NULL,text,-1,&pos,DT_NOCLIP,color);
    	}
    	virtual int TextWidth(char* text)
    	{
    		if (!IsValid()) return strlen(text)*8;
    		RECT pos;SetRect(&pos,0,0,0,0);
    		pFont->DrawTextA(NULL,text,-1,&pos,DT_CALCRECT,0);
    		return pos.right;
    	}
    	virtual int TextHeight(char* text)
    	{
    		if (!IsValid()) return 12;
    		RECT pos;SetRect(&pos,0,0,0,0);
    		pFont->DrawTextA(NULL,text,-1,&pos,DT_CALCRECT,0);
    		return pos.bottom;
    	}
    	virtual void Line(float x1,float y1,float x2,float y2,DWORD color)
    	{
    		if (!IsValid()) return;
    		CUSTOMVERTEX v[2];
    		SetVert(&v[0], x1,y1,color);
    		SetVert(&v[1], x2,y2,color);
    		SetupDrawing();
    		pDevice->DrawPrimitiveUP(D3DPT_LINELIST,1,v,sizeof(CUSTOMVERTEX));
    	}
    	virtual void FillGradient(float x,float y,float w,float h,DWORD color1,DWORD color2,DWORD color3,DWORD color4)
    	{
    		if (!IsValid()) return;
    		CUSTOMVERTEX v[4];
    		SetVert(&v[0], x,y,color1);
    		SetVert(&v[1], x+w,y,color2);
    		SetVert(&v[2], x+w,y+h,color3);
    		SetVert(&v[3], x,y+h,color4);
    		SetupDrawing();
    		pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,v,sizeof(CUSTOMVERTEX));
    	}
    	void SetVert(CUSTOMVERTEX* v, float x, float y, DWORD color)
    	{
    		v->x = x; v->y = y; v->z = 0.0f; v->rhw = 1.0f;
    		v->color = color;
    	}
    	virtual void Poly(POINT* points,int count,DWORD color)
    	{
    		if (!IsValid()) return;
    		if (count<3) return;
    		CUSTOMVERTEX* v = new CUSTOMVERTEX[count];
    		for (int i=0; i < count;i++)
    		{
    			SetVert(&v[i], points[i].x,points[i].y,color);
    		}
    		SetupDrawing();
    		pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,count-3+1,v,sizeof(CUSTOMVERTEX));
    		delete v;
    	}
    
    	//Extras
    	void Line_Batched(float x1,float y1,float x2,float y2,DWORD color)
    	{
    		SetVert(&Line_Batch[Line_Index+0], x1,y1,color);
    		SetVert(&Line_Batch[Line_Index+1], x2,y2,color);
    		Line_Index += 2;
    	}
    	void FillGradient_Batched(float x,float y,float w,float h,DWORD color1,DWORD color2,DWORD color3,DWORD color4)
    	{
    		SetVert(&Fill_Batch[Fill_Index+0], x,y,color1);
    		SetVert(&Fill_Batch[Fill_Index+1], x+w,y,color2);
    		SetVert(&Fill_Batch[Fill_Index+2], x+w,y+h,color3);
    
    		SetVert(&Fill_Batch[Fill_Index+3], x,y,color1);
    		SetVert(&Fill_Batch[Fill_Index+4], x+w,y+h,color3);
    		SetVert(&Fill_Batch[Fill_Index+5], x,y+h,color4);
    		Fill_Index += 6;
    	}
    	void Fill_Batched(float x,float y,float w,float h,DWORD color)
    	{
    		FillGradient_Batched(x,y,w,h,color,color,color,color);
    	}
    	void FillCentered_Batched(float x,float y,float w,float h,DWORD color)
    	{
    		FillGradient_Batched(x-w/2,y-h/2,w,h,color,color,color,color);
    	}
    	void Circle_Batched(int x, int y, int r, int s, DWORD color)
    	{
    		float Step = 3.14159265*2.0/s;
    		for (float a=0; a < 3.14159265*2.0; a += Step)
    		{
    			float x1 = r * cos(a) + x;
    			float y1 = r * sin(a) + y;
    			float x2 = r * cos(a+Step) + x;
    			float y2 = r * sin(a+Step) + y;
    			Line_Batched(x1,y1,x2,y2,color);
    		}
    	}
    	void Box_Batched(int x, int y, int w, int h, DWORD color)
    	{
    		Line_Batched(x,y,x+w,y,color);
    		Line_Batched(x+w,y,x+w,y+h,color);
    		Line_Batched(x+w,y+h,x,y+h,color);
    		Line_Batched(x,y+h,x,y,color);
    	}
    	void BoxCentered_Batched(int x, int y, int w, int h, DWORD color)
    	{
    		Box_Batched(x-w/2,y-h/2,w,h,color);
    	}
    
    };
    CCanvas* pCanvas = NULL;

    commando: You're probably the best non-coder coder I know LOL


  2. #2
    MrLionBr's Avatar
    Join Date
    Feb 2012
    Gender
    male
    Posts
    27
    Reputation
    10
    Thanks
    2
    Looks like works greatly. But, it's from you, certainly it works xD

    Good job man! =D

  3. #3
    supercarz1991's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Posts
    6,285
    Reputation
    435
    Thanks
    3,715
    My Mood
    Doh
    Quote Originally Posted by MrLionBr View Post
    Looks like works greatly. But, it's from you, certainly it works xD

    Good job man! =D
    probablyy doesn't lol

    commando: You're probably the best non-coder coder I know LOL


  4. #4
    iBazzoCA's Avatar
    Join Date
    Apr 2012
    Gender
    male
    Posts
    3
    Reputation
    10
    Thanks
    0
    My Mood
    Amazed
    What does it do?

  5. #5
    kolec94's Avatar
    Join Date
    Nov 2010
    Gender
    male
    Location
    Davenport,IA
    Posts
    1,784
    Reputation
    2
    Thanks
    104
    Quote Originally Posted by iBazzoCA View Post
    What does it do?
    its a custom class if u dont know wat to do with it ur in the wrong section

    [IMG]https://i988.photobucke*****m/albums/af4/mallard247/kolec94.png[/IMG]

Similar Threads

  1. [Info]Text Box Class
    By NOOBJr in forum Combat Arms Coding Help & Discussion
    Replies: 23
    Last Post: 01-19-2011, 01:21 PM
  2. Login Screen text box problems
    By xArms in forum CrossFire Help
    Replies: 2
    Last Post: 10-11-2010, 06:51 AM
  3. Need help saving info in text boxes please
    By bayley60 in forum Visual Basic Programming
    Replies: 10
    Last Post: 07-09-2010, 10:02 AM
  4. [Help]Print Text Box [Solved]
    By zmansquared in forum Visual Basic Programming
    Replies: 7
    Last Post: 03-10-2010, 06:56 PM
  5. [Help]Basic Text Box[Solved]
    By FlashDrive in forum Visual Basic Programming
    Replies: 3
    Last Post: 03-06-2010, 10:54 PM