SHARE
TWEET

Untitled

a guest Jan 22nd, 2020 75 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include "../menu.h"
  2.  
  3. void c_menu::combobox(int size, std::string name, std::string* itemname, int* item)
  4. {
  5.     if (groupbox_bottom <= y_offset + 41)
  6.         return;
  7.  
  8.     bool pressed = false;
  9.     bool open = false;
  10.     static bool selected_opened = false;
  11.     static bool click_rest;
  12.     static bool rest;
  13.     static std::string name_selected;
  14.  
  15.     if (GetAsyncKeyState(VK_LBUTTON) && mouse_in_params(x_offset + 25, y_offset + 14, 163, 20) && !click_rest)
  16.     {
  17.         name_selected = name;
  18.         pressed = true;
  19.         click_rest = true;
  20.     }
  21.     else if (!GetAsyncKeyState(VK_LBUTTON) && mouse_in_params(x_offset + 25, y_offset + 14, 163, 20))
  22.         click_rest = false;
  23.  
  24.     if (pressed)
  25.     {
  26.         if (!rest)
  27.             selected_opened = !selected_opened;
  28.         rest = true;
  29.     }
  30.     else
  31.         rest = false;
  32.  
  33.     if (name_selected == name)
  34.         open = selected_opened;
  35.  
  36.     render::get().draw_text(x_offset + 25, y_offset - 3, render::get().menu_font, name.c_str(), false, color(255, 255, 255, 255));
  37.     render::get().draw_filled_rect(x_offset + 25, y_offset + 14, 163, 20, color(95, 95, 95, 255));
  38.     render::get().draw_outline(x_offset + 25, y_offset + 14, 163, 20, color(0, 0, 0, 255));
  39.  
  40.     if (open)
  41.     {
  42.         render::get().draw_line(x_offset + 25 + 163 - 6, y_offset + 14 + 11, x_offset + 25 + 163 - 11, y_offset + 14 + 11, color(179, 179, 179, 255));
  43.         render::get().draw_line(x_offset + 25 + 163 - 7, y_offset + 14 + 10, x_offset + 25 + 163 - 10, y_offset + 14 + 10, color(179, 179, 179, 255));
  44.         render::get().draw_line(x_offset + 25 + 163 - 8, y_offset + 14 + 9, x_offset + 25 + 163 - 9, y_offset + 14 + 9, color(179, 179, 179, 255));
  45.  
  46.         render::get().draw_filled_rect(x_offset + 25, y_offset + 14 + 21, 163, (size * 16), color(95, 95, 95, 255));
  47.         render::get().draw_outline(x_offset + 25, y_offset + 14 + 21, 163, (size * 16), color(0, 0, 0, 255));
  48.  
  49.         for (int i = 0; i < size; i++)
  50.         {
  51.             if (GetAsyncKeyState(VK_LBUTTON) && mouse_in_params(x_offset + 25, y_offset + 34 + i * 16, 163, 16))
  52.                 *item = i;
  53.  
  54.             if (i == *item)
  55.                 render::get().draw_text(x_offset + 25 + 10, y_offset + 14 + 23 + i * 16, render::get().menu_font, itemname[i].c_str(), false, color(255, 255, 255, 255));
  56.             else
  57.                 render::get().draw_text(x_offset + 25 + 10, y_offset + 14 + 23 + i * 16, render::get().menu_font, itemname[i].c_str(), false, color(185, 185, 185, 255));
  58.         }
  59.     }
  60.     else
  61.     {
  62.         render::get().draw_line(x_offset + 25 + 163 - 6, y_offset + 14 + 9, x_offset + 25 + 163 - 11, y_offset + 14 + 9, color(179, 179, 179, 255));
  63.         render::get().draw_line(x_offset + 25 + 163 - 7, y_offset + 14 + 10, x_offset + 25 + 163 - 10, y_offset + 14 + 10, color(179, 179, 179, 255));
  64.         render::get().draw_line(x_offset + 25 + 163 - 8, y_offset + 14 + 11, x_offset + 25 + 163 - 9, y_offset + 14 + 11, color(179, 179, 179, 255));
  65.     }
  66.  
  67.     render::get().draw_text(x_offset + 35, y_offset + 19, render::get().menu_font, itemname[*item].c_str(), false, color(255, 255, 255, 255));
  68.  
  69.     if (open) // i added 1 more to 42 bec the space between the main box and the drop down
  70.         y_offset += 42 + (size * 16);
  71.     else
  72.         y_offset += 41;
  73. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top