From 3ff529b99a62b7f903612d3c991d7e257980472d Mon Sep 17 00:00:00 2001
From: Liza Carvelli <liza@carvel.li>
Date: Thu, 1 Aug 2024 18:47:13 +0200
Subject: [PATCH] Add an option to disable ESC

---
 Questionable/Configuration.cs              | 1 +
 Questionable/Controller/QuestController.cs | 2 +-
 Questionable/Windows/ConfigWindow.cs       | 7 +++++++
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Questionable/Configuration.cs b/Questionable/Configuration.cs
index 4b276961..4424db23 100644
--- a/Questionable/Configuration.cs
+++ b/Questionable/Configuration.cs
@@ -18,6 +18,7 @@ internal sealed class Configuration : IPluginConfiguration
         public uint MountId { get; set; } = 71;
         public GrandCompany GrandCompany { get; set; } = GrandCompany.None;
         public bool HideInAllInstances { get; set; } = true;
+        public bool UseEscToCancelQuesting { get; set; } = true;
     }
 
     internal sealed class AdvancedConfiguration
diff --git a/Questionable/Controller/QuestController.cs b/Questionable/Controller/QuestController.cs
index 4838353a..c92fee2b 100644
--- a/Questionable/Controller/QuestController.cs
+++ b/Questionable/Controller/QuestController.cs
@@ -140,7 +140,7 @@ internal sealed class QuestController
                 _combatController.Stop("HP = 0");
             }
         }
-        else if (_keyState[VirtualKey.ESCAPE])
+        else if (_configuration.General.UseEscToCancelQuesting && _keyState[VirtualKey.ESCAPE])
         {
             if (_currentTask != null || _taskQueue.Count > 0)
             {
diff --git a/Questionable/Windows/ConfigWindow.cs b/Questionable/Windows/ConfigWindow.cs
index 11693300..0fa60d69 100644
--- a/Questionable/Windows/ConfigWindow.cs
+++ b/Questionable/Windows/ConfigWindow.cs
@@ -76,6 +76,13 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
                     Save();
                 }
 
+                bool useEscToCancelQuesting = _configuration.General.UseEscToCancelQuesting;
+                if (ImGui.Checkbox("Use ESC to cancel questing/movement", ref useEscToCancelQuesting))
+                {
+                    _configuration.General.UseEscToCancelQuesting = useEscToCancelQuesting;
+                    Save();
+                }
+
                 ImGui.EndTabItem();
             }