#include "Menu.h"
#define Red D3DCOLOR_ARGB (255 , 255 , 0 , 0 )
#define Yellow D3DCOLOR_ARGB (255 , 255 , 255 , 0 )
#define Green D3DCOLOR_ARGB (255 , 0 , 255 , 0 )
#define Blue D3DCOLOR_ARGB (255 , 0 , 0 , 255 )
#define Purple D3DCOLOR_ARGB (255 , 102 , 0 , 153 )
#define Pink D3DCOLOR_ARGB (255 , 255 , 20 , 147 )
#define Orange D3DCOLOR_ARGB (255 , 255 , 165 , 0 )
#define Black D3DCOLOR_ARGB (255 , 0 , 0 , 0 )
#define White D3DCOLOR_ARGB (255 , 255 , 255 , 255 )
char Mtitle[81]="EasyCheat by Azerty54";
int Mpos=0;
int Mmax=0;
int Mxofs =160;
int Mysize=14;
int Mvisible=0;
int whatever;
char *Opt_Folder[] = { "-" , "+" };
char *Opt_on_off[] = { "Off","On" };
RECT rect;
RECT rect2;
RECT rect3;
struct {
int typ;
char *txt;
char **opt;
int *var;
int maxvalue;
} MENU[MENUMAXITEMS];
cMenu Menu;
void cMenu::AddItem(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++;
whatever=(Mmax*Mysize);
}
DrawBox(20,200,170,whatever,D3D color,pDevice);
void cMenu::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->DrawTextA(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;
if (i==Mpos)
color=Green;
else if (MENU[i].typ==MENUFOLDER)
color=Blue;
else if (MENU[i].typ==MENUTEXT)
color=Black;
else
color=(val)?Orange: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 cMenu::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);
} else if (GetAsyncKeyState(VK_DOWN)&1) {
do {
Mpos++;
if (Mpos==Mmax) Mpos=0;
} while (MENU[Mpos].typ==MENUTEXT);
} 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;
}
}
}