Uh, isn't what you posted suppose to look like:
Code:
#include "d3dmenu.h"
char Mtitle[81]=""; // Some room for a title
int Mpos=0; // current highlighted menuitem
int Mmax=0; // number of menu items
int Mxofs =160; // offset for option text
int Mysize=15; // heigh of a menuline
int Mvisible=1;
// predifine some basic options
char *Moptfolder[] = { "+" , "-" };
char *Moptonoff[] = { "Off", "On"};
RECT rect;
RECT rect2;
RECT rect3;
struct {
int typ; // type of menuline, folder, item
char *txt; // text to show
char **opt; // array of options
int *var; // variable containing current status
int maxvalue; // maximumvalue, normally 1 gives 0=off 1=on
} MENU[MENUMAXITEMS];
void MenuAddItem(char *txt, char **opt, int *var, int maxvalue, int typ)
{
MENU[Mmax].typ=typ;
MENU[Mmax].txt=txt;
MENU[Mmax].opt=opt;
MENU[Mmax].var=var;
MENU[Mmax].maxvalue=maxvalue;
Mmax++;
}
void MenuShow(int x, int y, ID3DXFont *pFont)
{
int i, val;
DWORD color;
SetRect( &rect, x+Mxofs/2, y, x+Mxofs /2 , y );
if (!Mvisible) return;
if (Mtitle[0]) {
pFont->DrawText(NULL,Mtitle,-1,&rect,DT_NOCLIP | DT_CENTER, MCOLOR_TITLE);
y+=Mysize;
}
for (i=0; i<Mmax; i++) {
val=(MENU[i].var)?(*MENU[i].var):0;
// determine color
if (i==Mpos)
color=MCOLOR_CURRENT;
else if (MENU[i].typ==MENUFOLDER)
color=MCOLOR_FOLDER;
else if (MENU[i].typ==MENUTEXT)
color=MCOLOR_TEXT;
else
color=(val)?MCOLOR_ACTIVE:MCOLOR_INACTIVE;
SetRect( &rect3, x, y, x , y );
SetRect( &rect2, x+Mxofs, y, x+Mxofs , y );
pFont->DrawText(NULL,MENU[i].txt,-1,&rect3, DT_NOCLIP,color);
if (MENU[i].opt) {
if (MENU[i].typ==MENUTEXT)
pFont->DrawText(NULL,(char *)MENU[i].opt,-1,&rect2, DT_NOCLIP | DT_RIGHT, color);
else
pFont->DrawText(NULL,(char *)MENU[i].opt[val],-1,&rect2, DT_NOCLIP | DT_RIGHT, color);
}
y+=Mysize;
}
}
void MenuNav(void)
{
if (GetAsyncKeyState(VK_INSERT)&1) Mvisible=(!Mvisible);
if (!Mvisible) return;
if (GetAsyncKeyState(VK_UP)&1) {
do {
Mpos--;
if (Mpos<0) Mpos=Mmax-1;
} while (MENU[Mpos].typ==MENUTEXT); // skip textitems
} else if (GetAsyncKeyState(VK_DOWN)&1) {
do {
Mpos++;
if (Mpos==Mmax) Mpos=0;
} while (MENU[Mpos].typ==MENUTEXT); // skip textitems
} else if (MENU[Mpos].var) {
int dir=0;
// bugfix: thx to ***-Wieter20
if (GetAsyncKeyState(VK_LEFT )&1 && *MENU[Mpos].var > 0 ) dir=-1;
if (GetAsyncKeyState(VK_RIGHT)&1 && *MENU[Mpos].var < (MENU[Mpos].maxvalue-1)) dir=1;
if (dir) {
*MENU[Mpos].var += dir;
if (MENU[Mpos].typ==MENUFOLDER) Mmax=0; // change on menufolder, force a rebuild
}
}
}
If you want to define your menu, do it in a different .cpp. Like in "hackbase.cpp".
Credit to Im V!rus:
Code:
#include <d3d9.h>
#include <d3dx9.h>
#pragma comment (lib, "d3d9.lib")
#pragma comment( lib, "d3dx9.lib" )
int CH_cheats = 1;
int CH_weap = 1;
int CH_stamina = 0;
int CH_fastammo = 1;
int CH_fasthealth = 0;
int CH_fastrepair = 0;
int CH_fastflag = 1;
int CH_nospread = 1;
int CH_norecoil = 1;
int CH_unlammo = 0;
int test =0;
// none standard options
char *sStamina[] = { "Off","Stealth","Full" };
char *Ctest[] = { "GoD" };
void RebuildMenu(void)
{
strcpy(Mtitle,"== D3Dmenu by Hans211 ==");
MenuAddItem("[V!rus]", Moptfolder, &CH_cheats, 2, MENUFOLDER);
if (CH_cheats) {
MenuAddItem("Skill Hack" , sStamina , &CH_stamina , 3, MENUITEM);
MenuAddItem("GoD Mode" , Moptonoff , &CH_fastammo , 2, MENUITEM);
MenuAddItem("Zombie Mode" , Moptonoff , &CH_fasthealth, 2, MENUITEM);
MenuAddItem("Ghost Mode" , Moptonoff , &CH_fastrepair, 2, MENUITEM);
}
MenuAddItem("[Test]", Moptfolder, &CH_weap, 2, MENUFOLDER);
if (CH_weap) {
MenuAddItem("Test" , Moptonoff , &CH_nospread, 2, MENUITEM);
MenuAddItem("Test" , Moptonoff , &CH_norecoil, 2, MENUITEM);
MenuAddItem("Test", Moptonoff , &CH_unlammo , 2, MENUITEM);
}
MenuAddItem("[V!rus]" , Ctest , &test,1,MENUFOLDER);
}
ID3DXFont* m_pFont;
void PreReset(void)
{
if(m_pFont){
if(m_pFont->Release())
m_pFont = NULL;
}
}
void Release( LPDIRECT3DDEVICE9 m_pD3Ddev)
{
// Look definition if u want edit it for make better text :D
D3DXCreateFont(m_pD3Ddev, 15, 0, FW_BOLD, 0, 0, DEFAULT_CHARSET, OUT_TT_ONLY_PRECIS, PROOF_QUALITY, DEFAULT_PITCH | FF_DONTCARE, TEXT("Arials"), &m_pFont );
}
You can add more custom menu options, i did it in d3dmenu.h,
Just add them below
Code:
extern char *Moptfolder[]; // "+" , "-"
extern char *Moptonoff[]; // "Off", "On"
If you want a base with all of that done, and you can just edit it, PM me.