Neler yeni
Türkiye'nin En Güncel Forum Sitesi

Forum içeriğine ve tüm hizmetlerimize erişim sağlamak için foruma kayıt olmalı yada giriş yapmalısınız. Forum üye olmak tamamen ücretsizdir.

D3D Menu Class

ByOnur58

Kayıtlı Üye
MFC Üyesi
  • Üyelik Tarihi
    7 Ocak 2015
  • Mesajlar
    2,113
  • MFC Puanı
    10
  • MFC Seviyesi

Kod:
class CDrawing
{
public:

	INT DrawLine( float x1, float y1, float x2, float y2, D3DCOLOR Color )
	{
		D3DXVECTOR2 Vector[ 2 ];
		
		Vector[ 0 ].x = x1;
		Vector[ 0 ].y = y1;
		Vector[ 1 ].x = x2;
		Vector[ 1 ].y = y2;
		
		m_line->Draw( Vector, 2, Color );
		
		return 0;
	}

	INT Unused( int x, int y, int w, int h, DWORD dwFlags, D3DCOLOR Color, char* szText )
	{
		RECT rFont = { x, y, w + x, h + y };
		m_font->DrawTextA( NULL, szText, -1, &rFont, dwFlags, Color );
		
		return 0;
	}

	INT Draw_Text( int x, int y, int w, int h, DWORD dwFlags, D3DCOLOR Color, char* szText, ... )
	{
		char szBuffer[ 255 ];
	
		va_list args;
		va_start( args, szText );
		vsprintf_s( szBuffer, szText, args );

		Unused( x, y - 1, w, h , dwFlags, D3DCOLOR_XRGB( 0, 0, 0 ), szBuffer );
		Unused( x, y + 1, w, h, dwFlags, D3DCOLOR_XRGB( 0, 0, 0 ), szBuffer );
		Unused( x - 1, y, w, h, dwFlags, D3DCOLOR_XRGB( 0, 0, 0 ), szBuffer );
		Unused( x + 1, y, w, h, dwFlags, D3DCOLOR_XRGB( 0, 0, 0 ), szBuffer );
		Unused( x, y, w, h, dwFlags, Color, szBuffer );

		va_end( args );

		return 0;
	}

	INT FillRGB( int x, int y, int w, int h, D3DCOLOR Color, LPDIRECT3DDEVICE9 pDevice )
	{
		D3DRECT rec = { x, y, x + w, y + h };
		pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, Color, 0, 0 );

		return 0;
	}

	INT DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, LPDIRECT3DDEVICE9 pDevice )
	{
		FillRGB( x, (y + h - px), w, px, BorderColor, pDevice );
		FillRGB( x, y, px, h, BorderColor, pDevice );
		FillRGB( x, y, w, px, BorderColor, pDevice );
		FillRGB( (x + w - px), y, px, h, BorderColor, pDevice );

		return 0;
	}

	INT DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, LPDIRECT3DDEVICE9 pDevice )
	{
		FillRGB( x, y, w, h, BoxColor, pDevice );
		DrawBorder( x, y, w, h, 1, BorderColor, pDevice );

		return 0;
	}

};


Kod:
#include "CDrawing.hpp"

CDrawing *cDrawing = new CDrawing();

POINT curPos;

char* szTabs[ 4 ] = { "ESP", "Radar", "Crosshair", "Customizations" };

int iMenuX = 100;
int iMenuY = 100;
int iMenuWidth = 530;
int iMenuHeight = 400;

int iLastX;
int iLastY;

int iItemTab1 = 0;
int iItemTab2 = 0;
int iItemTab3 = 0;
int iItemTab4 = 0;

enum Tabs
{
	tab1,
	tab2,
	tab3,
	tab4
};

struct TabsOptions
{
	Tabs ActiveTab;
};

TabsOptions tabsOptions;

struct ItemTab1
{
	char* szName;
	int iValue, iMinValue, iMaxValue, iIncDecValue, iType;

	D3DCOLOR Color;
}itemTab1[ 20 ];

struct ItemTab2
{
	char* szName;
	int iValue, iMinValue, iMaxValue, iIncDecValue, iType;

	D3DCOLOR Color;
}itemTab2[ 20 ];

