Code Monkey home page Code Monkey logo

zgui's Introduction


zgui logo


Simple immediate mode gui framework.

forthebadge forthebadge

Simple, two file immediate mode gui framework written in C++17 that is aimed to people who begin their journey with game hacking (but not only). It's main aspect is universality (it will work on all APIs; DirectX, OpenGL etc.) and fact that it is fully dependency free. Because of that 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. Guide how to embed it in your project & example code is on the bottom of README.

See gif below for preview.

How to use & example

The core thing that you need to do is to wrap some rendering functions.

At first, you should specify window name from where the input will be read from (top of zgui.cc)

constexpr std::string_view INPUT_WINDOW{ "" };

In top of hooks.cc (whatever) create some proxy functions. Functions used in this example are from valve_sdk (but their can be from wherever you want)

void line(int x, int y, int x2, int y2, Color c) { g_pSurface->Line(x, y, x2, y2, c); }
void rect(int x, int y, int x2, int y2, Color c) { g_pSurface->OutlinedRect(x, y, x2, y2, c); }
void filled_rect(int x, int y, int x2, int y2, Color c) { g_pSurface->FilledRect(x, y, x2, y2, c); }
void text(int x, int y, Color color, int font, bool center, const char* _input, ...) { g_pSurface->DrawT(x, y, color, font, center, _input); }
void get_text_size(unsigned long font, const wchar_t* text, int& wide, int& tall) { g_pSurface->GetTextSize(font, text, wide, tall); }
float get_frametime() { return g_pGlobalVars->frametime; }

then in your hooks initialize function

auto& draw_functions = g_zgui->get_functions();

draw_functions.draw_line = (zgui::line_t)line;
draw_functions.draw_rect = (zgui::rect_t)rect;
draw_functions.draw_filled_rect = (zgui::filled_rect_t)filled_rect;
draw_functions.draw_text = (zgui::text_t)text;
draw_functions.get_text_size = (zgui::get_text_size_t)get_text_size;
draw_functions.get_frametime = (zgui::get_frametime)get_frametime;

and finally, you can render the gui, here's short demo

static bool example = false;
static int example_int = 10;
if (g_zgui->begin_window("zgui example window", zgui::vec2{ 500, 350 }, g::Tahoma, zgui_window_flags_none))
{
  g_zgui->checkbox("sample checkbox#example", example);
  //  value before hash is visible ^
  g_zgui->slider_int("#sample_slider", 0, 40, example_int);
  //                  ^ value after hash is hidden"
  //
  // Hashing is demystified in zgui.hh
}
g_zgui->end_window();

Closing speech

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

zgui's People

Contributors

zxvnme avatar danielkrupinski avatar wiotq avatar

Watchers

James Cloos avatar

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.