Hi,
This is my 100% self-made menu from my AVA releases.. go check it out in the ava section if you wanna see more
Its a click on/off menu with multiple options
sooo here it is:
Menu.cpp:
[highlight=cpp]
#define Red D3DCOLOR_ARGB (255 , 255 , 0 , 0 )
#define Yellow D3DCOLOR_ARGB (255 , 255 , 255 , 0 )
#define Green D3DCOLOR_ARGB (255 , 0 , 255 , 0 )
#define Blue D3DCOLOR_ARGB (255 , 0 , 50 , 255 )
#define Purple D3DCOLOR_ARGB (255 , 102 , 0 , 153 )
#define Pink D3DCOLOR_ARGB (255 , 255 , 20 , 147 )
#define Orange D3DCOLOR_ARGB (255 , 255 , 165 , 0 )
#define Black D3DCOLOR_ARGB (255 , 0 , 0 , 0 )
#define White D3DCOLOR_ARGB (255 , 255 , 255 , 255 )
#define Cyan D3DCOLOR_ARGB (255 , 0 , 255 , 255 )
#define GreyGreen D3DCOLOR_ARGB ( 255 , 125 , 125 , 125)
cMenu Menu;
int MenuW = 205; //Width of Menu (Box)
int MenuH = 250; //Height of Menu (Box)
//Menu Coordinates:
int MenuX = 50;
int MenuY = 200;
//Is Menu Showing:
bool MenuVisible = false;
//Arrow Menu Options:
char *Opt_xhair[] = { "XHair: Off","XHair: Red","XHair: Blue","XHair: Green","XHair: American"}
void cMenu::ShowMenu(LPDIRECT3DDEVICE9 pDevice){ //Must Call In Present
if (GetAsyncKeyState(VK_INSERT)&1) MenuVisible=(!MenuVisible);
if (!MenuVisible) return;
if(MenuVisible){
//Menu Background:
pDevice->SetRenderState(D3DRS_ZENABLE, FALSE);//Puts Menu in Front
Directx.DrawBox(MenuX, MenuY, MenuW, 18, D3DCOLOR_ARGB(145, 0, 0, 0), Green, pDevice );
Directx.DrawBox(MenuX, MenuY+19, MenuW, MenuH, D3DCOLOR_ARGB(145, 0, 0, 0), Blue, pDevice );
//Menu Title:
Directx.PrintText(Directx.pFont, MenuX+5, MenuY+2, D3DCOLOR_ARGB(255, 0, 0, 255), "[MP] CAFlames AVA Base [GH]");
//Start Menu:
Menu.MenuItem(1, "Show FPS", MenuX+2, MenuY+19, pDevice); //options
Menu.ArrowMenuItem(2, Opt_xhair, MenuX+2, MenuY+19, 4, pDevice); //options
}
}
bool cMenu::MouseRegion(int x1, int y1, int x2, int y2)
{
POINT cPos;
GetCursorPos(&cPos);
if(cPos.x > x1 && cPos.x < x2 && cPos.y > y1 && cPos.y < y2){
return true;
} else {
return false;
}
}
void cMenu::MenuItem(int x, char text[], int MX, int MY, LPDIRECT3DDEVICE9 pDevice){
if(MenuVisible){
if(Menu.MouseRegion(MX, MY+((x)*16), MX+MenuW, MY+((x)*16)+16) && GetAsyncKeyState(VK_LBUTTON)&1){
Menu.cOpt[x].OnOff =! Menu.cOpt[x].OnOff;
}
if(Menu.cOpt[x].OnOff){
Directx.PrintText(Directx.pFont, MX+25, MY+(x*16), D3DCOLOR_ARGB(255, 0, 255, 0), text);
}else{
Directx.PrintText(Directx.pFont, MX+25, MY+(x*16), D3DCOLOR_ARGB(255, 255, 0, 0), text);
}
}
}
void cMenu::ArrowMenuItem(int i, char **textOpt, int MX, int MY, int choices, LPDIRECT3DDEVICE9 pDevice){
//Choices DOES NOT include 0
if(MenuVisible){
{//Starts Left Arrow Creation
Directx.DrawBox(MX+3, MY+(i*16)-2, 20, 20, White, Blue, pDevice);
Directx.PrintText(Directx.ARROWpFont, MX+5, MY+(i*16), D3DCOLOR_ARGB(255, 0, 0, 255), "<");
if(Menu.MouseRegion(MX+3, MY+((i)*16)-2, MX+3+20, MY+((i)*16)+18) && GetAsyncKeyState(VK_LBUTTON)&1){
if(Menu.cOpt[i].Arrow != 0){
Menu.cOpt[i].Arrow -= 1;//Makes sure its not at Max Choice
}else if(Menu.cOpt[i].Arrow == 0){
Menu.cOpt[i].Arrow = choices;
}
}
{
Directx.DrawBox(MX+MenuW-22, MY+(i*16)-2, 20, 20, White, Blue, pDevice);
Directx.PrintText(Directx.ARROWpFont, MX+MenuW-20, MY+(i*16), D3DCOLOR_ARGB(255, 0, 0, 255), ">");
if(Menu.MouseRegion(MX+MenuW-22, MY+((i)*16)-2, MX+MenuW-2, MY+((i)*16)+18) && GetAsyncKeyState(VK_LBUTTON)&1){
if(Menu.cOpt[i].Arrow != choices){
Menu.cOpt[i].Arrow += 1;//Makes sure its not at Max Choice
}else if(Menu.cOpt[i].Arrow == choices){
Menu.cOpt[i].Arrow = 0;
}
}
}
if(Menu.cOpt[i].Arrow == 0){
Directx.PrintText(Directx.pFont, MX+25, MY+(i*16), D3DCOLOR_ARGB(255, 255, 0, 0), (char *)textOpt[Menu.cOpt[i].Arrow]);
}else{
Directx.PrintText(Directx.pFont, MX+25, MY+(i*16), D3DCOLOR_ARGB(255, 0, 255, 0), (char *)textOpt[Menu.cOpt[i].Arrow]);
}
}
}
}
[/highlight]
Menu.h:
[highlight=cpp]
#ifndef __MENU_H__
#define __MENU_H__
#pragma once
const int MaxItems = 60;
struct ClickMenu{
bool OnOff;
int Arrow;
};
class cMenu{
public:
ClickMenu cOpt[MaxItems];
void ShowMenu(LPDIRECT3DDEVICE9 pDevice);
bool MouseRegion(int x1, int y1, int x2, int y2);
void MenuItem(int i, char text[], int MX, int MY, LPDIRECT3DDEVICE9 pDevice);
void ArrowMenuItem(int i, char **text, int MX, int MY, int choices, LPDIRECT3DDEVICE9 pDevice);
};
extern class cMenu Menu;
#endif
[/highlight]
print text function:
[highlight=cpp]
void cDirectx::PrintText(LPD3DXFONT Font, long x, long y, D3DCOLOR fontColor, char *text, ...)//Draw Text Function
{
RECT rct;
rct.left = x - 1;
rct.right = x + 1;
rct.top = y - 1 ;
rct.bottom = y + 1;
if(!text) { return; }
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);
RECT FontRect = { x, y, x, y };
pFont->DrawText(NULL, logbuf, -1, &rct, DT_NOCLIP, fontColor);
}
[/highlight]
Boxes:
[highlight=cpp]
void cDirectx::FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
{
D3DRECT rec = { x, y, x + w, y + h };
pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
}
void cDirectx:rawBorder(float x, float y, float w, float h, int thick, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice)
{
Directx.FillRGB( x, (y + h - thick), w, thick, BorderColor, pDevice);
Directx.FillRGB( x, y, thick, h, BorderColor, pDevice);
Directx.FillRGB( x, y, w, thick, BorderColor, pDevice);
Directx.FillRGB( (x + w - thick), y, thick, h, BorderColor, pDevice);
}
void cDirectx:rawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
{
Directx.FillRGB( x, y, w, h, BoxColor, pDevice );
Directx.DrawBorder( x, y, w, h, 1, BorderColor, pDevice );
}
[/highlight]
Items in examples in Main.cpp (Must be called in Present / EndScene):
[highlight=cpp]
if(Menu.cOpt[1].OnOff){ //FPS.
Directx.PrintText(Directx.pFont, 2, 20, D3DCOLOR_ARGB(255, 0, 255, 0), FrameRate);
}
if(Menu.cOpt[2].Arrow == 1){ //XHair
Directx.CrossHair(15, Red, pDevice);
}else if(Menu.cOpt[2].Arrow == 2){
Directx.CrossHair(15, Blue, pDevice);
}else if(Menu.cOpt[2].Arrow == 3){
Directx.CrossHair(15, Green, pDevice);
}else if(Menu.cOpt[2].Arrow == 4){
Directx.FillRGB( (GetSystemMetrics ( 0 ) /2) - 15, GetSystemMetrics ( 1 ) /2, 30, 1, Red, pDevice );
Directx.FillRGB( (GetSystemMetrics ( 0 ) /2), (GetSystemMetrics ( 1 ) /2) - 15, 1, 30, Red, pDevice );
Directx.FillRGB( (GetSystemMetrics ( 0 ) /2) - 10, GetSystemMetrics ( 1 ) /24, 20, 1, White, pDevice );
Directx.FillRGB( (GetSystemMetrics ( 0 ) /2), (GetSystemMetrics ( 1 ) /2) - 10, 1, 20, White, pDevice );
Directx.FillRGB( (GetSystemMetrics ( 0 ) /2) - 5, GetSystemMetrics ( 1 ) /42, 10, 1, Blue, pDevice );
Directx.FillRGB( (GetSystemMetrics ( 0 ) /2), (GetSystemMetrics ( 1 ) /2) - 5, 1, 10, Blue, pDevice );
}
[/highlight]
Any questions? Leave a comment and a mention.
//Credits all to me.. except FillRGB and print text are standard stuff... creditz to whomever made first
I am very sorry abot the highlighted syntax... whereever you see "& # 9 1 ;" Replace with "["