struct ItemTab3
{
	char* szName;
	int iValue, iMinValue, iMaxValue, iIncDecValue, iType;

	D3DCOLOR Color;
}itemTab3[ 20 ];

struct ItemTab4
{
	char* szName;
	int iValue, iMinValue, iMaxValue, iIncDecValue, iType;

	D3DCOLOR Color;
}itemTab4[ 20 ];

class CMenu
{
public:
	
	INT AddItem( char* szName, int iValue, int iMinValue, int iMaxValue, int iIncDecValue, D3DCOLOR Color, int iTab )
	{
		if( iTab == 1 )
		{
			itemTab1[ iItemTab1 ].szName = szName;
			itemTab1[ iItemTab1 ].iValue = iValue;
			itemTab1[ iItemTab1 ].iMinValue = iMinValue;
			itemTab1[ iItemTab1 ].iMaxValue = iMaxValue;
			itemTab1[ iItemTab1 ].iIncDecValue = iIncDecValue;
			itemTab1[ iItemTab1 ].Color = Color;

			iItemTab1++;
		}
		if( iTab == 2 )
		{
			itemTab2[ iItemTab2 ].szName = szName;
			itemTab2[ iItemTab2 ].iValue = iValue;
			itemTab2[ iItemTab2 ].iMinValue = iMinValue;
			itemTab2[ iItemTab2 ].iMaxValue = iMaxValue;
			itemTab2[ iItemTab2 ].iIncDecValue = iIncDecValue;
			itemTab2[ iItemTab2 ].Color = Color;

			iItemTab2++;
		}
		if( iTab == 3 )
		{
			itemTab3[ iItemTab3 ].szName = szName;
			itemTab3[ iItemTab3 ].iValue = iValue;
			itemTab3[ iItemTab3 ].iMinValue = iMinValue;
			itemTab3[ iItemTab3 ].iMaxValue = iMaxValue;
			itemTab3[ iItemTab3 ].iIncDecValue = iIncDecValue;
			itemTab3[ iItemTab3 ].Color = Color;

			iItemTab3++;
		}
		if( iTab == 4 )
		{
			itemTab4[ iItemTab4 ].szName = szName;
			itemTab4[ iItemTab4 ].iValue = iValue;
			itemTab4[ iItemTab4 ].iMinValue = iMinValue;
			itemTab4[ iItemTab4 ].iMaxValue = iMaxValue;
			itemTab4[ iItemTab4 ].iIncDecValue = iIncDecValue;
			itemTab4[ iItemTab4 ].Color = Color;

			iItemTab4++;
		}

		return 0;
	}

	INT MouseOverItem( int x, int y, int w, int h )
	{
		if( curPos.x > x && curPos.x < x + w && curPos.y > y && curPos.y < y + h )
			return 1;
		else
			return 0;
	}

