From b9da58e1380fb0b9d981fa83bdf2c03c906ed486 Mon Sep 17 00:00:00 2001 From: va_alpatov Date: Mon, 8 Jun 2026 03:43:08 +0300 Subject: [PATCH] added enity overlay aspect --- examples/example_hud/gui/main_window.cpp | 3 ++- examples/example_hud/gui/main_window.hpp | 3 +-- include/omath/hud/entity_overlay.hpp | 2 +- source/hud/entity_overlay.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/example_hud/gui/main_window.cpp b/examples/example_hud/gui/main_window.cpp index 1f60eb6..e653715 100644 --- a/examples/example_hud/gui/main_window.cpp +++ b/examples/example_hud/gui/main_window.cpp @@ -71,6 +71,7 @@ namespace imgui_desktop::gui ImGui::SliderFloat("X##ent", &m_entity_x, 100.f, vp->Size.x - 100.f); ImGui::SliderFloat("Top Y", &m_entity_top_y, 20.f, m_entity_bottom_y - 20.f); ImGui::SliderFloat("Bottom Y", &m_entity_bottom_y, m_entity_top_y + 20.f, vp->Size.y - 20.f); + ImGui::SliderFloat("Aspect", &m_entity_aspect, 1.f, 10.f); } if (ImGui::CollapsingHeader("Box", ImGuiTreeNodeFlags_DefaultOpen)) @@ -200,7 +201,7 @@ namespace imgui_desktop::gui { 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}, m_entity_aspect, std::make_shared()) .contents( // ── Boxes ──────────────────────────────────────────────────── diff --git a/examples/example_hud/gui/main_window.hpp b/examples/example_hud/gui/main_window.hpp index ad28b28..da88d90 100644 --- a/examples/example_hud/gui/main_window.hpp +++ b/examples/example_hud/gui/main_window.hpp @@ -26,8 +26,7 @@ namespace imgui_desktop::gui bool m_opened = true; // Entity - float m_entity_x = 550.f, m_entity_top_y = 150.f, m_entity_bottom_y = 450.f; - + float m_entity_x = 550.f, m_entity_top_y = 150.f, m_entity_bottom_y = 450.f, m_entity_aspect = 4.f; // Box omath::Color m_box_color{1.f, 1.f, 1.f, 1.f}; omath::Color m_box_fill{0.f, 0.f, 0.f, 0.f}; diff --git a/include/omath/hud/entity_overlay.hpp b/include/omath/hud/entity_overlay.hpp index 0596cb3..30c34f2 100644 --- a/include/omath/hud/entity_overlay.hpp +++ b/include/omath/hud/entity_overlay.hpp @@ -15,7 +15,7 @@ namespace omath::hud class EntityOverlay final { public: - EntityOverlay(const Vector2& top, const Vector2& bottom, + EntityOverlay(const Vector2& top, const Vector2& bottom, float aspect, const std::shared_ptr& renderer); // ── Boxes ──────────────────────────────────────────────────────── diff --git a/source/hud/entity_overlay.cpp b/source/hud/entity_overlay.cpp index 377faa2..244351f 100644 --- a/source/hud/entity_overlay.cpp +++ b/source/hud/entity_overlay.cpp @@ -460,9 +460,9 @@ namespace omath::hud return *this; } - EntityOverlay::EntityOverlay(const Vector2& top, const Vector2& bottom, + EntityOverlay::EntityOverlay(const Vector2& top, const Vector2& bottom, const float aspect, const std::shared_ptr& renderer) - : m_canvas(top, bottom), m_text_cursor_right(m_canvas.top_right_corner), + : m_canvas(top, bottom, aspect), m_text_cursor_right(m_canvas.top_right_corner), m_text_cursor_top(m_canvas.top_left_corner), m_text_cursor_bottom(m_canvas.bottom_left_corner), m_text_cursor_left(m_canvas.top_left_corner), m_renderer(renderer) {