From d9ce056e1307b59bca2531e66290c0424fe7fd3f Mon Sep 17 00:00:00 2001 From: Kelsi Date: Thu, 12 Mar 2026 07:45:51 -0700 Subject: [PATCH] feat: add zone name labels and hover coordinates to world map - Draw zone name text centered in each zone rect on the continent view; only rendered when the rect is large enough to fit the label without crowding (explored zones get gold text, unexplored get dim grey) - Show WoW coordinates under the cursor when hovering the map image in continent or zone view, bottom-right corner of the map panel --- src/rendering/world_map.cpp | 52 +++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/src/rendering/world_map.cpp b/src/rendering/world_map.cpp index 9c30a3b5..701c5148 100644 --- a/src/rendering/world_map.cpp +++ b/src/rendering/world_map.cpp @@ -12,6 +12,7 @@ #include "core/logger.hpp" #include #include +#include #include #include @@ -1016,6 +1017,40 @@ void WorldMap::renderImGuiOverlay(const glm::vec3& playerRenderPos, int screenWi } } + // Hover coordinate display — show WoW coordinates under cursor + if (currentIdx >= 0 && viewLevel != ViewLevel::WORLD) { + auto& io = ImGui::GetIO(); + ImVec2 mp = io.MousePos; + if (mp.x >= imgMin.x && mp.x <= imgMin.x + displayW && + mp.y >= imgMin.y && mp.y <= imgMin.y + displayH) { + float mu = (mp.x - imgMin.x) / displayW; + float mv = (mp.y - imgMin.y) / displayH; + + const auto& zone = zones[currentIdx]; + float left = zone.locLeft, right = zone.locRight; + float top = zone.locTop, bottom = zone.locBottom; + if (zone.areaID == 0) { + float l, r, t, b; + getContinentProjectionBounds(currentIdx, l, r, t, b); + left = l; right = r; top = t; bottom = b; + // Undo the kVOffset applied during renderPosToMapUV for continent + constexpr float kVOffset = -0.15f; + mv -= kVOffset; + } + + float hWowX = left - mu * (left - right); + float hWowY = top - mv * (top - bottom); + + char coordBuf[32]; + snprintf(coordBuf, sizeof(coordBuf), "%.0f, %.0f", hWowX, hWowY); + ImVec2 coordSz = ImGui::CalcTextSize(coordBuf); + float cx = imgMin.x + displayW - coordSz.x - 8.0f; + float cy = imgMin.y + displayH - coordSz.y - 8.0f; + drawList->AddText(ImVec2(cx + 1.0f, cy + 1.0f), IM_COL32(0, 0, 0, 180), coordBuf); + drawList->AddText(ImVec2(cx, cy), IM_COL32(220, 210, 150, 230), coordBuf); + } + } + // Continent view: clickable zone overlays if (viewLevel == ViewLevel::CONTINENT && continentIdx >= 0) { const auto& cont = zones[continentIdx]; @@ -1080,6 +1115,23 @@ void WorldMap::renderImGuiOverlay(const glm::vec3& playerRenderPos, int screenWi drawList->AddRect(ImVec2(sx0, sy0), ImVec2(sx1, sy1), IM_COL32(255, 255, 255, 30), 0.0f, 0, 1.0f); } + + // Zone name label — only if the rect is large enough to fit it + if (!z.areaName.empty()) { + ImVec2 textSz = ImGui::CalcTextSize(z.areaName.c_str()); + float rectW = sx1 - sx0; + float rectH = sy1 - sy0; + if (rectW > textSz.x + 4.0f && rectH > textSz.y + 2.0f) { + float tx = (sx0 + sx1) * 0.5f - textSz.x * 0.5f; + float ty = (sy0 + sy1) * 0.5f - textSz.y * 0.5f; + ImU32 labelCol = explored + ? IM_COL32(255, 230, 150, 210) + : IM_COL32(160, 160, 160, 80); + drawList->AddText(ImVec2(tx + 1.0f, ty + 1.0f), + IM_COL32(0, 0, 0, 130), z.areaName.c_str()); + drawList->AddText(ImVec2(tx, ty), labelCol, z.areaName.c_str()); + } + } } }