I will advice you to create a menu in C++, if you are familiar to C# I will suggest you to get your hands dirty with some C++ tuts.
Code:
#pragma once
#include "d3d9.h"
#include <windows.h>
#include <vector>
using namespace std;
class CMenu
{
public:
CMenu(LPDIRECT3DDEVICE9 lpDev);
/***[BOX]***/
void SetBodyBox(int x, int y, int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b, int text_r, int text_g, int text_b, int value_r, int value_g, int value_b, int highlight_r, int highlight_g, int highlight_b);
void SetBodyBox(int x, int y, int width, int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b, int text_r, int text_g, int text_b, int value_r, int value_g, int value_b, int highlight_r, int highlight_g, int highlight_b);
void SetTitleBox(int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b);
/***[\BOX]***/
/***[TEXT]***/
void SetTitleText(int r, int g, int b, char *text);
void DrawFreeMenuText(int x, int y, int width, int height, int r, int g, int b, char *text);
/***[\TEXT]***/
/***[HACKS]***/
void AddHack(char *hack_name, int default_value, int max_value);
BOOL UpdateHack(char *hack_name, int value, int number);
/***[\HACKS]***/
/***[MISC]***/
void DrawMenu();
void DoInput();
int GetNumHacks();
/***[\MISC]***/
private:
void DrawBox(D3DRECT *dimensions, D3DCOLOR back_color, D3DRECT *border_dimensions, D3DCOLOR border_color);
void DrawTitleText();
void DrawHackText(LPRECT rect, D3DCOLOR color, char *text);
void DrawHackText(LPRECT rect, D3DCOLOR color, int number);
void DrawHacks();
char *int_to_char_p(int to_char_p);
struct HACK
{
char *szName;
int default_value, max_value, current_value;
};
vector<HACK> hacks;
int hack_selection;
int hack_offset;
int hack_offset_width;
int title_offset_height;
BOOL bMenu;
D3DRECT body_box;
D3DCOLOR body_box_color;
D3DRECT body_box_border;
D3DCOLOR body_box_border_color;
D3DCOLOR body_box_text_color;
D3DCOLOR body_box_value_color;
D3DCOLOR body_box_highlight_color;
RECT body_box_rect;
D3DRECT title_box;
D3DCOLOR title_box_color;
D3DRECT title_box_border;
D3DCOLOR title_box_border_color;
RECT text_title_box;
D3DCOLOR text_title_color;
char *text_title_text;
LPDIRECT3DDEVICE9 m_pDev;
LPD3DXFONT font_body;
LPD3DXFONT font_title;
LPD3DXFONT font_free;
char *itcp_buf;
};
Code:
#include "CMenu.h"
#include "d3d9.h"
#include <windows.h>
#include <vector>
#include <string>
#include <sstream>
using namespace std;
CMenu::CMenu(LPDIRECT3DDEVICE9 lpDev) : m_pDev(lpDev)
{
hack_selection = 0;
hack_offset = 17;
hack_offset_width = 160;
title_offset_height = 26;
bMenu = FALSE;
text_title_text = "None";
hacks.clear();
D3DXCreateFont(m_pDev, 14, 5, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial", &font_body);
D3DXCreateFont(m_pDev, 16, 7, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial", &font_title);
D3DXCreateFont(m_pDev, 15, 5, FW_BOLD, 1, FALSE, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, ANTIALIASED_QUALITY, DEFAULT_PITCH|FF_DONTCARE, "Arial", &font_free);
itcp_buf = (char *)malloc(5); // 2 extra for the lulz
}
/***[BOX]***/
void CMenu::SetBodyBox(int x, int y, int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b, int text_r, int text_g, int text_b, int value_r, int value_g, int value_b, int highlight_r, int highlight_g, int highlight_b)
{
body_box.x1 = x;
body_box.x2 = x + hack_offset_width;
body_box.y1 = y;
body_box.y2 = y + (hack_offset * GetNumHacks() - 1);
body_box_color = D3DCOLOR_ARGB(255, r, g, b);
body_box_border.x1 = body_box.x1 - border_width;
body_box_border.x2 = body_box.x2 + border_width;
body_box_border.y1 = body_box.y1 - border_height;
body_box_border.y2 = body_box.y2 + border_height;
/***[TEXT]***/
body_box_rect.top = body_box.y1;
body_box_rect.bottom = body_box.y2;
body_box_rect.right = body_box.x2;
body_box_rect.left = body_box.x1;
body_box_text_color = D3DCOLOR_XRGB(text_r, text_g, text_b);
body_box_value_color = D3DCOLOR_XRGB(value_r, value_g, value_b);
body_box_highlight_color = D3DCOLOR_XRGB(highlight_r, highlight_g, highlight_b);
/***[\TEXT]***/
body_box_border_color = D3DCOLOR_ARGB(255, border_r, border_g, border_b);
}
void CMenu::SetBodyBox(int x, int y, int width, int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b, int text_r, int text_g, int text_b, int value_r, int value_g, int value_b, int highlight_r, int highlight_g, int highlight_b)
{
hack_offset_width = width;
body_box.x1 = x;
body_box.x2 = x + hack_offset_width;
body_box.y1 = y;
body_box.y2 = y + (hack_offset * GetNumHacks() - 1);
body_box_color = D3DCOLOR_ARGB(255, r, g, b);
body_box_border.x1 = body_box.x1 - border_width;
body_box_border.x2 = body_box.x2 + border_width;
body_box_border.y1 = body_box.y1 - border_height;
body_box_border.y2 = body_box.y2 + border_height;
/***[TEXT]***/
body_box_rect.top = body_box.y1;
body_box_rect.bottom = body_box.y2;
body_box_rect.right = body_box.x2;
body_box_rect.left = body_box.x1;
body_box_text_color = D3DCOLOR_XRGB(text_r, text_g, text_b);
body_box_value_color = D3DCOLOR_XRGB(value_r, value_g, value_b);
body_box_highlight_color = D3DCOLOR_XRGB(highlight_r, highlight_g, highlight_b);
/***[\TEXT]***/
body_box_border_color = D3DCOLOR_ARGB(255, border_r, border_g, border_b);
}
void CMenu::SetTitleBox(int r, int g, int b, int border_width, int border_height, int border_r, int border_g, int border_b)
{
title_box.x1 = body_box.x1;
title_box.x2 = body_box.x2;
title_box.y1 = body_box.y1 - title_offset_height;
title_box.y2 = body_box.y1;
title_box_color = D3DCOLOR_ARGB(255, r, g, b);
title_box_border.x1 = title_box.x1 - border_width;
title_box_border.x2 = title_box.x2 + border_width;
title_box_border.y1 = title_box.y1 - border_height;
title_box_border.y2 = title_box.y2 + border_height;
title_box_border_color = D3DCOLOR_ARGB(255, border_r, border_g, border_b);
}
/***[\BOX]***/
/***[TEXT]***/
void CMenu::SetTitleText(int r, int g, int b, char *text)
{
text_title_box.top = title_box.y1;
text_title_box.bottom = title_box.y2;
text_title_box.right = title_box.x2;
text_title_box.left = title_box.x1;
text_title_color = D3DCOLOR_XRGB(r, g, b);
text_title_text = text;
}
void CMenu::DrawFreeMenuText(int x, int y, int width, int height, int r, int g, int b, char *text)
{
if(bMenu)
{
RECT rect = {x, y, width, height};
font_free->DrawTextA(NULL, text, -1, &rect, 0, D3DCOLOR_XRGB(r, g, b));
}
}
/***[\TEXT]***/
/***[HACKS]***/
void CMenu::AddHack(char *hack_name, int default_value, int max_value)
{
HACK hack = {hack_name, default_value, max_value, default_value};
hacks.push_back(hack);
}
BOOL CMenu::UpdateHack(char *hack_name, int value, int number)
{
if(hacks.at(number - 1).szName == hack_name)
{
if(hacks.at(number - 1).current_value == value)
{
return TRUE;
}
}
return FALSE;
}
/***[\HACKS]***/
/***[MISC]***/
void CMenu::DrawMenu()
{
if(bMenu)
{
DrawBox(&body_box, body_box_color, &body_box_border, body_box_border_color);
DrawHacks();
if(text_title_text != "None")
{
DrawBox(&title_box, title_box_color, &title_box_border, title_box_border_color);
DrawTitleText();
}
}
}
void CMenu::DoInput()
{
while(1)
{
if(GetAsyncKeyState(VK_INSERT))
bMenu = !bMenu;
if(bMenu)
{
if(GetAsyncKeyState(VK_UP))
{
if(hack_selection == 0)
{
hack_selection = (GetNumHacks() - 1);
}
else if(hack_selection >= 1)
{
hack_selection--;
}
}
else if(GetAsyncKeyState(VK_DOWN))
{
if(hack_selection == (GetNumHacks() - 1))
{
hack_selection = 0;
}
else if(hack_selection < (GetNumHacks() - 1))
{
hack_selection++;
}
}
if(GetAsyncKeyState(VK_RIGHT))
{
if(hacks.at(hack_selection).current_value < hacks.at(hack_selection).max_value)
{
hacks.at(hack_selection).current_value++;
}
else
{
hacks.at(hack_selection).current_value = 0;
}
}
else if(GetAsyncKeyState(VK_LEFT))
{
if(hacks.at(hack_selection).current_value > 0)
{
hacks.at(hack_selection).current_value--;
}
else
{
hacks.at(hack_selection).current_value = hacks.at(hack_selection).max_value;
}
}
}
Sleep(103);
}
}
int CMenu::GetNumHacks()
{
return ((int)hacks.size());
}
/***[\MISC]***/
/***[PRIVATE]***/
void CMenu::DrawBox(D3DRECT *dimensions, D3DCOLOR back_color, D3DRECT *border_dimensions, D3DCOLOR border_color)
{
m_pDev->Clear(1, border_dimensions, D3DCLEAR_TARGET, border_color, 1.0f, 0);
m_pDev->Clear(1, dimensions, D3DCLEAR_TARGET, back_color, 1.0f, 0);
}
void CMenu::DrawTitleText()
{
font_title->DrawTextA(NULL, text_title_text, -1, &text_title_box, DT_CENTER | DT_VCENTER, text_title_color);
}
void CMenu::DrawHackText(LPRECT rect, D3DCOLOR color, char *text)
{
font_body->DrawTextA(NULL, text, -1, rect, 0, color);
}
void CMenu::DrawHackText(LPRECT rect, D3DCOLOR color, int number)
{
font_body->DrawTextA(NULL, int_to_char_p(number), -1, rect, 0, color);
}
void CMenu::DrawHacks()
{
for(int i = 0;i < hacks.size();i++)
{
/***[DRAW HACKS]***/
if(hack_selection == i)
DrawHackText(&body_box_rect, body_box_highlight_color, hacks.at(i).szName);
else
DrawHackText(&body_box_rect, body_box_text_color, hacks.at(i).szName);
body_box_rect.left += hack_offset_width - 8;
if(strlen(int_to_char_p(hacks.at(i).current_value)) > strlen("a"))
{
for(int j = 1;j <= (strlen(int_to_char_p(hacks.at(i).current_value)) - 1);j++)
{
body_box_rect.left -= 6;
}
}
DrawHackText(&body_box_rect, body_box_value_color, hacks.at(i).current_value);
body_box_rect.left = body_box.x1;
/***[\DRAW HACKS]***/
body_box_rect.top += hack_offset;
}
body_box_rect.top = body_box.y1;
}
char *CMenu::int_to_char_p(int to_char_p)
{
stringstream ss;
ss << to_char_p;
strcpy(itcp_buf, ss.str().c_str());
return itcp_buf;
}
/***[\PRIVATE]***/