BERBAGI ITU INDAH D3D MENU: // Project : Basic D3D Menu - TopicsExpress



          

BERBAGI ITU INDAH D3D MENU: // Project : Basic D3D Menu v1.4 // Author : Hans211 // Date : 11 April 2009 // // Credits : // People of : Game-Deception, DXT, GHBsys, Unknown Cheats // // Tools used: // Microsoft Visual Studio c++ 6.0 // DirectX9 SDK Update (summer 2004) // D3Dfont.cpp // // Features: // Use Insert key to show/hide menu // Use up and down arrow keys to manouvre through the menuitems // Use Control + arrow keys to move the menu // Use left and right arrow keys to toggle menuitems // Items can have multiple custom states like: Off On or Head Neck Spine // Support for textonly items // Support for folder style items // // Changes: // 1.4 Added simple menu move // 1.3 Put everything in a class, // 1.2 Thx to DXT-Wieter20 for pointing this out // Check for left and right key first and then if value is within range // #include d3dmenu.h // Adding items, group, text to the menu void D3DMenu::AddItem(char *txt, int *var, char **opt, int maxval, int typ) { if (noitems>=(maxitems-1)) return; MENU[noitems]->typ=typ; MENU[noitems]->txt=txt; MENU[noitems]->opt=opt; MENU[noitems]->var=var; MENU[noitems]->maxval=maxval; noitems++; totheight=(noitems*height)+titleheight; } void D3DMenu::AddGroup(char *txt, int *var, char **opt, int maxval) { AddItem(txt, var, opt, maxval, MENUGROUP); } void D3DMenu::AddText(char *txt, char *opt) { AddItem(txt,0,(char **)opt,0,MENUTEXT); } // Show the Menu void D3DMenu::Show(CD3DFont *pFont) { int i,val,cy; DWORD color; if (!visible) return; cy=y; if (title) { pFont->DrawText((float)(x+totwidth/2), (float)cy+1, col_title,title,D3DFONT_SHADOW|D3DFONT_CENTERED); cy+=titleheight; } for (i=0; ityp==MENUTEXT) { pFont->DrawText((float)x, (float)cy, col_text,MENU[i]->txt,D3DFONT_SHADOW); if (MENU[i]->opt) { pFont->DrawText((float)(x+ofs), (float)cy, col_text,(char *)MENU[i]->opt, D3DFONT_RIGHT|D3DFONT_SHADOW); } } else { val=(MENU[i]->var)?(*MENU[i]->var):0; // determine color if (i==cur) color=col_current; else if (MENU[i]->typ==MENUGROUP) color=col_group; else color=(val)?col_on:col_off; pFont->DrawText((float)x, (float)cy, color,MENU[i]->txt,D3DFONT_SHADOW); if (MENU[i]->opt) { pFont->DrawText((float)(x+ofs), (float)cy, color,(char *)MENU[i]->opt[val],D3DFONT_RIGHT|D3DFONT_SHADOW); } } cy+=height; } } // check for Menu navigation keys void D3DMenu::Nav(void) { if (GetAsyncKeyState(VK_INSERT)&1) visible=(!visible); if (!visible) return; if (GetAsyncKeyState(VK_CONTROL) ) { if (GetAsyncKeyState(VK_UP)&1 ) y-=10; if (GetAsyncKeyState(VK_DOWN)&1 ) y+=10; if (GetAsyncKeyState(VK_LEFT)&1 ) x-=10; if (GetAsyncKeyState(VK_RIGHT)&1) x+=10; } else { if (GetAsyncKeyState(VK_UP)&1) { do { cur--; if (curtyp==MENUTEXT); // skip textitems } else if (GetAsyncKeyState(VK_DOWN)&1) { do { cur++; if (cur==noitems) cur=0; } while (MENU[cur]->typ==MENUTEXT); // skip textitems } else if (MENU[cur]->var) { int dir=0; // bugfix: thx to Dxt-Wieter20 if (GetAsyncKeyState(VK_LEFT )&1 && *MENU[cur]->var > 0 ) dir=-1; if (GetAsyncKeyState(VK_RIGHT)&1 && *MENU[cur]->var < (MENU[cur]->maxval-1)) dir=1; if (dir) { *MENU[cur]->var += dir; if (MENU[cur]->typ==MENUGROUP) noitems=0; // change on menufolder, force a rebuild } } } }
Posted on: Sat, 27 Dec 2014 18:06:44 +0000

Recently Viewed Topics




© 2015