add projectile

This commit is contained in:
2026-03-17 19:36:35 +03:00
parent 37ea091282
commit b8e61f49fa
5 changed files with 59 additions and 4 deletions

View File

@@ -164,6 +164,17 @@ namespace imgui_desktop::gui
ImGui::SliderFloat("Radius##aim", &m_aim_radius, 1.f, 10.f);
}
if (ImGui::CollapsingHeader("Projectile Aim"))
{
ImGui::Checkbox("Show##proj", &m_show_proj);
ImGui::ColorEdit4("Color##proj", reinterpret_cast<float*>(&m_proj_color), ImGuiColorEditFlags_NoInputs);
ImGui::SliderFloat("Size##proj", &m_proj_size, 1.f, 30.f);
ImGui::SliderFloat("Line width##proj", &m_proj_line_width, 0.5f, 5.f);
ImGui::SliderFloat("Pos X##proj", &m_proj_pos_x, 0.f, vp->Size.x);
ImGui::SliderFloat("Pos Y##proj", &m_proj_pos_y, 0.f, vp->Size.y);
ImGui::Combo("Figure##proj", &m_proj_figure, "Circle\0Square\0");
}
if (ImGui::CollapsingHeader("Snap Line"))
{
ImGui::Checkbox("Show##snap", &m_show_snap);
@@ -235,6 +246,7 @@ namespace imgui_desktop::gui
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<ProjectileAim::Figure>(m_proj_figure)}),
when(m_show_snap, SnapLine{{vp->Size.x / 2.f, vp->Size.y}, m_snap_color, m_snap_width}));
}

View File

@@ -82,5 +82,13 @@ namespace imgui_desktop::gui
omath::Color m_snap_color = omath::Color::from_rgba(255, 50, 50, 255);
float m_snap_width = 1.5f;
bool m_show_snap = true;
// Projectile aim
omath::Color m_proj_color = omath::Color::from_rgba(255, 50, 50, 255);
float m_proj_size = 10.f;
float m_proj_line_width = 1.5f;
float m_proj_pos_x = 300.f, m_proj_pos_y = 30.f;
int m_proj_figure = 1; // 0=circle, 1=square
bool m_show_proj = true;
};
} // namespace imgui_desktop::gui

View File

@@ -183,6 +183,7 @@ namespace omath::hud
void dispatch(const widget::SnapLine& snap_line);
void dispatch(const widget::ScanMarker& scan_marker);
void dispatch(const widget::AimDot& aim_dot);
void dispatch(const widget::ProjectileAim& proj_widget);
void draw_progress_ring(const Vector2<float>& center, const widget::ProgressRing& ring);
void draw_outlined_text(const Vector2<float>& position, const Color& color, const std::string_view& text);
void draw_dashed_line(const Vector2<float>& from, const Vector2<float>& to, const Color& color, float dash_len,

View File

@@ -71,6 +71,20 @@ namespace omath::hud::widget
Color color;
float radius = 3.f;
};
struct ProjectileAim
{
enum class Figure
{
CIRCLE,
SQUARE,
};
Vector2<float> position;
Color color;
float size = 3.f;
float line_size = 1.f;
Figure figure = Figure::SQUARE;
};
// ── Side-agnostic widgets (used inside XxxSide containers) ────────────────

View File

@@ -553,7 +553,7 @@ namespace omath::hud
// ── Icons ────────────────────────────────────────────────────────────────────
EntityOverlay& EntityOverlay::add_right_icon(const std::any& texture_id, const float width, const float height,
const Color& tint, const float offset)
const Color& tint, const float offset)
{
const auto pos = m_text_cursor_right + Vector2<float>{offset, 0.f};
m_renderer->add_image(texture_id, pos, pos + Vector2<float>{width, height}, tint);
@@ -562,7 +562,7 @@ namespace omath::hud
}
EntityOverlay& EntityOverlay::add_left_icon(const std::any& texture_id, const float width, const float height,
const Color& tint, const float offset)
const Color& tint, const float offset)
{
const auto pos = m_text_cursor_left + Vector2<float>{-(offset + width), 0.f};
m_renderer->add_image(texture_id, pos, pos + Vector2<float>{width, height}, tint);
@@ -571,7 +571,7 @@ namespace omath::hud
}
EntityOverlay& EntityOverlay::add_top_icon(const std::any& texture_id, const float width, const float height,
const Color& tint, const float offset)
const Color& tint, const float offset)
{
m_text_cursor_top.y -= height;
const auto pos = m_text_cursor_top + Vector2<float>{0.f, -offset};
@@ -580,7 +580,7 @@ namespace omath::hud
}
EntityOverlay& EntityOverlay::add_bottom_icon(const std::any& texture_id, const float width, const float height,
const Color& tint, const float offset)
const Color& tint, const float offset)
{
const auto pos = m_text_cursor_bottom + Vector2<float>{0.f, offset};
m_renderer->add_image(texture_id, pos, pos + Vector2<float>{width, height}, tint);
@@ -641,6 +641,26 @@ namespace omath::hud
{
m_renderer->add_filled_circle(aim_dot.position, aim_dot.radius, aim_dot.color);
}
void EntityOverlay::dispatch(const widget::ProjectileAim& proj_widget)
{
const auto box_width = std::abs(m_canvas.top_right_corner.x - m_canvas.top_left_corner.x);
const auto box_height = std::abs(m_canvas.bottom_left_corner.y - m_canvas.top_left_corner.y);
const auto box_center = m_canvas.top_left_corner+Vector2{box_width, box_height} / 2.f;
m_renderer->add_line(box_center, proj_widget.position, proj_widget.color, proj_widget.line_size);
if (proj_widget.figure == widget::ProjectileAim::Figure::CIRCLE)
{
m_renderer->add_filled_circle(proj_widget.position, proj_widget.size, proj_widget.color);
}
else if (proj_widget.figure == widget::ProjectileAim::Figure::SQUARE)
{
const auto box_min = proj_widget.position - Vector2{proj_widget.size, proj_widget.size} / 2.f;
const auto box_max = proj_widget.position + Vector2{proj_widget.size, proj_widget.size} / 2.f;
m_renderer->add_filled_rectangle(box_min, box_max, proj_widget.color);
}
}
void EntityOverlay::draw_progress_ring(const Vector2<float>& center, const widget::ProgressRing& ring)
{