Advertisement
Guest User

Untitled

a guest
Jul 18th, 2010
256
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 22.67 KB | None | 0 0
  1. /*LTFX Menu Advanced
  2. s0beit & GHOSTER - created the first version of LTFX Menu
  3. NeoIII - ReCoded full menu:
  4. - added automated Item Settings loading and saving option.
  5. - added possibility to add random count of 'describe' chars for addmenuitem func.
  6. - added Menu Group system.
  7. - added menuitem Hotkeys. ( i am not anymore sure if they was there on original version )
  8. - added Drag&Drop funcionality.
  9. - added navigation support for mouse & keys + handling keys with 'ProcKeyHook' ( SetWindowLong( ... ) on the Game Window )
  10. - tweaked and changed here and there... you can look yourself...
  11. Hans211 - Transparent Draw Functions ( i left them out here, sry )
  12. Last Update - 01.01.2010 by NeoIII
  13. */
  14. #include <windows.h>
  15. #include "cltfx.h"
  16. #include <stdio.h>
  17. #include <math.h>
  18. //#define _CRT_SECURE_NO_WARNINGS
  19.  
  20. extern cMenu menu;
  21.  
  22. cMenu::cMenu( int MAX_MENU, int MAX_GROUP )
  23. {
  24. MAX_ITEMS = 0;
  25. MAX_GROUPS = 0;
  26. menuItem = new pItem[ MAX_MENU ];
  27. menuGroup = new pGroup[ MAX_GROUP ];
  28. this->bMenu = false;
  29. this->bMusic = false;
  30. }
  31.  
  32. /*
  33. cMenu::~cMenu()
  34. {
  35. MAX_ITEMS = 0;
  36. MAX_GROUPS = 0;
  37. delete menuItem;
  38. delete menuGroup;
  39. }
  40. */
  41. void cMenu::SetActiveMode( bool m_bMode ) { bMenu = m_bMode; }
  42. //void cMenu::SetMusicMode( bool m_bMode ) { bMusic = m_bMode; }
  43. void cMenu::SetColor( int type, const D3DCOLOR color ) { MenuColors[type] = 0; MenuColors[type] = color; }
  44. void cMenu::SetInitialCoords( int x, int y ) { menuPos.x = ( x > 0 ) ? x : 1; menuPos.y = ( y > 0 ) ? y : 1; }
  45. //void cMenu::SetSettingFile( char *SettingsFile ) { strncpy( szSettingsFile, SettingsFile, 256 ); bCanUseSettings = false; }
  46. void cMenu::InitializeMenu( void ) { bInitialized = true; }
  47.  
  48. void cMenu::InitalizeFont(char *font, int size, IDirect3DDevice9* pD3Ddev)
  49. {
  50. menuFont = new CD3DFont(font, size, 0);
  51. menuFont->InitDeviceObjects(pD3Ddev);
  52. menuFont->RestoreDeviceObjects();
  53. this->FontCreated = true;
  54. this->firstInit = true;
  55. }
  56.  
  57. void cMenu::PostReset(char *font, int size, IDirect3DDevice9* pD3Ddev)
  58. {
  59. if(menuFont == NULL)
  60. {
  61. menuFont = new CD3DFont(font, size,0);
  62. menuFont->InitDeviceObjects(pD3Ddev);
  63. menuFont->RestoreDeviceObjects();
  64. this->FontCreated = true;
  65. }
  66. }
  67.  
  68. void cMenu::PreReset( void )
  69. {
  70. if(menuFont)
  71. {
  72. menuFont->InvalidateDeviceObjects();
  73. menuFont->DeleteDeviceObjects();
  74. menuFont = NULL;
  75. this->FontCreated = false;
  76. }
  77. }
  78.  
  79. int cMenu::AddMenuGroup(char title[20])
  80. {
  81. if( !bInitialized )return -1;
  82.  
  83. int index = MAX_GROUPS;
  84. strncpy( menuGroup[index].title, title, 20 );
  85. menuGroup[index].value = 0.00f;
  86. menuGroup[index].GroupID= index;
  87. menuGroup[index].min = 0;
  88. menuGroup[index].max = 1;
  89.  
  90. if( !menuGroup[index].settings && bCanUseSettings )
  91. {
  92. char VarKey[20] = {0};
  93. strncpy( VarKey, title, 20);
  94. menuGroup[index].settings = true;
  95. menuGroup[index].value = 0;
  96. if( menuGroup[index].value > menuGroup[index].max )
  97. menuGroup[index].value = ( float )menuGroup[index].max;
  98. if( menuGroup[index].value < menuGroup[index].min)
  99. menuGroup[index].value = ( float )menuGroup[index].min;
  100. }
  101. MAX_GROUPS++;
  102. return index;
  103. }
  104.  
  105. int cMenu::AddMenuItem(char title[20], float *cvar, int min, int max, int GroupID, int vKey, char *Opt, ...)
  106. {
  107. if( !bInitialized )return -1;
  108. if( MAX_GROUPS < GroupID )return -1;
  109.  
  110. int index = MAX_ITEMS;
  111. strncpy( menuItem[index].title, title, 20 );
  112. menuItem[index].value = cvar;
  113. menuItem[index].max = max;
  114. menuItem[index].min = min;
  115. menuItem[index].GroupID = GroupID;
  116.  
  117. if( !menuItem[index].settings && bCanUseSettings )
  118. {
  119. char VarKey[20] = {0};
  120. strncpy( VarKey, title, 20);
  121. menuItem[index].settings = true;
  122. menuItem[index].value[0] = 0;
  123. if( menuItem[index].value[0] > max )
  124. menuItem[index].value[0] = ( float )max;
  125. if( menuItem[index].value[0] < min)
  126. menuItem[index].value[0] = ( float )min;
  127. }
  128. if( vKey == 0 && bCanUseSettings )
  129. {
  130. char VarKey[20] = {0};
  131. strncpy( VarKey, title, 20);
  132. menuItem[index].vKey = 0;
  133. }
  134. else
  135. menuItem[index].vKey = vKey;
  136.  
  137. if( Opt != NULL )
  138. {
  139. menuItem[index].useDesc = true;
  140. va_list vl;
  141. int i = 0;
  142. char* str=Opt;
  143. va_start(vl,Opt);
  144. do {
  145. strncpy( menuItem[index].desc[i], str, 50);
  146. str=va_arg(vl,char*);
  147. i++;
  148. } while (str!=NULL);
  149. va_end(vl);
  150. } else
  151. menuItem[index].useDesc = false;
  152.  
  153. MAX_ITEMS++;
  154. return index;
  155. }
  156.  
  157. void cMenu::SaveMenuSettings( void )
  158. {
  159. if( !bInitialized || !bCanUseSettings )return;
  160.  
  161. for( int i = 0; i <= ( MAX_GROUPS - 1 ); i++ )
  162. {
  163. char VarKey[20] = {0};
  164. strncpy( VarKey, menuGroup[i].title, 20);
  165. }
  166. for( int i = 0; i <= ( MAX_ITEMS - 1 ); i++)
  167. {
  168. char VarKey[20] = {0};
  169. strncpy( VarKey, menuItem[i].title, 20);
  170. }
  171. }
  172.  
  173. int cMenu::GetMaxItemsToDraw( void )
  174. {
  175. if( !bInitialized )return -1;
  176.  
  177. int ItemsToDraw = 0;
  178. for( int i = 0; i <= ( MAX_GROUPS - 1 ); i++ )
  179. {
  180. ItemsToDraw++;
  181. if(menuGroup[i].value)
  182. {
  183. for( int f = 0; f <= ( MAX_ITEMS - 1 ); f++)
  184. {
  185. if(menuItem[f].GroupID == menuGroup[i].GroupID)
  186. ItemsToDraw++;
  187. }
  188. }
  189. }
  190. return ItemsToDraw-1;
  191. }
  192.  
  193. int cMenu::GetMaxItemsInGroup( int index )
  194. {
  195. if( !bInitialized )return -1;
  196.  
  197. int Items = 0;
  198. for( int i = 0; i <= ( MAX_ITEMS - 1 ); i++)
  199. {
  200. if(menuItem[i].GroupID == index)
  201. Items++;
  202. }
  203. return Items;
  204. }
  205.  
  206. int cMenu::GetRealIterator( int Item, int &Type )
  207. {
  208. if( !bInitialized )return false;
  209.  
  210. int Items = 0;
  211.  
  212. for( int i = 0; i <= ( MAX_GROUPS - 1 ); i++ )
  213. {
  214. if( Items == Item )
  215. {
  216. Type = T_GROUP;
  217. return i;
  218. }
  219. Items++;
  220.  
  221. if(menuGroup[i].value)
  222. {
  223. for( int f = 0; f <= ( MAX_ITEMS - 1 ); f++)
  224. {
  225. if(menuItem[f].GroupID == menuGroup[i].GroupID)
  226. {
  227. if( Items == Item )
  228. {
  229. Type = T_ITEM;
  230. return f;
  231. }
  232. Items++;
  233. }
  234. }
  235. }
  236. }
  237. return -1;
  238. }
  239.  
  240. void cMenu::DisableAllMenuItems()
  241. {
  242. if( !bInitialized )return;
  243.  
  244. curItem = 0;
  245.  
  246. for (int i = 0; i <= ( MAX_ITEMS - 1 ); i++)
  247. menuItem[i].value[0] = 0.00f;
  248.  
  249. for( int i = 0; i <= ( MAX_GROUPS - 1 ); i++ )
  250. menuGroup[i].value = 0.00f;
  251. }
  252.  
  253. bool cMenu::IsMouseInVector( int x, int y, int w, int h )
  254. {
  255. return (( m_mouse.x >= x )&&( m_mouse.x <= ( x + w ) )&&( m_mouse.y >= y )&&( m_mouse.y <= ( y + h ) )) ? true : false;
  256. }
  257.  
  258. void cMenu::DrawMenu( char* title, IDirect3DDevice9* pDevice )
  259. {
  260. if( !bMenu || !bInitialized )return;
  261. int x = menuPos.x;
  262. int y = menuPos.y;
  263. int curDrawItem = 0;
  264.  
  265. int MaxItems = GetMaxItemsToDraw( );
  266. if( MaxItems < 1 || MAX_GROUPS < 1 || MAX_ITEMS < 1 )
  267. return;
  268. /*====================================================*/
  269. DrawBox( (x-10), y, 170, 23, MenuColors[C_BOX_BORDER], MenuColors[C_BOX], pDevice );
  270. DrawGameTextPixel( (x + 3), (y + 4), MenuColors[C_BOX], title ); y += 35;
  271. DrawBox( (x-10), (y-10), 170, ((MaxItems*13) + 35), MenuColors[C_BOX_BORDER], MenuColors[C_BOX], pDevice );
  272. /*====================================================*/
  273.  
  274. for( int i = 0; i <= ( MAX_GROUPS - 1 ); i++ )
  275. {
  276. D3DCOLOR GroupColor = MenuColors[C_DEFAULT];
  277. if( IsMouseInVector( (menuPos.x + 5), ( ( menuPos.y + 36 ) + (curDrawItem * 13) ), 120, 10 ) )
  278. GroupColor = MenuColors[C_MOUSEOVER];
  279. else if( curDrawItem == curItem )
  280. GroupColor = MenuColors[C_SELECTED];
  281. else
  282. GroupColor = MenuColors[C_GROUP];
  283.  
  284. DrawGameTextPixel( x, y + (curDrawItem * 13), GroupColor, menuGroup[i].title);
  285. DrawGameTextPixel( x + 120, y + (curDrawItem * 13), GroupColor, ( menuGroup[i].value ) ? "+" : "-" );
  286. curDrawItem++;
  287.  
  288. if(menuGroup[i].value)
  289. {
  290. for( int f = 0; f <= ( MAX_ITEMS - 1 ); f++)
  291. {
  292. if(menuItem[f].GroupID == menuGroup[i].GroupID)
  293. {
  294. D3DCOLOR DrawColor = MenuColors[C_DEFAULT];
  295. if( IsMouseInVector( (menuPos.x + 5), ( ( menuPos.y + 36 ) + (curDrawItem * 13) ), 120, 10 ) )
  296. DrawColor = MenuColors[C_MOUSEOVER];
  297. else if( curDrawItem == curItem )
  298. DrawColor = MenuColors[C_SELECTED];
  299. else if( menuItem[f].value[0] )
  300. DrawColor = MenuColors[C_ACTIVATED];
  301.  
  302. DrawGameTextPixel( x + 10, y + (curDrawItem * 13), DrawColor, menuItem[f].title);
  303. if( ( int )menuItem[f].max != 1 && ( int )menuItem[f].value[0] != 0 )
  304. {
  305. if( menuItem[f].useDesc )
  306. DrawGameTextPixel( x + 130, y + (curDrawItem * 13), DrawColor, menuItem[f].desc[(int)menuItem[f].value[0]-1] );
  307. else
  308. DrawGameTextPixel( x + 130, y + (curDrawItem * 13), DrawColor, "%2.2f", menuItem[f].value[0] );
  309. } else {
  310. DrawGameTextPixel( x + 130, y + (curDrawItem * 13), DrawColor, ( ( int )menuItem[f].value[0] ) ? "On" : "Off" );
  311. }
  312. curDrawItem++;
  313. }
  314. }
  315. }
  316. }
  317. }
  318. /*
  319. void cMenu::HandleItemHotkeys( WPARAM wKey )
  320. {
  321. if( !bInitialized )return;
  322.  
  323. for (int i = 0; i <= ( MAX_ITEMS - 1 ); i++)
  324. {
  325. if( menuItem[i].vKey == NULL )continue;
  326. if( wKey == menuItem[i].vKey )
  327. {
  328. float iNextValue = ( menuItem[i].value[0] + 1 );
  329.  
  330. if( iNextValue <= menuItem[i].max )
  331. {
  332. menuItem[i].value[0]++;
  333. }
  334.  
  335. if( iNextValue > menuItem[i].max )
  336. {
  337. menuItem[i].value[0] = ( float )menuItem[i].min;
  338. }
  339. }
  340. }
  341. }
  342. */
  343. /*
  344. void cMenu::HandleKeyNavigation()
  345. {
  346. if( bMenu == false || bInitialized == false )return;
  347.  
  348. if(GetAsyncKeyState(VK_UP)&1)
  349. {
  350. if( curItem <= 0 )
  351. curItem = GetMaxItemsToDraw( ) + 1;
  352. if( curItem > 0 )
  353. curItem--;
  354. }
  355.  
  356. if(GetAsyncKeyState(VK_DOWN)&1)
  357. {
  358. if( curItem >= GetMaxItemsToDraw( ) )
  359. curItem = ( 0 - 1 );
  360. if( curItem < GetMaxItemsToDraw( ) )
  361. curItem++;
  362. }
  363.  
  364. if(GetAsyncKeyState(VK_RIGHT)&1)
  365. {
  366. int iType = -1;
  367. int iterator = GetRealIterator(curItem,iType);
  368. if( iterator == -1 )return;
  369.  
  370. if( iType == T_GROUP )
  371. {
  372. if( menuGroup[iterator].value < menuGroup[iterator].max )
  373. {
  374. menuGroup[iterator].value++;
  375. }
  376. } else if( iType == T_ITEM ) {
  377. if( menuItem[iterator].value[0] < menuItem[iterator].max )
  378. {
  379. menuItem[iterator].value[0]++;
  380. }
  381. }
  382. }
  383.  
  384. if(GetAsyncKeyState(VK_LEFT )&1)
  385. {
  386. int iType = -1;
  387. int iterator = GetRealIterator(curItem,iType);
  388. if( iterator == -1 )return;
  389.  
  390. if( iType == T_GROUP )
  391. {
  392. if( menuGroup[iterator].value > menuGroup[iterator].min )
  393. {
  394. menuGroup[iterator].value--;
  395. }
  396. } else if( iType == T_ITEM ) {
  397. if( menuItem[iterator].value[0] > menuItem[iterator].min )
  398. {
  399. menuItem[iterator].value[0]--;
  400. }
  401. }
  402. }
  403. }
  404. */
  405. /*
  406. void cMenu::HandleMouseNavigation( WPARAM wKey )
  407. {
  408. if( bMenu == false || bInitialized == false || moving[0] || moving[1] || moving[2] )return;
  409.  
  410. int curNavItem = 0;
  411. for( int i = 0; i <= ( MAX_GROUPS - 1 ); i++ )
  412. {
  413. if( IsMouseInVector( (menuPos.x + 5), ( ( menuPos.y + 36 ) + (curNavItem * 13) ), 120, 10 ) && m_mouse.m_bIsLeftSingleClicked )
  414. {
  415. //Groups
  416. float fNextValue = ( menuGroup[i].value + 1 );
  417.  
  418. if( fNextValue <= menuGroup[i].max )
  419. {
  420. menuGroup[i].value++;
  421. if( curItem > curNavItem )curItem += GetMaxItemsInGroup( menuGroup[i].GroupID );
  422. }
  423.  
  424. if( fNextValue > menuGroup[i].max )
  425. {
  426. menuGroup[i].value = ( float )menuGroup[i].min;
  427. if( curItem > curNavItem )curItem -= GetMaxItemsInGroup( menuGroup[i].GroupID );
  428. }
  429.  
  430. if( curItem < 0 )curItem = 0;
  431. if( curItem > GetMaxItemsToDraw( ) )curItem = GetMaxItemsToDraw( );
  432. }
  433. curNavItem++;
  434.  
  435. if(menuGroup[i].value)
  436. {
  437. for( int f = 0; f <= ( MAX_ITEMS - 1 ); f++)
  438. {
  439. if(menuItem[f].GroupID == menuGroup[i].GroupID)
  440. {
  441. if( IsMouseInVector( (menuPos.x + 5), ( ( menuPos.y + 36 ) + (curNavItem * 13) ), 120, 10 ) && m_mouse.m_bIsLeftSingleClicked )
  442. {
  443. //MenuItems
  444. float fNextValue = ( menuItem[f].value[0] + 1 );
  445.  
  446. if( fNextValue <= menuItem[f].max )
  447. menuItem[f].value[0]++;
  448.  
  449. if( fNextValue > menuItem[f].max )
  450. menuItem[f].value[0] = ( float )menuItem[f].min;
  451. }
  452. curNavItem++;
  453. }
  454. }
  455. }
  456. }
  457. }
  458. */
  459. void cMenu::DragMenuWindow(void)
  460. {
  461. if( bMenu == false || bInitialized == false || menu.moving[1] || menu.moving[2])return;
  462.  
  463. if (m_mouse.m_bIsLeftHeld)
  464. {
  465. if( IsMouseInVector(menuPos.x-20,menuPos.y-20,170,40) )
  466. {
  467. menuPos.x = ( m_mouse.x - 30 );
  468. menuPos.y = ( m_mouse.y - 10 );
  469. moving[0] = true;
  470. }
  471. } else {
  472. moving[0] = false;
  473. }
  474. }
  475.  
  476. void cMenu::MenuNav(void)
  477. {
  478. // my menu navigation here
  479. }
  480.  
  481. /*
  482. void cMenu::HandleKeys( WPARAM wParams, LPARAM lParams, UINT msg )
  483. {
  484. //store the left click state for single-click checking
  485. bool m_bLeftClickOldState = m_mouse.m_bIsLeftSingleClicked;
  486.  
  487. //clear the old data...sucka!
  488. m_mouse.m_bIsRightClicked = false;
  489. m_mouse.m_bIsLeftSingleClicked = false;
  490. m_mouse.m_bIsMiddleClicked = false;
  491. m_mouse.m_bIsLeftHeld = false;
  492.  
  493. if( msg == WM_KEYDOWN )
  494. {
  495. if( GetAsyncKeyState(VK_INSERT)&1 || GetAsyncKeyState(VK_F12)&1 )
  496. {
  497. SetActiveMode( !bMenu );
  498. } else {
  499. //HandleKeyNavigation();
  500. //HandleItemHotkeys( wParams );
  501. }
  502. }
  503.  
  504. if( msg == WM_NCHITTEST )
  505. {
  506. m_mouse.x = ( ( int )( short )LOWORD( lParams ) );
  507. m_mouse.y = ( ( int )( short )HIWORD( lParams ) );
  508. }
  509. //when we don't check msg, this means its being held ( useful for dragging windows )
  510. m_mouse.m_bIsRightClicked = ( wParams == MK_RBUTTON ) ? true : false;
  511. m_mouse.m_bIsLeftHeld = ( wParams == MK_LBUTTON ) ? true : false;
  512. m_mouse.m_bIsMiddleClicked = ( wParams == MK_MBUTTON ) ? true : false;
  513.  
  514. if( m_bLeftClickOldState == false )
  515. {
  516. m_mouse.m_bIsLeftSingleClicked = ( msg == WM_LBUTTONDOWN && wParams == MK_LBUTTON );
  517. }
  518. DragMenuWindow();
  519. HandleMouseNavigation( wParams );
  520. }
  521. */
  522.  
  523. //Draw Funcs
  524. void cMenu::DrawText( int x, int y, DWORD color, char *szFormat, ... )
  525. {
  526. if( !szFormat )return;
  527.  
  528. char logbuf[256] = { 0 };
  529.  
  530. va_list va_alist;
  531. va_start (va_alist, szFormat);
  532. _vsnprintf(logbuf, sizeof(logbuf), szFormat, va_alist);
  533. va_end (va_alist);
  534.  
  535. RECT font_rect;
  536. SetRect( &font_rect, x, y, 0, 0 );
  537. menuFont->DrawText( ( FLOAT )x, ( FLOAT )y, color, logbuf );
  538. }
  539.  
  540. void cMenu::DrawGameTextPixel(int x, int y, DWORD color, char *szFormat, ... )
  541. {
  542. if( !szFormat )return;
  543.  
  544. char logbuf[256] = { 0 };
  545.  
  546. va_list va_alist;
  547. va_start (va_alist, szFormat);
  548. _vsnprintf(logbuf, sizeof(logbuf), szFormat, va_alist);
  549. va_end (va_alist);
  550.  
  551. menuFont->DrawText((float)x+1, (float)y, D3DCOLOR_ARGB( 255, 0, 0, 0 ), logbuf);
  552. menuFont->DrawText((float)x-1, (float)y, D3DCOLOR_ARGB( 255, 0, 0, 0 ), logbuf);
  553. menuFont->DrawText((float)x, (float)y+1, D3DCOLOR_ARGB( 255, 0, 0, 0 ), logbuf);
  554. menuFont->DrawText((float)x, (float)y-1, D3DCOLOR_ARGB( 255, 0, 0, 0 ), logbuf);
  555.  
  556. //menuFont->DrawText((float)x, (float)y, color, logbuf, D3DFONT_SHADOW);
  557. menuFont->DrawText((float)x, (float)y, color, logbuf);
  558. }
  559.  
  560. int cMenu::GetTextWidth(char* text)
  561. {
  562. SIZE Size = {0,0};
  563. if( menuFont->GetTextExtent(text,&Size) == S_OK )
  564. return Size.cx;
  565. return 0;
  566. }
  567.  
  568. void cMenu::FillRGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
  569. {
  570. if( w < 0 )w = 1;
  571. if( h < 0 )h = 1;
  572. if( x < 0 )x = 1;
  573. if( y < 0 )y = 1;
  574.  
  575. D3DRECT rec = { x, y, x + w, y + h };
  576. pDevice->Clear( 1, &rec, D3DCLEAR_TARGET, color, 0, 0 );
  577. }
  578.  
  579. void cMenu::FillARGB( int x, int y, int w, int h, D3DCOLOR color, IDirect3DDevice9* pDevice )
  580. {
  581. //Transparent Draw Func by Hans211, removed.
  582. //do it yourself you dont really need it...
  583. FillRGB( x, y, w, h, color, pDevice );
  584. }
  585.  
  586. void cMenu::FillARGBGradient( int x, int y, int w, int h, D3DCOLOR color1, DWORD color2, IDirect3DDevice9* pDevice )
  587. {
  588. //removed.
  589. //do it yourself you dont really need it...
  590. }
  591.  
  592. void cMenu::DrawBorder( int x, int y, int w, int h, int px, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
  593. {
  594. FillARGB( x, (y + h - px), w, px, BorderColor, pDevice );
  595. FillARGB( x, y, px, h, BorderColor, pDevice );
  596. FillARGB( x, y, w, px, BorderColor, pDevice );
  597. FillARGB( (x + w - px), y, px, h, BorderColor, pDevice );
  598. }
  599.  
  600. void cMenu::DrawBox( int x, int y, int w, int h, D3DCOLOR BoxColor, D3DCOLOR BorderColor, IDirect3DDevice9* pDevice )
  601. {
  602. FillARGB( x, y, w, h, BoxColor, pDevice );
  603. DrawBorder( x, y, w, h, 1, BorderColor, pDevice );
  604. }
  605.  
  606. void cMenu::DrawHealthBox( int x, int y, DWORD m_dColorOut, DWORD m_dColorIn, int m_iHealth, int m_iMaxHealth, IDirect3DDevice9* pDevice )
  607. {
  608. float mx = ( float )m_iMaxHealth / 4;
  609. float w = ( float )m_iHealth / 4;
  610. x -= ( ( int )mx / 2 );
  611.  
  612. //background
  613. FillARGB( x, y, ( int )mx, 4, m_dColorOut, pDevice );
  614. //inside
  615. FillARGB( x, y, ( int )w, 4, m_dColorIn, pDevice );
  616. //outline
  617. DrawBorder( x - 1, y - 1, ( int )mx + 2, 6, 1, D3DCOLOR_ARGB( 255, 30, 30, 30 ), pDevice );
  618. }
  619. /*
  620. void cMenu::DrawMouse( IDirect3DDevice9* pDevice, bool DrawIt )
  621. {
  622. if( bMenu == false && !DrawIt )return;
  623.  
  624. DWORD black = D3DCOLOR_ARGB( 255, 0, 0, 0 );
  625. DWORD color = D3DCOLOR_ARGB( 255, 0, 0, 255 );
  626. int x = m_mouse.x, y = m_mouse.y;
  627.  
  628. //removed, thats a stylie thing that you can do yourself :)
  629. }
  630.  
  631. void cMenu::DrawRadar( int x, int y, int size, IDirect3DDevice9* pDevice )
  632. {
  633. //not needed on the menu but well i used it...
  634. //int x = 300, y = 300, size = 150;
  635. DrawBox( x, y, size, size, D3DCOLOR_ARGB( 150, 51, 51, 51 ), D3DCOLOR_ARGB( 250, 25, 220, 251 ), pDevice );
  636. DrawBox( (x+5), (y+5), (size-10), (size-10), D3DCOLOR_ARGB( 255, 31, 31, 31 ), D3DCOLOR_ARGB( 255, 184, 184, 184 ), pDevice );
  637. FillARGB( (x+(size/2)), (y+6), 1, (size-12), D3DCOLOR_ARGB( 255, 0, 255, 0 ), pDevice );
  638. FillARGB( (x+6), (y+(size/2)), (size-12), 1, D3DCOLOR_ARGB( 255, 0, 255, 0 ), pDevice );
  639. }
  640.  
  641. void cMenu::DrawDot( int x, int y, int r, int g, int b, IDirect3DDevice9* pDevice )
  642. {
  643. DWORD color = D3DCOLOR_ARGB( 255, r, g, b );
  644. FillRGB(x-1,y-1,2,2,color,pDevice);
  645. }
  646. */
  647. void cMenu::DrawLine(int x1, int y1, int x2, int y2, D3DCOLOR col, IDirect3DDevice9* pDevice)
  648. {
  649. const DWORD D3D_FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;
  650. LineVertex points[2] =
  651. {
  652. { (float)x1, (float)y1, 0.0f, 0.0f, col, 1.0f, 1.0f },
  653. { (float)x2, (float)y2, 0.0f, 0.0f, col, 1.0f, 1.0f },
  654. };
  655. //allow for translucency
  656. pDevice->SetRenderState( D3DRS_ALPHABLENDENABLE,true );
  657. pDevice->SetRenderState( D3DRS_ZENABLE, D3DZB_FALSE );
  658. pDevice->SetRenderState( D3DRS_FOGENABLE, false );
  659.  
  660. pDevice->SetFVF(D3D_FVF);
  661. pDevice->SetTexture(0, NULL);
  662. pDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, 1, points, sizeof(LineVertex));
  663. }
  664.  
  665. LineVertex cMenu::CreateD3DTLVERTEX (float X, float Y, float Z, float RHW, D3DCOLOR color, float U, float V) { LineVertex v = {X,Y,Z,RHW,color,U,V}; return v; }
  666.  
  667. void cMenu::DrawCircle(int x, int y, float radius, D3DCOLOR color, IDirect3DDevice9* pDevice)
  668. {
  669. //cool for Sphere ESP :D
  670. const DWORD D3D_FVF = D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1;
  671. const int NUMPOINTS = 24;
  672. const float PI = ( float )3.141592654f;
  673. LineVertex Circle[NUMPOINTS + 1];
  674. float X, Y, Theta, WedgeAngle;
  675. WedgeAngle = (float)((2*PI) / NUMPOINTS);
  676.  
  677. for(int i=0; i<=NUMPOINTS; i++)
  678. {
  679. Theta = i * WedgeAngle;
  680. X = (float)(x + radius * cos(Theta));
  681. Y = (float)(y - radius * sin(Theta));
  682. Circle[i] = CreateD3DTLVERTEX(X, Y, 0.0f, 1.0f, color, 0.0f, 0.0f);
  683. }
  684. pDevice->SetFVF(D3D_FVF);
  685. pDevice->SetTexture(0, NULL);
  686. pDevice->DrawPrimitiveUP(D3DPT_LINESTRIP, NUMPOINTS, &Circle[0], sizeof(Circle[0]));
  687. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement