unknowncheats uc-forum.com ucdownloads ucdownloads.com

Go Back   UC-Tutorials - Multiplayer Game Hacking and Cheat Tutorials > Programming > Direct3D

- Sponsored Advertisement -
http://www.myfpscheats.com/


Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2009, 04:34 AM
Alkatraz Alkatraz is offline
Administrator
 
Join Date: Jan 2007
Posts: 72
Default [Source] - Button Menu D3D9

Credits Stevepwns



I started with micros button struct and made this,

It can be a little laggy when you draw to many (more than 10 or 15) but it works pretty good and is easy to use.

I figured I'd share it and hope some can learn from it, its seems to be a good start.
use what ever text and rect render method your familiar with. I left mime for example code.

Credits to Micro and Me if you use this please



Enjoy:

//In Declerations::
//create your button
Code:
struct Buttons
{
     int      num;
     char     *caption;
     int      x;
     int      y;
     int      w;
     int      h;
     bool     clicked;
     bool     mOver;

}; Buttons Button[20];
//In Initialize::
//call as such
Code:
initbtn( 1, "option", 25, 100, 125, 20);
//Function your calling
Code:
void initbtn(int bnum, char *bcaption, int bx, int by, int bw, int bh )
{
     Button[bnum].num       = bnum;
     Button[bnum].caption   = bcaption;
     Button[bnum].x         = bx;
     Button[bnum].y         = by;
     Button[bnum].w         = bw;
     Button[bnum].h         = bh;
     Button[bnum].clicked   = false;
}
//In End Scene::
//Call as such
Code:
RenderButton( m_pD3Ddev, 1); //or create array to draw multiple buttons
//Function your calling
Code:
void RenderButton( IDirect3DDevice9 *pD3Ddev, int butnum )
{
     int mw = Button[butnum].x + Button[butnum].w;
     int mh = Button[butnum].y + Button[butnum].h;
           //Defualt apperance
          drawguibox( Button[butnum].x, Button[butnum].y,  Button[butnum].w,  Button[butnum].h, 0, 0, 0, 255, 0, 0, 255, 100 );
          DrawText( Button[butnum].x + 15, Button[butnum].y + 3, Button[butnum].caption, 0, 0, 0);

         POINT cur;
         GetCursorPos( &cur );
        
          //if the mouse coords are
          //the same as the buttons coords
          if ( cur.x >= Button[butnum].x &&  cur.x <= mw && cur.y >= Button[butnum].y && cur.y <= mh )
          {
                  //draw with higher opacity
                  drawguibox( Button[butnum].x, Button[butnum].y,  Button[butnum].w,  Button[butnum].h, 255, 255, 255, 125, 0, 0, 255, 125 );
                  DrawText( Button[butnum].x + 15, Button[butnum].y + 3, Button[butnum].caption, 255, 0, 0);

                  //if mouse button is clicked
                  if ( GetAsyncKeyState( VK_LBUTTON ) &1 )
                  {                
                          //then the button has been clicked
                         Button[butnum].clicked = !Button[butnum].clicked;
                   }
           }

          if ( Button[butnum].clicked )
         {
                //the buttton has been clicked and the text
                //color changes to show its been clicked
               DrawText( Button[butnum].x + 15, Button[butnum].y + 3, Button[butnum].caption, 0, 255, 0);

          }
}
Reply With Quote
Reply

  • Submit Thread to Digg
  • Submit Thread to del.icio.us
  • Submit Thread to StumbleUpon
  • Submit Thread to Google
  • Submit Thread to Facebook
  • Submit Thread to My Yahoo!
  • Submit Thread to MySpace
  • Submit Thread to Twitter
  • Submit Thread to Reddit

Tags
button, d3d9, menu, source

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT. The time now is 06:47 AM.