fix igt timer

This commit is contained in:
TakaRikka
2026-04-26 16:51:10 -07:00
parent 6cf94b4491
commit 206c02b527
8 changed files with 70 additions and 50 deletions
+2 -2
View File
@@ -4009,8 +4009,8 @@ int daAlink_c::procGanonFinishInit() {
#if TARGET_PC
if (dusk::getSettings().game.speedrunMode) {
if (dusk::g_imguiConsole.isSpeedrunStart()) {
dusk::g_imguiConsole.stopSpeedrun();
if (dusk::m_speedrunInfo.m_isRunStarted) {
dusk::m_speedrunInfo.stopRun();
}
}
#endif
+3 -2
View File
@@ -145,8 +145,9 @@ void dBrightCheck_c::modeMove() {
if (dusk::getSettings().game.speedrunMode && !dusk::getSettings().game.hideTvSettingsScreen) {
// start a new run if a run isn't already in progress
if (!dusk::g_imguiConsole.isSpeedrunStart()) {
dusk::g_imguiConsole.startSpeedrun();
if (!dusk::m_speedrunInfo.m_isRunStarted) {
dusk::ImGuiMenuGame::resetForSpeedrunMode();
dusk::m_speedrunInfo.startRun();
}
}
#endif
+3 -2
View File
@@ -417,8 +417,9 @@ void dScnName_c::changeGameScene() {
#if TARGET_PC
if (dusk::getSettings().game.speedrunMode && dusk::getSettings().game.hideTvSettingsScreen) {
// start a new run on file load if a run isn't already in progress
if (!dusk::g_imguiConsole.isSpeedrunStart()) {
dusk::g_imguiConsole.startSpeedrun();
if (!dusk::m_speedrunInfo.m_isRunStarted) {
dusk::ImGuiMenuGame::resetForSpeedrunMode();
dusk::m_speedrunInfo.startRun();
}
}
#endif
-5
View File
@@ -29,11 +29,6 @@ public:
static bool CheckMenuViewToggle(ImGuiKey key, bool& active);
void AddToast(std::string_view message, float duration = 3.f);
bool isSpeedrunStart() const { return m_menuGame.isRunStarted(); }
void startSpeedrun() { m_menuGame.startRun(); }
void stopSpeedrun() { m_menuGame.stopRun(); }
void incSpeedrunTotalLoadTime(OSTime time) { m_menuGame.incTotalLoadTime(time); }
private:
struct Toast {
std::string message;
+8 -5
View File
@@ -1051,6 +1051,8 @@ namespace dusk {
getSettings().game.enableTurboKeybind.setValue(false);
}
SpeedrunInfo m_speedrunInfo;
void ImGuiMenuGame::drawSpeedrunTimerOverlay() {
if (!getSettings().game.speedrunMode) {
return;
@@ -1058,10 +1060,7 @@ namespace dusk {
// L+R+A+Start to reset timer
if (mDoCPd_c::getHoldL(PAD_1) && mDoCPd_c::getHoldR(PAD_1) && mDoCPd_c::getHoldA(PAD_1) && mDoCPd_c::getTrigStart(PAD_1)) {
m_speedrunInfo.m_endTimestamp = 0;
m_speedrunInfo.m_startTimestamp = 0;
m_speedrunInfo.m_totalLoadTime = 0;
m_speedrunInfo.m_isRunStarted = false;
m_speedrunInfo.reset();
}
// L+R+A+Z to manually stop timer
@@ -1091,9 +1090,13 @@ namespace dusk {
ImGui::SameLine(60.0f);
ImGuiStringViewText(GetFormattedTime(elapsedTime));
if (!m_speedrunInfo.m_isPauseIGT) {
m_speedrunInfo.m_igtTimer = elapsedTime - m_speedrunInfo.m_totalLoadTime;
}
ImGui::Text("IGT");
ImGui::SameLine(60.0f);
ImGuiStringViewText(GetFormattedTime(elapsedTime - m_speedrunInfo.m_totalLoadTime));
ImGuiStringViewText(GetFormattedTime(m_speedrunInfo.m_igtTimer));
}
ImGui::End();
}
+34 -18
View File
@@ -8,6 +8,39 @@
#include "imgui.h"
namespace dusk {
struct SpeedrunInfo {
void startRun() {
m_isRunStarted = true;
m_startTimestamp = OSGetTime();
}
void stopRun() {
m_isRunStarted = false;
m_endTimestamp = OSGetTime() - m_startTimestamp;
}
void reset() {
m_isRunStarted = false;
m_startTimestamp = 0;
m_endTimestamp = 0;
m_isPauseIGT = false;
m_loadStartTimestamp = 0;
m_totalLoadTime = 0;
m_igtTimer = 0;
}
bool m_isRunStarted = false;
OSTime m_startTimestamp = 0;
OSTime m_endTimestamp = 0;
bool m_isPauseIGT = false;
OSTime m_loadStartTimestamp = 0;
OSTime m_totalLoadTime = 0;
OSTime m_igtTimer = 0;
};
extern SpeedrunInfo m_speedrunInfo;
class ImGuiMenuGame {
public:
ImGuiMenuGame();
@@ -20,17 +53,6 @@ namespace dusk {
static void ToggleFullscreen();
static void resetForSpeedrunMode();
bool isRunStarted() const { return m_speedrunInfo.m_isRunStarted; }
void startRun() {
resetForSpeedrunMode();
m_speedrunInfo.m_isRunStarted = true;
m_speedrunInfo.m_startTimestamp = OSGetTime();
}
void stopRun() {
m_speedrunInfo.m_isRunStarted = false;
m_speedrunInfo.m_endTimestamp = OSGetTime() - m_speedrunInfo.m_startTimestamp;
}
void incTotalLoadTime(OSTime time) { m_speedrunInfo.m_totalLoadTime += time; }
private:
void drawAudioMenu();
@@ -55,13 +77,7 @@ namespace dusk {
int m_inputOverlayCorner = 3;
std::string m_controllerName;
struct {
bool m_showTimerWindow = false;
bool m_isRunStarted = false;
OSTime m_startTimestamp = 0;
OSTime m_endTimestamp = 0;
OSTime m_totalLoadTime = 0;
} m_speedrunInfo;
bool m_showTimerWindow = false;
};
}
+20
View File
@@ -7,6 +7,8 @@
#include "f_op/f_op_overlap_req.h"
#include "f_pc/f_pc_manager.h"
#include "dusk/imgui/ImGuiMenuGame.hpp"
void fopOvlpReq_SetPeektime(overlap_request_class*, u16);
static int fopOvlpReq_phase_Done(overlap_request_class* i_overlapReq) {
@@ -16,6 +18,16 @@ static int fopOvlpReq_phase_Done(overlap_request_class* i_overlapReq) {
i_overlapReq->peektime = 0;
i_overlapReq->field_0x8 = 0;
i_overlapReq->field_0xc = 0;
#if TARGET_PC
if (dusk::getSettings().game.speedrunMode) {
if (dusk::m_speedrunInfo.m_isRunStarted) {
dusk::m_speedrunInfo.m_isPauseIGT = false;
dusk::m_speedrunInfo.m_totalLoadTime += OSGetTime() - dusk::m_speedrunInfo.m_loadStartTimestamp;
dusk::m_speedrunInfo.m_loadStartTimestamp = OSGetTime();
}
}
#endif
return cPhs_NEXT_e;
}
@@ -81,6 +93,14 @@ static int fopOvlpReq_phase_Create(overlap_request_class* i_overlapReq) {
fpcLy_SetCurrentLayer(i_overlapReq->layer);
i_overlapReq->request_id =
fpcM_Create(i_overlapReq->procname, NULL, NULL);
#if TARGET_PC
if (dusk::m_speedrunInfo.m_isRunStarted) {
dusk::m_speedrunInfo.m_isPauseIGT = true;
dusk::m_speedrunInfo.m_loadStartTimestamp = OSGetTime();
}
#endif
return cPhs_NEXT_e;
}
-16
View File
@@ -40,10 +40,6 @@ static cPhs_Step fopScnRq_phase_IsDoneOverlap(scene_request_class* i_sceneReq) {
static BOOL l_fopScnRq_IsUsingOfOverlap;
#if TARGET_PC
static OSTime l_fopScnRq_StartTime = 0;
#endif
static cPhs_Step fopScnRq_phase_Done(scene_request_class* i_sceneReq) {
if (i_sceneReq->create_request.parameters != 1) {
@@ -53,14 +49,6 @@ static cPhs_Step fopScnRq_phase_Done(scene_request_class* i_sceneReq) {
}
l_fopScnRq_IsUsingOfOverlap = FALSE;
#if TARGET_PC
if (dusk::getSettings().game.speedrunMode) {
if (dusk::g_imguiConsole.isSpeedrunStart()) {
dusk::g_imguiConsole.incSpeedrunTotalLoadTime(OSGetTime() - l_fopScnRq_StartTime);
}
}
#endif
return cPhs_NEXT_e;
}
@@ -101,10 +89,6 @@ static scene_request_class* fopScnRq_FadeRequest(s16 i_procname, u16 i_peektime)
req = fopOvlpM_Request(i_procname, i_peektime);
if (req != NULL) {
l_fopScnRq_IsUsingOfOverlap = TRUE;
#if TARGET_PC
l_fopScnRq_StartTime = OSGetTime();
#endif
}
}