zxvnme / zgui

zxvnme's graphical user interface
MIT License
399 stars 53 forks source link

Menu not resizing on move. #46

Closed Tech2890 closed 5 years ago

Tech2890 commented 5 years ago

Menu doesn't resize on move or the menu elements.

image

I'm calling this in present btw. The text moves accordingly but nothing else also I will post a fix if I find one.

Setting up like this: ` void line(int x, int y, int x2, int y2, zgui::color c) noexcept { g_render.Line(x, y, x2, y2, { c.r, c.g, c.b, c.a }); } void rect(int x, int y, int x2, int y2, zgui::color c) noexcept { / draw outlined rectangle using your renderer / g_render.Rect(x, y, x2, y2, { c.r, c.g, c.b, c.a }); } void filled_rect(int x, int y, int x2, int y2, zgui::color c) noexcept { / draw filled rectangle using your renderer / g_render.RectFilled(x, y, x2, y2, { c.r, c.g, c.b, c.a }); } void text(int x, int y, zgui::color color, int font, bool center, const char text) noexcept { / draw text using your renderer / g_render.String(x, y, center ? FONT_CENTERED_X | FONT_DROPSHADOW : FONT_DROPSHADOW, { color.r, color.g, color.b, color.a }, g_fonts.fonts[font], text); } void get_text_size(unsigned long font, const char text, int& wide, int& tall) noexcept { / calculate text size here / auto p = get_text_dimensions(g_fonts.fonts[font], true, text); wide = p.x; tall = p.y; } float get_frametime() noexcept { / return frametime / return g_globals->absoluteframetime; }

zgui::functions.draw_line = line; zgui::functions.draw_rect = rect; zgui::functions.draw_filled_rect = filled_rect; zgui::functions.draw_text = text; zgui::functions.get_text_size = get_text_size; zgui::functions.get_frametime = get_frametime; `

Rendering:

` void zgui_menu::render() { zgui::poll_input("Counter-Strike: Global Offensive");

static bool example = false;
static int example_int = 10;
if (zgui::begin_window("zgui example window", { 500, 350 }, FONT_ESP, zgui::zgui_window_flags_none))
{
    zgui::checkbox("sample checkbox #example", example);
    // value before hash is visible ^
    zgui::slider_int("#sample_slider", 0, 40, example_int);
    //                ^ value after hash is hidden"
    //
    // Hashing is demystified in zgui.hh
    // Search for [hashing controls names] to get more details.
    zgui::end_window();
}

} `

Tech2890 commented 5 years ago

From:

g_render.Rect(x, y, x2, y2, { c.r, c.g, c.b, c.a });
g_render.RectFilled(x, y, x2, y2, { c.r, c.g, c.b, c.a });

To:

g_render.Rect(x, y, x + x2, y + y2, { c.r, c.g, c.b, c.a });
g_render.RectFilled(x, y, x + x2, y + y2, { c.r, c.g, c.b, c.a });

This is what I changed after looking your code. Just in case anyone else has this problem, it was just a stupid mistake.