designer1337 / csgo-cheat-base

simple csgo internal base.
MIT License
238 stars 50 forks source link

[ source ] better checkbox #109

Open float69 opened 2 years ago

float69 commented 2 years ago

static int stage = 0;

bool in_region = input::in_region(x, y, w, h);

auto arrow = [](int x, int y, color clr) -> void
{
    for (int i = 0; i < 3; i++)
        render::draw_filled_rect(x + i, y + i, 5 - i * 2, 1, clr);
};

if (input::key_clicked(VK_LBUTTON) && in_region)
{
    isComboOpen = !isComboOpen;
}

render::grad_rect(vec2_t(x - 1, y), vec2_t(w + 1, h), color(36, 36, 36), color(28, 28, 28));
render::draw_outline(x - 1, y, w + 1, h, color(60, 60, 60, 255));
render::draw_outline(x - 2, y - 1, w + 3, h + 2, color(4, 4, 4, 255));

render::text(x, y - 14, font, name, false, color::white());
render::text(x + 4, y + 2, font, items.at(*v), false, color::white());

arrow(x + w - 11, y + h / 2 - 1, isComboOpen ? variables::menu::accent : color::white());

if (input::key_clicked(VK_LBUTTON) && !in_region && !isComboOpen)
{
    isComboOpen = false;
}

if (isComboOpen)
{
    stage = min(stage + 1, 2);

    auto item = items;

    for (int i = 0; i < item.size(); i++)
    {
        csize_t control = { x, y + 10 + i * 18 + 12, w - 1, 18 };

        //render::grad_rect(vec2_t(x - 1, y + 22), vec2_t(w + 1, h + i * 22), color(36, 36, 36, 255), color(26, 26, 26, 255));
        //render::draw_filled_rect(x - 1, y + 22, w + 1, h + i * 22, color(36, 36, 36));

        render::draw_filled_rect(control.x - 2, control.y - 2, control.w + 4, control.h + 4, color(4, 4, 4, 255));
        render::draw_filled_rect(control.x - 1, control.y - 1, control.w + 2, control.h + 2, color(60, 60, 60, 255));
        render::draw_filled_rect(control.x, control.y, control.w, control.h, color(36, 36, 36, 255));

        bool in_region2 = input::in_region(control.x, control.y, control.w, control.h);

        render::text(control.x + 4, control.y + 2, render::fonts::verdana, items[i], false, *v == i ? color(variables::menu::accent.r, variables::menu::accent.g, variables::menu::accent.b, 255) : color::white());

        if (*v == i)
        {
            render::draw_filled_rect(control.x, control.y, control.w, control.h, color(0, 0, 0, 35));
            render::draw_line(control.x, control.y + 4, control.x, control.y + 12, color(variables::menu::accent.r, variables::menu::accent.g, variables::menu::accent.b, 255));
        }
        else if (in_region2)
        {
            render::draw_filled_rect(control.x, control.y, control.w, control.h, color(0, 0, 0, 65));
        }

        if (input::key_clicked(VK_LBUTTON) && in_region2)
        {
            *v = i;
        }

        if (stage == 2)
        {
            if (input::key_clicked(VK_LBUTTON) && !in_region2)
            {
                stage = 0; /* reset */
                isComboOpen = false;
            }
        }
    }
}
gr1ndy commented 2 years ago

ss?

float69 commented 2 years ago

ss?

it don't have an ss, but it makes it so if you press on the text, it activates the checkbox.

st3ph4nnn commented 2 years ago

the code here is for a combobox as i understand? also just add the text size.x to the region so u can do what u said and ur gucci