Advertisement
Guest User

Untitled

a guest
Jan 25th, 2020
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.79 KB | None | 0 0
  1. #include "menu.hpp"
  2. #include <d3d9.h>
  3. #include <d3dx9.h>
  4. #include "../sdk/helper/render.hpp"
  5. #include "tab_font.hpp"
  6.  
  7. #define NK_INCLUDE_FIXED_TYPES
  8. #define NK_INCLUDE_STANDARD_IO
  9. #define NK_INCLUDE_STANDARD_VARARGS
  10. #define NK_INCLUDE_DEFAULT_ALLOCATOR
  11. #define NK_INCLUDE_VERTEX_BUFFER_OUTPUT
  12. #define NK_INCLUDE_FONT_BAKING
  13. #define NK_INCLUDE_DEFAULT_FONT
  14. #define NK_IMPLEMENTATION
  15. #define NK_D3D9_IMPLEMENTATION
  16. #include "framework/nuklear.h"
  17. #include "framework/nuklear_d3d9.h"
  18.  
  19. menu_t::~menu_t()
  20. {
  21. nk_d3d9_shutdown();
  22. }
  23.  
  24.  
  25. struct nk_image legitbot_icon;
  26. struct nk_image ragebot_icon;
  27. struct nk_image visuals_icon;
  28. struct nk_image misc_icon;
  29. struct nk_image inventory_icon;
  30. struct nk_image settings_icon;
  31.  
  32.  
  33. static int tab_state = 1;
  34. bool font_init = false;
  35.  
  36.  
  37. NK_API int nk_tab(struct nk_context* ctx, const char* title, int icon, int active)
  38. {
  39.  
  40. struct nk_style_item c = ctx->style.button.normal;
  41. if (active) { ctx->style.button.normal = ctx->style.button.active; }
  42. int r = nk_button_label(ctx, title, icon);
  43. ctx->style.button.normal = c;
  44. return r;
  45. }
  46.  
  47.  
  48. auto menu_t::gui() -> void
  49. {
  50.  
  51. if (nk_begin(ctx, "cookiecheat alpha", nk_rect(50, 50, 800, 600), NK_WINDOW_BORDER | NK_WINDOW_MOVABLE | NK_WINDOW_TITLE)) {
  52.  
  53.  
  54. nk_layout_row_static(ctx, 40, 200, 1);
  55. if (nk_tab(ctx, "Legitbot", 1, tab_state == 1)) {
  56. tab_state = 1;
  57. }
  58. nk_layout_row_static(ctx, 40, 200, 1);
  59. if (nk_tab(ctx, "Ragebot", 2, tab_state == 2)) {
  60. tab_state = 2;
  61. }
  62. nk_layout_row_static(ctx, 40, 200, 1);
  63. if (nk_tab(ctx, "Visuals", 3, tab_state == 3)) {
  64. tab_state = 3;
  65. }
  66. nk_layout_row_static(ctx, 40, 200, 1);
  67. if (nk_tab(ctx, "Misc", 4, tab_state == 4)) {
  68. tab_state = 4;
  69. }
  70. nk_layout_row_static(ctx, 40, 200, 1);
  71. if (nk_tab(ctx, "Inventory", 5, tab_state == 5)) {
  72. tab_state = 5;
  73. }
  74. nk_layout_row_static(ctx, 40, 200, 1);
  75. if (nk_tab(ctx, "Settings", 6, tab_state == 6)) {
  76. tab_state = 6;
  77. }
  78.  
  79. if(tab_state == 1) {
  80. }
  81. else if (tab_state == 2) {
  82. }
  83. else if (tab_state == 3) {
  84. }
  85. else if (tab_state == 4) {
  86. }
  87. else if (tab_state == 5) {
  88. }
  89. else if (tab_state == 6) {
  90. }
  91. }
  92. nk_end(ctx);
  93. }
  94.  
  95. auto menu_t::initialize(IDirect3DDevice9* device) -> void
  96. {
  97. is_initialized = true;
  98.  
  99. auto viewport = D3DVIEWPORT9();
  100. device->GetViewport(&viewport);
  101. ctx = nk_d3d9_init(device, viewport.Width, viewport.Height);
  102.  
  103. struct nk_font_atlas* atlas_menu = nullptr;
  104. struct nk_font_atlas* atlas_tabs = nullptr;
  105. struct nk_font_config config_menu = nk_font_config(17);
  106. struct nk_font_config config_tabs = nk_font_config(30);
  107.  
  108.  
  109. nk_d3d9_font_stash_begin(&atlas_menu);
  110. struct nk_font* font = nk_font_atlas_add_from_memory(atlas_menu, (void*)(menu_font_byte), nk_size(sizeof(menu_font_byte)), 17, &config_menu);
  111. nk_d3d9_font_stash_end();
  112.  
  113. nk_d3d9_font_stash_begin(&atlas_tabs);
  114. tabfont = nk_font_atlas_add_from_memory(atlas_tabs, (void*)(tab_font_byte), nk_size(sizeof(tab_font_byte)), 30, &config_tabs);
  115. nk_d3d9_font_stash_end();
  116.  
  117. //set the font
  118. if (font)
  119. nk_style_set_font(ctx, &font->handle);
  120. }
  121.  
  122. auto menu_t::on_reset(IDirect3DDevice9* device, D3DPRESENT_PARAMETERS* present_parameters) -> void
  123. {
  124. if (ctx)
  125. {
  126. nk_free(ctx);
  127. ctx = nullptr;
  128. }
  129.  
  130. nk_d3d9_release();
  131.  
  132. is_initialized = false;
  133. }
  134.  
  135. auto menu_t::after_reset(IDirect3DDevice9* device, D3DPRESENT_PARAMETERS* present_parameters) -> void
  136. {
  137. initialize(device);
  138. }
  139.  
  140. auto menu_t::on_endscene(IDirect3DDevice9* device) -> void
  141. {
  142. if (!is_initialized)
  143. initialize(device);
  144. if (ctx::menu.get()->is_open) {
  145. gui();
  146.  
  147. nk_d3d9_render(NK_ANTI_ALIASING_ON);
  148.  
  149. nk_input_begin(ctx);
  150. nk_input_end(ctx);
  151. }
  152. }
  153.  
  154.  
  155. auto menu_t::on_wnd_proc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam) -> void
  156. {
  157. nk_d3d9_handle_event(hwnd, msg, wparam, lparam);
  158. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement