keybode

rh gui

Feb 26th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 25.83 KB | None | 0 0
  1. #define TITLE_SIZE 15
  2.  
  3. MCV(bool) ready( cheat_cvar_s* val_a,cheat_cvar_s* val_x,cheat_cvar_s* val_y,cheat_cvar_s* val_w,cheat_cvar_s* val_h )
  4. {
  5.   return ( val_a!=NULL&&val_x!=NULL&&val_y!=NULL&&val_w!=NULL&&val_h!=NULL&&val_a->GetBool() )
  6.     ? true
  7.     : false;
  8. }
  9. MCV(void) draw_rect( int x, int y, int w, int h, dword cololol )
  10. {
  11.   if ( m_pExport )
  12.   {
  13.     m_pExport->FillRGBA(x,y-1,w+1,1,cololol);      // top
  14.     m_pExport->FillRGBA(x-1,y-1,1,h+1,cololol);    // bottom
  15.     m_pExport->FillRGBA(x,y+h,w,1,cololol);        // left
  16.     m_pExport->FillRGBA(x+w,y,1,h+1,cololol);      // right
  17.   }
  18. }
  19. MCV(void) draw_move( __int32& x_off,__int32 &y_off, bool &moving, cheat_cvar_s* val_a,cheat_cvar_s* val_x,cheat_cvar_s* val_y,cheat_cvar_s* val_w,cheat_cvar_s* val_h )
  20. {
  21.   if ( !ready(val_a,val_x,val_y,val_w,val_h) )
  22.   {
  23.     return;
  24.   }
  25.  
  26.   if ( m_pExport->_mouse__over(val_x->GetInt(), val_y->GetInt() - TITLE_SIZE, val_w->GetInt(), TITLE_SIZE ) )
  27.   {
  28.     m_pExport->imouse_type = base_hack::gui_cursor_type::_MOUSE_ARROW_RIGHT_LEFT_UP_DOWN;
  29.  
  30.     if ( m_pExport->M1A_Pressed )
  31.     {
  32.       x_off = m_pExport->m_X - val_x->GetInt();
  33.       y_off = m_pExport->m_Y - val_y->GetInt();
  34.       moving = true;
  35.     }
  36.   }
  37.  
  38.   if ( moving == true )
  39.   {
  40.     int xxx = m_pExport->m_X - x_off;
  41.     int yyy = m_pExport->m_Y - y_off;
  42.  
  43.     val_x->SetValue((xxx < 0) ? 0 : (xxx<m_pExport->ScreenW) ? xxx : (m_pExport->ScreenW - val_w->GetInt()));
  44.     val_y->SetValue((yyy < 0) ? 0 : (yyy<m_pExport->ScreenH) ? yyy : (m_pExport->ScreenH - val_h->GetInt()));
  45.  
  46.     if ( !m_pExport->M1A_Pressed && moving == true )
  47.     {
  48.       moving = false;
  49.     }
  50.   }
  51. }
  52. MCV(void) draw_size( __int32& w_off,__int32 &h_off, bool &__www, bool &__hhh, bool &__wwhh, cheat_cvar_s* val_a,cheat_cvar_s* val_x,cheat_cvar_s* val_y,cheat_cvar_s* val_w,cheat_cvar_s* val_h )
  53. {
  54.   if ( !ready(val_a,val_x,val_y,val_w,val_h) )
  55.   {
  56.     return;
  57.   }
  58.  
  59.   // Drag W
  60.   if ( m_pExport->_mouse__over(val_x->GetInt()+val_w->GetInt()-1,val_y->GetInt(),4,val_h->GetInt()-10))
  61.   {
  62.     m_pExport->imouse_type = base_hack::gui_cursor_type::_MOUSE_ARROW_RIGHT_LEFT;
  63.  
  64.     if ( m_pExport->M1A_Pressed )
  65.     {
  66.       w_off = m_pExport->m_X - val_w->GetInt();
  67.       __www = true;
  68.     }
  69.   }
  70.   if ( __www == true )
  71.   {
  72.     int www = m_pExport->m_X - w_off;
  73.  
  74.     val_w->SetValue( www <= val_w->GetMinValue() ? val_w->GetMinValue() : www );
  75.  
  76.     if ( !m_pExport->M1A_Pressed && __www == true)
  77.     {
  78.       __www = false;
  79.     }
  80.   }
  81.  
  82.   // Drag H
  83.   if ( m_pExport->_mouse__over(val_x->GetInt(),val_y->GetInt()+val_h->GetInt()-1,val_w->GetInt()-10,4))
  84.   {
  85.     m_pExport->imouse_type = base_hack::gui_cursor_type::_MOUSE_ARROW_DOWN;
  86.     if ( m_pExport->M1A_Pressed )
  87.     {
  88.       h_off = m_pExport->m_Y - val_h->GetInt();
  89.       __hhh = true;
  90.     }
  91.   }
  92.   if ( __hhh == true )
  93.   {
  94.     int hhh = m_pExport->m_Y - h_off;
  95.  
  96.     val_h->SetValue( hhh <= val_h->GetMinValue() ? val_h->GetMinValue() : hhh );
  97.  
  98.     if ( !m_pExport->M1A_Pressed && __hhh == true)
  99.     {
  100.       __hhh = false;
  101.     }
  102.   }
  103.  
  104.   // Drag W/H
  105.   if ( m_pExport->_mouse__over(val_x->GetInt()+val_w->GetInt()-10,val_y->GetInt()+val_h->GetInt()-10,11,11))
  106.   {
  107.     m_pExport->imouse_type = base_hack::gui_cursor_type::_MOUSE_LEFT;
  108.  
  109.     if ( m_pExport->M1A_Pressed )
  110.     {
  111.       w_off  = m_pExport->m_X - val_w->GetInt();
  112.       h_off  = m_pExport->m_Y - val_h->GetInt();
  113.       __wwhh = true;
  114.     }
  115.   }
  116.   if ( __wwhh == true )
  117.   {
  118.     int www = m_pExport->m_X - w_off;
  119.     int hhh = m_pExport->m_Y - h_off;
  120.  
  121.     val_w->SetValue( www <= val_w->GetMinValue() ? val_w->GetMinValue() : www );
  122.     val_h->SetValue( hhh <= val_h->GetMinValue() ? val_h->GetMinValue() : hhh );
  123.  
  124.     if ( !m_pExport->M1A_Pressed && __wwhh == true )
  125.     {
  126.       __wwhh = false;
  127.     }
  128.   }
  129. }
  130. MCV(void) draw_form( cheat_cvar_s* val_a,cheat_cvar_s* val_x,cheat_cvar_s* val_y,cheat_cvar_s* val_w,cheat_cvar_s* val_h, dword dwBorderColor, dword dwTitleColor, dword dwBackColor, dword dwTextColor, cpchar pszTitle )
  131. {
  132.   if ( !ready(val_a,val_x,val_y,val_w,val_h) )
  133.   {
  134.     return;
  135.   }
  136.  
  137.   int title_x = val_x->GetInt();
  138.   int title_y = val_y->GetInt() - (TITLE_SIZE+2);
  139.   int title_w = val_w->GetInt();
  140.   int title_h = TITLE_SIZE;
  141.  
  142.   //////////////////////////////////////////////////////////////////////////
  143.   // TitleBar Border Draw
  144.   //   draw_rect(
  145.   //     title_x-1,
  146.   //     title_y-1,
  147.   //     title_w+2,
  148.   //     title_h+2,
  149.   //     dwBorderColor );
  150.   draw_rect(
  151.     title_x,
  152.     title_y,
  153.     title_w,
  154.     title_h,
  155.     dwBorderColor );
  156.  
  157.   // TitleBar BackGround Draw
  158.   m_pExport->FillRGBA(
  159.     title_x,
  160.     title_y,
  161.     title_w,
  162.     title_h,
  163.     dwTitleColor );
  164.  
  165.   //////////////////////////////////////////////////////////////////////////
  166.   // TitleBar title
  167.   if ( pszTitle && pszTitle[0] )
  168.   {
  169.     m_pExport->draw_string(false,title_x+5,title_y+1,dwTextColor,"%s",pszTitle);
  170.   }
  171.  
  172.   //////////////////////////////////////////////////////////////////////////
  173.   // Border Draw
  174.   //   draw_rect(
  175.   //     val_x->GetInt()-1,
  176.   //     val_y->GetInt()-1,
  177.   //     val_w->GetInt()+2,
  178.   //     val_h->GetInt()+2,
  179.   //     dwBorderColor );
  180.   draw_rect(
  181.     val_x->GetInt(),
  182.     val_y->GetInt(),
  183.     val_w->GetInt(),
  184.     val_h->GetInt(),
  185.     dwBorderColor );
  186.  
  187.   // BackGround Draw
  188.   m_pExport->FillRGBA(
  189.     val_x->GetInt(),
  190.     val_y->GetInt(),
  191.     val_w->GetInt(),
  192.     val_h->GetInt(),
  193.     dwBackColor );
  194.  
  195.   //////////////////////////////////////////////////////////////////////////
  196.   // close button
  197.   uint32
  198.     _closeX=val_x->GetInt() + (val_w->GetInt() - 15),
  199.     _closeY=val_y->GetInt() - TITLE_SIZE;
  200.  
  201.   dword dwCloseColors = dwTextColor;
  202.  
  203.   if ( m_pExport->_mouse__over(_closeX,_closeY,10,10) )
  204.   {
  205.     // if hoovering, red-it
  206.     dwCloseColors = DWORD_RGBA(255,0,0,255);
  207.  
  208.     // show dem user, cliks
  209.     m_pExport->imouse_type = base_hack::_MOUSE_HAND;
  210.  
  211.     if ( m_pExport->M1A_Pressed )
  212.     {
  213.       // close the window
  214.       val_a->SetValue( 0 );
  215.     }
  216.   }
  217.  
  218.   // button like border
  219.   draw_rect(_closeX,_closeY,10,10,dwBorderColor);
  220.  
  221.   // x letter, color swap at hovering
  222.   m_pExport->draw_string(false,_closeX + 2,_closeY - 2,dwCloseColors,"X");
  223. }
  224. MCV(void) _draw_mouse( void )
  225. {
  226.   if ( !m_pExport->bMouseActive )
  227.   {
  228.     return;
  229.   }
  230.  
  231.   uint32 x = m_pExport->m_X;
  232.   uint32 y = m_pExport->m_Y;
  233.  
  234.   dword mouse_cc = m_pExport->GetColorByIdx( 3 )->dwGetColor_rgba(); // white
  235.   dword border_o = m_pExport->GetColorByIdx( 4 )->dwGetColor_rgba(); // black
  236.  
  237.   if ( m_pExport->imouse_type == base_hack::gui_cursor_type::_MOUSE_CURSOR )
  238.   {
  239.     m_pExport->FillRGBA( x-1,y-1,1,12 ,border_o);
  240.     m_pExport->FillRGBA( x,y-1,1,1 ,border_o);
  241.     m_pExport->FillRGBA( x,y,1,10 ,mouse_cc);
  242.     m_pExport->FillRGBA( x, y+10,1,1 ,border_o);
  243.     m_pExport->FillRGBA( x+1,y,1,1 ,border_o);
  244.     m_pExport->FillRGBA( x+1,y+1,1,8 ,mouse_cc);
  245.     m_pExport->FillRGBA( x+1,y+9,1,1 ,border_o);
  246.     m_pExport->FillRGBA( x+2,y+1,1,1 ,border_o);
  247.     m_pExport->FillRGBA( x+2,y+2,1,6 ,mouse_cc);
  248.     m_pExport->FillRGBA( x+2,y+8,1,1 ,border_o);
  249.     m_pExport->FillRGBA( x+3,y+2,1,1 ,border_o);
  250.     m_pExport->FillRGBA( x+3,y+3,1,6 ,mouse_cc);
  251.     m_pExport->FillRGBA( x+3,y+9,1,2 ,border_o);
  252.     m_pExport->FillRGBA( x+4,y+3,1,1 ,border_o);
  253.     m_pExport->FillRGBA( x+4,y+4,1,7 ,mouse_cc);
  254.     m_pExport->FillRGBA( x+4,y+11,1,2 ,border_o);
  255.     m_pExport->FillRGBA( x+5,y+4,1,1 ,border_o);
  256.     m_pExport->FillRGBA( x+5,y+5,1,2 ,mouse_cc);
  257.     m_pExport->FillRGBA( x+5,y+7,1,2 ,border_o);
  258.     m_pExport->FillRGBA( x+5,y+9,1,4 ,mouse_cc);
  259.     m_pExport->FillRGBA( x+5,y+13,1 ,1,border_o);
  260.     m_pExport->FillRGBA( x+6,y+5,1 ,1,border_o);
  261.     m_pExport->FillRGBA( x+6,y+6,1,1 ,mouse_cc);
  262.     m_pExport->FillRGBA( x+6,y+7,1,1 ,border_o);
  263.     m_pExport->FillRGBA( x+6,y+9,1,2 ,border_o);
  264.     m_pExport->FillRGBA( x+6,y+11,1,2 ,mouse_cc);
  265.     m_pExport->FillRGBA( x+6,y+13,1,1 ,border_o);
  266.     m_pExport->FillRGBA( x+7, y+6,1,2 ,border_o);
  267.     m_pExport->FillRGBA( x+7,y+11,1,2 ,border_o);
  268.   }
  269.   if ( m_pExport->imouse_type == base_hack::gui_cursor_type::_MOUSE_ARROW_UP )
  270.   {
  271. // diy
  272.   }
  273.   if ( m_pExport->imouse_type == base_hack::gui_cursor_type::_MOUSE_ARROW_DOWN )
  274.   {
  275. // diy
  276.   }
  277.   if ( m_pExport->imouse_type == base_hack::gui_cursor_type::_MOUSE_ARROW_RIGHT_LEFT )
  278.   {
  279. // diy
  280.   }
  281.   if ( m_pExport->imouse_type == base_hack::gui_cursor_type::_MOUSE_ARROW_RIGHT_LEFT_UP_DOWN )
  282.   {
  283. // diy
  284.   }
  285.   if ( m_pExport->imouse_type == base_hack::gui_cursor_type::_MOUSE_EDIT )
  286.   {
  287. // diy
  288.   }
  289.   if ( m_pExport->imouse_type == base_hack::gui_cursor_type::_MOUSE_HAND )
  290.   {
  291. // diy
  292.   }
  293.   if ( m_pExport->imouse_type == base_hack::gui_cursor_type::_MOUSE_RIGHT )
  294.   {
  295. // diy
  296.   }
  297.   if ( m_pExport->imouse_type == base_hack::gui_cursor_type::_MOUSE_LEFT )
  298.   {
  299. // diy
  300.   }
  301. }
  302.  
  303. struct _button
  304. {
  305.   char text[128];
  306.  
  307.   // void _C cb( void );
  308.   pvoid _callback;
  309.  
  310.   MCV(void) init( pchar title )
  311.   {
  312.     _callback = NULL;
  313.     tools::_sprintf(text,"%s",title);
  314.   }
  315.   MCV(void) draw( uint32 x, uint32 y, uint32 w, uint32 h, dword dwBorder, dword dwBackground, dword dwText, dword dwSelected )
  316.   {
  317.     // cliks
  318.     if ( _callback != NULL )
  319.     {
  320.       if ( m_pExport->_mouse__over(x,y,w,h) )
  321.       {
  322.         //selection coloring
  323.         //selection rectangle arround the line
  324.         //in case the guy isnt sure he is on good line
  325.         dwBackground = dwSelected;
  326.         m_pExport->imouse_type = base_hack::gui_cursor_type::_MOUSE_HAND;
  327.  
  328.         //send command
  329.         static bool once = false;
  330.         if ( !once && m_pExport->M1A_Pressed )
  331.         {
  332.           once = true;
  333.           try
  334.           {
  335.             ((void (_C*)())(_callback))();
  336.           }
  337.           catch (...)
  338.           {
  339.             tools::speak( "_button (%s@"FMT_ADDRESS") -C-R-A-S-H-E-D-" __FUNCTION__, text, _callback );
  340.           }
  341.         }
  342.         else
  343.         {
  344.           if ( once && !m_pExport->M1A_Pressed )
  345.           {
  346.             once = false;
  347.           }
  348.         }
  349.       }
  350.     }
  351.  
  352.     // TitleBar Border Draw
  353.     draw_rect(x-1, y-1, w+2, h+2, dwBorder );
  354.  
  355.     // TitleBar BackGround Draw
  356.     m_pExport->FillRGBA( x, y, w, h, dwBackground );
  357.  
  358.     // draw title
  359.     m_pExport->draw_string( false, x+2,y+2,dwText, text );
  360.   }
  361. };
  362. struct _input_box
  363. {
  364.   struct _inlines
  365.   {
  366.     char line[1024];
  367.   };
  368.  
  369.   // how many stored lines & actual line (input)
  370.   int Scroll_i,Count_i;
  371.  
  372.   // current input
  373.   _inlines textInput;
  374.  
  375.   // stored line list (input)
  376.   _inlines * MUTPTR previous;  // _inlines[256];
  377.  
  378.   MCV(void) init( void )
  379.   {
  380.     previous = new _inlines[256];
  381.     erase_content();
  382.   }
  383.   MCV(void) draw_input( uint32 x, uint32 y, uint32 w, uint32 h, dword dwInput, dword dwText )
  384.   {
  385.     if ( m_pExport->_mouse__over( x, y, w, h ))
  386.     {
  387.       m_pExport->imouse_type = base_hack::gui_cursor_type::_MOUSE_EDIT;
  388.       dwInput = DWORD_RGBA(RED(dwInput),0,BLUE(dwInput),255);
  389.     }
  390.  
  391.     // Input BackGround Draw
  392.     m_pExport->FillRGBA( x, y, w, h, dwInput );
  393.  
  394.     // input text
  395.     m_pExport->draw_string( false,x, y, dwText, textInput.line );
  396.   }
  397.  
  398.   // hello world
  399.   MCV(void) erase_content(void)
  400.   {
  401.     Scroll_i = Count_i = 0;
  402.     tools::fillmem(previous,0,sizeof(_inlines) * 256);
  403.   }
  404.   MCV(void) HandleKeyBoard( int uMsg, WPARAM wParam, LPARAM )
  405.   {
  406.     // dont overflow
  407.     if ( Count_i >= 255 ) {
  408.       erase_content();
  409.     }
  410.  
  411.     switch( uMsg )
  412.     {
  413.     case WM_KEYDOWN:
  414.     case WM_SYSKEYDOWN:
  415.       {
  416.         switch(wParam)
  417.         {
  418.         case VK_UP:
  419.           {
  420.             if ( Count_i <= 0 )
  421.             {
  422.               tools::_sprintf(textInput.line,"");
  423.               break;
  424.             }
  425.  
  426.             Scroll_i  = _clamp<int>(Scroll_i - 1,0,Count_i-1);
  427.             textInput = previous[Scroll_i];
  428.             break;
  429.           }
  430.         case VK_DOWN:
  431.           {
  432.             if ( Count_i <= 0 )
  433.             {
  434.               tools::_sprintf(textInput.line,"");
  435.               break;
  436.             }
  437.             Scroll_i  = _clamp<int>(Scroll_i + 1,0,Count_i-1);
  438.             textInput = previous[Scroll_i];
  439.             break;
  440.           }
  441.         case VK_HOME:
  442.           {
  443.             if ( Count_i <= 0 )
  444.             {
  445.               tools::_sprintf(textInput.line,"");
  446.               break;
  447.             }
  448.             Scroll_i  = _clamp<int>(Count_i - 1,0,Count_i-1);
  449.             textInput = previous[Scroll_i];
  450.             break;
  451.           }
  452.         case VK_END:
  453.           {
  454.             if ( Count_i <= 0 )
  455.             {
  456.               tools::_sprintf(textInput.line,"");
  457.               break;
  458.             }
  459.             Scroll_i = 0;
  460.             textInput = previous[Scroll_i];
  461.             break;
  462.           }
  463.         case VK_NEXT:
  464.           {
  465.             if ( Count_i <= 0 )
  466.             {
  467.               tools::_sprintf(textInput.line,"");
  468.               break;
  469.             }
  470.             // PG UP
  471.             Scroll_i  = _clamp<int>(Scroll_i - 10,0,Count_i-1);
  472.             textInput = previous[Scroll_i];
  473.             break;
  474.           }
  475.         case VK_PRIOR:
  476.           {
  477.             if ( Count_i <= 0 )
  478.             {
  479.               tools::_sprintf(textInput.line,"");
  480.               break;
  481.             }
  482.             // PG DOWN
  483.             Scroll_i  = _clamp<int>(Scroll_i + 10,0,Count_i-1);
  484.             textInput = previous[Scroll_i];
  485.             break;
  486.           }
  487.         case VK_SPACE:
  488.           {
  489.             char tmp[2048];
  490.             tools::_sprintf(tmp,"%s \0",textInput.line);
  491.             tools::_sprintf(textInput.line,"%s\0",tmp);
  492.             break;
  493.           }
  494.         case VK_BACK:
  495.           {
  496.             if ( !textInput.line[0] )
  497.             {
  498.               break;
  499.             }
  500.  
  501.             uint32 len = tools::_strlen( textInput.line );
  502.             if ( !len )
  503.             {
  504.               break;
  505.             }
  506.  
  507.             textInput.line[len - 1] = 0;
  508.  
  509.             break;
  510.           }
  511.         case VK_RETURN:
  512.           {
  513.             if ( !textInput.line[0] )
  514.             {
  515.               break;
  516.             }
  517.  
  518.             uint32 len = tools::_strlen( textInput.line );
  519.             if ( !len )
  520.             {
  521.               break;
  522.             }
  523.  
  524.             // put to list in case wanna  re-use
  525.             previous[Count_i++] = textInput;
  526.  
  527.             // move
  528.             Scroll_i  = _clamp<int>(Scroll_i - 1,0,Count_i-1);
  529.  
  530.             // call stub
  531.             m_pExport->ParseLine( textInput.line );
  532.  
  533.             // reset
  534.             tools::fillmem(&textInput,0,sizeof(textInput));
  535.  
  536.             break;
  537.           }
  538.         default:
  539.           {
  540.             char m_vecKp[0x2];
  541.             tools::fillmem(&m_vecKp,0,sizeof(m_vecKp));
  542.  
  543.             byte m_vecKs[256];
  544.             tools::fillmem(&m_vecKs,0,sizeof(m_vecKs));
  545.  
  546.             if ( GetKeyboardState( m_vecKs ) )
  547.             {
  548.               if ( ToAsciiEx( wParam, 0, m_vecKs, (LPWORD)m_vecKp, 0, 0 ) >= 1 )
  549.               {
  550.                 char tmp[2048];
  551.                 tools::_sprintf(tmp,"%s%s\0",textInput.line,m_vecKp);
  552.                 tools::_sprintf(textInput.line,"%s\0",tmp);
  553.                 break;
  554.               }
  555.             }
  556.           }
  557.         }
  558.         break;
  559.       }
  560.     }
  561.   }
  562. };
  563. struct _output_box
  564. {
  565.   struct _outlines
  566.   {
  567.     char _line[PAGESIZE];
  568.   };
  569.  
  570.   // how many stored lines & actual line (output)
  571.   int Scroll_o,Count_o;
  572.  
  573.   // stored line list (output)
  574.   _outlines * MUTPTR vPrintLines;// _outlines[4096];
  575.  
  576.   // used for cliking on line,
  577.   // void _C callback( uint32 index );
  578.   pvoid line_function_ptr;
  579.  
  580.   MCV(void) init( void )
  581.   {
  582.     vPrintLines = new _outlines[4096];
  583.     line_function_ptr = NULL;
  584.     Scroll_o = Count_o = 0;
  585.   }
  586.   MCV(void) draw_output( uint32 x, uint32 y, uint32 w, uint32 h, dword dwOutput, dword dwSelected )
  587.   {
  588.     // Output BackGround Draw
  589.     m_pExport->FillRGBA(x,y,w,h,dwOutput );
  590.  
  591.     int iactual_scroll = (Count_o/* - 1*/) - Scroll_o;
  592.  
  593.     int _line_x = x + 1;
  594.     int _line_y = y + (h - ((m_pExport->m_nHUDHeight*2) + 4));
  595.  
  596.     // avoid spam
  597.     static bool executed = false;
  598.     while ( --iactual_scroll >= 0 )
  599.     {
  600.       if( _line_y <= y + 5 )
  601.       {
  602.         break;
  603.       }
  604.  
  605.       //selection coloring and clik handle
  606.       if ( line_function_ptr != NULL )
  607.       {
  608.         if ( m_pExport->_mouse__over(_line_x,_line_y,w,m_pExport->m_nHUDHeight) )
  609.         {
  610.           //selection coloring
  611.           //selection rectangle arround the line
  612.           //in case the guy isnt sure he is on good line
  613.           m_pExport->imouse_type = base_hack::gui_cursor_type::_MOUSE_HAND;
  614.           m_pExport->FillRGBA(_line_x,_line_y,w, m_pExport->m_nHUDHeight, dwSelected );
  615.  
  616.           //send command
  617.           static bool once = false;
  618.           if ( !once && m_pExport->M1A_Pressed )
  619.           {
  620.             once = true;
  621.             try
  622.             {
  623.               ((void (_C*)(uint32))(line_function_ptr))( iactual_scroll );
  624.             }
  625.             catch (...)
  626.             {
  627.               tools::speak( "_output_box (%i@"FMT_ADDRESS") -C-R-A-S-H-E-D-" __FUNCTION__, iactual_scroll,line_function_ptr );
  628.             }
  629.           }
  630.           else
  631.           {
  632.             if ( once && !m_pExport->M1A_Pressed )
  633.             {
  634.               once = false;
  635.             }
  636.           }
  637.         }
  638.       }
  639.  
  640.       // text yay
  641.       m_pExport->draw_string_fmt( w - 4, _line_x, _line_y, vPrintLines[iactual_scroll]._line );
  642.  
  643.       _line_y -= m_pExport->m_nHUDHeight;
  644.     };
  645.   }
  646.  
  647.   // hello world
  648.   MCV(void) erase_content(void)
  649.   {
  650.     Scroll_o = Count_o = 0;
  651.     tools::fillmem(vPrintLines,0,sizeof(_outlines) * 4096);
  652.   }
  653.   MCV(void) Printf(pchar  szText, ... )
  654.   {
  655.     if ( !vPrintLines )
  656.     {
  657.       return;
  658.     }
  659.  
  660.     if ( Count_o >= 4095 ) {
  661.       erase_content();
  662.     }
  663.  
  664.     _outlines m_szBufA = {
  665.       "input is off limits too small or big."
  666.     };
  667.  
  668.     uint32 len = _vsprintf(m_szBufA._line,szText,(va_list)&szText + _INTSIZEOF(szText));
  669.     if ( len < 1
  670.       || len >= (PAGESIZE-1) )
  671.     {
  672.       vPrintLines[Count_o++] = m_szBufA;
  673.       return;
  674.     }
  675.  
  676.     m_szBufA._line[ len ] = 0;
  677.  
  678.     pchar nexttab = tools::_strstr(m_szBufA._line,"\t");
  679.     if ( nexttab )
  680.     {
  681.       char tmp0[PAGESIZE];
  682.       char tmp1[PAGESIZE];
  683.  
  684.       nexttab[0] = 0;
  685.       tools::_sprintf(tmp0,"%s",m_szBufA._line);
  686.       tools::_sprintf(tmp1,"%s",&nexttab[1]);
  687.  
  688.       Printf("%s    %s",tmp0,tmp1);
  689.       return;
  690.     }
  691.  
  692.     pchar nextlin3 = tools::_strstr(m_szBufA._line,"\n");
  693.     if ( nextlin3 )
  694.     {
  695.       char tmp0[PAGESIZE];
  696.       char tmp1[PAGESIZE];
  697.  
  698.       nextlin3[0] = 0;
  699.       tools::_sprintf(tmp0,"%s",m_szBufA._line);
  700.       tools::_sprintf(tmp1,"%s",&nextlin3[1]);
  701.  
  702.       // space for incase it's just a next line,
  703.       Printf("%s",tmp0); // first one
  704.       Printf("%s",tmp1); // next one
  705.       return;
  706.     }
  707.  
  708.     pchar nextline = tools::_strstr(m_szBufA._line,"\r\n");
  709.     if ( nextline )
  710.     {
  711.       char tmp0[PAGESIZE];
  712.       char tmp1[PAGESIZE];
  713.  
  714.       nextline[0] = 0;
  715.       nextline[1] = 0;
  716.       tools::_sprintf(tmp0,"%s",m_szBufA._line);
  717.       tools::_sprintf(tmp1,"%s",&nextline[2]);
  718.  
  719.       // space for incase it's just a next line,
  720.       Printf("%s ",tmp0); // first one
  721.       Printf("%s",tmp1);  // next one
  722.       return;
  723.     }
  724.  
  725.     //add to list or fresh list
  726.     vPrintLines[Count_o++] = m_szBufA;
  727.     return;
  728.   }
  729.   MCV(void) Printf(pwchar szText, ... )
  730.   {
  731.     wchar_t m_szBufW[PAGESIZE];
  732.     m_szBufW[vswprintf(m_szBufW,szText,(va_list)(wchar_t*)&szText + _INTSIZEOF(szText))] = 0;
  733.  
  734.     static char m_szBufA[PAGESIZE * 2];
  735.     if ( !CharToOemW(m_szBufW,m_szBufA) )
  736.     {
  737.       return;
  738.     }
  739.  
  740.     Printf(m_szBufA);
  741.   }
  742.   MCV(void) HandleScrolling( int uMsg, WPARAM wParam, LPARAM )
  743.   {
  744.     switch( uMsg )
  745.     {
  746.     case WM_KEYDOWN:
  747.     case WM_SYSKEYDOWN:
  748.       {
  749.         switch(wParam)
  750.         {
  751.         case VK_END:
  752.           {
  753.             Scroll_o = 0;
  754.             break;
  755.           }
  756.         case VK_HOME:
  757.           {
  758.             Scroll_o = _clamp<int>(Count_o-1,0,Count_o-1);
  759.             break;
  760.           }
  761.         case VK_UP:
  762.           {
  763.             // Scrool UP ==> mouse
  764.             Scroll_o = _clamp<int>(Scroll_o - 1,0,Count_o-1);
  765.             break;
  766.           }
  767.         case VK_DOWN:
  768.           {
  769.             // Scrool DOWN ==> mouse
  770.             Scroll_o = _clamp<int>(Scroll_o + 1,0,Count_o-1);
  771.             break;
  772.           }
  773.         case VK_NEXT:
  774.           {
  775.             // PG UP
  776.             Scroll_o = _clamp<int>(Scroll_o - 10,0,Count_o-1);
  777.             break;
  778.           }
  779.         case VK_PRIOR:
  780.           {
  781.             // PG DOWN
  782.             Scroll_o = _clamp<int>(Scroll_o + 10,0,Count_o-1);
  783.             break;
  784.           }
  785.         default:
  786.           {
  787.             break;
  788.           }
  789.         }
  790.         break;
  791.       }
  792.     case WM_MOUSEWHEEL:
  793.       {
  794.         if ( GET_WHEEL_DELTA_WPARAM( wParam ) > 0 )
  795.         {
  796.           // Scrool UP ==> mouse wheel
  797.           Scroll_o = _clamp<int>(Scroll_o + 3,0,Count_o-1);
  798.         }
  799.         else
  800.         {
  801.           // Scrool DOWN ==> mouse wheel
  802.           Scroll_o = _clamp<int>(Scroll_o - 3,0,Count_o-1);
  803.         }
  804.         break;
  805.       }
  806.     }
  807.   }
  808. };
  809. struct _slider_vert
  810. {
  811.   bool drag_SV,is_value_changed;
  812.  
  813.   uint32 current_value,min_value,max_value;
  814.  
  815.   dword degrade_start,degrade_finish;
  816.  
  817.   MCV(void) init( uint32 _val, uint32 _min, uint32 _max )
  818.   {
  819.     drag_SV          = false;
  820.     is_value_changed = false;
  821.     current_value    = _val;
  822.     degrade_start    = min_value = _min;
  823.     degrade_finish   = max_value = _max;
  824.   }
  825.   MCV(void) draw( uint32 _x, uint32 _y, dword dwBorder, dword dwBack )
  826.   {
  827.     //reset
  828.     is_value_changed = false;
  829.  
  830.     int real_x = _x;
  831.     int real_y = _y;
  832.  
  833.     int x_off = 0;
  834.     int y_off = 0;
  835.  
  836.     // Line
  837.     m_pExport->draw_2d_box( real_x,real_y,2,max_value , dwBorder );
  838.     m_pExport->FillRGBA( real_x,real_y,2,max_value , dwBack );
  839.  
  840.     // Cursor
  841.     m_pExport->draw_2d_box( real_x-3,real_y-3+current_value,8,4,dwBorder );
  842.     m_pExport->FillRGBA( real_x-3,real_y-3+current_value,8,4,dwBack );
  843.  
  844.     drag_SV = m_pExport->_mouse1_lock(real_x-3,real_y,7,max_value);
  845.  
  846.     if ( drag_SV )
  847.     {
  848.       int yY = m_pExport->m_Y - real_y;
  849.  
  850.       current_value = yY;
  851.  
  852.       if ( m_pExport->_mouse1_lock(real_x-3,real_y+current_value-4,13,7) )
  853.       {
  854.         y_off = m_pExport->m_Y - current_value;
  855.         is_value_changed = true;
  856.       }
  857.  
  858.       int newY = m_pExport->m_Y - y_off;
  859.  
  860.       //bound to min/max
  861.       current_value = newY;
  862.       current_value = _clamp( current_value, min_value, max_value );
  863.     }
  864.   }
  865. };
  866. struct _slider_horiz
  867. {
  868.   bool drag_SH,is_value_changed;
  869.  
  870.   uint32 current_value,min_value,max_value;
  871.  
  872.   dword degrade_start,degrade_finish;
  873.  
  874.   MCV(void) init( uint32 _val, uint32 _min, uint32 _max )
  875.   {
  876.     drag_SH          = false;
  877.     is_value_changed = false;
  878.     current_value    = _val;
  879.     degrade_start    = min_value = _min;
  880.     degrade_finish   = max_value = _max;
  881.   }
  882.   MCV(void) draw( uint32 _x, uint32 _y, dword dwBorder, dword dwBack )
  883.   {
  884.     //reset
  885.     is_value_changed     = false;
  886.  
  887.     int real_x = _x;
  888.     int real_y = _y;
  889.  
  890.     int x_off = 0;
  891.     int y_off = 0;
  892.     //////////////////////////////////////////////////////////////////////////
  893.     // Line
  894.     m_pExport->draw_2d_box( real_x,real_y,max_value,2,dwBorder );
  895.     m_pExport->FillRGBA( real_x,real_y,max_value,2,dwBack );
  896.  
  897.     //////////////////////////////////////////////////////////////////////////
  898.     // Cursor
  899.     m_pExport->draw_2d_box( real_x + current_value,real_y-3,4,8,dwBorder );
  900.     m_pExport->FillRGBA( real_x + current_value,real_y-3,4,8,dwBack );
  901.     //////////////////////////////////////////////////////////////////////////
  902.  
  903.     drag_SH = m_pExport->_mouse1_lock(real_x,real_y-3,max_value,7);
  904.  
  905.     if ( drag_SH )
  906.     {
  907.       current_value = m_pExport->m_X - real_x;
  908.  
  909.       if ( m_pExport->_mouse1_lock(real_x+current_value-2,real_y-6,6,13) )
  910.       {
  911.         x_off              = m_pExport->m_X - current_value;
  912.         is_value_changed   = true;
  913.       }
  914.  
  915.       int newX             = m_pExport->m_X - x_off;
  916.  
  917.       //bound to min/max
  918.       current_value = newX;
  919.       current_value = _clamp(current_value,min_value,max_value);
  920.     }
  921.   }
  922. };
  923. struct _checkbox
  924. {
  925.   // untested (no gui items use 'em)
  926.   // todo: use 'em
  927.  
  928.   bool is_checked;
  929.  
  930.   MCV(void) init( bool initial_value )
  931.   {
  932.     is_checked = initial_value;
  933.   }
  934.  
  935.   MCV(void) draw( uint32 x, uint32 y, dword dwBorder, dword dwBack, dword dwCheck, dword dwText, pchar title )
  936.   {
  937.     // Backround
  938.     m_pExport->draw_2d_box(x,y,12,12,dwBorder);
  939.     m_pExport->   FillRGBA(x,y,12,12,dwBack);
  940.  
  941.     // V
  942.     if ( is_checked )
  943.     {
  944.       m_pExport->FillRGBA(x+3,y+5,1,3,dwCheck);
  945.       m_pExport->FillRGBA(x+4,y+6,1,3,dwCheck);
  946.       m_pExport->FillRGBA(x+5,y+7,1,3,dwCheck);
  947.       m_pExport->FillRGBA(x+6,y+6,1,3,dwCheck);
  948.       m_pExport->FillRGBA(x+7,y+5,1,3,dwCheck);
  949.       m_pExport->FillRGBA(x+8,y+4,1,3,dwCheck);
  950.       m_pExport->FillRGBA(x+9,y+3,1,3,dwCheck);
  951.     }
  952.  
  953.     // Title
  954.     if ( title && title[0] )
  955.     {
  956.       m_pExport->draw_string(false,x+16,y,dwText, "%s",title );
  957.     }
  958.  
  959.     // clik
  960.     static bool __once = false;
  961.     if ( m_pExport->_mouse__over(x,y,20,20) )
  962.     {
  963.       if ( !__once && m_pExport->M1A_Pressed )
  964.       {
  965.         is_checked = !is_checked;
  966.         __once = true;
  967.       }
  968.     }
  969.     else
  970.     {
  971.       if ( __once && !m_pExport->M1A_Pressed )
  972.       {
  973.         __once = false;
  974.       }
  975.     }
  976.   }
  977. };
  978. struct _static
  979. {
  980.   // untested (no gui items use 'em)
  981.   // todo: use 'em
  982.  
  983.   char text[256];
  984.  
  985.   MCV(void) init( pchar title )
  986.   {
  987.     if ( title && title[0] )
  988.     {
  989.       tools::_sprintf(text,"%s",title);
  990.     }
  991.   }
  992.   MCV(void) draw( uint32 x, uint32 y, uint32 w, uint32 h, dword dwBack, dword dwText )
  993.   {
  994.     draw_rect(x,y,w,h,dwBack);
  995.  
  996.     m_pExport->draw_string(false,x+15,y,dwText,"%s",text);
  997.   }
  998. };
Advertisement
Add Comment
Please, Sign In to add comment