	INT InitMenu( LPDIRECT3DDEVICE9 pDevice )
	{
		static bool bMenu = true;

		if( bMenu )
		{
			cDrawing->DrawBox( iMenuX, iMenuY, iMenuWidth, iMenuHeight, D3DCOLOR_XRGB( itemTab4[ 0 ].iValue, itemTab4[ 1 ].iValue, itemTab4[ 2 ].iValue ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );
			cDrawing->DrawBorder( iMenuX + 10, iMenuY + 40, iMenuWidth - 20, iMenuHeight - 50, 1, D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );
			for( int i = 0; i < 4; i++ )
			{
				cDrawing->DrawBox( i * 130 + iMenuX + 10, iMenuY + 10, 120, 20, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );
				cDrawing->Draw_Text( i * 130 + iMenuX + 10, iMenuY + 10, 120, 20, DT_NOCLIP | DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB( 192, 192, 192 ), szTabs[ i ] );
			}

			if( tabsOptions.ActiveTab == tab1 )
			{
				for( int i = 0; i < iItemTab1; i++ )
				{
					cDrawing->DrawBox( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );
					cDrawing->DrawBox( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );

					cDrawing->Draw_Text( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20, DT_NOCLIP | DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB( 192, 192, 192 ), "-" );

					cDrawing->FillRGB( iMenuX + iMenuWidth - 290, i * 30 + iMenuY + 50, ( itemTab1[ i ].iValue / ( double ) itemTab1[ i ].iMaxValue ) * 240, 20, itemTab1[ i ].Color, pDevice );
					cDrawing->DrawBorder( iMenuX + iMenuWidth - 290, i * 30 + iMenuY + 50, 240, 20, 1, D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );

					cDrawing->Draw_Text( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20, DT_NOCLIP | DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB( 192, 192, 192 ), "+" );

					cDrawing->Draw_Text( iMenuX + 20, i * 30 + iMenuY + 50, 0, 0, DT_NOCLIP, D3DCOLOR_XRGB( 192, 192, 192 ), "%s - %i", itemTab1[ i ].szName, itemTab1[ i ].iValue );
				}
			}
			else if( tabsOptions.ActiveTab == tab2 )
			{
				for( int i = 0; i < iItemTab2; i++ )
				{
					cDrawing->DrawBox( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );
					cDrawing->DrawBox( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );

					cDrawing->Draw_Text( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20, DT_NOCLIP | DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB( 192, 192, 192 ), "-" );

					cDrawing->FillRGB( iMenuX + iMenuWidth - 290, i * 30 + iMenuY + 50, ( itemTab2[ i ].iValue / ( double ) itemTab2[ i ].iMaxValue ) * 240, 20, itemTab2[ i ].Color, pDevice );
					cDrawing->DrawBorder( iMenuX + iMenuWidth - 290, i * 30 + iMenuY + 50, 240, 20, 1, D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );

					cDrawing->Draw_Text( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20, DT_NOCLIP | DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB( 192, 192, 192 ), "+" );

					cDrawing->Draw_Text( iMenuX + 20, i * 30 + iMenuY + 50, 0, 0, DT_NOCLIP, D3DCOLOR_XRGB( 192, 192, 192 ), "%s - %i", itemTab2[ i ].szName, itemTab2[ i ].iValue );
				}
			}
			else if( tabsOptions.ActiveTab == tab3 )
			{
				for( int i = 0; i < iItemTab3; i++ )
				{
					cDrawing->DrawBox( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );
					cDrawing->DrawBox( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );

					cDrawing->Draw_Text( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20, DT_NOCLIP | DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB( 192, 192, 192 ), "-" );

					cDrawing->FillRGB( iMenuX + iMenuWidth - 290, i * 30 + iMenuY + 50, ( itemTab3[ i ].iValue / ( double ) itemTab3[ i ].iMaxValue ) * 240, 20, itemTab3[ i ].Color, pDevice );
					cDrawing->DrawBorder( iMenuX + iMenuWidth - 290, i * 30 + iMenuY + 50, 240, 20, 1, D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );

					cDrawing->Draw_Text( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20, DT_NOCLIP | DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB( 192, 192, 192 ), "+" );

					cDrawing->Draw_Text( iMenuX + 20, i * 30 + iMenuY + 50, 0, 0, DT_NOCLIP, D3DCOLOR_XRGB( 192, 192, 192 ), "%s - %i", itemTab3[ i ].szName, itemTab3[ i ].iValue );
				}
			}
			else if( tabsOptions.ActiveTab == tab4 )
			{
				for( int i = 0; i < iItemTab4; i++ )
				{
					cDrawing->DrawBox( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );
					cDrawing->DrawBox( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );

					cDrawing->Draw_Text( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20, DT_NOCLIP | DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB( 192, 192, 192 ), "-" );

					cDrawing->FillRGB( iMenuX + iMenuWidth - 290, i * 30 + iMenuY + 50, ( itemTab4[ i ].iValue / ( double ) itemTab4[ i ].iMaxValue ) * 240, 20, itemTab4[ i ].Color, pDevice );
					cDrawing->DrawBorder( iMenuX + iMenuWidth - 290, i * 30 + iMenuY + 50, 240, 20, 1, D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );

					cDrawing->Draw_Text( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20, DT_NOCLIP | DT_CENTER | DT_VCENTER, D3DCOLOR_XRGB( 192, 192, 192 ), "+" );

					cDrawing->Draw_Text( iMenuX + 20, i * 30 + iMenuY + 50, 0, 0, DT_NOCLIP, D3DCOLOR_XRGB( 192, 192, 192 ), "%s - %i", itemTab4[ i ].szName, itemTab4[ i ].iValue );
				}
			}

			GetCursorPos( &curPos );
			cDrawing->DrawBox( curPos.x, curPos.y, 5, 5, D3DCOLOR_XRGB( 65, 65, 65 ), D3DCOLOR_XRGB( 0, 0, 0 ), pDevice );
		}

		if( GetAsyncKeyState( VK_DELETE ) &1 )
		{
			bMenu =! bMenu;
		}
	
		if( GetAsyncKeyState( VK_LBUTTON ) &1 )
		{
			if( bMenu )
			{
				if( tabsOptions.ActiveTab == tab1 )
				{
					for( int i = 0; i < iItemTab1; i++ )
					{
						if( MouseOverItem( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20 ) && itemTab1[ i ].iValue != itemTab1[ i ].iMinValue )
						{
							itemTab1[ i ].iValue -= itemTab1[ i ].iIncDecValue;
						}
						if( MouseOverItem( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20 ) && itemTab1[ i ].iValue != itemTab1[ i ].iMaxValue )
						{
							itemTab1[ i ].iValue += itemTab1[ i ].iIncDecValue;
						}
					}
				}

				else if( tabsOptions.ActiveTab == tab2 )
				{
					for( int i = 0; i < iItemTab2; i++ )
					{
						if( MouseOverItem( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20 ) && itemTab2[ i ].iValue != itemTab2[ i ].iMinValue )
						{
							itemTab2[ i ].iValue -= itemTab2[ i ].iIncDecValue;
						}
						if( MouseOverItem( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20 ) && itemTab2[ i ].iValue != itemTab2[ i ].iMaxValue )
						{
							itemTab2[ i ].iValue += itemTab2[ i ].iIncDecValue;
						}
					}
				}

				else if( tabsOptions.ActiveTab == tab3 )
				{
					for( int i = 0; i < iItemTab3; i++ )
					{
						if( MouseOverItem( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20 ) && itemTab3[ i ].iValue != itemTab3[ i ].iMinValue )
						{
							itemTab3[ i ].iValue -= itemTab3[ i ].iIncDecValue;
						}
						if( MouseOverItem( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20 ) && itemTab3[ i ].iValue != itemTab3[ i ].iMaxValue )
						{
							itemTab3[ i ].iValue += itemTab3[ i ].iIncDecValue;
						}
					}
				}

				else if( tabsOptions.ActiveTab == tab4 )
				{
					for( int i = 0; i < iItemTab4; i++ )
					{
						if( MouseOverItem( iMenuX + iMenuWidth - 320, i * 30 + iMenuY + 50, 20, 20 ) && itemTab4[ i ].iValue != itemTab4[ i ].iMinValue )
						{
							itemTab4[ i ].iValue -= itemTab4[ i ].iIncDecValue;
						}
						if( MouseOverItem( iMenuX + iMenuWidth - 40, i * 30 + iMenuY + 50, 20, 20 ) && itemTab4[ i ].iValue != itemTab4[ i ].iMaxValue )
						{
							itemTab4[ i ].iValue += itemTab4[ i ].iIncDecValue;
						}
					}
				}
			
				if( MouseOverItem( iMenuX + 10, iMenuY + 10, 120, 20 ) )
				{
					tabsOptions.ActiveTab = tab1;
				}
				else if( MouseOverItem( iMenuX + 140, iMenuY + 10, 120, 20 ) )
				{
					tabsOptions.ActiveTab = tab2;
				}
				else if( MouseOverItem( iMenuX + 270, iMenuY + 10, 120, 20 ) )
				{
					tabsOptions.ActiveTab = tab3;
				}
				else if( MouseOverItem( iMenuX + 400, iMenuY + 10, 120, 20 ) )
				{
					tabsOptions.ActiveTab = tab4;
				}
			}
		}

		else if( GetAsyncKeyState( VK_LBUTTON ) < 0 )
		{
			if( bMenu )
			{
				if( MouseOverItem( iMenuX, iMenuY, iMenuWidth - 5, iMenuHeight - 5 ) )
				{
					iMenuX += ( curPos.x - iLastX );
					iMenuY += ( curPos.y - iLastY );
				}
			}
		}

		iLastX = curPos.x;
		iLastY = curPos.y;

		return 0;
	}

};
 
Üst Alt