mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-23 07:40:14 +00:00
ui: click-to-target via nameplate hit testing
Left-clicking anywhere within a nameplate's bounding box (name text + health bar) calls setTarget() for that unit. Uses manual mouse position hit testing since nameplates are drawn on the background DrawList rather than as ImGui widgets. Click is ignored when ImGui has captured the mouse (e.g. when a window is open).
This commit is contained in:
parent
3fce3adb39
commit
6f7363fbcb
1 changed files with 12 additions and 0 deletions
|
|
@ -4902,6 +4902,18 @@ void GameScreen::renderNameplates(game::GameHandler& gameHandler) {
|
|||
: IM_COL32(240, 200, 100, A(230));
|
||||
drawList->AddText(ImVec2(nameX + 1.0f, nameY + 1.0f), IM_COL32(0, 0, 0, A(160)), labelBuf);
|
||||
drawList->AddText(ImVec2(nameX, nameY), nameColor, labelBuf);
|
||||
|
||||
// Click to target: detect left-click inside the combined nameplate region
|
||||
if (!ImGui::GetIO().WantCaptureMouse && ImGui::IsMouseClicked(ImGuiMouseButton_Left)) {
|
||||
ImVec2 mouse = ImGui::GetIO().MousePos;
|
||||
float nx0 = nameX - 2.0f;
|
||||
float ny0 = nameY - 1.0f;
|
||||
float nx1 = nameX + textSize.x + 2.0f;
|
||||
float ny1 = sy + barH + 2.0f;
|
||||
if (mouse.x >= nx0 && mouse.x <= nx1 && mouse.y >= ny0 && mouse.y <= ny1) {
|
||||
gameHandler.setTarget(guid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue