Giter VIP home page Giter VIP logo

zgui's Introduction

zgui logo

Simple immediate mode gui framework

forthebadge forthebadge

discord

Simple, two file immediate mode gui framework written in C++17, mainly aimed for people beginning their journey with game hacking (but not limited to). Its main goals are to be universal (it works on all graphics APIs; DirectX, OpenGL, Vulkan etc.) and dependency free. Therefore zgui is really easy to use and it has simple but aesthetic UI that can be extended or modified easily too.

All functions of framework are described in header file.
Dont forget to check out official zgui wiki, you will find there documentation of zgui and guide how to use zgui.

Also shoutout to alphauc for example zgui implementation in his SDK

See gif for preview.

Donators

Huge thanks to vocan for finance support of the project :)

If you want to be here and give donation to zgui, write to me on official zgui discord.

Acknowledgments

Special thanks to cyanidee for explaining me loads of things. ... and all the community contributors.

zgui's People

Contributors

danielkrupinski avatar patrykkolodziej avatar smefpw avatar txxmo avatar wiotq avatar zxvnme avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zgui's Issues

[bug?]text input code 50(number 2) gets polled 3 times

I'm using designer1337's csgo cheat base(propably not relevant, but mentioning it incase it is) with zgui, and when I'm using a text input field, the number 2 (above W, not the numpad 2) gets detected 3 times per keystroke. first two times it writes a 2, and a third time it writes a whitespace character or something like that.
image

Not sure if this is a reproducible issue, but I've fixed it by isolating the qwerty numbers into another else-if:

else if (i > 47 && i <= 57) {
                    if (utils::input::key_pressed(i)) {
                        for (int j = 0; j < 10; j++) {
                            if(special_characters[j].vk == i)
                                value += utils::input::key_down(VK_SHIFT) ? special_characters[j].shift : special_characters[j].regular;
                        }
                    }
                }

What happened

Hello, I'm no. 1 fan of you, your project and C++17. I just don't understand why did you leave our FunnyBucket 💔

[REQUEST] Control Override Font

Is your feature request related to a problem? Please describe.
Font Override could be related to a problem if you're somewhat lazy, or if you're new to using said framework and rendering methods. It would make life easier for the developer using ZGUI by allowing them to change fonts in their menu on the fly.

Describe the solution you'd like
A solution to said "issue" is to make a font override function in the source code similar to the "same_line" or "next_column" functions. You would call it before the controls you want the function to apply to and afterwards it will take effect on the controls.
example:
zgui::override_font(menufont_2); zgui::checkbox("Checkbox with menufont_2 #Checkbox", bool);

Describe alternatives you've considered
You can obviously go ahead and manually change all fonts for controls in the source of the framework, however that takes quite a bit of time and fiddling around with code, or looking at things. I think this function will be beneficial to most people as some people might want to have a big flashy font for their window header, and a subtle but clean font for their controls inside of their window.

[BUG] Crashing with fade_factor

Just implemented zgui, went fairly well. Running into issues with:
const int fade_factor = static_cast<int>(1.0f / 0.15f * functions.get_frametime() * 255); //crashing here
inside of the:
bool zgui::begin_window

Just rendering a test window, everything is implemented.

font?

quick question, after looking at the documentation I don't really understand how where supposed to import or add fonts? If someone who knows how to import fonts or the storage type of fonts that we can import that would be a appreciated!

[REQUEST] tabs

zxvnmeToday at 10:48 PM
u can make issue on github with idea of adding something like function for rendering tabs so i wont forget about implementing it when i will continue zgui

very detailed request

less of a [BUG] but more of a [HELP]

i'm trying to add some gradients from xy0, but when i'm trying to make them into "context.window.render" functions rater then "render::" (so i can draw over stuff), i don't get the output i'm looking for...

not wanted output, but draws over stuff:
https://i.imgur.com/HNbvpKz.png

void GradientH(float x, float y, float w, float h, color c1, color c2)
{
	context.window.render.emplace_back(zgui::zgui_control_render_t{ {x, y}, zgui::zgui_render_type::zgui_filled_rect, c1, "", {w, h} });
	BYTE first = c2.r;
	BYTE second = c2.g;
	BYTE third = c2.b;
	for (float i = 0; i < w; i++)
	{
		float fi = i, fw = w;
		float a = fi / fw;
		/*DWORD*/float ia = a * 255;
		context.window.render.emplace_back(zgui::zgui_control_render_t{ {x + i, y}, zgui::zgui_render_type::zgui_filled_rect, color(first, second, third, ia), "", {1, h} });
	}
}

