Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    boboben1's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    89
    Reputation
    10
    Thanks
    29
    My Mood
    Paranoid

    Menu.h - MY VERY OWN MENU!

    Well i spent 4 hours today learning and writing a menu for any game:



    CREDITS:
    ME
    A ton of c++ tutorials
    _____________________
    For an easy class for fonts:
    NTKID
    K@N@vel

    AND HERE IS MY CODE (IT IS SOMEWHAT CLEAN!):

    Code:
    #include "main.h"
    #include <d3d9.h>
    #include <d3dx9.h>
    #pragma comment(lib,"d3d9.lib")
    #pragma comment(lib,"d3dx9.lib")
    #include <windows.h>
    #pragma once
    class m_CItem;
    class m_CMenu;
    
    class m_CItem
    {
    public:
    	char* itemName;
    	bool enabled;
    private:
    };
    class ImportFont
    {
    protected:
    	LPD3DXFONT m_pFont;
    public:
    	ImportFont::ImportFont(LPDIRECT3DDEVICE9 pDevice,int Size,LPWSTR pFacename)
    	{
    		D3DXCreateFontW(pDevice,Size,0,FW_BOLD,1,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,ANTIALIASED_QUALITY,DEFAULT_PITCH|FF_DONTCARE,pFacename,&m_pFont);
    	}
    	ImportFont::~ImportFont()
    	{
    		if(m_pFont)
    		{
    			m_pFont->Release();
    			m_pFont = NULL;
    		}
    	}
    	VOID ImportFont::LostDevice()
    	{
    		if(m_pFont)
    			m_pFont->OnLostDevice();
    	}
    	VOID ImportFont::ResetDevice()
    	{
    		if(m_pFont)
    			m_pFont->OnResetDevice();
    	}
    	VOID ImportFont::Draw(INT x,INT y,LPCWSTR pString,D3DCOLOR Color)
    	{
    		if(m_pFont)
    		{
    			RECT Rect = { x, y, 0, 0 }; 
    			m_pFont->DrawTextW(NULL,pString,-1,&Rect,DT_NOCLIP,Color);
    		}
    	}
    };
    class m_CMenu
    {
    public:
    	void getInput()
    	{
    		if (GetAsyncKeyState(VK_INSERT)&1)
    			Show = !Show;
    		if (GetAsyncKeyState(VK_DOWN)&1)
    		{
    			if (CurrentChoice < GetArrLength(MenuItems)-1)
    				CurrentChoice++;
    		}
    		if (GetAsyncKeyState(VK_UP)&1)
    		{
    			if (CurrentChoice > 0)
    				CurrentChoice--;
    		}
    		if (GetAsyncKeyState(VK_RIGHT)&1)
    		{
    			MenuItems[CurrentChoice]->enabled = true;
    		}
    		if (GetAsyncKeyState(VK_LEFT)&1)
    		{
    			MenuItems[CurrentChoice]->enabled = false;
    		}
    	}
    	~m_CMenu()
    	{
    		if (pFont)
    		{
    			delete pFont;
    			pFont = 0;
    		}
    	}
    	m_CMenu(LPDIRECT3DDEVICE9& aDevice, int xx, int yy)
    	{
    		height = GetArrLength(MenuItems) * 20 + 10;
    		width = 100;
    		pDevice = aDevice;
    		for (int i = 0; i < GetArrLength(MenuItems); i++)
    			MenuItems[i] = new m_CItem();
    		//TODO: add labels here
    		MenuItems[0]->itemName = "Hello";
    		MenuItems[1]->itemName = "Hello";
    		MenuItems[2]->itemName = "Hello";
    		MenuItems[3]->itemName = "Hello";
    		MenuItems[4]->itemName = "Hello";
    		MenuItems[5]->itemName = "Hello";
    		MenuItems[6]->itemName = "Hello";
    		MenuItems[7]->itemName = "Hello";
    		MenuItems[8]->itemName = "Hello";
    		MenuItems[9]->itemName = "Hello";
    		//MenuItems[10]->itemName = "Hello";
    		Show = false;
    		pFont = new ImportFont(pDevice,14,L"tahoma");
    		x = xx;
    		y = yy;
    		CurrentChoice = 0;
    		//wchar_t istr[32];
    		//_itow_s(height, istr, 10);
    		//MessageBox(0,istr,0,0);
    	}
    	int x, y, width, height;
    	void DrawMenu()
    	{
    		if (Show)
    		{
    			static D3DRECT rect = {x,y,x+width,y+height};
    			//pFont->Draw(60,60,L"hello",D3DCOLOR_ARGB(255,255,255,255));
    
    			pDevice->Clear(0,&rect,0,D3DCOLOR_ARGB(255,0,0,0),0,0);
    			pFont->Draw(x+5,y+5,L"Test Hook",D3DCOLOR_ARGB(255,255,255,255));
    			int location = 20;
    			for (int i = 0; i < GetArrLength(MenuItems);i++)
    			{
    				location += 20;
    				if (CurrentChoice == i)
    				{
    					int len = strlen(MenuItems[i]->itemName)+1;
    					wchar_t *wText = new wchar_t[len];
    					memset(wText,0,len);
    					::MultiByteToWideChar(  CP_ACP, NULL,MenuItems[i]->itemName, -1, wText,len );
    
    					pFont->Draw(x+5,y+location,wText,D3DCOLOR_ARGB(255,255,255,0));
    				}
    				else
    				{
    					int len = strlen(MenuItems[i]->itemName)+1;
    					wchar_t *wText = new wchar_t[len];
    					memset(wText,0,len);
    					::MultiByteToWideChar(  CP_ACP, NULL,MenuItems[i]->itemName, -1, wText,len );
    
    					pFont->Draw(x+5,y+location,wText,D3DCOLOR_ARGB(255,255,255,255));
    				}
    				if (MenuItems[i]->enabled)
    					pFont->Draw(x+width-20,y+location,L"Enabled",D3DCOLOR_ARGB(255,255,255,0));
    				else
    					pFont->Draw(x+width-20,y+location,L"Disabled",D3DCOLOR_ARGB(255,255,255,0));
    			}
    		}
    	}
    	void Set(int Number, char* Name)
    	{
    		MenuItems[Number]->itemName = Name;
    	}
    	template<typename T, int size>
    	int GetArrLength(T(&)[size]){return size;}
    	void Hacks()
    	{
    		//todo: add hacks here
    	}
    	m_CItem* MenuItems[10];
    	LPDIRECT3DDEVICE9 pDevice;
    	ImportFont* pFont;
    	int CurrentChoice;
    	bool Show;
    };
    Yes, It has unneeded functions because i was testing using them. They just make it easier to add things to the menu dynamically.
    Games that i am bothering to make a screenshot of:
    Black ops
    Battlefield Heroes
    BTW this works for all games.
    SCREENSHOTS:





    IS THIS THE CORRECT SECTION? It works with combat arms too, although i am not posting a screenshot of CA.
    Last edited by boboben1; 03-17-2011 at 09:18 PM.

  2. The Following 2 Users Say Thank You to boboben1 For This Useful Post:

    HurleyppL (07-02-2011),Turbulence (03-18-2011)

  3. #2
    ISony's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    13
    Reputation
    5
    Thanks
    0
    woah dude awsome

  4. #3
    Disturbed's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    10,472
    Reputation
    1267
    Thanks
    2,587
    /Moved.

    CA source cavers are going to eat you alive.


  5. The Following 4 Users Say Thank You to Disturbed For This Useful Post:

    boboben1 (03-17-2011),NextGen1 (03-17-2011),PashaAmd (03-17-2011),swatfx (03-18-2011)

  6. #4
    RawrPancakes's Avatar
    Join Date
    Jan 2011
    Gender
    male
    Posts
    53
    Reputation
    10
    Thanks
    1
    My Mood
    Asleep
    Quote Originally Posted by boboben1 View Post
    Well i spent 4 hours today learning and writing a menu for any game:



    CREDITS:



    AND HERE IS MY CODE (IT IS SOMEWHAT CLEAN!):

    Code:
    #include "main.h"
    #include <d3d9.h>
    #include <d3dx9.h>
    #pragma comment(lib,"d3d9.lib")
    #pragma comment(lib,"d3dx9.lib")
    #include <windows.h>
    #pragma once
    class m_CItem;
    class m_CMenu;
    
    class m_CItem
    {
    public:
    	char* itemName;
    	bool enabled;
    private:
    };
    class ImportFont
    {
    protected:
    	LPD3DXFONT m_pFont;
    public:
    	ImportFont::ImportFont(LPDIRECT3DDEVICE9 pDevice,int Size,LPWSTR pFacename)
    	{
    		D3DXCreateFontW(pDevice,Size,0,FW_BOLD,1,0,DEFAULT_CHARSET,OUT_DEFAULT_PRECIS,ANTIALIASED_QUALITY,DEFAULT_PITCH|FF_DONTCARE,pFacename,&m_pFont);
    	}
    	ImportFont::~ImportFont()
    	{
    		if(m_pFont)
    		{
    			m_pFont->Release();
    			m_pFont = NULL;
    		}
    	}
    	VOID ImportFont::LostDevice()
    	{
    		if(m_pFont)
    			m_pFont->OnLostDevice();
    	}
    	VOID ImportFont::ResetDevice()
    	{
    		if(m_pFont)
    			m_pFont->OnResetDevice();
    	}
    	VOID ImportFont::Draw(INT x,INT y,LPCWSTR pString,D3DCOLOR Color)
    	{
    		if(m_pFont)
    		{
    			RECT Rect = { x, y, 0, 0 }; 
    			m_pFont->DrawTextW(NULL,pString,-1,&Rect,DT_NOCLIP,Color);
    		}
    	}
    };
    class m_CMenu
    {
    public:
    	void getInput()
    	{
    		if (GetAsyncKeyState(VK_INSERT)&1)
    			Show = !Show;
    		if (GetAsyncKeyState(VK_DOWN)&1)
    		{
    			if (CurrentChoice < GetArrLength(MenuItems)-1)
    				CurrentChoice++;
    		}
    		if (GetAsyncKeyState(VK_UP)&1)
    		{
    			if (CurrentChoice > 0)
    				CurrentChoice--;
    		}
    		if (GetAsyncKeyState(VK_RIGHT)&1)
    		{
    			MenuItems[CurrentChoice]->enabled = true;
    		}
    		if (GetAsyncKeyState(VK_LEFT)&1)
    		{
    			MenuItems[CurrentChoice]->enabled = false;
    		}
    	}
    	~m_CMenu()
    	{
    		if (pFont)
    		{
    			delete pFont;
    			pFont = 0;
    		}
    	}
    	m_CMenu(LPDIRECT3DDEVICE9& aDevice, int xx, int yy)
    	{
    		height = GetArrLength(MenuItems) * 20 + 10;
    		width = 100;
    		pDevice = aDevice;
    		for (int i = 0; i < GetArrLength(MenuItems); i++)
    			MenuItems[i] = new m_CItem();
    		//TODO: add labels here
    		MenuItems[0]->itemName = "Hello";
    		MenuItems[1]->itemName = "Hello";
    		MenuItems[2]->itemName = "Hello";
    		MenuItems[3]->itemName = "Hello";
    		MenuItems[4]->itemName = "Hello";
    		MenuItems[5]->itemName = "Hello";
    		MenuItems[6]->itemName = "Hello";
    		MenuItems[7]->itemName = "Hello";
    		MenuItems[8]->itemName = "Hello";
    		MenuItems[9]->itemName = "Hello";
    		//MenuItems[10]->itemName = "Hello";
    		Show = false;
    		pFont = new ImportFont(pDevice,14,L"tahoma");
    		x = xx;
    		y = yy;
    		CurrentChoice = 0;
    		//wchar_t istr[32];
    		//_itow_s(height, istr, 10);
    		//MessageBox(0,istr,0,0);
    	}
    	int x, y, width, height;
    	void DrawMenu()
    	{
    		if (Show)
    		{
    			static D3DRECT rect = {x,y,x+width,y+height};
    			//pFont->Draw(60,60,L"hello",D3DCOLOR_ARGB(255,255,255,255));
    
    			pDevice->Clear(0,&rect,0,D3DCOLOR_ARGB(255,0,0,0),0,0);
    			pFont->Draw(x+5,y+5,L"Test Hook",D3DCOLOR_ARGB(255,255,255,255));
    			int location = 20;
    			for (int i = 0; i < GetArrLength(MenuItems);i++)
    			{
    				location += 20;
    				if (CurrentChoice == i)
    				{
    					int len = strlen(MenuItems[i]->itemName)+1;
    					wchar_t *wText = new wchar_t[len];
    					memset(wText,0,len);
    					::MultiByteToWideChar(  CP_ACP, NULL,MenuItems[i]->itemName, -1, wText,len );
    
    					pFont->Draw(x+5,y+location,wText,D3DCOLOR_ARGB(255,255,255,0));
    				}
    				else
    				{
    					int len = strlen(MenuItems[i]->itemName)+1;
    					wchar_t *wText = new wchar_t[len];
    					memset(wText,0,len);
    					::MultiByteToWideChar(  CP_ACP, NULL,MenuItems[i]->itemName, -1, wText,len );
    
    					pFont->Draw(x+5,y+location,wText,D3DCOLOR_ARGB(255,255,255,255));
    				}
    				if (MenuItems[i]->enabled)
    					pFont->Draw(x+width-20,y+location,L"Enabled",D3DCOLOR_ARGB(255,255,255,0));
    				else
    					pFont->Draw(x+width-20,y+location,L"Disabled",D3DCOLOR_ARGB(255,255,255,0));
    			}
    		}
    	}
    	void Set(int Number, char* Name)
    	{
    		MenuItems[Number]->itemName = Name;
    	}
    	template<typename T, int size>
    	int GetArrLength(T(&)[size]){return size;}
    	void Hacks()
    	{
    		//todo: add hacks here
    	}
    	m_CItem* MenuItems[10];
    	LPDIRECT3DDEVICE9 pDevice;
    	ImportFont* pFont;
    	int CurrentChoice;
    	bool Show;
    };
    Yes, It has unneeded functions because i was testing using them. They just make it easier to add things to the menu dynamically.
    SCREENSHOTS:

    COMING SOON
    hey cool but what tuts did u use im intreseted in learning C++/VisualBasic too
    Are you ready..... To get pwnnnd By Pancakes O.o
    Things to do
    Get 100 post
    get 500 post
    get 1000 post
    get 10000 post
    GET 1milion post {}
    get banned NOT hacking
    get banned WHILE hacking
    https://www.mpgh.net/forum/signaturepics/sigpic717527_1.gif

  7. #5
    Sketchy's Avatar
    Join Date
    Mar 2011
    Gender
    male
    Posts
    4,876
    Reputation
    515
    Thanks
    663
    My Mood
    Inspired
    Quote Originally Posted by Disturbed View Post
    /Moved.

    CA source cavers are going to eat you alive.
    @Disturbed I seriously hope you saw this before me because you replied like 3 seconds after my mention.
    I'm going to steal the code

  8. #6
    Disturbed's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    10,472
    Reputation
    1267
    Thanks
    2,587
    Quote Originally Posted by iFaceBook View Post

    @Disturbed I seriously hope you saw this before me because you replied like 3 seconds after my mention.
    I'm going to steal the code
    Lol, I had already moved it by the time you posted.


  9. The Following User Says Thank You to Disturbed For This Useful Post:

    NextGen1 (03-17-2011)

  10. #7
    boboben1's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    89
    Reputation
    10
    Thanks
    29
    My Mood
    Paranoid
    Ty for moving it.

  11. #8
    _Fk127_'s Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    720
    Reputation
    16
    Thanks
    208
    My Mood
    Bitchy
    Nice simple menu class. Your intelligence level has already surpassed that of 90% of the section so..



    Put this image in your signature if you support HTML5 development!

  12. #9
    boboben1's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    89
    Reputation
    10
    Thanks
    29
    My Mood
    Paranoid
    can you see my screenshots?

    Nice simple menu class. Your intelligence level has already surpassed that of 90% of the section so..
    It took a while to find out how to convert char* to lpcwstr.
    Last edited by boboben1; 03-17-2011 at 09:24 PM.

  13. #10
    Disturbed's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    10,472
    Reputation
    1267
    Thanks
    2,587
    Quote Originally Posted by boboben1 View Post
    can you see my screenshots?
    Right click on the image on the Image shack page and Select "Copy Image URL". Use THAT inside of the [IMG] tags.


  14. #11
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,159
    Reputation
    490
    Thanks
    2,253
    this aint yours..
    Font Class By ntKid

  15. #12
    boboben1's Avatar
    Join Date
    Feb 2009
    Gender
    male
    Posts
    89
    Reputation
    10
    Thanks
    29
    My Mood
    Paranoid
    Quote Originally Posted by Disturbed View Post


    Right click on the image on the Image shack page and Select "Copy Image URL". Use THAT inside of the [IMG] tags.
    I did... it is not showing up... does image shack work?

    this aint yours..
    Font Class By ntKid
    i made everything else. I just used that importfont class because it was quicker.
    Last edited by boboben1; 03-17-2011 at 09:26 PM.

  16. #13
    whit's Avatar
    Join Date
    Jan 2010
    Gender
    male
    Posts
    7,159
    Reputation
    490
    Thanks
    2,253
    Well this should be in the D3D section tho

  17. #14
    _Fk127_'s Avatar
    Join Date
    Nov 2010
    Gender
    male
    Posts
    720
    Reputation
    16
    Thanks
    208
    My Mood
    Bitchy
    Quote Originally Posted by whit View Post
    Well this should be in the D3D section tho
    That section is dead



    Put this image in your signature if you support HTML5 development!

  18. #15
    Lawllypawp's Avatar
    Join Date
    Feb 2011
    Gender
    female
    Location
    Melbourne, Australia
    Posts
    582
    Reputation
    27
    Thanks
    66
    My Mood
    Sick
    GetAsyncKeyState is detected.

Page 1 of 2 12 LastLast