Disable synthhelper if a macro is running
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user