From 7397ca547a7ee58022af72b1385db8030ffa06be Mon Sep 17 00:00:00 2001 From: Limiana <5073202+Limiana@users.noreply.github.com> Date: Mon, 30 Sep 2024 23:14:56 +0300 Subject: [PATCH 1/2] Add TextAdvance ipc --- Questionable/External/TextAdvanceIpc.cs | 79 +++++++++++++++++++++++++ Questionable/QuestionablePlugin.cs | 2 + 2 files changed, 81 insertions(+) create mode 100644 Questionable/External/TextAdvanceIpc.cs diff --git a/Questionable/External/TextAdvanceIpc.cs b/Questionable/External/TextAdvanceIpc.cs new file mode 100644 index 00000000..bb771b02 --- /dev/null +++ b/Questionable/External/TextAdvanceIpc.cs @@ -0,0 +1,79 @@ +using Dalamud.Plugin; +using Dalamud.Plugin.Ipc; +using Dalamud.Plugin.Services; +using FFXIVClientStructs.FFXIV.Client.Game; +using Questionable.Controller; +using Questionable.Data; +using Questionable.Model.Common; +using System; + +namespace Questionable.External; + +internal sealed class TextAdvanceIpc : IDisposable +{ + private bool _isExternalControlActivated; + private readonly QuestController _questController; + private readonly IFramework _framework; + private readonly ICallGateSubscriber _isInExternalControl; + private readonly ICallGateSubscriber _enableExternalControl; + private readonly ICallGateSubscriber _disableExternalControl; + private readonly string _pluginName; + private readonly ExternalTerritoryConfig _externalTerritoryConfig = new(); + + public TextAdvanceIpc(IDalamudPluginInterface pluginInterface, IFramework framework, QuestController questController) + { + _framework = framework; + _questController = questController; + _isInExternalControl = pluginInterface.GetIpcSubscriber("TextAdvance.IsInExternalControl"); + _enableExternalControl = pluginInterface.GetIpcSubscriber("TextAdvance.EnableExternalControl"); + _disableExternalControl = pluginInterface.GetIpcSubscriber("TextAdvance.DisableExternalControl"); + _pluginName = pluginInterface.InternalName; + _framework.Update += OnUpdate; + } + + public void Dispose() + { + _framework.Update -= OnUpdate; + if(_isExternalControlActivated) + { + _disableExternalControl.InvokeFunc(_pluginName); + } + } + + public void OnUpdate(IFramework framework) + { + if(_questController.IsRunning) + { + if(!_isInExternalControl.InvokeFunc()) + { + if(_enableExternalControl.InvokeFunc(_pluginName, _externalTerritoryConfig)) + { + _isExternalControlActivated = true; + } + } + } + else + { + if(_isExternalControlActivated) + { + if(_disableExternalControl.InvokeFunc(_pluginName) || !_isInExternalControl.InvokeFunc()) + { + _isExternalControlActivated = false; + } + } + } + } + + public class ExternalTerritoryConfig + { + public bool? EnableQuestAccept = true; + public bool? EnableQuestComplete = true; + public bool? EnableRewardPick = true; + public bool? EnableRequestHandin = true; + public bool? EnableCutsceneEsc = true; + public bool? EnableCutsceneSkipConfirm = true; + public bool? EnableTalkSkip = true; + public bool? EnableRequestFill = true; + public bool? EnableAutoInteract = false; + } +} diff --git a/Questionable/QuestionablePlugin.cs b/Questionable/QuestionablePlugin.cs index a3731ed4..b9a1c54e 100644 --- a/Questionable/QuestionablePlugin.cs +++ b/Questionable/QuestionablePlugin.cs @@ -124,6 +124,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); serviceCollection.AddSingleton(); + serviceCollection.AddSingleton(); } private static void AddTaskFactories(ServiceCollection serviceCollection) @@ -289,6 +290,7 @@ public sealed class QuestionablePlugin : IDalamudPlugin serviceProvider.GetRequiredService(); serviceProvider.GetRequiredService(); serviceProvider.GetRequiredService().Enable(); + serviceProvider.GetRequiredService(); } public void Dispose() From 708e260eee95a508758e00b24758d08ac79eb84e Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Sat, 5 Oct 2024 14:32:29 +0200 Subject: [PATCH 2/2] Add config option for TA settings --- Directory.Build.targets | 2 +- Questionable/Configuration.cs | 1 + Questionable/External/TextAdvanceIpc.cs | 14 ++++++++++---- Questionable/Windows/ConfigWindow.cs | 7 +++++++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Directory.Build.targets b/Directory.Build.targets index 939fb575..590411dd 100644 --- a/Directory.Build.targets +++ b/Directory.Build.targets @@ -1,5 +1,5 @@ - 3.8 + 3.9 diff --git a/Questionable/Configuration.cs b/Questionable/Configuration.cs index 3ea014cb..f2a25164 100644 --- a/Questionable/Configuration.cs +++ b/Questionable/Configuration.cs @@ -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 diff --git a/Questionable/External/TextAdvanceIpc.cs b/Questionable/External/TextAdvanceIpc.cs index bb771b02..dd4fa395 100644 --- a/Questionable/External/TextAdvanceIpc.cs +++ b/Questionable/External/TextAdvanceIpc.cs @@ -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 _isInExternalControl; private readonly ICallGateSubscriber _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("TextAdvance.IsInExternalControl"); _enableExternalControl = pluginInterface.GetIpcSubscriber("TextAdvance.EnableExternalControl"); _disableExternalControl = pluginInterface.GetIpcSubscriber("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 } } diff --git a/Questionable/Windows/ConfigWindow.cs b/Questionable/Windows/ConfigWindow.cs index 0b278c04..0416943f 100644 --- a/Questionable/Windows/ConfigWindow.cs +++ b/Questionable/Windows/ConfigWindow.cs @@ -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.");