From 2c6d7c2dfaf8c11c7d90894c2d7ce032da704ab4 Mon Sep 17 00:00:00 2001 From: Orange Date: Sun, 12 Jul 2026 11:10:13 +0300 Subject: [PATCH] bar fixes --- source/hud/entity_overlay.cpp | 46 +++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/source/hud/entity_overlay.cpp b/source/hud/entity_overlay.cpp index 2b0aed2..8f7a9c7 100644 --- a/source/hud/entity_overlay.cpp +++ b/source/hud/entity_overlay.cpp @@ -85,12 +85,14 @@ namespace omath::hud const auto max_bar_height = std::abs(m_canvas.top_right_corner.y - m_canvas.bottom_right_corner.y); const auto bar_start = Vector2{m_text_cursor_right.x + offset, m_canvas.bottom_right_corner.y}; - m_renderer->add_filled_rectangle(bar_start, bar_start + Vector2(width, -max_bar_height), bg_color); + const auto bar_min = bar_start - Vector2{0.f, max_bar_height}; + const auto bar_max = bar_start + Vector2{width, 0.f}; + const auto fill_min = bar_start - Vector2{0.f, max_bar_height * ratio}; + m_renderer->add_filled_rectangle(bar_min, bar_max, bg_color); - draw_glow_rectangle(bar_start, bar_start + Vector2(width, -max_bar_height * ratio), glow); - draw_filled_rectangle(bar_start, bar_start + Vector2(width, -max_bar_height * ratio), color); - m_renderer->add_rectangle(bar_start - Vector2(1.f, 0.f), - bar_start + Vector2(width, -max_bar_height), outline_color); + draw_glow_rectangle(fill_min, bar_max, glow); + draw_filled_rectangle(fill_min, bar_max, color); + m_renderer->add_rectangle(bar_min, bar_max, outline_color); m_text_cursor_right.x += offset + width; @@ -104,12 +106,14 @@ namespace omath::hud const auto max_bar_height = std::abs(m_canvas.top_left_corner.y - m_canvas.bottom_right_corner.y); const auto bar_start = Vector2{m_text_cursor_left.x - (offset + width), m_canvas.bottom_left_corner.y}; - m_renderer->add_filled_rectangle(bar_start, bar_start + Vector2(width, -max_bar_height), bg_color); + const auto bar_min = bar_start - Vector2{0.f, max_bar_height}; + const auto bar_max = bar_start + Vector2{width, 0.f}; + const auto fill_min = bar_start - Vector2{0.f, max_bar_height * ratio}; + m_renderer->add_filled_rectangle(bar_min, bar_max, bg_color); - draw_glow_rectangle(bar_start, bar_start + Vector2(width, -max_bar_height * ratio), glow); - draw_filled_rectangle(bar_start, bar_start + Vector2(width, -max_bar_height * ratio), color); - m_renderer->add_rectangle(bar_start - Vector2(1.f, 0.f), - bar_start + Vector2(width, -max_bar_height), outline_color); + draw_glow_rectangle(fill_min, bar_max, glow); + draw_filled_rectangle(fill_min, bar_max, color); + m_renderer->add_rectangle(bar_min, bar_max, outline_color); m_text_cursor_left.x -= offset + width; @@ -143,11 +147,14 @@ namespace omath::hud const auto max_bar_width = std::abs(m_canvas.top_left_corner.x - m_canvas.bottom_right_corner.x); const auto bar_start = Vector2{m_canvas.top_left_corner.x, m_text_cursor_top.y - offset}; - m_renderer->add_filled_rectangle(bar_start, bar_start + Vector2(max_bar_width, -height), bg_color); + const auto bar_min = bar_start - Vector2{0.f, height}; + const auto bar_max = bar_start + Vector2{max_bar_width, 0.f}; + const auto fill_max = Vector2{bar_start.x + max_bar_width * ratio, bar_start.y}; + m_renderer->add_filled_rectangle(bar_min, bar_max, bg_color); - draw_glow_rectangle(bar_start, bar_start + Vector2(max_bar_width * ratio, -height), glow); - draw_filled_rectangle(bar_start, bar_start + Vector2(max_bar_width * ratio, -height), color); - m_renderer->add_rectangle(bar_start, bar_start + Vector2(max_bar_width, -height), outline_color); + draw_glow_rectangle(bar_min, fill_max, glow); + draw_filled_rectangle(bar_min, fill_max, color); + m_renderer->add_rectangle(bar_min, bar_max, outline_color); m_text_cursor_top.y -= offset + height; @@ -553,10 +560,13 @@ namespace omath::hud const auto max_bar_width = std::abs(m_canvas.bottom_right_corner.x - m_canvas.bottom_left_corner.x); const auto bar_start = Vector2{m_canvas.bottom_left_corner.x, m_text_cursor_bottom.y + offset}; - m_renderer->add_filled_rectangle(bar_start, bar_start + Vector2(max_bar_width, height), bg_color); - draw_glow_rectangle(bar_start, bar_start + Vector2(max_bar_width * ratio, height), glow); - draw_filled_rectangle(bar_start, bar_start + Vector2(max_bar_width * ratio, height), color); - m_renderer->add_rectangle(bar_start, bar_start + Vector2(max_bar_width, height), outline_color); + const auto bar_min = bar_start; + const auto bar_max = bar_start + Vector2{max_bar_width, height}; + const auto fill_max = bar_start + Vector2{max_bar_width * ratio, height}; + m_renderer->add_filled_rectangle(bar_min, bar_max, bg_color); + draw_glow_rectangle(bar_min, fill_max, glow); + draw_filled_rectangle(bar_min, fill_max, color); + m_renderer->add_rectangle(bar_min, bar_max, outline_color); m_text_cursor_bottom.y += offset + height;