Open GLadiator279 opened 3 years ago
You do not need to create a string variable, you can write the names in the element call, for example, like this:
menu_framework::combo_box(x + 120, y + 165, x + 260, watermark_font, "Box type", { "1", "2", "3" }, &variables::visuals::esp::box_type);
penis fart
Sorry for being late. If u atleast paste it try to optimize it. Your whole code can be shortened to 20 lines and have it work the same way.
bool open = false;
static bool selected_opened = false;
static bool rest;
static std::string name_selected;
if ((cursor.x > position) && (cursor.x < position + w) && (cursor.y > y) && (cursor.y < y + h) && GetAsyncKeyState(VK_LBUTTON) & 1) {
name_selected = string;
if (!rest)
selected_opened = !selected_opened;
rest = true;
}
else
rest = false;
if (name_selected == string)
open = selected_opened;
this can be 3 lines and work the same, literally. ` static bool open = false;
if (get_pos(x, y, w, h))
open = !open;`
only my preference but this can be out of this if statement
if (open) { render::draw_filled_rect(position + 2, y - 1, w, 15 + (size * 15), color(36, 36, 36, 255));
This can also be shortened to 1 line and much optimized.
if (i == *values) { render::text(position + 7, (y - 1) + 15 + (i * 15), font, elements[i].c_str(), false, color::white()); } else { render::text(position + 7, (y - 1) + 15 + (i * 15), font, elements[i].c_str(), false, color::white(100)); }
render::text(x + ( w / 2 ), y + 15 + (i * 15), font, elements[i], true, i == *current ? active : idle);
Look, i just made it better for you all
static bool open = false;
if (get_pos(x, y, w, h))
open = !open;
std::size_t size = elements.size();
render::draw_filled_rect(x + 2, y - 1, w, open ? 15 + (size * 15) : h, groupbox_background_alt);
render::draw_outline(x + 2, y - 1, w, open ? 15 + (size * 15) : h, outline_color);
render::text(x + ( w / 2 ), y + 2, font, elements[*current], true, text_color);
render::text(x + w + 10, y + 1, font, text, false, text_color);
if (open) {
for (int i = 0; i < size; i++) {
if (get_pos(x, y, w, h + 15 + (i * 15))) {
*current = i;
return;
}
render::text(x + ( w / 2 ), y + 15 + (i * 15), font, elements[i], true, i == *current ? active : idle);
}
}
Sorry for being late. If u atleast paste it try to optimize it. Your whole code can be shortened to 20 lines and have it work the same way.
bool open = false; static bool selected_opened = false; static bool rest; static std::string name_selected; if ((cursor.x > position) && (cursor.x < position + w) && (cursor.y > y) && (cursor.y < y + h) && GetAsyncKeyState(VK_LBUTTON) & 1) { name_selected = string; if (!rest) selected_opened = !selected_opened; rest = true; } else rest = false; if (name_selected == string) open = selected_opened;
this can be 3 lines and work the same, literally. ` static bool open = false;
if (get_pos(x, y, w, h)) open = !open;`
only my preference but this can be out of this if statement
if (open) { render::draw_filled_rect(position + 2, y - 1, w, 15 + (size * 15), color(36, 36, 36, 255));
This can also be shortened to 1 line and much optimized.
if (i == *values) { render::text(position + 7, (y - 1) + 15 + (i * 15), font, elements[i].c_str(), false, color::white()); } else { render::text(position + 7, (y - 1) + 15 + (i * 15), font, elements[i].c_str(), false, color::white(100)); }
render::text(x + ( w / 2 ), y + 15 + (i * 15), font, elements[i], true, i == *current ? active : idle);
Look, i just made it better for you all
static bool open = false; if (get_pos(x, y, w, h)) open = !open; std::size_t size = elements.size(); render::draw_filled_rect(x + 2, y - 1, w, open ? 15 + (size * 15) : h, groupbox_background_alt); render::draw_outline(x + 2, y - 1, w, open ? 15 + (size * 15) : h, outline_color); render::text(x + ( w / 2 ), y + 2, font, elements[*current], true, text_color); render::text(x + w + 10, y + 1, font, text, false, text_color); if (open) { for (int i = 0; i < size; i++) { if (get_pos(x, y, w, h + 15 + (i * 15))) { *current = i; return; } render::text(x + ( w / 2 ), y + 15 + (i * 15), font, elements[i], true, i == *current ? active : idle); } }
Good job, thanks for the explanation.
I saw a post here that a person cannot make a combobox. I decided to try to do it, and I succeeded. I am far from being a pro, so yes, semi-pasted from xy0.
I have put the code on pastebin as at the moment the code paste on github is broken.
How to use
Don't swear if the code isn't very good, thanks.