diff --git a/Craftimizer/Configuration.cs b/Craftimizer/Configuration.cs index c903f9b..cd473f4 100644 --- a/Craftimizer/Configuration.cs +++ b/Craftimizer/Configuration.cs @@ -90,6 +90,7 @@ public class Configuration : IPluginConfiguration [JsonConverter(typeof(PopulateConverter))] public SolverConfig SynthHelperSolverConfig { get; set; } = SolverConfig.SynthHelperDefault; public bool EnableSynthHelper { get; set; } = true; + public bool DisableSynthHelperOnMacro { get; set; } = true; public bool ShowOptimalMacroStat { get; set; } = true; public int SynthHelperStepCount { get; set; } = 5; diff --git a/Craftimizer/Windows/Settings.cs b/Craftimizer/Windows/Settings.cs index 715948f..35a1003 100644 --- a/Craftimizer/Windows/Settings.cs +++ b/Craftimizer/Windows/Settings.cs @@ -656,6 +656,14 @@ public sealed class Settings : Window, IDisposable var isDirty = false; + DrawOption( + "Disable when running macro", + "Disables itself when an in-game macro is running.", + Config.DisableSynthHelperOnMacro, + v => Config.DisableSynthHelperOnMacro = v, + ref isDirty + ); + DrawOption( "Step Count", "The number of future actions to solve for during an in-game craft.", diff --git a/Craftimizer/Windows/SynthHelper.cs b/Craftimizer/Windows/SynthHelper.cs index d5fdc77..7bf6f61 100644 --- a/Craftimizer/Windows/SynthHelper.cs +++ b/Craftimizer/Windows/SynthHelper.cs @@ -14,6 +14,7 @@ using FFXIVClientStructs.FFXIV.Client.Game; using FFXIVClientStructs.FFXIV.Client.Game.Character; using FFXIVClientStructs.FFXIV.Client.UI; using FFXIVClientStructs.FFXIV.Client.UI.Agent; +using FFXIVClientStructs.FFXIV.Client.UI.Shell; using ImGuiNET; using System; using System.Collections.Generic; @@ -85,34 +86,6 @@ public sealed unsafe class SynthHelper : Window, IDisposable Service.WindowSystem.AddWindow(this); } - private bool wasInCraftAction; - public override void Update() - { - Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis"); - - if (Addon != null) - { - var agent = AgentRecipeNote.Instance(); - var recipeId = (ushort)agent->ActiveCraftRecipeId; - - if (agent->ActiveCraftRecipeId == 0) - IsCrafting = false; - else if (!IsCrafting) - { - IsCrafting = true; - OnStartCrafting(recipeId); - } - } - else - IsCrafting = false; - - Macro.FlushQueue(); - - var isInCraftAction = Service.Condition[ConditionFlag.Crafting40]; - if (!isInCraftAction && wasInCraftAction) - OnFinishedUsingAction(); - wasInCraftAction = isInCraftAction; - } private bool wasOpen; public override bool DrawConditions() @@ -121,28 +94,57 @@ public sealed unsafe class SynthHelper : Window, IDisposable if (isOpen != wasOpen) { if (wasOpen) + { + IsCrafting = false; HelperTaskTokenSource?.Cancel(); + } } wasOpen = isOpen; return isOpen; } + private bool wasInCraftAction; private bool ShouldDraw() { if (Service.ClientState.LocalPlayer == null) return false; - if (Addon == null) + if (!Service.Configuration.EnableSynthHelper) return false; - if (!IsCrafting) + if (Service.Configuration.DisableSynthHelperOnMacro && + RaptureShellModule.Instance()->MacroCurrentLine >= 0) + return false; + + Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis"); + + if (Addon == null) return false; // Check if Synthesis addon is visible if (Addon->AtkUnitBase.WindowNode == null) return false; + var agent = AgentRecipeNote.Instance(); + var recipeId = (ushort)agent->ActiveCraftRecipeId; + + if (agent->ActiveCraftRecipeId == 0) + return false; + + if (!IsCrafting) + { + IsCrafting = true; + OnStartCrafting(recipeId); + } + + Macro.FlushQueue(); + + var isInCraftAction = Service.Condition[ConditionFlag.Crafting40]; + if (!isInCraftAction && wasInCraftAction) + OnFinishedUsingAction(); + wasInCraftAction = isInCraftAction; + return true; }