csgo-cheat-base icon indicating copy to clipboard operation
csgo-cheat-base copied to clipboard

Help With My Dropdown Box

Open YNXModz opened this issue 4 years ago • 3 comments

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::vectorstd::stringitems, 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;

render::draw_filled_rect(variables::menu::x + 24, y - 1, width + 2, height + 2, function ? color::fadedCherryRed() : color(20, 20, 20, 205));
render::draw_filled_rect(variables::menu::x + 25, y, width, height, color(36, 36, 36, 255));
render::draw_rect(variables::menu::x + 25, y + height + 1, width, (height * items.size()), function ? color(36, 36, 36, 255) : color(0, 0, 0, 0));
render::text(variables::menu::x + 30, y + 5, render::fonts::watermark_font, items[Option], false, color::white());



if (function)
{
	for (int i = 0; i < items.size(); i++)
	{
		if ((cursor.x > variables::menu::x + 25) && (cursor.x < variables::menu::x + 25 + width) && (cursor.y > y + height + (height * i)) && (cursor.y < y + height + 20 + (height * i)) && GetAsyncKeyState(VK_LBUTTON) & 1)
		{
			Option = i;
		}

		render::text(variables::menu::x + 30, y + height + 5 + (20 * i), render::fonts::watermark_font, items[i].c_str(), false, color::white());
	}
}

}`

YNXModz avatar Oct 31 '20 06:10 YNXModz

old garbage code, but should be working.

use fgui or zgui next time.

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);

}

rcszephyr avatar Oct 31 '20 13:10 rcszephyr

old garbage code, but should be working.

use fgui or zgui next time.

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

YNXModz avatar Oct 31 '20 16:10 YNXModz

how did u add to the menu i am shit with frameworks so please don't be mean

Dreams0001 avatar Nov 15 '20 20:11 Dreams0001