Add config option for TA settings v3.9
authorLiza Carvelli <liza@carvel.li>
Sat, 5 Oct 2024 12:32:29 +0000 (14:32 +0200)
committerLiza Carvelli <liza@carvel.li>
Sat, 5 Oct 2024 12:32:51 +0000 (14:32 +0200)
Directory.Build.targets
Questionable/Configuration.cs
Questionable/External/TextAdvanceIpc.cs
Questionable/Windows/ConfigWindow.cs

index 939fb575a0d699921611203332ef045521636a80..590411dd5e770fe6e7c352631e82813d318f0a5b 100644 (file)
@@ -1,5 +1,5 @@
 <Project>
     <PropertyGroup>
-        <Version>3.8</Version>
+        <Version>3.9</Version>
     </PropertyGroup>
 </Project>
index 3ea014cb81f83633d96e64a0187ba0d127627235..f2a251640dcb63f05213679f5d0a02b763d47cb2 100644 (file)
@@ -20,6 +20,7 @@ internal sealed class Configuration : IPluginConfiguration
         public bool UseEscToCancelQuesting { get; set; } = true;
         public bool ShowIncompleteSeasonalEvents { get; set; } = true;
         public bool AutomaticallyCompleteSnipeTasks { get; set; }
+        public bool ConfigureTextAdvance { get; set; } = true;
     }
 
     internal sealed class AdvancedConfiguration
index bb771b02441adf26e2838999be4f0015c8de179d..dd4fa395979d1617186a2172f1ca28c9f680a164 100644 (file)
@@ -6,6 +6,7 @@ using Questionable.Controller;
 using Questionable.Data;
 using Questionable.Model.Common;
 using System;
+using System.Diagnostics.CodeAnalysis;
 
 namespace Questionable.External;
 
@@ -13,6 +14,7 @@ internal sealed class TextAdvanceIpc : IDisposable
 {
     private bool _isExternalControlActivated;
     private readonly QuestController _questController;
+    private readonly Configuration _configuration;
     private readonly IFramework _framework;
     private readonly ICallGateSubscriber<bool> _isInExternalControl;
     private readonly ICallGateSubscriber<string, ExternalTerritoryConfig, bool> _enableExternalControl;
@@ -20,10 +22,11 @@ internal sealed class TextAdvanceIpc : IDisposable
     private readonly string _pluginName;
     private readonly ExternalTerritoryConfig _externalTerritoryConfig = new();
 
-    public TextAdvanceIpc(IDalamudPluginInterface pluginInterface, IFramework framework, QuestController questController)
+    public TextAdvanceIpc(IDalamudPluginInterface pluginInterface, IFramework framework, QuestController questController, Configuration configuration)
     {
         _framework = framework;
         _questController = questController;
+        _configuration = configuration;
         _isInExternalControl = pluginInterface.GetIpcSubscriber<bool>("TextAdvance.IsInExternalControl");
         _enableExternalControl = pluginInterface.GetIpcSubscriber<string, ExternalTerritoryConfig, bool>("TextAdvance.EnableExternalControl");
         _disableExternalControl = pluginInterface.GetIpcSubscriber<string, bool>("TextAdvance.DisableExternalControl");
@@ -40,9 +43,9 @@ internal sealed class TextAdvanceIpc : IDisposable
         }
     }
 
-    public void OnUpdate(IFramework framework)
+    private void OnUpdate(IFramework framework)
     {
-        if(_questController.IsRunning)
+        if(_configuration.General.ConfigureTextAdvance && _questController.IsRunning)
         {
             if(!_isInExternalControl.InvokeFunc())
             {
@@ -64,8 +67,10 @@ internal sealed class TextAdvanceIpc : IDisposable
         }
     }
 
-    public class ExternalTerritoryConfig
+    [SuppressMessage("ReSharper", "MemberCanBePrivate.Global")]
+    public sealed class ExternalTerritoryConfig
     {
+#pragma warning disable CS0414 // Field is assigned but its value is never used
         public bool? EnableQuestAccept = true;
         public bool? EnableQuestComplete = true;
         public bool? EnableRewardPick = true;
@@ -75,5 +80,6 @@ internal sealed class TextAdvanceIpc : IDisposable
         public bool? EnableTalkSkip = true;
         public bool? EnableRequestFill = true;
         public bool? EnableAutoInteract = false;
+#pragma warning restore CS0414 // Field is assigned but its value is never used
     }
 }
index 0b278c04babe920223dbedaa4f5becef421df28e..0416943f73b74501515e57c3346b205d9f080197 100644 (file)
@@ -90,6 +90,13 @@ internal sealed class ConfigWindow : LWindow, IPersistableWindowConfig
                     Save();
                 }
 
+                bool configureTextAdvance = _configuration.General.ConfigureTextAdvance;
+                if (ImGui.Checkbox("Automatically configure TextAdvance with the recommended settings", ref configureTextAdvance))
+                {
+                    _configuration.General.ConfigureTextAdvance = configureTextAdvance;
+                    Save();
+                }
+
                 if (ImGui.CollapsingHeader("Cheats"))
                 {
                     ImGui.TextColored(ImGuiColors.DalamudRed, "This setting will be removed in a future version, and will be\navailable through TextAdvance instead.");