#include "hacks.h";
int MenuIndex = 0;
D3DCOLOR fontRed = D3DCOLOR_ARGB(255, 255, 0, 0);
D3DCOLOR fontGreen = D3DCOLOR_ARGB(255, 0, 255, 0);
D3DCOLOR fontBlue = D3DCOLOR_ARGB(255, 0, 0, 255);
D3DCOLOR fontWhite = D3DCOLOR_ARGB(255, 255, 255, 255);
D3DCOLOR fontBlack = D3DCOLOR_ARGB(255, 0, 0, 0);
void Hacks::CreateFont(IDirect3DDevice9 *d3dDevice, std::string choiceFont)
{
D3DXCreateFont( d3dDevice, 20, 0, FW_BOLD, 0, FALSE, DEFAULT_CHARSET,
OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
choiceFont.c_str(), &font );
}
void Hacks::InitializeMenuItems()
{
hack[WALLHACK].name = "Feature 1";
hack[CUSTOM_CROSSHAIR].name = "Features 2";
hack[NO_RECOIL].name = "Features 3";
hack[UNLIM_AMMO].name = "Features 4";
hack[AUTO_FIRE].name = "Features 5";
hack[HIDE_MENU].name = "Hide hack [INSERT]";
hack[HIDE_MENU].on = false; //Makes the hack show on startup
}
void Hacks::DrawText(LPCSTR TextToDraw, int x, int y, D3DCOLOR Colour)
{
RECT rct = { x - 120, y, x + 120, y + 15 };
font->DrawText(NULL, TextToDraw, -1, &rct, DT_NOCLIP, Colour);
}
void Hacks::DrawMenu(IDirect3DDevice9 *d3dDevice)
{
if(!hack[HIDE_MENU].on)
{
DrawFilledRectangle( 55, 20, 200, 50, fontBlue, d3dDevice );
DrawBorderBox(55, 20, 200, 50, 4, fontBlack, d3dDevice );
DrawText("DX Menu TUT", 190, 30, fontWhite);
DrawFilledRectangle( 30, 55, 250, (62*MAX_MENU_ITEMS),fontBlue, d3dDevice );
DrawBorderBox(30, 55, 250, (62*MAX_MENU_ITEMS), 6, fontBlack, d3dDevice );
int y = 40;
for(int i = 0; i < MAX_MENU_ITEMS; i ++)
{
DrawFilledRectangle( 45, 30+y, 220, 40, hack[i].on ? fontGreen : fontRed, d3dDevice );
DrawBorderBox(45, 30+y, 220, 40, 4, fontBlack, d3dDevice );
if(MenuIndex == i)
{
DrawBorderBox(41, 26+y, 228, 48, 4, fontWhite, d3dDevice );
}
DrawText(hack[i].name.c_str(), 170 , 39+y, fontBlack);
y+= 50;
}
DrawText("Select using arrow keys", 170, ((62*MAX_MENU_ITEMS)+7), fontWhite);
DrawText("Turn ON/OFF [END] key", 170, ((62*MAX_MENU_ITEMS)+27), fontWhite);
}
}
void Hacks::DrawFilledRectangle(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* d3dDevice)
{
D3DRECT rec = { x, y, x + w, y + h };
d3dDevice->Clear(1, &rec, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, 0, 0);
}
void Hacks::DrawBorderBox( int x, int y, int w, int h, int thickness, D3DCOLOR Colour, IDirect3DDevice9 *d3dDevice)
{
DrawFilledRectangle( x, y, w, thickness, Colour, d3dDevice );
DrawFilledRectangle( x, y, thickness, h, Colour, d3dDevice );
DrawFilledRectangle( (x + w), y, thickness, h, Colour, d3dDevice );
DrawFilledRectangle( x, y + h, w+thickness, thickness, Colour, d3dDevice );
}
void Hacks::KeyboardInput()
{
if(GetAsyncKeyState(VK_UP)&1)
{
if(MenuIndex > 0)
{
MenuIndex--;
}
}
if(GetAsyncKeyState(VK_DOWN)&1)
{
if(MenuIndex < MAX_MENU_ITEMS-1)
{
MenuIndex++;
}
}
if(GetAsyncKeyState(VK_END)&1)
{
hack[MenuIndex].on = !hack[MenuIndex].on;
}
if(GetAsyncKeyState(VK_INSERT)&1)
{
hack[HIDE_MENU].on = !hack[HIDE_MENU].on;
}
}