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.
This commit is contained in:
Kelsi 2026-03-29 21:54:57 -07:00
parent 8376757f7e
commit f23a7c06d9

View file

@ -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);