So.... i got a D3D menu and it has 13 errors can some help?
#include "d3dmenu.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;
// predifine some basic options
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 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(float x, float y, CD3DFont *pFont)
{
int i, val;
DWORD color;
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->DrawText(x+Mxofs, y, color,(char *)MENU[i].opt,D3DFONT_RIGHT);
else
pFont->DrawText(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
}
}
}