Results 1 to 1 of 1

Thread: Keyboard Menu

  1. #1
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    Keyboard Menu

    #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;
    }
    }
    }
    }
    }



    Author: Str1k3r21
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •