From d1eaee6e6e46c61e4fc85cbe21ac77fb1cbe99f0 Mon Sep 17 00:00:00 2001 From: va_alpatov Date: Sun, 7 Jun 2026 19:08:01 +0300 Subject: [PATCH 1/2] improved outline arguments --- examples/example_hud/gui/main_window.cpp | 58 +++++++++++++------- include/omath/hud/entity_overlay.hpp | 24 ++++---- include/omath/hud/entity_overlay_widgets.hpp | 7 ++- source/hooks/hooks_manager.cpp | 2 +- source/hud/entity_overlay.cpp | 25 +++++---- 5 files changed, 70 insertions(+), 46 deletions(-) diff --git a/examples/example_hud/gui/main_window.cpp b/examples/example_hud/gui/main_window.cpp index 9a4646e..1f60eb6 100644 --- a/examples/example_hud/gui/main_window.cpp +++ b/examples/example_hud/gui/main_window.cpp @@ -196,6 +196,10 @@ namespace imgui_desktop::gui const DashedBar dbar{m_bar_color, m_bar_outline_color, m_bar_bg_color, m_bar_width, m_bar_value, m_bar_dash_len, m_bar_dash_gap, m_bar_offset}; + auto outline_helper = [](const bool is_outline) -> Outlined + { + return is_outline ? Outlined::On : Outlined::Off; + }; omath::hud::EntityOverlay({m_entity_x, m_entity_top_y}, {m_entity_x, m_entity_bottom_y}, std::make_shared()) .contents( @@ -207,47 +211,61 @@ namespace imgui_desktop::gui RightSide{ when(m_show_right_bar, bar), when(m_show_right_dashed_bar, dbar), - when(m_show_right_labels, - Label{{0.f, 1.f, 0.f, 1.f}, m_label_offset, m_outlined, "Health: 100/100"}), - when(m_show_right_labels, - Label{{1.f, 0.f, 0.f, 1.f}, m_label_offset, m_outlined, "Shield: 125/125"}), - when(m_show_right_labels, - Label{{1.f, 0.f, 1.f, 1.f}, m_label_offset, m_outlined, "*LOCKED*"}), + when(m_show_right_labels, Label{{0.f, 1.f, 0.f, 1.f}, + m_label_offset, + outline_helper(m_outlined), + "Health: 100/100"}), + when(m_show_right_labels, Label{{1.f, 0.f, 0.f, 1.f}, + m_label_offset, + outline_helper(m_outlined), + "Shield: 125/125"}), + when(m_show_right_labels, Label{{1.f, 0.f, 1.f, 1.f}, + m_label_offset, + outline_helper(m_outlined), + "*LOCKED*"}), - SpaceVertical{10}, + SpaceVertical{10}, when(m_show_ring, ProgressRing{m_ring_color, m_ring_bg, m_ring_radius, m_ring_ratio, m_ring_thickness, m_ring_offset}), }, LeftSide{ when(m_show_left_bar, bar), when(m_show_left_dashed_bar, dbar), - when(m_show_left_labels, Label{omath::Color::from_rgba(255, 128, 0, 255), - m_label_offset, m_outlined, "Armor: 75"}), - when(m_show_left_labels, Label{omath::Color::from_rgba(0, 200, 255, 255), - m_label_offset, m_outlined, "Level: 42"}), + when(m_show_left_labels, + Label{omath::Color::from_rgba(255, 128, 0, 255), m_label_offset, + outline_helper(m_outlined), "Armor: 75"}), + when(m_show_left_labels, + Label{omath::Color::from_rgba(0, 200, 255, 255), m_label_offset, + outline_helper(m_outlined), "Level: 42"}), }, TopSide{ when(m_show_top_bar, bar), when(m_show_top_dashed_bar, dbar), - when(m_show_centered_top, Centered{Label{omath::Color::from_rgba(0, 255, 255, 255), - m_label_offset, m_outlined, "*VISIBLE*"}}), + when(m_show_centered_top, + Centered{Label{omath::Color::from_rgba(0, 255, 255, 255), m_label_offset, + outline_helper(m_outlined), "*VISIBLE*"}}), when(m_show_top_labels, Label{omath::Color::from_rgba(255, 255, 0, 255), m_label_offset, - m_outlined, "*SCOPED*"}), + outline_helper(m_outlined), "*SCOPED*"}), when(m_show_top_labels, Label{omath::Color::from_rgba(255, 0, 0, 255), m_label_offset, - m_outlined, "*BLEEDING*"}), + outline_helper(m_outlined), "*BLEEDING*"}), }, BottomSide{ when(m_show_bottom_bar, bar), when(m_show_bottom_dashed_bar, dbar), - when(m_show_centered_bottom, Centered{Label{omath::Color::from_rgba(255, 255, 255, 255), - m_label_offset, m_outlined, "PlayerName"}}), + when(m_show_centered_bottom, + Centered{Label{omath::Color::from_rgba(255, 255, 255, 255), m_label_offset, + outline_helper(m_outlined), "PlayerName"}}), when(m_show_bottom_labels, Label{omath::Color::from_rgba(200, 200, 0, 255), - m_label_offset, m_outlined, "42m"}), + m_label_offset, outline_helper(m_outlined), "42m"}), }, - when(m_show_aim, AimDot{{m_entity_x, m_entity_top_y+40.f}, m_aim_color, m_aim_radius}), + when(m_show_aim, AimDot{{m_entity_x, m_entity_top_y + 40.f}, m_aim_color, m_aim_radius}), when(m_show_scan, ScanMarker{m_scan_color, m_scan_outline, m_scan_outline_thickness}), when(m_show_skeleton, Skeleton{m_skel_color, m_skel_thickness}), - when(m_show_proj, ProjectileAim{{m_proj_pos_x, m_proj_pos_y}, m_proj_color, m_proj_size, m_proj_line_width, static_cast(m_proj_figure)}), + when(m_show_proj, ProjectileAim{{m_proj_pos_x, m_proj_pos_y}, + m_proj_color, + m_proj_size, + m_proj_line_width, + static_cast(m_proj_figure)}), when(m_show_snap, SnapLine{{vp->Size.x / 2.f, vp->Size.y}, m_snap_color, m_snap_width})); } diff --git a/include/omath/hud/entity_overlay.hpp b/include/omath/hud/entity_overlay.hpp index a203a9f..0596cb3 100644 --- a/include/omath/hud/entity_overlay.hpp +++ b/include/omath/hud/entity_overlay.hpp @@ -57,22 +57,22 @@ namespace omath::hud float offset = 5.f); // ── Labels ─────────────────────────────────────────────────────── - EntityOverlay& add_right_label(const Color& color, float offset, bool outlined, const std::string_view& text); + EntityOverlay& add_right_label(const Color& color, float offset, widget::Outlined outlined, const std::string_view& text); - EntityOverlay& add_left_label(const Color& color, float offset, bool outlined, const std::string_view& text); + EntityOverlay& add_left_label(const Color& color, float offset, widget::Outlined outlined, const std::string_view& text); - EntityOverlay& add_top_label(const Color& color, float offset, bool outlined, std::string_view text); + EntityOverlay& add_top_label(const Color& color, float offset, widget::Outlined outlined, std::string_view text); - EntityOverlay& add_bottom_label(const Color& color, float offset, bool outlined, std::string_view text); + EntityOverlay& add_bottom_label(const Color& color, float offset, widget::Outlined outlined, std::string_view text); - EntityOverlay& add_centered_top_label(const Color& color, float offset, bool outlined, + EntityOverlay& add_centered_top_label(const Color& color, float offset, widget::Outlined outlined, const std::string_view& text); - EntityOverlay& add_centered_bottom_label(const Color& color, float offset, bool outlined, + EntityOverlay& add_centered_bottom_label(const Color& color, float offset, widget::Outlined outlined, const std::string_view& text); template - EntityOverlay& add_right_label(const Color& color, const float offset, const bool outlined, std::format_string fmt, + EntityOverlay& add_right_label(const Color& color, const float offset, const widget::Outlined outlined, std::format_string fmt, Args&&... args) { return add_right_label(color, offset, outlined, @@ -80,7 +80,7 @@ namespace omath::hud } template - EntityOverlay& add_left_label(const Color& color, const float offset, const bool outlined, std::format_string fmt, + EntityOverlay& add_left_label(const Color& color, const float offset, const widget::Outlined outlined, std::format_string fmt, Args&&... args) { return add_left_label(color, offset, outlined, @@ -88,7 +88,7 @@ namespace omath::hud } template - EntityOverlay& add_top_label(const Color& color, const float offset, const bool outlined, std::format_string fmt, + EntityOverlay& add_top_label(const Color& color, const float offset, const widget::Outlined outlined, std::format_string fmt, Args&&... args) { return add_top_label(color, offset, outlined, @@ -96,7 +96,7 @@ namespace omath::hud } template - EntityOverlay& add_bottom_label(const Color& color, const float offset, const bool outlined, + EntityOverlay& add_bottom_label(const Color& color, const float offset, const widget::Outlined outlined, std::format_string fmt, Args&&... args) { return add_bottom_label(color, offset, outlined, @@ -104,7 +104,7 @@ namespace omath::hud } template - EntityOverlay& add_centered_top_label(const Color& color, const float offset, const bool outlined, + EntityOverlay& add_centered_top_label(const Color& color, const float offset, const widget::Outlined outlined, std::format_string fmt, Args&&... args) { return add_centered_top_label(color, offset, outlined, @@ -112,7 +112,7 @@ namespace omath::hud } template - EntityOverlay& add_centered_bottom_label(const Color& color, const float offset, const bool outlined, + EntityOverlay& add_centered_bottom_label(const Color& color, const float offset, const widget::Outlined outlined, std::format_string fmt, Args&&... args) { return add_centered_bottom_label(color, offset, outlined, diff --git a/include/omath/hud/entity_overlay_widgets.hpp b/include/omath/hud/entity_overlay_widgets.hpp index 69c66b2..6b2e300 100644 --- a/include/omath/hud/entity_overlay_widgets.hpp +++ b/include/omath/hud/entity_overlay_widgets.hpp @@ -30,6 +30,11 @@ namespace omath::hud::widget float thickness = 1.f; }; + enum class Outlined + { + Off, + On, + }; struct CorneredBox { Color color; @@ -118,7 +123,7 @@ namespace omath::hud::widget { Color color; float offset; - bool outlined; + Outlined outlined; std::string_view text; }; diff --git a/source/hooks/hooks_manager.cpp b/source/hooks/hooks_manager.cpp index cc35cab..3cfe775 100644 --- a/source/hooks/hooks_manager.cpp +++ b/source/hooks/hooks_manager.cpp @@ -660,7 +660,7 @@ namespace omath::hooks LRESULT __stdcall HooksManager::wnd_proc_detour(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) { - auto& mgr = get(); + const auto& mgr = get(); callback_ptr cb; WNDPROC original; { diff --git a/source/hud/entity_overlay.cpp b/source/hud/entity_overlay.cpp index 4833979..377faa2 100644 --- a/source/hud/entity_overlay.cpp +++ b/source/hud/entity_overlay.cpp @@ -98,10 +98,11 @@ namespace omath::hud return *this; } - EntityOverlay& EntityOverlay::add_right_label(const Color& color, const float offset, const bool outlined, + EntityOverlay& EntityOverlay::add_right_label(const Color& color, const float offset, + const widget::Outlined outlined, const std::string_view& text) { - if (outlined) + if (outlined == widget::Outlined::On) draw_outlined_text(m_text_cursor_right + Vector2{offset, 0.f}, color, text); else m_renderer->add_text(m_text_cursor_right + Vector2{offset, 0.f}, color, text.data()); @@ -110,12 +111,12 @@ namespace omath::hud return *this; } - EntityOverlay& EntityOverlay::add_top_label(const Color& color, const float offset, const bool outlined, + EntityOverlay& EntityOverlay::add_top_label(const Color& color, const float offset, const widget::Outlined outlined, const std::string_view text) { m_text_cursor_top.y -= m_renderer->calc_text_size(text.data()).y; - if (outlined) + if (outlined == widget::Outlined::On) draw_outlined_text(m_text_cursor_top + Vector2{0.f, -offset}, color, text); else m_renderer->add_text(m_text_cursor_top + Vector2{0.f, -offset}, color, text.data()); @@ -392,12 +393,12 @@ namespace omath::hud return *this; } - EntityOverlay& EntityOverlay::add_bottom_label(const Color& color, const float offset, const bool outlined, + EntityOverlay& EntityOverlay::add_bottom_label(const Color& color, const float offset, const widget::Outlined outlined, const std::string_view text) { const auto text_size = m_renderer->calc_text_size(text); - if (outlined) + if (outlined == widget::Outlined::On) draw_outlined_text(m_text_cursor_bottom + Vector2{0.f, offset}, color, text); else m_renderer->add_text(m_text_cursor_bottom + Vector2{0.f, offset}, color, text); @@ -407,13 +408,13 @@ namespace omath::hud return *this; } - EntityOverlay& EntityOverlay::add_left_label(const Color& color, const float offset, const bool outlined, + EntityOverlay& EntityOverlay::add_left_label(const Color& color, const float offset, const widget::Outlined outlined, const std::string_view& text) { const auto text_size = m_renderer->calc_text_size(text); const auto pos = m_text_cursor_left + Vector2{-(offset + text_size.x), 0.f}; - if (outlined) + if (outlined == widget::Outlined::On) draw_outlined_text(pos, color, text); else m_renderer->add_text(pos, color, text); @@ -423,7 +424,7 @@ namespace omath::hud return *this; } - EntityOverlay& EntityOverlay::add_centered_bottom_label(const Color& color, const float offset, const bool outlined, + EntityOverlay& EntityOverlay::add_centered_bottom_label(const Color& color, const float offset, const widget::Outlined outlined, const std::string_view& text) { const auto text_size = m_renderer->calc_text_size(text); @@ -431,7 +432,7 @@ namespace omath::hud m_canvas.bottom_left_corner.x + (m_canvas.bottom_right_corner.x - m_canvas.bottom_left_corner.x) / 2.f; const auto pos = Vector2{box_center_x - text_size.x / 2.f, m_text_cursor_bottom.y + offset}; - if (outlined) + if (outlined == widget::Outlined::On) draw_outlined_text(pos, color, text); else m_renderer->add_text(pos, color, text); @@ -441,7 +442,7 @@ namespace omath::hud return *this; } - EntityOverlay& EntityOverlay::add_centered_top_label(const Color& color, const float offset, const bool outlined, + EntityOverlay& EntityOverlay::add_centered_top_label(const Color& color, const float offset, const widget::Outlined outlined, const std::string_view& text) { const auto text_size = m_renderer->calc_text_size(text); @@ -451,7 +452,7 @@ namespace omath::hud m_text_cursor_top.y -= text_size.y; const auto pos = Vector2{box_center_x - text_size.x / 2.f, m_text_cursor_top.y - offset}; - if (outlined) + if (outlined == widget::Outlined::On) draw_outlined_text(pos, color, text); else m_renderer->add_text(pos, color, text); From de8a540426ff9eb234ab6784ce4059556bc00c37 Mon Sep 17 00:00:00 2001 From: va_alpatov Date: Sun, 7 Jun 2026 19:22:41 +0300 Subject: [PATCH 2/2] applied fix for lua --- source/lua/lua_hud.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/source/lua/lua_hud.cpp b/source/lua/lua_hud.cpp index 9dd2420..e0ac8a9 100644 --- a/source/lua/lua_hud.cpp +++ b/source/lua/lua_hud.cpp @@ -159,6 +159,12 @@ namespace return {1.f, 1.f, 1.f, 1.f}; } + [[nodiscard]] + omath::hud::widget::Outlined outlined_from_bool(const bool outlined) + { + return outlined ? omath::hud::widget::Outlined::On : omath::hud::widget::Outlined::Off; + } + [[nodiscard]] omath::hud::EntityOverlay make_overlay(const omath::Vector2& top, const omath::Vector2& bottom, const std::shared_ptr& renderer) @@ -374,37 +380,37 @@ namespace omath::lua [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& { - return overlay.add_right_label(color, offset, outlined, text); + return overlay.add_right_label(color, offset, outlined_from_bool(outlined), text); }, "add_left_label", [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& { - return overlay.add_left_label(color, offset, outlined, text); + return overlay.add_left_label(color, offset, outlined_from_bool(outlined), text); }, "add_top_label", [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& { - return overlay.add_top_label(color, offset, outlined, text); + return overlay.add_top_label(color, offset, outlined_from_bool(outlined), text); }, "add_bottom_label", [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& { - return overlay.add_bottom_label(color, offset, outlined, text); + return overlay.add_bottom_label(color, offset, outlined_from_bool(outlined), text); }, "add_centered_top_label", [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& { - return overlay.add_centered_top_label(color, offset, outlined, text); + return overlay.add_centered_top_label(color, offset, outlined_from_bool(outlined), text); }, "add_centered_bottom_label", [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& { - return overlay.add_centered_bottom_label(color, offset, outlined, text); + return overlay.add_centered_bottom_label(color, offset, outlined_from_bool(outlined), text); }, "add_right_space_vertical", &omath::hud::EntityOverlay::add_right_space_vertical,