Исходник metamod dynamic keybinds & watermark

Статус
В этой теме нельзя размещать новые ответы.
  • 33
  • 20
За основу взят стиль метамода, ибо красиво и минималистично
Так же в ватермарке будет написано [debug] после названия чита, если вы компилируете в дебаге
В коде много комментариев, так что можно взять под основу для своей ватермарки.
Так же можно довольно поменять паддинги, все константы находятся наверху.
Все необходимые инклюды тоже написаны.
Скриншоты:
Посмотреть вложение 832
Посмотреть вложение 833

Код:
C++:
/*
Inclused u need:
#include <ctime> // std::time, std::put_time, std::localtime
#include <sstream> // std::ostringstream
// client_state interface for net_channel
// globals interface
*/

/*
Font setup:
create_font(font: verdana_12, windows_font_name: "Verdana", tall: 12, weight: 100, blur: 0, flags: ANTIALIAS | SHADOW, [[maybe_unused]]range_min: 0, [[maybe_unused]]range_max: 0);
*/
C++:
void hud::watermark() {
    // Constants for padding, etc...
    const auto margin = 10; // Padding between screen edges and watermark
    const auto padding = 4; // Padding between watermark 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

    // Setup time
    auto t = std::time(nullptr);
    std::ostringstream time;
    // Format: 12:59:09
    time << std::put_time(std::localtime(&t), "%H:%M:%S");

    // Cheat variables
    std::string logo = "octane";
#ifdef _DEBUG
    logo.append(" [debug]"); // :)
#endif
    const std::string user = "dungeon master";

    // Game variables
    // Mine i:: namespace == interfaces:: namespace o_0
    auto net_channel = i::client_state->m_net_channel; // Receiving ping may differ from cheat base
    auto delay = (int)(net_channel ? net_channel->get_latency(FLOW_INCOMING) : 0);
    auto tick_rate = (int)(1.f / i::globals->m_tick_interval); // m_interval_per_tick

    // Setup main watermark text
    auto text = logo + " | " + user + " | delay: " + std::to_string(delay) + "ms | " + std::to_string(tick_rate) + "tick | " + time.str().data();
    // If you has tinyformat lib you can use code below
    //auto text = tfm::format("%s | %s | delay: %ims | %itick | %s", logo, user, delay, tick_rate, time.str().data());

    // How to get screen_size o_0:
    // int w, h;
    // interfaces::surface->get_screen_size(w, h);

    //  pos
    //   v
    // [ octane | sove | delay: 0ms | 64tick | 12:59:09 ]
    // ^-^ padding                                      ^--^ margin
    //   ^--------------------------------------------^ size
    //
    // Calculating text size and position
    auto text_size = render::measure_text(font::verdana_12, text);
    // float text_size_x, text_size_y; render::get_text_size(font::verdana_12, text, text_size_x, text_size_y);
    auto text_pos = vec2(render::m_screen_size.x - margin - padding - text_size.x, // Right align + margin + padding + text_size
                                margin + padding); // Top align
    //vec2_t = (float, float)

    //pos
    // v
    // [ octane | sove | delay: 0ms | 64tick | 12:59:09 ]
    // ^-^ padding                                      ^--^ margin
    // ^------------------------------------------------^ size
    //
    // Calculating watermark background size and position
    auto bg_size = vec2(padding + text_size.x + padding, // Width
                              padding + text_size.y + padding); // Height
    auto bg_pos = vec2(render::m_screen_size.x - margin - padding - text_size.x - padding, // Right align + margin
                             margin); // Top align

    // Run on hooks::panel::paint_traverse
    // Surface rendering
    render::rect(bg_pos.x, bg_pos.y, bg_size.x, bg_size.y, col_background); // Background
    render::rect(bg_pos.x, bg_pos.y, bg_size.x, 2, col_accent); // Accent line
    render::text(text_pos.x, text_pos.y, font::verdana_12, text, col_text); // Text
}
C++:
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)
}

Возможные наименования структур в вашей пасте ?
color - col_t - color_t - Color
vec2 - vec2_t - vector2d - Vector2d
 
Статус
В этой теме нельзя размещать новые ответы.
Активность
Пока что здесь никого нет

Похожие темы

  • Закрыта
Исходник lw watermark
Ответы
0
Просмотры
2K
Ответы
5
Просмотры
2K
Ответы
7
Просмотры
1K
Ответы
4
Просмотры
1K
Сверху Снизу