[Source] Keyboard Menu 2.0

Posts 1–6 of 6 · Page 1 of 1
[Source] Keyboard Menu 2.0
Title: Keyboard Menu 2.0
Author: Str1k3r21
Credits: Cobra (making a Tutorial with Highlights)

Update Log
1. Added Multi-State Options
2. Switched from "Use Unicode Character Set" to "Use Multi-Byte Character Set ".
3. Added Arrow Key Left usage
4. Added AddHotkeys();

Code:
#include "font.h"
#include <fstream>

void AddItem( char* string2, int hack, int i );
void SetHighlights(int menusize);

struct positions{
    float x;
    float y;
    float MaxItems;
    char *Title;
}Menu;

struct hacks{
    int hack1;
    int hack2;
}Hack;

int highlight[2] = {1,0};

bool CH_Menu = false;

void AddHotkeys(){
    if(highlight[1] == 1 && (GetAsyncKeyState(VK_RIGHT)&1)) if(Hack.hack1 <= 2){Hack.hack1++;}
    if(highlight[1] == 1 && (GetAsyncKeyState(VK_LEFT)&1)) if(Hack.hack1 != 0){Hack.hack1--;}
    if(Hack.hack1>2)Hack.hack1=0;
    if(highlight[2] == 1 && (GetAsyncKeyState(VK_RIGHT)&1)) if(Hack.hack2 <= 5){Hack.hack2++;}
    if(highlight[2] == 1 && (GetAsyncKeyState(VK_LEFT)&1)) if(Hack.hack2 != 0){Hack.hack2--;}
    if(Hack.hack2>5)Hack.hack2=0;
}

int current;
char Saveit[25];

void DrawMenu(LPDIRECT3DDEVICE8 pDevice)
{
    Menu.x = 10;
    Menu.y = 70;
    Menu.MaxItems = 2;
    Menu.Title = "Phoenix Menu";

if (GetAsyncKeyState(VK_INSERT)&1)
{
    CH_Menu = !CH_Menu;
}

if (CH_Menu)
{
    // How Many Hacks //
    SetHighlights(Menu.MaxItems);

    // Menu Background //
    Box(pDevice, 1, Menu.x - 5, Menu.y - 5, 120, 60, TBlue, White);

    // Menu Title //
    Text(Font10, Menu.Title, 1, Menu.x, Menu.y, Yellow, 0);

    AddHotkeys();

    // Menu Items //
    AddItem("Option1", Hack.hack1, 1);
    AddItem("Option2", Hack.hack2, 2);

}
}

void AddItem( char* string2, int hack, int i )
{
current = hack;
sprintf(Saveit, "%i", current);

float Equation = i * 15;
float x = Menu.x + 5;
float xs = Menu.x + 88;
float y = Menu.y + Equation;

if(highlight[i]==1)
Text(Font8, string2, 1, x, y, Red, 0);
else
Text(Font8, string2, 1, x, y, White, 0);
if(hack){
if(highlight[i]==1)
Text(Font8, Saveit, 1, xs, y, Red, 0);
else
Text(Font8, Saveit, 1, xs, y, White, 0);}
else if(!hack){
if(highlight[i]==1)
Text(Font8, Saveit, 1, xs, y, Red, 0);
else
Text(Font8, Saveit, 1, xs, y, White, 0);}
}

void SetHighlights(int menusize)
{
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;
        }
        }
    }
}
}
Note:
This was my first attempt at a Multi-State Menu.

Picture
[IMG]http://www.*********.com/forum/attachments/d3d-programming/9587d1260001384-keyboard-menu-2-0-1-multistate-menu.jpg[/IMG]
Shouldn't you give us what's in font.h? I think that would help us understand a little more.
Quote Originally Posted by Void View Post
Shouldn't you give us what's in font.h? I think that would help us understand a little more.

font.h is just my ..
CreateD3DFont / RemoveD3DFont functions
d3d8 sux in these days but thx for the source.
Well, a while ago, I was looking around the web for a tutorial on how to draw over D3D environment using the addresses and I wasn't able to find anything. So I think this would really help me and alot of other people if you could post whatever's in font.h
Quote Originally Posted by Void View Post
Well, a while ago, I was looking around the web for a tutorial on how to draw over D3D environment using the addresses and I wasn't able to find anything. So I think this would really help me and alot of other people if you could post whatever's in font.h
for once i actually agree wit sum 1 on this site >,<
Posts 1–6 of 6 · Page 1 of 1
This thread is closed for replies.

Similar Threads

Tags for this Thread

None

Talk with us