Hey! I was following D3D menu tutorials made by Fleep Hacks on youtube. When I had finished, compiled, and tested the menu, everything was fine except the text that were supposed to be inside of rectangles which were the options. I just started learning and I have no clue what's wrong with it. Here's the code:
Code:
#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(0, 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 = "Wallhack";
hack[ESP].name = "ESP";
hack[NO_RECOIL].name = "No Recoil";
hack[CUSTOM_CROSSHAIR].name = "Custom Crosshair";
hack[TEST].name = "Test";
hack[HIDE_MENU].name = "Close Menu [INSERT]";
hack[HIDE_MENU].on = false;
}
void Hacks::Draw_Text(LPCSTR TextToDraw, int x, int y, D3DCOLOR Color)
{
RECT rct = {x - 120, y, x + 120, y + 15};
Font->DrawText(NULL, TextToDraw, -1, &rct, DT_NOCLIP, Color);
}
void Hacks::DrawMenu(IDirect3DDevice9 *d3dDevice)
{
if(!hack[HIDE_MENU].on)
{
DrawFilledRect( 55, 20, 200, 50, fontBlue, d3dDevice );
DrawBorderBox(55, 20, 200, 50, 4, fontBlack, d3dDevice );
Draw_Text("HackTrader.net", 190, 30, fontWhite);
DrawFilledRect( 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 ++)
{
DrawFilledRect( 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);
}
Draw_Text(hack[i].name.c_str(), 170, 39+y, fontBlack);
y+= 50;
}
Draw_Text("Scroll Using Arrow Keys", 170, ((62*MAX_MENU_ITEMS)+7), fontWhite);
Draw_Text("Activate Hacks [END] Key", 170, ((62*MAX_MENU_ITEMS)+27), fontWhite);
}
}
void Hacks::DrawFilledRect(int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9 *d3dDevice)
{
D3DRECT BarRect = { x, y, x + w, y + h};
d3dDevice->Clear(1, &BarRect, D3DCLEAR_TARGET | D3DCLEAR_TARGET, color, 0, 0);
}
void Hacks::DrawBorderBox(int x, int y, int w, int h, int thickness, D3DCOLOR color, IDirect3DDevice9* pDevice)
{
DrawFilledRect(x, y, w, thickness, color, pDevice); //Top Vertical Line
DrawFilledRect(x, y, thickness, h, color, pDevice); //Top Horizontal Line
DrawFilledRect(x+w, y, thickness, h, color, pDevice); //Right Vertical Line
DrawFilledRect(x, y+h, w+thickness, thickness, color, pDevice); //Bottom Horizontal Line
}
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(MenuIndex > MAX_MENU_ITEMS-1)
{
MenuIndex = 0;
}
if(GetAsyncKeyState(VK_INSERT)&1)
{
hack[HIDE_MENU].on = !hack[HIDE_MENU].on;
}
if(GetAsyncKeyState(VK_END))
{
hack[MenuIndex].on = !hack[MenuIndex].on;
Sleep(100);
if(MenuIndex == WALLHACK && fontRed)
{
//Wallhack On
}
if(MenuIndex == WALLHACK && fontGreen)
{
//Wallhack Off
}
if(MenuIndex == ESP && fontRed)
{
//ESP On
}
if(MenuIndex == ESP && fontGreen)
{
//ESP Off
}
}
}