Hans211 base
hey i was trying to test out hans menu source and i dont know what i did wrong can someone tel me what they think.
Code:
#include "d3dmenu.h"
#include "Font.h"
char Mtitle[81]=""; // Some room for a title
int Mpos=0; // current highlighted menuitem
int Mmax=0; // number of menu items
float Mxofs =160.0f; // offset for option text
float Mysize=14.0f; // heigh of a menuline
int Mvisible=1;
char *Moptfolder[] = { "+" , "-" };
char *Moptonoff[] = { "Off", "On"};
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 AddItemToMenu(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(float x, float y, CD3DFont *pFont)
{
int i, val;
DWORD color;
char sFPS[20]="xxx fps";
int CH_DirectX = 1;
int CH_Players = 1;
int CH_Chams = 0;
int CH_Boxes = 1;
int CH_Skeleton = 0;
int CH_PlayerGlow = 0;
int CH_Speed = 1;
int CH_Fly = 1;
int CH_Sway = 1;
void RebuildMenu(void);
{
strcpy(Mtitle,"== D3Dmenu by Hans211 ==");
MenuAddItem("[DirectX]", Moptfolder, &CH_DirectX, 2, MENUFOLDER);
if (CH_DirectX) {
MenuAddItem("Chams" , Moptonoff , &CH_Chams , 3, MENUITEM);
MenuAddItem("Boxes" , Moptonoff , &CH_Boxes , 2, MENUITEM);
MenuAddItem("Skeleton" , Moptonoff , &CH_Skeleton, 2, MENUITEM);
MenuAddItem("Player Glow" , Moptonoff , &CH_PlayerGlow, 2, MENUITEM);
}
MenuAddItem("[Player]", Moptfolder, &CH_Players, 2, MENUFOLDER);
if (CH_Players) {
MenuAddItem("Speed Hack" , Moptonoff , &CH_Speed, 2, MENUITEM);
MenuAddItem("Fly hack" , Moptonoff , &CH_Fly, 2, MENUITEM);
MenuAddItem("No Sway", Moptonoff , &CH_Sway , 2, MENUITEM);
}
MenuAddItem("Framerate" , (char **)sFPS , 0,0,MENUTEXT);
}
if (!Mvisible) return;
if (Mtitle[0]) {
pFont->DrawText(x, y, MCOLOR_TITLE, Mtitle);
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;
pFont->DrawText(x, y, color,MENU[i].txt,0);
if (MENU[i].opt) {
if (MENU[i].typ==MENUTEXT)
pFont->DrawTextW(x+Mxofs, y, color,(char *)MENU[i].opt,D3DFONT_RIGHT);
else
pFont->DrawTextW(x+Mxofs, y, color,(char *)MENU[i].opt[val],D3DFONT_RIGHT);
}
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
}
}
}
hehehehehheheheeheh
