Merge pull request #196 from orange-cpp/feature/outline

improved outline arguments
This commit is contained in:
2026-06-07 19:39:20 +03:00
committed by GitHub
6 changed files with 82 additions and 52 deletions
+38 -20
View File
@@ -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, 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}; 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}, omath::hud::EntityOverlay({m_entity_x, m_entity_top_y}, {m_entity_x, m_entity_bottom_y},
std::make_shared<omath::hud::ImguiHudRenderer>()) std::make_shared<omath::hud::ImguiHudRenderer>())
.contents( .contents(
@@ -207,47 +211,61 @@ namespace imgui_desktop::gui
RightSide{ RightSide{
when(m_show_right_bar, bar), when(m_show_right_bar, bar),
when(m_show_right_dashed_bar, dbar), when(m_show_right_dashed_bar, dbar),
when(m_show_right_labels, when(m_show_right_labels, Label{{0.f, 1.f, 0.f, 1.f},
Label{{0.f, 1.f, 0.f, 1.f}, m_label_offset, m_outlined, "Health: 100/100"}), m_label_offset,
when(m_show_right_labels, outline_helper(m_outlined),
Label{{1.f, 0.f, 0.f, 1.f}, m_label_offset, m_outlined, "Shield: 125/125"}), "Health: 100/100"}),
when(m_show_right_labels, when(m_show_right_labels, Label{{1.f, 0.f, 0.f, 1.f},
Label{{1.f, 0.f, 1.f, 1.f}, m_label_offset, m_outlined, "*LOCKED*"}), 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, when(m_show_ring, ProgressRing{m_ring_color, m_ring_bg, m_ring_radius, m_ring_ratio,
m_ring_thickness, m_ring_offset}), m_ring_thickness, m_ring_offset}),
}, },
LeftSide{ LeftSide{
when(m_show_left_bar, bar), when(m_show_left_bar, bar),
when(m_show_left_dashed_bar, dbar), when(m_show_left_dashed_bar, dbar),
when(m_show_left_labels, Label{omath::Color::from_rgba(255, 128, 0, 255), when(m_show_left_labels,
m_label_offset, m_outlined, "Armor: 75"}), Label{omath::Color::from_rgba(255, 128, 0, 255), m_label_offset,
when(m_show_left_labels, Label{omath::Color::from_rgba(0, 200, 255, 255), outline_helper(m_outlined), "Armor: 75"}),
m_label_offset, m_outlined, "Level: 42"}), when(m_show_left_labels,
Label{omath::Color::from_rgba(0, 200, 255, 255), m_label_offset,
outline_helper(m_outlined), "Level: 42"}),
}, },
TopSide{ TopSide{
when(m_show_top_bar, bar), when(m_show_top_bar, bar),
when(m_show_top_dashed_bar, dbar), when(m_show_top_dashed_bar, dbar),
when(m_show_centered_top, Centered{Label{omath::Color::from_rgba(0, 255, 255, 255), when(m_show_centered_top,
m_label_offset, m_outlined, "*VISIBLE*"}}), 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, 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, 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{ BottomSide{
when(m_show_bottom_bar, bar), when(m_show_bottom_bar, bar),
when(m_show_bottom_dashed_bar, dbar), when(m_show_bottom_dashed_bar, dbar),
when(m_show_centered_bottom, Centered{Label{omath::Color::from_rgba(255, 255, 255, 255), when(m_show_centered_bottom,
m_label_offset, m_outlined, "PlayerName"}}), 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), 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_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_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<ProjectileAim::Figure>(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<ProjectileAim::Figure>(m_proj_figure)}),
when(m_show_snap, SnapLine{{vp->Size.x / 2.f, vp->Size.y}, m_snap_color, m_snap_width})); when(m_show_snap, SnapLine{{vp->Size.x / 2.f, vp->Size.y}, m_snap_color, m_snap_width}));
} }
+12 -12
View File
@@ -57,22 +57,22 @@ namespace omath::hud
float offset = 5.f); float offset = 5.f);
// ── Labels ─────────────────────────────────────────────────────── // ── 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); 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); const std::string_view& text);
template<typename... Args> template<typename... Args>
EntityOverlay& add_right_label(const Color& color, const float offset, const bool outlined, std::format_string<Args...> fmt, EntityOverlay& add_right_label(const Color& color, const float offset, const widget::Outlined outlined, std::format_string<Args...> fmt,
Args&&... args) Args&&... args)
{ {
return add_right_label(color, offset, outlined, return add_right_label(color, offset, outlined,
@@ -80,7 +80,7 @@ namespace omath::hud
} }
template<typename... Args> template<typename... Args>
EntityOverlay& add_left_label(const Color& color, const float offset, const bool outlined, std::format_string<Args...> fmt, EntityOverlay& add_left_label(const Color& color, const float offset, const widget::Outlined outlined, std::format_string<Args...> fmt,
Args&&... args) Args&&... args)
{ {
return add_left_label(color, offset, outlined, return add_left_label(color, offset, outlined,
@@ -88,7 +88,7 @@ namespace omath::hud
} }
template<typename... Args> template<typename... Args>
EntityOverlay& add_top_label(const Color& color, const float offset, const bool outlined, std::format_string<Args...> fmt, EntityOverlay& add_top_label(const Color& color, const float offset, const widget::Outlined outlined, std::format_string<Args...> fmt,
Args&&... args) Args&&... args)
{ {
return add_top_label(color, offset, outlined, return add_top_label(color, offset, outlined,
@@ -96,7 +96,7 @@ namespace omath::hud
} }
template<typename... Args> template<typename... Args>
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<Args...> fmt, Args&&... args) std::format_string<Args...> fmt, Args&&... args)
{ {
return add_bottom_label(color, offset, outlined, return add_bottom_label(color, offset, outlined,
@@ -104,7 +104,7 @@ namespace omath::hud
} }
template<typename... Args> template<typename... Args>
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<Args...> fmt, Args&&... args) std::format_string<Args...> fmt, Args&&... args)
{ {
return add_centered_top_label(color, offset, outlined, return add_centered_top_label(color, offset, outlined,
@@ -112,7 +112,7 @@ namespace omath::hud
} }
template<typename... Args> template<typename... Args>
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<Args...> fmt, Args&&... args) std::format_string<Args...> fmt, Args&&... args)
{ {
return add_centered_bottom_label(color, offset, outlined, return add_centered_bottom_label(color, offset, outlined,
+6 -1
View File
@@ -30,6 +30,11 @@ namespace omath::hud::widget
float thickness = 1.f; float thickness = 1.f;
}; };
enum class Outlined
{
Off,
On,
};
struct CorneredBox struct CorneredBox
{ {
Color color; Color color;
@@ -118,7 +123,7 @@ namespace omath::hud::widget
{ {
Color color; Color color;
float offset; float offset;
bool outlined; Outlined outlined;
std::string_view text; std::string_view text;
}; };
+1 -1
View File
@@ -660,7 +660,7 @@ namespace omath::hooks
LRESULT __stdcall HooksManager::wnd_proc_detour(HWND hwnd, UINT msg, WPARAM w_param, LPARAM l_param) 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<wnd_proc_callback> cb; callback_ptr<wnd_proc_callback> cb;
WNDPROC original; WNDPROC original;
{ {
+13 -12
View File
@@ -98,10 +98,11 @@ namespace omath::hud
return *this; 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) const std::string_view& text)
{ {
if (outlined) if (outlined == widget::Outlined::On)
draw_outlined_text(m_text_cursor_right + Vector2<float>{offset, 0.f}, color, text); draw_outlined_text(m_text_cursor_right + Vector2<float>{offset, 0.f}, color, text);
else else
m_renderer->add_text(m_text_cursor_right + Vector2<float>{offset, 0.f}, color, text.data()); m_renderer->add_text(m_text_cursor_right + Vector2<float>{offset, 0.f}, color, text.data());
@@ -110,12 +111,12 @@ namespace omath::hud
return *this; 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) const std::string_view text)
{ {
m_text_cursor_top.y -= m_renderer->calc_text_size(text.data()).y; 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<float>{0.f, -offset}, color, text); draw_outlined_text(m_text_cursor_top + Vector2<float>{0.f, -offset}, color, text);
else else
m_renderer->add_text(m_text_cursor_top + Vector2<float>{0.f, -offset}, color, text.data()); m_renderer->add_text(m_text_cursor_top + Vector2<float>{0.f, -offset}, color, text.data());
@@ -392,12 +393,12 @@ namespace omath::hud
return *this; 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 std::string_view text)
{ {
const auto text_size = m_renderer->calc_text_size(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<float>{0.f, offset}, color, text); draw_outlined_text(m_text_cursor_bottom + Vector2<float>{0.f, offset}, color, text);
else else
m_renderer->add_text(m_text_cursor_bottom + Vector2<float>{0.f, offset}, color, text); m_renderer->add_text(m_text_cursor_bottom + Vector2<float>{0.f, offset}, color, text);
@@ -407,13 +408,13 @@ namespace omath::hud
return *this; 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 std::string_view& text)
{ {
const auto text_size = m_renderer->calc_text_size(text); const auto text_size = m_renderer->calc_text_size(text);
const auto pos = m_text_cursor_left + Vector2<float>{-(offset + text_size.x), 0.f}; const auto pos = m_text_cursor_left + Vector2<float>{-(offset + text_size.x), 0.f};
if (outlined) if (outlined == widget::Outlined::On)
draw_outlined_text(pos, color, text); draw_outlined_text(pos, color, text);
else else
m_renderer->add_text(pos, color, text); m_renderer->add_text(pos, color, text);
@@ -423,7 +424,7 @@ namespace omath::hud
return *this; 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 std::string_view& text)
{ {
const auto text_size = m_renderer->calc_text_size(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; m_canvas.bottom_left_corner.x + (m_canvas.bottom_right_corner.x - m_canvas.bottom_left_corner.x) / 2.f;
const auto pos = Vector2<float>{box_center_x - text_size.x / 2.f, m_text_cursor_bottom.y + offset}; const auto pos = Vector2<float>{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); draw_outlined_text(pos, color, text);
else else
m_renderer->add_text(pos, color, text); m_renderer->add_text(pos, color, text);
@@ -441,7 +442,7 @@ namespace omath::hud
return *this; 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 std::string_view& text)
{ {
const auto text_size = m_renderer->calc_text_size(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; m_text_cursor_top.y -= text_size.y;
const auto pos = Vector2<float>{box_center_x - text_size.x / 2.f, m_text_cursor_top.y - offset}; const auto pos = Vector2<float>{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); draw_outlined_text(pos, color, text);
else else
m_renderer->add_text(pos, color, text); m_renderer->add_text(pos, color, text);
+12 -6
View File
@@ -159,6 +159,12 @@ namespace
return {1.f, 1.f, 1.f, 1.f}; 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]] [[nodiscard]]
omath::hud::EntityOverlay make_overlay(const omath::Vector2<float>& top, const omath::Vector2<float>& bottom, omath::hud::EntityOverlay make_overlay(const omath::Vector2<float>& top, const omath::Vector2<float>& bottom,
const std::shared_ptr<LuaHudRenderer>& renderer) const std::shared_ptr<LuaHudRenderer>& renderer)
@@ -374,37 +380,37 @@ namespace omath::lua
[](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset,
const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& 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", "add_left_label",
[](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset,
const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& 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", "add_top_label",
[](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset,
const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& 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", "add_bottom_label",
[](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset,
const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& 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", "add_centered_top_label",
[](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset,
const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& 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", "add_centered_bottom_label",
[](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset, [](omath::hud::EntityOverlay& overlay, const omath::Color& color, const float offset,
const bool outlined, const std::string& text) -> omath::hud::EntityOverlay& 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, "add_right_space_vertical", &omath::hud::EntityOverlay::add_right_space_vertical,