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

[pasta friendly] nice combobox & multicombobox for your pHack

Open st3ph4nnn opened this issue 3 years ago • 3 comments

since many people ask for it and most of the sources released here are not proper, i thought i would share what i made for myself. i've commented the code so if anyone doesnt understand they can learn hopefully. there's a little "anti paste" the function get_pos() but if you have enough brain you should figure what it does

combobox:

   void gui::combobox(std::string text, int x, int y, int w, int h, unsigned long font, const std::vector<std::string> elements, int* current) {
static bool open = false; // if we dont use "static" it wont stay opened.

if (get_pos(x, y, w, h)) // figure this yourself
	open = !open; // flip the bool.

std::size_t size = elements.size(); // get the array size, so we can loop thru it

render::draw_filled_rect(x + 2, y - 1, w, open ? 15 + (size * 15) : h, groupbox_background_alt); // increasing the h if its opened, we could also do the same with Y and render more rectangles but nah
render::draw_outline(x + 2, y - 1, w, open ? 15 + (size * 15) : h, outline_color); // increasing the h if its opened, we could also do the same with Y and render more rectangles but nah
render::text(x + ( w / 2 ), y + 2, font, elements[*current], true, text_color); // render the item selected.
render::text(x + w + 10, y + 1, font, text, false, text_color); // the label

if (open) {
	for (int i = 0; i < size; i++) { // loop thru the array
		if (get_pos(x, y, w, h + 15 + (i * 15))) { // figure get_pos yourself.
			*current = i; // set the current item to i, basically the element u click.
			return;
		}

		render::text(x + ( w / 2 ), y + 15 + (i * 15), font, elements[i], true, i == *current ? active : idle); // render all the elements
	}
}

multicombobox (also has a little add on feature)

    void gui::multi_combobox(std::string text, int x, int y, int w, int h, unsigned long font, const std::vector<std::string> elements, bool* item) {
static bool open = false; // if we dont use "static" it wont stay opened.

if (get_pos(x, y, w, h)) // figure this yourself
	open = !open; // flip the bool.

std::size_t size = elements.size();// get the array size, so we can loop thru it

render::draw_filled_rect(x + 2, y - 1, w, open ? 15 + (size * 15) : h, groupbox_background_alt); // draw some stuff, as usual we use the height and no the y cuz yes
render::draw_outline(x + 2, y - 1, w, open ? 15 + (size * 15) : h, outline_color); // draw some stuff, as usual we use the height and no the y cuz yes

// nice little feature i thought of, feel free to use it lol
std::string display;
for (int i = 0; i < size; i++) {
	if (item[i]) {
		if (!(render::get_text_size(font, display).x > w / 1.5))
			display += elements[i] + "; ";
		else
			display = elements[i] + "; ...";
	}
}
// text rendering
render::text(x + (w / 2), y + 2, font, display.empty() ? "nothing" : display, true, text_color); // if the display string is empty, render "nothing" else render display.
render::text(x + w + 10, y + 1, font, text, false, text_color); // label

if (open) {
	for (int i = 0; i < size; i++) { // loop thru the array
		if (get_pos(x, y, w, h + 15 + (i * 15))) // figure get_pos yourself
			item[i] = !item[i]; // since we use a bool array, we just flip the corresponding bool in that array

		render::text(x + (w / 2), y + 15 + (i * 15), font, elements[i], true, item[i] == true ? active : idle); // render the elements
	}
}

example use of it:

inline int main_combo{0}; inline bool test[3] = { false, false, false };

gui::combobox("cadua is awesome", variables::menu::x + 15, variables::menu::y + 110, 120, 20, render::fonts::menu_font, { "yess", "noo" }, &main_combo); gui::multi_combobox("tommy i love you", variables::menu::x + 15, variables::menu::y + 160, 120, 20, render::fonts::menu_font, { "what de fok", "no what", "wait" }, test);

screenshots:

image

image

st3ph4nnn avatar Aug 09 '21 10:08 st3ph4nnn

PLZ WITHOUT ANTIPASTE

MyNameIsKodak avatar Aug 12 '21 06:08 MyNameIsKodak

if you gonna say "pasta friendly", and you gonna release a source with antipaste, you look kinda retarderd...

wainer1337 avatar Aug 26 '21 19:08 wainer1337

@wainer1337 you can clearly figure that out in like 2 seconds lol, you're the retarded paster here tbh

maecry avatar Jun 01 '22 04:06 maecry