From 70e10179238f60fb5b8e15fb64d75cf43b21d9c7 Mon Sep 17 00:00:00 2001 From: Garrett Cox Date: Wed, 27 Dec 2023 00:08:37 +0000 Subject: [PATCH] Add frame advance option to developer tools (#3435) --- soh/soh/SohMenuBar.cpp | 20 ++++++++++++++++++++ soh/src/code/z_frame_advance.c | 3 ++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 904a57558..614a6b690 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1475,6 +1475,26 @@ void DrawDeveloperToolsMenu() { UIWidgets::Tooltip("Optimized debug warp screen, with the added ability to chose entrances and time of day"); UIWidgets::PaddedEnhancementCheckbox("Debug Warp Screen Translation", "gDebugWarpScreenTranslation", true, false, false, "", UIWidgets::CheckboxGraphics::Cross, true); UIWidgets::Tooltip("Translate the Debug Warp Screen based on the game language"); + if (gPlayState != NULL) { + UIWidgets::PaddedSeparator(); + ImGui::Checkbox("Frame Advance##frameAdvance", (bool*)&gPlayState->frameAdvCtx.enabled); + if (gPlayState->frameAdvCtx.enabled) { + ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 6.0f)); + ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0,0)); + ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); + ImGui::PushStyleColor(ImGuiCol_Border, ImVec4(0.22f, 0.38f, 0.56f, 1.0f)); + if (ImGui::Button("Advance 1", ImVec2(ImGui::GetContentRegionAvail().x / 2.0f, 0.0f))) { + CVarSetInteger("gFrameAdvance", 1); + } + ImGui::SameLine(); + ImGui::Button("Advance (Hold)"); + if (ImGui::IsItemActive()) { + CVarSetInteger("gFrameAdvance", 1); + } + ImGui::PopStyleVar(3); + ImGui::PopStyleColor(1); + } + } UIWidgets::PaddedSeparator(); ImGui::PushStyleVar(ImGuiStyleVar_FramePadding, ImVec2(12.0f, 6.0f)); ImGui::PushStyleVar(ImGuiStyleVar_ButtonTextAlign, ImVec2(0,0)); diff --git a/soh/src/code/z_frame_advance.c b/soh/src/code/z_frame_advance.c index 930db59b3..e48bd0c35 100644 --- a/soh/src/code/z_frame_advance.c +++ b/soh/src/code/z_frame_advance.c @@ -18,9 +18,10 @@ s32 FrameAdvance_Update(FrameAdvanceContext* frameAdvCtx, Input* input) { frameAdvCtx->enabled = !frameAdvCtx->enabled; } - if (!frameAdvCtx->enabled || (CHECK_BTN_ALL(input->cur.button, BTN_Z) && + if (!frameAdvCtx->enabled || CVarGetInteger("gFrameAdvance", 0) || (CHECK_BTN_ALL(input->cur.button, BTN_Z) && (CHECK_BTN_ALL(input->press.button, BTN_R) || (CHECK_BTN_ALL(input->cur.button, BTN_R) && (++frameAdvCtx->timer >= 9))))) { + CVarClear("gFrameAdvance"); frameAdvCtx->timer = 0; return true; }