From 54750d465631bba5b00d0c96a91121d1b57bb5fc Mon Sep 17 00:00:00 2001 From: Kelsi Date: Wed, 11 Mar 2026 23:41:05 -0700 Subject: [PATCH] Add right-click context menu to target frame name Right-clicking the target's name now shows: Set Focus, Clear Target, and for player targets: Whisper, Invite to Group, Trade, Add Friend, Ignore. --- src/ui/game_screen.cpp | 49 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 47 insertions(+), 2 deletions(-) diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 18e6d1ce..7f57e067 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -2499,13 +2499,58 @@ void GameScreen::renderTargetFrame(game::GameHandler& gameHandler) { ImGui::SetCursorPosX(ImGui::GetCursorPosX() + 18.0f); } - // Entity name and type + // Entity name and type — Selectable so we can attach a right-click context menu std::string name = getEntityName(target); ImVec4 nameColor = hostileColor; ImGui::SameLine(0.0f, 0.0f); - ImGui::TextColored(nameColor, "%s", name.c_str()); + ImGui::PushStyleColor(ImGuiCol_Text, nameColor); + ImGui::PushStyleColor(ImGuiCol_Header, ImVec4(0,0,0,0)); + ImGui::PushStyleColor(ImGuiCol_HeaderHovered, ImVec4(1,1,1,0.08f)); + ImGui::PushStyleColor(ImGuiCol_HeaderActive, ImVec4(1,1,1,0.12f)); + ImGui::Selectable(name.c_str(), false, ImGuiSelectableFlags_DontClosePopups, + ImVec2(ImGui::CalcTextSize(name.c_str()).x, 0)); + ImGui::PopStyleColor(4); + + // Right-click context menu on the target name + if (ImGui::BeginPopupContextItem("##TargetNameCtx")) { + const bool isPlayer = (target->getType() == game::ObjectType::PLAYER); + const uint64_t tGuid = target->getGuid(); + + ImGui::TextDisabled("%s", name.c_str()); + ImGui::Separator(); + + if (ImGui::MenuItem("Set Focus")) { + gameHandler.setFocus(tGuid); + } + if (ImGui::MenuItem("Clear Target")) { + gameHandler.clearTarget(); + } + if (isPlayer) { + ImGui::Separator(); + if (ImGui::MenuItem("Whisper")) { + selectedChatType = 4; + strncpy(whisperTargetBuffer, name.c_str(), sizeof(whisperTargetBuffer) - 1); + whisperTargetBuffer[sizeof(whisperTargetBuffer) - 1] = '\0'; + refocusChatInput = true; + } + if (ImGui::MenuItem("Invite to Group")) { + gameHandler.inviteToGroup(name); + } + if (ImGui::MenuItem("Trade")) { + gameHandler.initiateTrade(tGuid); + } + ImGui::Separator(); + if (ImGui::MenuItem("Add Friend")) { + gameHandler.addFriend(name); + } + if (ImGui::MenuItem("Ignore")) { + gameHandler.addIgnore(name); + } + } + ImGui::EndPopup(); + } // Level (for units/players) — colored by difficulty if (target->getType() == game::ObjectType::UNIT || target->getType() == game::ObjectType::PLAYER) {