wanted output, but not drawing over stuff:
https://i.imgur.com/NCdyjgD.png

void GradientH(float x, float y, float w, float h, color c1, color c2)
{
	render::filled_rect(x, y, w, h, c1);
	BYTE first = c2.r;
	BYTE second = c2.g;
	BYTE third = c2.b;
	for (float i = 0; i < w; i++)
	{
		float fi = i, fw = w;
		float a = fi / fw;
		/*DWORD*/float ia = a * 255;
		render::filled_rect(x + i, y, 1, h, color(first, second, third, ia));
	}
}

any help is greatly appreciated, ive looked over this about 10 times, and cant seem to understand why it doesn't work.

[BUG] Menu rendering invisible

hey guys im new to this stuff and not really good at c++ but my menu isnt rendering onto my canvas and its just blocking all input until I toggle it using insert here's my code:

void renderMenu()
{
    zgui::poll_input("Counter-Strike: Global Offensive");

    if (zgui::begin_window("test", { 380, 520 }, zgui::zgui_window_flags_none)) {

        zgui::begin_groupbox("test", { 375, 515 }, zgui::zgui_window_flags_none);
        bool esp = false;
        zgui::checkbox("esp toggle", esp);
        zgui::end_groupbox();

    }
    zgui::end_window();
}

any help is appreciated

[REQUEST] AND [PROBLEM]

Hello... if anyone could help that would be awesome. im new to coding and i followed the steps till i got to the embedding process. then i got stuck. can this be made into a dll or exe even? if anyone could get back to me that would be great!

[BUG] Game crashing when injecting?

For some reason, injecting the cheat I'm working on causes my game to immediately crash. Here is my code for the menu.

`Color ToZGUI(zgui::color c) {
Color col = Color(c.r, c.g, c.b, c.a);
return col;
}

void line(int x, int y, int x2, int y2, zgui::color c) noexcept {
g_pSurface->Line(x, y, x2, y2, ToZGUI(c));
}

void rect(int x, int y, int x2, int y2, zgui::color c) noexcept {
g_pSurface->OutlinedRect(x, y, x2, y2, ToZGUI(c));
}

void filled_rect(int x, int y, int x2, int y2, zgui::color c) noexcept {
g_pSurface->FilledRect(x, y, x2, y2, ToZGUI(c));
}

void text(int x, int y, zgui::color c, int font, bool center, const char* text) noexcept {
g_pSurface->DrawSetTextColor(ToZGUI(c));
g_pSurface->DrawSetTextPos(x, y);
g_pSurface->DrawSetTextFont(font);
const char* _input = text;
size_t length = strlen(_input);
wchar_t text_wchar[30];
mbstowcs_s(&length, text_wchar, _input, length);
g_pSurface->DrawPrintText(text_wchar, strlen(text));
}

void get_text_size(unsigned long font, const char* text, int& wide, int& tall) noexcept {
g_pSurface->GetTextSize(font, (wchar_t*)text, wide, tall);
}

float get_frametime() noexcept { return g_pGlobalVars->frametime; }

void Menu::Initialize() {
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;
}

void Menu::Render()
{
const unsigned long _font = Globals::CourierNew;

static bool _pressed = true;

if (!_pressed && GetAsyncKeyState(VK_INSERT))
	_pressed = true;
else if (_pressed && !GetAsyncKeyState(VK_INSERT))
{
	_pressed = false;
	menuOpened = !menuOpened;
}

g_InputSystem->EnableInput(!menuOpened);

if (menuOpened)
{
	zgui::poll_input("Counter-Strike: Global Offensive");

	if (zgui::begin_window("zgui example window", { 500, 350 }, _font, zgui::zgui_window_flags_none))
	{
		zgui::text("sample checkbox #example");
		zgui::end_window();
	}
}

}`

Any ideas would be amazing.

