From e68b281b18f5cff7d3bac92d4de797043e207ff5 Mon Sep 17 00:00:00 2001
From: Ted Newman <Tawling@users.noreply.github.com>
Date: Thu, 15 Feb 2024 17:39:24 -0800
Subject: [PATCH] [Enhancement] Preserve minimap toggle state between areas
 (#3906)

* Add enhancement to preserve minimap toggle state between areas

* add map toggle enhancement to presets
---
 soh/soh/Enhancements/presets.h | 1 +
 soh/soh/SohMenuBar.cpp         | 2 ++
 soh/src/code/z_construct.c     | 4 +++-
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/soh/soh/Enhancements/presets.h b/soh/soh/Enhancements/presets.h
index 8a9b963e8..572439e22 100644
--- a/soh/soh/Enhancements/presets.h
+++ b/soh/soh/Enhancements/presets.h
@@ -331,6 +331,7 @@ const std::vector<const char*> cheatCvars = {
     "gCosmetics.Link_HeadScale.Value",
     "gCosmetics.Link_SwordScale.Changed",
     "gCosmetics.Link_SwordScale.Value",
+    "gEnhancements.RememberMapToggleState",
 };
 
 const std::vector<const char*> randomizerCvars = {
diff --git a/soh/soh/SohMenuBar.cpp b/soh/soh/SohMenuBar.cpp
index d74649290..5f41f1e25 100644
--- a/soh/soh/SohMenuBar.cpp
+++ b/soh/soh/SohMenuBar.cpp
@@ -988,6 +988,8 @@ void DrawEnhancementsMenu() {
                 UIWidgets::Tooltip("Disables the voice audio when Navi calls you");
                 UIWidgets::PaddedEnhancementCheckbox("Disable Hot/Underwater Warning Text", "gDisableTunicWarningText", true, false);
                 UIWidgets::Tooltip("Disables warning text when you don't have on the Goron/Zora Tunic in Hot/Underwater conditions.");
+                UIWidgets::PaddedEnhancementCheckbox("Remember Minimap State Between Areas", "gEnhancements.RememberMapToggleState");
+                UIWidgets::Tooltip("Preserves the minimap visibility state when going between areas rather than defaulting it to \"on\" when going through loading zones.");
 
                 ImGui::EndMenu();
             }
diff --git a/soh/src/code/z_construct.c b/soh/src/code/z_construct.c
index b95902cc5..c8a340492 100644
--- a/soh/src/code/z_construct.c
+++ b/soh/src/code/z_construct.c
@@ -430,7 +430,9 @@ void Regs_InitDataImpl(void) {
     WREG(28) = 0;
     R_OW_MINIMAP_X = 238;
     R_OW_MINIMAP_Y = 164;
-    R_MINIMAP_DISABLED = CVarGetInteger("gMinimalUI", 0);
+    if (!CVarGetInteger("gEnhancements.RememberMapToggleState", 0)) {
+        R_MINIMAP_DISABLED = CVarGetInteger("gMinimalUI", 0);
+    }
     WREG(32) = 122;
     WREG(33) = 60;
     WREG(35) = 0;