Open YNXModz opened 3 years ago
old garbage code, but should be working.
bool mouse_region(int x, int y, int x2, int y2)
{
if (cursor.x > x && cursor.y > y && cursor.x < x2 + x && cursor.y < y2 + y)
return true;
return false;
}
auto arrow = [](int x, int y)
{
for (auto i = 5; i >= 2; --i)
{
auto offset = 5 - i;
render::draw_line(x + offset, y + offset, x + offset + std::clamp(i - offset, 0, 5), y + offset, color::white(155));
}
};
void shit_combo(std::int32_t x, std::int32_t y, unsigned long font, const std::string string, int& value, bool& opened, std::vector<std::string_view> items)
{
//o_O
int x2 = x + 5, y2 = y + 15;
int w = 67, h = 13;
//r-button 🤣
if (mouse_region(x, y, w, h) && (key_press(VK_LBUTTON) || key_press(VK_RBUTTON)))
opened = !opened;
//bg
render::draw_filled_rect(x + 1, y + 1, w - 1, h - 1, opened ? color(52, 134, 235, 255) : color(36, 36, 36, 255));
//combo name
render::text(x + w + 3, y, font, string, false, color::white());
//selected item
render::text(x + 3, y, font, items.at(value).data(), false, color::white());
if (opened)
{
for (auto i = 0u; i < items.size(); i++)
{
if (mouse_region(x + 1, y + (15 * i), w, h) && key_press(VK_LBUTTON)) //or GetAsyncKeyState
value = i;
//items bg
render::draw_filled_rect(x, y + (15 * i), w + 1, h + 1, value == i ? color(64, 64, 64, 155) : color(36, 36, 36, 255));
//items...
render::text(x + 3, y + (15 * i), font, items.at(i).data(), false, color::white());
}
}
// XD arrow
arrow(x + w - 7, y + 6);
}
old garbage code, but should be working.
bool mouse_region(int x, int y, int x2, int y2) { if (cursor.x > x && cursor.y > y && cursor.x < x2 + x && cursor.y < y2 + y) return true; return false; } auto arrow = [](int x, int y) { for (auto i = 5; i >= 2; --i) { auto offset = 5 - i; render::draw_line(x + offset, y + offset, x + offset + std::clamp(i - offset, 0, 5), y + offset, color::white(155)); } }; void shit_combo(std::int32_t x, std::int32_t y, unsigned long font, const std::string string, int& value, bool& opened, std::vector<std::string_view> items) { //o_O int x2 = x + 5, y2 = y + 15; int w = 67, h = 13; //r-button 🤣 if (mouse_region(x, y, w, h) && (key_press(VK_LBUTTON) || key_press(VK_RBUTTON))) opened = !opened; //bg render::draw_filled_rect(x + 1, y + 1, w - 1, h - 1, opened ? color(52, 134, 235, 255) : color(36, 36, 36, 255)); //combo name render::text(x + w + 3, y, font, string, false, color::white()); //selected item render::text(x + 3, y, font, items.at(value).data(), false, color::white()); if (opened) { for (auto i = 0u; i < items.size(); i++) { if (mouse_region(x + 1, y + (15 * i), w, h) && key_press(VK_LBUTTON)) //or GetAsyncKeyState value = i; //items bg render::draw_filled_rect(x, y + (15 * i), w + 1, h + 1, value == i ? color(64, 64, 64, 155) : color(36, 36, 36, 255)); //items... render::text(x + 3, y + (15 * i), font, items.at(i).data(), false, color::white()); } } // XD arrow arrow(x + w - 7, y + 6); }
thank you a lot, it worked
how did u add to the menu i am shit with frameworks so please don't be mean
so basically im working on a drop down box for my menu while using this base and i cant get my y values to work properly to make a full dynamic drop down box, heres my code.
`void menu_framework::LeftDropdown(std::int32_t y, unsigned long font, const std::string string, std::vectoritems, int Option, bool& function)
{
GetCursorPos(&cursor);
int width = 120;
int height = 20;
if ((cursor.x > variables::menu::x + 25) && (cursor.x < variables::menu::x + 25 + width) && (cursor.y > y) && (cursor.y < y + height) && GetAsyncKeyState(VK_LBUTTON) & 1)
function = !function;
}`