From 61eba0efad955aa74311ebb5f33350e296069781 Mon Sep 17 00:00:00 2001 From: Malkierian Date: Sun, 20 Aug 2023 11:00:04 -0700 Subject: [PATCH] Add toggle option for save states (#3095) * Add toggle option for save states, off by default, with significant warning about what they actually do before enabling (double checkbox confirmation). Add overlay text notification when attempting to use any of the state hotkeys if save states aren't enabled. Stays up for 6 seconds. * Added coloration (yellow and orange) to the warning header. * A little more clarification in the warning. --- soh/soh/OTRGlobals.cpp | 15 +++++++++++++++ soh/soh/SohMenuBar.cpp | 26 ++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index e05468684..6c7d5eec5 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -878,6 +878,11 @@ extern "C" void Graph_StartFrame() { switch (dwScancode) { case KbScancode::LUS_KB_F5: { + if (CVarGetInteger("gSaveStatesEnabled", 0) == 0) { + LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()-> + TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); + return; + } const unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); const SaveStateReturn stateReturn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::SAVE }); @@ -895,6 +900,11 @@ extern "C" void Graph_StartFrame() { break; } case KbScancode::LUS_KB_F6: { + if (CVarGetInteger("gSaveStatesEnabled", 0) == 0) { + LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()-> + TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); + return; + } unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); slot++; if (slot > 5) { @@ -905,6 +915,11 @@ extern "C" void Graph_StartFrame() { break; } case KbScancode::LUS_KB_F7: { + if (CVarGetInteger("gSaveStatesEnabled", 0) == 0) { + LUS::Context::GetInstance()->GetWindow()->GetGui()->GetGameOverlay()-> + TextDrawNotification(6.0f, true, "Save states not enabled. Check Cheats Menu."); + return; + } const unsigned int slot = OTRGlobals::Instance->gSaveStateMgr->GetCurrentSlot(); const SaveStateReturn stateReturn = OTRGlobals::Instance->gSaveStateMgr->AddRequest({ slot, RequestType::LOAD }); diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp index 0d932adba..6e188a1ab 100644 --- a/soh/soh/SohMenuBar.cpp +++ b/soh/soh/SohMenuBar.cpp @@ -1169,6 +1169,7 @@ void DrawCheatsMenu() { UIWidgets::Tooltip("Makes every surface in the game climbable"); UIWidgets::PaddedEnhancementCheckbox("Hookshot Everything", "gHookshotEverything", true, false); UIWidgets::Tooltip("Makes every surface in the game hookshot-able"); + UIWidgets::Spacer(2.0f); UIWidgets::EnhancementSliderFloat("Hookshot Reach Multiplier: %.1fx", "##gCheatHookshotReachMultiplier", "gCheatHookshotReachMultiplier", 1.0f, 5.0f, "", 1.0f, false); UIWidgets::EnhancementSliderFloat("Bomb Timer Multiplier: %.1fx", "##gBombTimerMultiplier", "gBombTimerMultiplier", 0.1f, 5.0f, "", 1.0f, false); UIWidgets::PaddedEnhancementCheckbox("Moon Jump on L", "gMoonJumpOnL", true, false); @@ -1202,6 +1203,30 @@ void DrawCheatsMenu() { UIWidgets::Tooltip("This syncs the ingame time with the real world time"); UIWidgets::PaddedEnhancementCheckbox("No ReDead/Gibdo Freeze", "gNoRedeadFreeze", true, false); UIWidgets::Tooltip("Prevents ReDeads and Gibdos from being able to freeze you with their scream"); + UIWidgets::Spacer(2.0f); + if (ImGui::BeginMenu("Save States")) { + ImGui::TextColored({ 0.85f, 0.85f, 0.0f, 1.0f }, " " ICON_FA_EXCLAMATION_TRIANGLE); + ImGui::SameLine(); + ImGui::TextColored({ 0.85f, 0.35f, 0.0f, 1.0f }, " WARNING!!!! "); + ImGui::SameLine(); + ImGui::TextColored({ 0.85f, 0.85f, 0.0f, 1.0f }, ICON_FA_EXCLAMATION_TRIANGLE); + UIWidgets::PaddedText("These are NOT like emulator states.", true, false); + UIWidgets::PaddedText("They do not save your game progress, and", true, false); + UIWidgets::PaddedText("they WILL break across transitions and", true, false); + UIWidgets::PaddedText("load zones (like doors). Support for", true, false); + UIWidgets::PaddedText("related issues will not be provided.", true, false); + if (UIWidgets::PaddedEnhancementCheckbox("I promise I have read the warning", "gSaveStatePromise", true, false)) { + CVarSetInteger("gSaveStatesEnabled", 0); + LUS::Context::GetInstance()->GetWindow()->GetGui()->SaveConsoleVariablesOnNextTick(); + } + if (CVarGetInteger("gSaveStatePromise", 0) == 1) { + UIWidgets::PaddedEnhancementCheckbox("I understand, enable save states", "gSaveStatesEnabled", true, false); + UIWidgets::Tooltip("F5 to save, F6 to change slots, F7 to load"); + } + + ImGui::EndMenu(); + } + UIWidgets::Spacer(2.0f); { static int32_t betaQuestEnabled = CVarGetInteger("gEnableBetaQuest", 0); @@ -1266,6 +1291,7 @@ void DrawCheatsMenu() { } } + UIWidgets::Spacer(2.0f); if (ImGui::Button("Change Age")) { CVarSetInteger("gSwitchAge", 1); }