Page 1 of 3 123 LastLast
Results 1 to 15 of 45
  1. #1
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow

    [Source]Simple menu class

    Uhg, not much to say, I made a simple menu class this morning for myself to use since I don't like everyone else's.

    The function's name speak for themselves, except for InitControls. To initiate the hotkeys for the menu, just put InitControls in a loop and create a seperate thread for it.

    [highlight=cpp]
    void MainThread()
    {
    while(true)
    {
    MenuInstance->InitControls();
    }
    }

    ....

    CreateThread(0,0,(LPTHREAD_START_ROUTINE)MainThrea d,0,0,0);
    [/highlight]

    That's the only seemingly confusing part. Use the menu item's index to get it's current status ( on/off ). When your module detaches I made a function to release the classes private members so you don't get leaks.

    Here we go.

    Menu.h:
    [highlight=cpp]
    #ifndef MENU_H
    #define MENU_H

    #include <windows.h>
    #include <d3d9.h>
    #include <d3dx9.h>

    struct MenuItem {
    int index;
    char* text;
    bool status;
    MenuItem* pNext;
    };

    class cMenu {
    private:
    IDirect3DDevice9* m_pDevice;
    ID3DXFont* m_pFont;
    MenuItem* MenuItems;
    int CurrSelected;
    int m_nItems;

    public:
    cMenu(IDirect3DDevice9*,ID3DXFont*);
    void Update(IDirect3DDevice9*,ID3DXFont*);

    void AddItem(char*,int);
    void RenderMenu(void);
    void InitControls(void);
    void Release(void);
    bool GetStatus(int);
    };

    #endif
    [/highlight]

    Menu.cpp
    [highlight=cpp]
    #include "Menu.h"


    cMenu::cMenu(IDirect3DDevice9 *pDevice, ID3DXFont *pFont)
    {
    cMenu::m_pDevice = pDevice;
    cMenu::m_pFont = pFont;
    cMenu::MenuItems = NULL;
    cMenu::CurrSelected = 1;
    cMenu::m_nItems = 0;
    }

    void cMenu::Update(IDirect3DDevice9 *pDevice, ID3DXFont *pFont)
    {
    cMenu::m_pDevice = pDevice;
    cMenu::m_pFont = pFont;
    }

    void cMenu::AddItem(char *text, int index)
    {
    MenuItem* Ptr = new MenuItem;
    MenuItem* Before = new MenuItem;
    MenuItem* New = new MenuItem;

    New->index = index;
    New->text = text;
    New->status = false;
    New->pNext = NULL;

    if(cMenu::MenuItems == NULL)
    {
    cMenu::MenuItems = New;
    cMenu::MenuItems->pNext = NULL;
    } else {
    Ptr = cMenu::MenuItems;
    while(Ptr->pNext != NULL)
    {
    Ptr = Ptr->pNext;
    }
    Ptr->pNext = New;
    }
    cMenu::m_nItems++;

    }

    void cMenu::RenderMenu()
    {
    MenuItem* Ptr = new MenuItem;
    MenuItem* Before = new MenuItem;
    MenuItem* New = new MenuItem;

    RECT rect;
    rect.top = 20;
    rect.left = 20;
    rect.right = 150;
    rect.bottom = 20;

    Ptr = cMenu::MenuItems;
    do
    {
    if(!(Ptr->index == CurrSelected) && !Ptr->status)
    {
    cMenu::m_pFont->DrawText(0,Ptr->text,-1,&rect,DT_LEFT|DT_NOCLIP,D3DCOLOR_XRGB(255,0,0)) ;
    cMenu::m_pFont->DrawText(0,"Off",-1,&rect,DT_RIGHT|DT_NOCLIP,D3DCOLOR_XRGB(255,0,0)) ;
    }
    if(Ptr->index == CurrSelected && !Ptr->status)
    {
    cMenu::m_pFont->DrawText(0,Ptr->text,-1,&rect,DT_LEFT|DT_NOCLIP,D3DCOLOR_XRGB(0,255,0)) ;
    cMenu::m_pFont->DrawText(0,"Off",-1,&rect,DT_RIGHT|DT_NOCLIP,D3DCOLOR_XRGB(0,255,0)) ;
    }

    if(!(Ptr->index == CurrSelected) && Ptr->status)
    {
    cMenu::m_pFont->DrawText(0,Ptr->text,-1,&rect,DT_LEFT|DT_NOCLIP,D3DCOLOR_XRGB(255,0,0)) ;
    cMenu::m_pFont->DrawText(0,"On",-1,&rect,DT_RIGHT|DT_NOCLIP,D3DCOLOR_XRGB(255,0,0)) ;
    }
    if(Ptr->index == CurrSelected && Ptr->status)
    {
    cMenu::m_pFont->DrawText(0,Ptr->text,-1,&rect,DT_LEFT|DT_NOCLIP,D3DCOLOR_XRGB(0,255,0)) ;
    cMenu::m_pFont->DrawText(0,"On",-1,&rect,DT_RIGHT|DT_NOCLIP,D3DCOLOR_XRGB(0,255,0)) ;
    }


    rect.top += 17;
    Ptr = Ptr->pNext;
    }while(Ptr != NULL);



    }

    void cMenu::InitControls()
    {
    MenuItem* Ptr = new MenuItem;

    if(GetAsyncKeyState(VK_DOWN))
    {
    if(CurrSelected != cMenu::m_nItems)
    CurrSelected += 1;

    Sleep(100);
    }
    if(GetAsyncKeyState(VK_UP))
    {
    if(CurrSelected != 1)
    CurrSelected -= 1;

    Sleep(100);
    }
    if(GetAsyncKeyState(VK_RIGHT))
    {
    Ptr = cMenu::MenuItems;
    while(Ptr != NULL)
    {
    if(Ptr->index == CurrSelected)
    {
    break;
    }
    Ptr = Ptr->pNext;
    }
    Ptr->status = !Ptr->status;

    Sleep(100);
    }
    if(GetAsyncKeyState(VK_LEFT))
    {
    Ptr = cMenu::MenuItems;
    while(Ptr != NULL)
    {
    if(Ptr->index == CurrSelected)
    {
    break;
    }
    Ptr = Ptr->pNext;
    }
    Ptr->status = !Ptr->status;

    Sleep(100);
    }
    }

    void cMenu::Release()
    {
    cMenu::m_pDevice->Release();
    cMenu::m_pFont->Release();
    }

    bool cMenu::GetStatus(int index)
    {
    MenuItem* Ptr = new MenuItem;
    Ptr = cMenu::MenuItems;
    while(Ptr != NULL)
    {
    if(Ptr->index == index)
    {
    break;
    }
    Ptr = Ptr->pNext;
    }
    return Ptr->status;
    }
    [/highlight]

    Also.. I made a small example just in case you guys can't figure out how to use it.. The whole project is the attached file below.

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

    'Bruno (08-10-2010),0rbit (08-10-2010),258456 (08-10-2010),ac1d_buRn (08-18-2010),Auxilium (08-10-2010),Crash (08-25-2010),DBag4Life69 (08-26-2010),egarn2 (10-20-2012),fvestrgenrl (08-27-2010),hellomen11 (05-21-2012),inmate (08-10-2010),Isilvar (11-23-2012),Jason (10-05-2010),kip3300 (12-02-2010),Lyoto Machida (06-03-2011),Melodia (08-10-2010),NextGen1 (10-04-2010),noammn (08-16-2010),schim (08-16-2010),scimmyboy (08-10-2010),scuarplex (08-13-2010),spelgabber (09-30-2012),SPLUXOR (12-25-2013),Tekkn0logik (09-06-2010),tempta43 (08-21-2010),therofl (11-02-2010),UDS97 (07-27-2011),unspeakable (09-15-2012),VvITylerIvV (08-10-2010),why06 (08-16-2010),WTX-HACK (11-30-2012)

  3. #2
    scimmyboy's Avatar
    Join Date
    Jan 2008
    Gender
    male
    Location
    https://mpgh.net MPGHCash: $442,596,199
    Posts
    5,645
    Reputation
    26
    Thanks
    896
    My Mood
    Happy
    YOU SUCK. YOU SUCK. first post. love you david

  4. #3
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Looks gewd. Won't use however because im still learning C++

  5. #4
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Ohai there Patrick. The thanks button is waiting to be pressed. |:

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

    therofl (11-02-2010),WTFXD185 (04-16-2011)

  7. #5
    Auxilium's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    深い碧の果てに
    Posts
    4,518
    Reputation
    445
    Thanks
    609
    My Mood
    Happy
    Pressed

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

    Void (08-10-2010),WTFXD185 (04-16-2011)

  9. #6
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    wow... Attachments Pending Approval? fail... C++ section now needs approval

    Nice david ;d anyway i wouldn't expect a different result from ya =D unfortunately i don't know much (anything) about D3D to comment that much.
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  10. The Following 2 Users Say Thank You to 'Bruno For This Useful Post:

    therofl (11-02-2010),Void (08-10-2010)

  11. #7
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Oyaa credits to Brinuz for his linked lists tutorial.

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

    'Bruno (08-10-2010),therofl (11-02-2010)

  13. #8
    'Bruno's Avatar
    Join Date
    Dec 2009
    Gender
    male
    Location
    Portugal
    Posts
    2,883
    Reputation
    290
    Thanks
    1,036
    My Mood
    Busy
    Quote Originally Posted by Void View Post
    Oyaa credits to Brinuz for his linked lists tutorial.
    =o im surprised that someone used it lulz
    Light travels faster than sound. That's why most people seem bright until you hear them speak.

  14. The Following 2 Users Say Thank You to 'Bruno For This Useful Post:

    258456 (08-10-2010),therofl (11-02-2010)

  15. #9
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    I'm the only one who thanked it I think. |:

  16. The Following User Says Thank You to Void For This Useful Post:

    therofl (11-02-2010)

  17. #10
    Melodia's Avatar
    Join Date
    Dec 2009
    Gender
    female
    Posts
    2,608
    Reputation
    276
    Thanks
    1,662
    My Mood
    Dead
    Cute ~
    Love You All~

  18. The Following User Says Thank You to Melodia For This Useful Post:

    Void (08-10-2010)

  19. #11
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    Quote Originally Posted by Melodia View Post
    Cute ~
    Why thank you Mel. /

  20. The Following User Says Thank You to Void For This Useful Post:

    therofl (11-02-2010)

  21. #12
    inmate's Avatar
    Join Date
    Jul 2009
    Gender
    male
    Location
    Bottrop, NRW, Germany
    Posts
    131
    Reputation
    10
    Thanks
    194
    My Mood
    Amazed
    Quote Originally Posted by Melodia View Post
    Cute ~
    Agree

  22. #13
    Fabolous's Avatar
    Join Date
    Jul 2010
    Gender
    male
    Location
    192.168.1.01
    Posts
    2,704
    Reputation
    261
    Thanks
    682
    My Mood
    Paranoid
    Not Gellins base. But VOID'S base

  23. #14
    Void's Avatar
    Join Date
    Sep 2009
    Gender
    male
    Location
    Inline.
    Posts
    3,198
    Reputation
    205
    Thanks
    1,445
    My Mood
    Mellow
    It's just a class..

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

    Melodia (08-12-2010),therofl (11-02-2010)

  25. #15
    freedompeace's Avatar
    Join Date
    Jul 2010
    Gender
    female
    Posts
    3,033
    Reputation
    340
    Thanks
    2,792
    My Mood
    Sad
    Quote Originally Posted by Void View Post
    It's just a class..
    Hey Void, does unlocking the cursor mid-game (eg, while you're in game killing people / re-spawning) allow mouse co-ordinates other than center to be grabbed?

    (I don't have the game, so I can't find out - I have 1GB internet per month, and Combat Arms is well... rather large)

Page 1 of 3 123 LastLast

Similar Threads

  1. [SOURCE] Simple Teleport hack
    By Solify in forum Combat Arms EU Hack Coding/Source Code
    Replies: 42
    Last Post: 10-09-2010, 01:09 PM
  2. My C# Menu Class
    By User1 in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 10
    Last Post: 08-16-2010, 09:28 PM
  3. [C++ SOURCE]Simple D3D Show Time and Date
    By mastermods in forum Combat Arms Hack Coding / Programming / Source Code
    Replies: 12
    Last Post: 08-11-2010, 08:50 AM
  4. [Source] Keyboard Menu 2.0
    By phoenixraider in forum C++/C Programming
    Replies: 5
    Last Post: 12-31-2009, 06:02 PM
  5. [Source] Checkbox Menu by Str1k3r21 *D3D8*
    By phoenixraider in forum C++/C Programming
    Replies: 7
    Last Post: 03-31-2009, 05:24 PM