Advertisement
Guest User

Untitled

a guest
Jan 20th, 2019
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.08 KB | None | 0 0
  1. #include "menu.h"
  2. #include "config saving/config saving.h"
  3. /*
  4. Menu framework credits to stickrpg
  5. */
  6.  
  7. vec2_t c_menu::mouse_pos()
  8. {
  9. POINT mouse_position;
  10. GetCursorPos(&mouse_position);
  11. ScreenToClient(FindWindow(0, "Counter-Strike: Global Offensive"), &mouse_position);
  12. return { static_cast<float>(mouse_position.x), static_cast<float>(mouse_position.y) };
  13. }
  14. bool c_menu::mouse_in_params(int x, int y, int x2, int y2) {
  15. if (mouse_pos().x > x && mouse_pos().y > y && mouse_pos().x < x2 + x && mouse_pos().y < y2 + y)
  16. return true;
  17. return false;
  18. }
  19.  
  20. enum TABS {
  21. Aimbot = 0,
  22. Visuals = 1,
  23. Misc = 2,
  24. AntiAim = 3
  25.  
  26.  
  27. };
  28.  
  29. bool test = false;
  30. int testcombo = 0;
  31. int test_slider;
  32. void c_menu::draw()
  33. {
  34. static bool _pressed = true;
  35.  
  36. if (!_pressed && GetAsyncKeyState(VK_INSERT))
  37. _pressed = true;
  38. else if (_pressed && !GetAsyncKeyState(VK_INSERT))
  39. {
  40. _pressed = false;
  41. menu_opened = !menu_opened;
  42.  
  43. interfaces::inputsystem->enable_input(!menu_opened);
  44. }
  45. interfaces::engine->get_screen_size(screen_width, screen_width);
  46. static vec2_t _mouse_pos;
  47.  
  48. static int _drag_x = 300;
  49. static int _drag_y = 300;
  50. static int _width = 480;
  51. static int _height = 340;
  52.  
  53. static bool _dragging = false;
  54. bool _click = false;
  55. static bool _resizing = false;
  56. if (menu_opened)
  57. {
  58. MenuAlpha_Main = min(MenuAlpha_Main + 15, 255);
  59. MenuAlpha_Text = min(MenuAlpha_Text + 5, 255);
  60.  
  61. if (GetAsyncKeyState(VK_LBUTTON))
  62. _click = true;
  63.  
  64. vec2_t _mouse_pos = mouse_pos();
  65.  
  66. if (_dragging && !_click)
  67. _dragging = false;
  68.  
  69. if (_resizing && !_click)
  70. _resizing = false;
  71.  
  72. if (_dragging && _click)
  73. {
  74. _pos.x = _mouse_pos.x - _drag_x;
  75. _pos.y = _mouse_pos.y - _drag_y;
  76. }
  77.  
  78.  
  79. //if (_resizing && _click) {
  80. // _width = _mouse_pos.x - _pos.x;
  81. // _height = _mouse_pos.y - _pos.y;
  82.  
  83. // if (_width < 480) _width = 480;
  84. // if (_height < 340) _height = 340;
  85.  
  86. // if (_width > 960) _width = 960;
  87. // if (_height > 680) _height = 680;
  88. //}
  89.  
  90.  
  91. if (mouse_in_params(_pos.x, _pos.y, _width, _height) && !(mouse_in_params(_pos.x + 20, _pos.y + 20, _width - 10, _height - 10)))
  92. {
  93. _dragging = true;
  94. _drag_x = _mouse_pos.x - _pos.x;
  95. _drag_y = _mouse_pos.y - _pos.y;
  96. }
  97.  
  98. // if (mouse_in_params(_pos.x + 20, _pos.y + 20, _width - 10, _height - 10))
  99. // {
  100. // _resizing = true;
  101. // }
  102. }
  103. else {
  104. MenuAlpha_Main = max(MenuAlpha_Main - 15, 0);
  105. MenuAlpha_Text = max(MenuAlpha_Text - 25, 0);
  106. }
  107.  
  108. render::get().draw_filled_rect(_pos.x, _pos.y, _width, _height, color(50, 50, 50, MenuAlpha_Main));
  109.  
  110. render::get().draw_filled_rect(_pos.x, _pos.y + 21, 100, _height - 21, color(46, 46, 46, MenuAlpha_Main));
  111.  
  112. render::get().draw_filled_rect(_pos.x, _pos.y + 20, _width, 1, color(195, 141, 145, MenuAlpha_Main));
  113.  
  114. render::get().draw_filled_rect(_pos.x + 100, _pos.y + 21, 1, _height - 21, color(37, 37, 37, MenuAlpha_Main));
  115.  
  116. render::get().draw_outline(_pos.x, _pos.y, _width, _height, color(0, 0, 0, MenuAlpha_Main / 3));
  117.  
  118. render::get().draw_text(_pos.x + 10, _pos.y + 2, render::get().menu_font, "PASTE", false, color(255, 0, 0, MenuAlpha_Text));
  119.  
  120. int in_sizew = _height - 32;
  121.  
  122. static int tab_selected = 0;
  123. static const int tab_amount = 3;
  124. static std::string tab_names[tab_amount] = { "A", "B", "C", R"(D)"
  125. };
  126.  
  127. for (int i = 0; i < tab_amount; i++)
  128. {
  129. RECT text_size = render::get().GetTextSize2(render::get().tab_font, tab_names[i].c_str());
  130.  
  131. int tab_area[4] = { _pos.x, _pos.y + 20 + i * (in_sizew / tab_amount), 100, (in_sizew / tab_amount) };
  132.  
  133. if (GetAsyncKeyState(VK_LBUTTON) && mouse_in_params(tab_area[0], tab_area[1], tab_area[2], tab_area[3]))
  134. tab_selected = i;
  135.  
  136. if (tab_selected == i)
  137. render::get().draw_text(tab_area[0] + (tab_area[2] / 2) - (text_size.right / 2), tab_area[1] + (tab_area[3] / 2) - (text_size.bottom / 2), render::get().tab_font, tab_names[i].c_str(), false, color(185, 185, 185, MenuAlpha_Text));
  138. else
  139. render::get().draw_text(tab_area[0] + (tab_area[2] / 2) - (text_size.right / 2), tab_area[1] + (tab_area[3] / 2) - (text_size.bottom / 2), render::get().tab_font, tab_names[i].c_str(), false, color(125, 125, 125, MenuAlpha_Text));
  140. }
  141.  
  142. if (tab_selected == Visuals) {
  143. groupbox(106, 31, 180, 300, "players");
  144. checkbox("active", &c_config::get().visuals_enabled);
  145. checkbox("name", &c_config::get().player_name);
  146. checkbox("box", &c_config::get().player_box);
  147. checkbox("health", &c_config::get().player_health);
  148. checkbox("weapon", &c_config::get().player_weapon);
  149. checkbox("armor", &c_config::get().player_armor);
  150. checkbox("chams", &c_config::get().chams);
  151. static std::string test_combobox[7] = { "platinum", "glass", "crystal clear", "gold", "chrome", "plastic", "crystal blue" };
  152.  
  153. if (c_config::get().chams) {
  154. combobox(7, "cham material", test_combobox, &c_config::get().cham_material);
  155. }
  156.  
  157.  
  158. groupbox(294, 31, 180, 300, "effects");
  159. checkbox("force crosshair", &c_config::get().force_crosshair);
  160. slider(10, "viewmodel x", &c_config::get().viewmodel_x, "%", 1);
  161. slider(10, "viewmodel y", &c_config::get().viewmodel_y, "%", 1);
  162. slider(20, "viewmodel z", &c_config::get().viewmodel_z, "%", 1);
  163. slider(135, "field of view", &c_config::get().fov, "%", 1);
  164. }
  165. else if (tab_selected == Misc) {
  166. groupbox(106, 31, 180, 300, "Main");
  167.  
  168. groupbox(294, 31, 180, 300, "Config");
  169. checkbox("save", &c_config::get().misc_save_config);
  170. checkbox("load", &c_config::get().misc_load_config);
  171. }
  172.  
  173. if (c_config::get().misc_save_config) {
  174. Config->Save();
  175. c_config::get().misc_save_config = false;
  176. }
  177.  
  178. if (c_config::get().misc_load_config) {
  179. Config->Load();
  180. c_config::get().misc_load_config = false;
  181. }
  182.  
  183. }
  184.  
  185. void c_menu::draw_radar()
  186. {
  187.  
  188.  
  189. static int _drag_x = 300;
  190. static int _drag_y = 300;
  191. static int _width = 200;
  192. static int _height = 200;
  193.  
  194. static bool _dragging = false;
  195. bool _click = false;
  196. static bool _resizing = false;
  197.  
  198.  
  199. if (GetAsyncKeyState(VK_LBUTTON))
  200. _click = true;
  201.  
  202. vec2_t _mouse_pos = mouse_pos();
  203.  
  204. if (_dragging && !_click)
  205. _dragging = false;
  206.  
  207. if (_resizing && !_click)
  208. _resizing = false;
  209.  
  210. if (_dragging && _click)
  211. {
  212. _pos_radar.x = _mouse_pos.x - _drag_x;
  213. _pos_radar.y = _mouse_pos.y - _drag_y;
  214. }
  215.  
  216. if (mouse_in_params(_pos_radar.x, _pos_radar.y, _width, _height) && !(mouse_in_params(_pos_radar.x + 20, _pos_radar.y + 20, _width - 10, _height - 10)))
  217. {
  218. _dragging = true;
  219. _drag_x = _mouse_pos.x - _pos_radar.x;
  220. _drag_y = _mouse_pos.y - _pos_radar.y;
  221. }
  222.  
  223. //
  224.  
  225. render::get().draw_filled_rect(_pos_radar.x, _pos_radar.y, _width, _height, color(50, 50, 50, 255));
  226.  
  227. render::get().draw_filled_rect(_pos_radar.x, _pos_radar.y + 20, _width, _height - 20, color(46, 46, 46, 255));
  228.  
  229. render::get().draw_filled_rect(_pos_radar.x, _pos_radar.y + 20, _width, 1, color(195, 141, 145, 255));
  230.  
  231. render::get().draw_outline(_pos_radar.x, _pos_radar.y, _width, _height, color(0, 0, 0, 255 / 3));
  232.  
  233. render::get().draw_text(_pos_radar.x + 10, _pos_radar.y + 2, render::get().menu_font, "radar", false, color(180, 180, 180, 255));
  234. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement