From e8fe53650b790bb6fe5d7cca007062d59447f21a Mon Sep 17 00:00:00 2001 From: Kelsi Date: Thu, 12 Mar 2026 06:14:18 -0700 Subject: [PATCH] feat: add respawn countdown timer to the death dialog The "You are dead." dialog now shows a "Release in M:SS" countdown tracking time elapsed since death. The countdown runs from 6 minutes (WoW's forced-release window) and disappears once it reaches zero. Timer resets automatically when the player is no longer dead. --- include/ui/game_screen.hpp | 6 ++++++ src/ui/game_screen.cpp | 27 +++++++++++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/include/ui/game_screen.hpp b/include/ui/game_screen.hpp index 83f04567..b7cf2f53 100644 --- a/include/ui/game_screen.hpp +++ b/include/ui/game_screen.hpp @@ -112,6 +112,12 @@ private: std::vector zoneToasts_; std::string lastKnownZone_; static constexpr float kZoneToastLifetime = 3.0f; + + // Death screen: elapsed time since the death dialog first appeared + float deathElapsed_ = 0.0f; + bool deathTimerRunning_ = false; + // WoW forces release after ~6 minutes; show countdown until then + static constexpr float kForcedReleaseSec = 360.0f; void renderZoneToasts(float deltaTime); bool showPlayerInfo = false; bool showSocialFrame_ = false; // O key toggles social/friends list diff --git a/src/ui/game_screen.cpp b/src/ui/game_screen.cpp index 0da74826..7ddfe7a3 100644 --- a/src/ui/game_screen.cpp +++ b/src/ui/game_screen.cpp @@ -10988,7 +10988,18 @@ void GameScreen::renderTaxiWindow(game::GameHandler& gameHandler) { // ============================================================ void GameScreen::renderDeathScreen(game::GameHandler& gameHandler) { - if (!gameHandler.showDeathDialog()) return; + if (!gameHandler.showDeathDialog()) { + deathTimerRunning_ = false; + deathElapsed_ = 0.0f; + return; + } + float dt = ImGui::GetIO().DeltaTime; + if (!deathTimerRunning_) { + deathElapsed_ = 0.0f; + deathTimerRunning_ = true; + } else { + deathElapsed_ += dt; + } auto* window = core::Application::getInstance().getWindow(); float screenW = window ? static_cast(window->getWidth()) : 1280.0f; @@ -11006,7 +11017,7 @@ void GameScreen::renderDeathScreen(game::GameHandler& gameHandler) { // "Release Spirit" dialog centered on screen float dlgW = 280.0f; - float dlgH = 100.0f; + float dlgH = 130.0f; ImGui::SetNextWindowPos(ImVec2(screenW / 2 - dlgW / 2, screenH * 0.35f), ImGuiCond_Always); ImGui::SetNextWindowSize(ImVec2(dlgW, dlgH), ImGuiCond_Always); @@ -11025,6 +11036,18 @@ void GameScreen::renderDeathScreen(game::GameHandler& gameHandler) { ImGui::SetCursorPosX((dlgW - textW) / 2); ImGui::TextColored(ImVec4(1.0f, 0.2f, 0.2f, 1.0f), "%s", deathText); + // Respawn timer: show how long until forced release + float timeLeft = kForcedReleaseSec - deathElapsed_; + if (timeLeft > 0.0f) { + int mins = static_cast(timeLeft) / 60; + int secs = static_cast(timeLeft) % 60; + char timerBuf[48]; + snprintf(timerBuf, sizeof(timerBuf), "Release in %d:%02d", mins, secs); + float tw = ImGui::CalcTextSize(timerBuf).x; + ImGui::SetCursorPosX((dlgW - tw) / 2); + ImGui::TextColored(ImVec4(0.65f, 0.65f, 0.65f, 1.0f), "%s", timerBuf); + } + ImGui::Spacing(); ImGui::Spacing();