From aeb55b8fe9f8ec9afd9423ada880079580d6ec6d Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Mon, 31 May 2021 13:07:41 -0700 Subject: [PATCH] Move room time calculate to ImGuiConsole::PostUpdate --- Runtime/ImGuiConsole.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Runtime/ImGuiConsole.cpp b/Runtime/ImGuiConsole.cpp index af8cce47b..e71834856 100644 --- a/Runtime/ImGuiConsole.cpp +++ b/Runtime/ImGuiConsole.cpp @@ -747,11 +747,6 @@ void ImGuiConsole::ShowDebugOverlay() { hasPrevious = true; double igt = g_GameState->GetTotalPlayTime(); - if (m_currentRoom != g_StateManager->GetCurrentArea()) { - m_currentRoom = static_cast(g_StateManager->GetCurrentArea()); - m_lastRoomTime = igt - m_currentRoomStart; - m_currentRoomStart = igt; - } double currentRoomTime = igt - m_currentRoomStart; u32 curFrames = u32(std::round(u32(currentRoomTime * 60))); u32 lastFrames = u32(std::round(u32(m_lastRoomTime * 60))); @@ -1180,6 +1175,15 @@ void ImGuiConsole::PostUpdate() { entities.fill(ImGuiEntityEntry{}); inspectingEntities.clear(); } + + // Always calculate room time regardless of if the overlay is displayed, this allows us have an accurate display if + // the user chooses to display it later on during gameplay + if (g_StateManager && m_currentRoom != g_StateManager->GetCurrentArea()) { + const double igt = g_GameState->GetTotalPlayTime(); + m_currentRoom = static_cast(g_StateManager->GetCurrentArea()); + m_lastRoomTime = igt - m_currentRoomStart; + m_currentRoomStart = igt; + } } void ImGuiConsole::Shutdown() {