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.
This commit is contained in:
Malkierian 2023-08-20 11:00:04 -07:00 committed by GitHub
parent b040a894d1
commit 61eba0efad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 0 deletions

View File

@ -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 });

View File

@ -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);
}