diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index be699b9c..c2ac1c25 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -1982,16 +1982,39 @@ void GameScreen::renderTargetFrame(game::GameHandler& gameHandler) { ImGui::PopStyleColor(); } + // Compute remaining once for overlay + tooltip + uint64_t tNowMs = static_cast( + std::chrono::duration_cast( + std::chrono::steady_clock::now().time_since_epoch()).count()); + int32_t tRemainMs = aura.getRemainingMs(tNowMs); + + // Duration countdown overlay + if (tRemainMs > 0) { + ImVec2 iconMin = ImGui::GetItemRectMin(); + ImVec2 iconMax = ImGui::GetItemRectMax(); + char timeStr[12]; + int secs = (tRemainMs + 999) / 1000; + if (secs >= 3600) + snprintf(timeStr, sizeof(timeStr), "%dh", secs / 3600); + else if (secs >= 60) + snprintf(timeStr, sizeof(timeStr), "%d:%02d", secs / 60, secs % 60); + else + snprintf(timeStr, sizeof(timeStr), "%d", secs); + ImVec2 textSize = ImGui::CalcTextSize(timeStr); + float cx = iconMin.x + (iconMax.x - iconMin.x - textSize.x) * 0.5f; + float cy = iconMax.y - textSize.y - 1.0f; + ImGui::GetWindowDrawList()->AddText(ImVec2(cx + 1, cy + 1), + IM_COL32(0, 0, 0, 200), timeStr); + ImGui::GetWindowDrawList()->AddText(ImVec2(cx, cy), + IM_COL32(255, 255, 255, 255), timeStr); + } + // Tooltip if (ImGui::IsItemHovered()) { std::string name = spellbookScreen.lookupSpellName(aura.spellId, assetMgr); if (name.empty()) name = "Spell #" + std::to_string(aura.spellId); - uint64_t nowMs = static_cast( - std::chrono::duration_cast( - std::chrono::steady_clock::now().time_since_epoch()).count()); - int32_t remaining = aura.getRemainingMs(nowMs); - if (remaining > 0) { - int seconds = remaining / 1000; + if (tRemainMs > 0) { + int seconds = tRemainMs / 1000; if (seconds < 60) { ImGui::SetTooltip("%s (%ds)", name.c_str(), seconds); } else {