Add duration countdown overlay to target frame aura icons

Matches the same fix applied to the player buff bar: icons in the
target frame now show their remaining duration at the icon bottom edge
with a drop shadow, shared between the always-visible overlay and the
hover tooltip.
This commit is contained in:
Kelsi 2026-03-09 16:37:55 -07:00
parent 088a11e62a
commit f0d1702d5f

View file

@ -1982,16 +1982,39 @@ void GameScreen::renderTargetFrame(game::GameHandler& gameHandler) {
ImGui::PopStyleColor();
}
// Compute remaining once for overlay + tooltip
uint64_t tNowMs = static_cast<uint64_t>(
std::chrono::duration_cast<std::chrono::milliseconds>(
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<uint64_t>(
std::chrono::duration_cast<std::chrono::milliseconds>(
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 {