From f23a7c06d947bfffa97cdddcc0545c5d0fd722f5 Mon Sep 17 00:00:00 2001 From: Kelsi Date: Sun, 29 Mar 2026 21:54:57 -0700 Subject: [PATCH] fix: nameplate click hitbox used name text width, not health bar width The click region for targeting via nameplates was bounded by the name text (nameX to nameX+textSize.x). Short names like "Wolf" produced a ~30px clickable strip, while the health bar below was 80px wide. Clicks on the bar outside the name text bounds were ignored. Now uses the wider of name text or health bar for the horizontal hit area. --- src/ui/game_screen.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index e89aab46..42f3a6b9 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -12184,13 +12184,17 @@ void GameScreen::renderNameplates(game::GameHandler& gameHandler) { } } - // Click to target / right-click context: detect clicks inside the nameplate region + // Click to target / right-click context: detect clicks inside the nameplate region. + // Use the wider of name text or health bar for the horizontal hit area so short + // names like "Wolf" don't produce a tiny clickable strip narrower than the bar. if (!ImGui::GetIO().WantCaptureMouse) { ImVec2 mouse = ImGui::GetIO().MousePos; - float nx0 = nameX - 2.0f; + float hitLeft = std::min(nameX, barX) - 2.0f; + float hitRight = std::max(nameX + textSize.x, barX + barW) + 2.0f; float ny0 = nameY - 1.0f; - float nx1 = nameX + textSize.x + 2.0f; float ny1 = sy + barH + 2.0f; + float nx0 = hitLeft; + float nx1 = hitRight; if (mouse.x >= nx0 && mouse.x <= nx1 && mouse.y >= ny0 && mouse.y <= ny1) { // Track mouseover for [target=mouseover] macro conditionals gameHandler.setMouseoverGuid(guid);