PDA

View Full Version : Highlight Menu little modificated



ZeaS
05-20-2008, 11:17 AM
I've modificated Cobras menu a little and release it here because i think it looks better:

d3d8dev.cpp

in HRESULT CD3DManager::Initialize() add

m_pMenu = new CD3DFont("Arial", 8, D3DFONT_BOLD);
m_pMenu->InitDeviceObjects(m_pD3Ddev);
m_pMenu->RestoreDeviceObjects();
in HRESULT CD3DManager::PreReset() add

m_pMenu->InvalidateDeviceObjects();
m_pMenu->DeleteDeviceObjects();
m_pMenu = NULL;
in HRESULT CD3DManager::PostReset() add

m_pMenu = new CD3DFont("Arial", 8, D3DFONT_BOLD);
m_pMenu->InitDeviceObjects(m_pD3Ddev);
m_pMenu->RestoreDeviceObjects();
in HRESULT CD3DManager::Release() add

m_pMenu->InvalidateDeviceObjects();
m_pMenu->DeleteDeviceObjects();
m_pMenu = NULL;

Now Creat a new ".h" file, call it like menu.h or something and paste this in it

/*---------------------------------BOOL HACKS---------------------------------*/
bool CH_Menu;
bool CH_Chams;
bool CH_Wire;
/*---------------------------------NEEDED---------------------------------*/
int highlight[4] = {1,0,0,0}; //add always + 1
D3DCOLOR unused = D3DCOLOR_ARGB(255, 255, 255, 255);
D3DCOLOR used = D3DCOLOR_ARGB(255, 255, 0, 0);
D3DCOLOR choose = D3DCOLOR_ARGB(255, 0, 255, 0);
CD3DFont* m_pMenu = NULL;
char Display_Line[256];
/*---------------------------------FUNCTIONS---------------------------------*/
void AddItems( float x, float y, DWORD color, char* String, bool hack, char* a, char* b )
{
if (m_pMenu)
{
char buffer1[256];
char buffer2[256];
sprintf( buffer1, "%s :", String);
sprintf( buffer2, "%s", (hack ? a : b));
m_pMenu->DrawText( x, y, color, buffer1);
m_pMenu->DrawText( x + 120, y, choose, buffer2);
}
}
void BackGround( int x, int y, int h, int w, DWORD color, LPDIRECT3DDEVICE8 pDevice )
{
if(m_pMenu)
{
if(CH_Menu)
{
{
D3DRECT rec;
rec.x1 = x;
rec.x2 = x + w;
rec.y1 = y;
rec.y2 = y + h;
pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
}
}
}
}
void DrawGameText(int x, int y, DWORD color, char *text, ...)
{
if(m_pMenu)
{
if(CH_Menu)
{
va_list va_alist;
char logbuf[256] = {0};
va_start (va_alist, text);
_vsnprintf (logbuf+strlen(logbuf), sizeof(logbuf) - strlen(logbuf), text, va_alist);
va_end (va_alist);
m_pMenu->DrawText((float)x, (float)y, color, logbuf);
}
}
}
/*---------------------------------MAINMENU---------------------------------*/
void DrawMenu(int menusize)
{
if (GetAsyncKeyState(VK_NUMPAD2)&1)
{
CH_Menu = !CH_Menu;
}
if (m_pMenu)
{
if (CH_Menu)
{
/*---------------------------------ADD Hacks Here---------------------------------*/
if(highlight[1] == 1)
AddItems(15, 52, used, "Player Chams", CH_Chams, "On", "Off");
else
AddItems(15, 52, unused, "Player Chams", CH_Chams, "On", "Off");

if(highlight[2]==1)
AddItems(15, 62, used, "WireFrame", CH_Wire, "On", "Off");
else
AddItems(15, 62, unused, "WireFrame", CH_Wire, "On", "Off");
/*---------------------------------Menu Use---------------------------------*/
if(GetAsyncKeyState(VK_UP)&1)
{
for(int i=0; i < menusize+1; i++)
{
if (highlight[i] == 1)
{
int a = i-1;

if(a < 0)
break;

else
{
highlight[a]=1;
highlight[i]=0;
break;
}
}
}
}

if(GetAsyncKeyState(VK_DOWN)&1)
{
for(int i=0; i < menusize+2; i++)
{
if (highlight[i] == 1)
{
int a = i+1;

if(a > menusize)
break;

else
{
highlight[a]=1;
highlight[i]=0;
break;
}
}
}
}
/*-----------------------------Activae/Deaktivate Hacks here-----------------------------*/
if(highlight[1] == 1 && (GetAsyncKeyState(VK_RIGHT)&1))
CH_Chams = !CH_Chams;

if(highlight[2] == 1 && (GetAsyncKeyState(VK_RIGHT)&1))
CH_Wire = !CH_Wire;

}
}
}


now go back to d3d8dev.cpp and add "#include "menu.h"

go down to endscene and do your functions

BackGround(13, 49, 102, 162, D3DCOLOR_ARGB(255, 255, 0, 0), m_pD3Ddev);
BackGround(14, 50, 100, 160, D3DCOLOR_ARGB(255, 0, 0, 0), m_pD3Ddev);
DrawMenu(2); //always + 1
DrawGameText(60, 30, D3DCOLOR_ARGB(255, 255, 235, 0), "New Menu");


how to use:
if you add one more hack then do here +1

DrawMenu(2); //always + 1

and here

int highlight[4] = {1,0,0,0}; //add always + 1


whats other then cobras?:
1. you don't have your on/off next to your name like

Chams: ON
Wire: On
/*-----Now------*/
Chams: On
WireF: On

2. you can do easy change all colors, and you can change the "on/off" color

3. you can draw easy a background with border and Text...

4. you don't need the "char chamsstring[20] = {NULL};" anymore

Screen: http://img503.imageshack.us/img503/2843/3364712823ee3.jpg

Have Fun

olie122333
05-20-2008, 11:22 AM
this looks nice, i will try now :D

Bigxxx
05-20-2008, 12:08 PM
Thanks looks great!
Helped a lot :)

Spenser
05-22-2008, 06:18 PM
It overlaps when I try to add another hack.

I added 1 to each thing.

Gr4v1ty
06-10-2008, 04:46 PM
Thanks! I will need some help to know what to chage because I started with the highlight method of Cobra but i don't want to restart from ZERO. I would need some help to know what to modify.