Menu not resizing on move.

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

}
`

[BUG] windowed mode

menu input works completely fine on fullscreen, but not in windowed mode.

calling in painttraverse:

auto panel_to_draw = fnv::hash(interfaces::panel->get_panel_name(panel));

switch (panel_to_draw) {
case fnv::hash("MatSystemTopPanel"):
	g_Menu.Render();
	break;

case fnv::hash("FocusOverlayPanel"):
	interfaces::panel->set_keyboard_input_enabled(panel, g_Menu.menuOpened);
	interfaces::panel->set_mouse_input_enabled(panel, g_Menu.menuOpened);
	break;
}

any help?

[BUG] menu opened check is not working.

as title says, i can't lock cursor in csgo cuz opened check is not working.

void __stdcall hooks::lockcursor_hk(void* ecx) {
	if (zgui::gui_window_context_t().opened) {
		interfaces::surface->unlock_cursor();
		return;
	}
	else
		return ((void(__thiscall*)(void*)) o_lockcursor)(interfaces::surface);
}

for example, this code won't work:
if (zgui::gui_window_context_t().opened)

but ghetto check like this is working fine:
if (GetKeyState(VK_INSERT))

About fonts

I want to change the font code of other languages. How can I change it, such as Chinese, Turkish, Russian?

[BUG] Click goes "through" menu elements

Describe the bug
When clicking on a listbox, combobox, multicombobox, the thing under the list appearing get triggered too, here is a gif to understand me better.
https://i.imgur.com/9ECDCqa.gifv

To Reproduce
Steps to reproduce the behavior:

  1. Make a combobox, listbox.
  2. Put a interactive element under (checkbox, another combobox, listbox)
  3. Click

Expected behavior
Only the opened element should get triggered.

Screenshots
See the gif ^

[BUG] Elements don't get triggered.

Describe the bug
Sliders, Comboboxes, Keybind, every zgui's elements (except the checkbox) don't get triggered if you didn't trigger a tab or checkbox before. GIF : https://i.imgur.com/CqSEziy.gifv
Also bug when you first open the menu.

To Reproduce
Steps to reproduce the behavior:

  1. Change tab
  2. Try to change sliders' values or whatever

Expected behavior
The selected element should get triggered.

[REQUEST] Groupbox Scrolling

Describe the solution you'd like
Scrolling for group boxes.

Describe alternatives you've considered
Pagination, drawing buttons with numbers to switch pages.

Additional context
No additional context.

align groupboxes one after the other

so im tryna make 2 groupboxes, one on the left and one on the right.
i tried using sameline after the end of the first groupbox and its not working.
is there a special thingy that i can use?
`
zgui::begin_groupbox("chams", zgui::vec2{ 235,311 });

zgui::checkbox("enemy chams", variables.visuals.chams.bool_enemy);

zgui::slider_int("enemy red", 0, 255, variables.visuals.chams.color_enemy[0]);

zgui::slider_int("enemy green", 0, 255, variables.visuals.chams.color_enemy[1]);

zgui::slider_int("enemy blue", 0, 255, variables.visuals.chams.color_enemy[2]);

zgui::slider_int("enemy alpha", 0, 255, variables.visuals.chams.color_enemy[3]);

zgui::end_groupbox();

zgui::same_line();

zgui::begin_groupbox("fakelag", zgui::vec2{ 235,311 });

zgui::checkbox("fakelag", variables.misc.bool_fakelag);

zgui::slider_int("fakelag value", 0, 14, variables.misc.int_fakelag);

zgui::end_groupbox();
`
https://imgur.com/a/Aq2w1xt

Checkbox not working [BUG] (CS GO)

Describe the bug
Checkboxes are not working for me.

To Reproduce
Steps to reproduce the behavior:

  1. Setup gui in paint_traverse and run input in painttraverse also.
  2. Add a checkbox.
  3. Compile
  4. Try and click and it won't work.

Expected behavior
I would think the checkbox would check but it doesn't.

Screenshots
No screenshot to add.

Desktop (please complete the following information):

  • OS: Windows 10
  • Version: Latest

Jak dodac te menu ?

Jak dodac te menu mozesz jakoś bardziej to wytłumaczyc?

Czy byłbyś wstanie dodać takie menu do stickrpghooka? byłbym bardzo wdzięczny

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.