void hud::keybinds() {
// Constants for pos, padding, etc...
const auto pos = vec2(10, 500);
const auto padding = 4; // Padding between keybind elements
// Constants for colors
const auto col_background = color(0, 0, 0, 240); // Watermark background color
const auto col_accent = color(90, 120, 240); // Watermark line accent color
const auto col_text = color(255, 255, 255); // Watermark text color
// Element name
const std::string name = "keybinds";
const auto name_size = render::measure_text(font::verdana_12, name);
// float name_size_x, name_size_y; render::get_text_size(font::verdana_12, name, name_size_x, name_size_y);
//pos
// v
// [ keybinds ]
// ill have two number 9s
// a number 9 large
//
// ^-^ padding
// ^--------------^ size
// List of keybinds
std::vector<std::string> keybinds;
if (true) // Here your config bool
keybinds.push_back("ill have two number 9s");
if (true) // Here your config bool
keybinds.push_back("a number 9 large");
if (true) // Here your config bool
keybinds.push_back("a number 6 with extra dip");
if (true) // Here your config bool
keybinds.push_back("a number 7");
if (true) // Here your config bool
keybinds.push_back("two number 45s");
if (true) // Here your config bool
keybinds.push_back("one with cheese");
if (true) // Here your config bool
keybinds.push_back("and a large soda");
// Adjust width for biggest entry
auto biggest_text_width = name_size.x;
// auto biggest_text_width = name_size_width;
auto keybind_position_y = padding + name_size.y + padding + padding;
// Run on hooks::panel::paint_traverse
// Surface rendering
for (std::string keybind : keybinds) {
// Get current keybind text size
const auto keybind_size = render::measure_text(font::verdana_12, keybind);
// float keybind_size_x, keybind_size_y; render::get_text_size(font::verdana_12, name, keybind_size_x, keybind_size_y);
// Check if bigger one
biggest_text_width = std::fmaxf(biggest_text_width, keybind_size.x);
// Render keybind name
render::text(pos.x + padding, pos.y + keybind_position_y, font::verdana_12, keybind, col_text);
// Calculating position for our next keybind
keybind_position_y += keybind_size.y + padding;
}
auto bg_size = vec2(padding + biggest_text_width + padding,
padding + name_size.y + padding);
render::rect(pos.x, pos.y, bg_size.x, bg_size.y, col_background); // Background
render::rect(pos.x, pos.y, bg_size.x, 2, col_accent); // Accent line
render::text(pos.x + (bg_size.x * 0.5f) - (name_size.x * 0.5f), pos.y + padding, font::verdana_12, name, col_text); // Element name
// If your rendering class has ALIGN_CENTER flag, you can use this flag instead of - (name_size.x * 0.5f)
}