Disable synthhelper if a macro is running
This commit is contained in:
@@ -90,6 +90,7 @@ public class Configuration : IPluginConfiguration
|
|||||||
[JsonConverter(typeof(PopulateConverter))]
|
[JsonConverter(typeof(PopulateConverter))]
|
||||||
public SolverConfig SynthHelperSolverConfig { get; set; } = SolverConfig.SynthHelperDefault;
|
public SolverConfig SynthHelperSolverConfig { get; set; } = SolverConfig.SynthHelperDefault;
|
||||||
public bool EnableSynthHelper { get; set; } = true;
|
public bool EnableSynthHelper { get; set; } = true;
|
||||||
|
public bool DisableSynthHelperOnMacro { get; set; } = true;
|
||||||
public bool ShowOptimalMacroStat { get; set; } = true;
|
public bool ShowOptimalMacroStat { get; set; } = true;
|
||||||
public int SynthHelperStepCount { get; set; } = 5;
|
public int SynthHelperStepCount { get; set; } = 5;
|
||||||
|
|
||||||
|
|||||||
@@ -656,6 +656,14 @@ public sealed class Settings : Window, IDisposable
|
|||||||
|
|
||||||
var isDirty = false;
|
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(
|
DrawOption(
|
||||||
"Step Count",
|
"Step Count",
|
||||||
"The number of future actions to solve for during an in-game craft.",
|
"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.Game.Character;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||||
|
using FFXIVClientStructs.FFXIV.Client.UI.Shell;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -85,34 +86,6 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
|||||||
Service.WindowSystem.AddWindow(this);
|
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;
|
private bool wasOpen;
|
||||||
public override bool DrawConditions()
|
public override bool DrawConditions()
|
||||||
@@ -121,28 +94,57 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
|||||||
if (isOpen != wasOpen)
|
if (isOpen != wasOpen)
|
||||||
{
|
{
|
||||||
if (wasOpen)
|
if (wasOpen)
|
||||||
|
{
|
||||||
|
IsCrafting = false;
|
||||||
HelperTaskTokenSource?.Cancel();
|
HelperTaskTokenSource?.Cancel();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
wasOpen = isOpen;
|
wasOpen = isOpen;
|
||||||
return isOpen;
|
return isOpen;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool wasInCraftAction;
|
||||||
private bool ShouldDraw()
|
private bool ShouldDraw()
|
||||||
{
|
{
|
||||||
if (Service.ClientState.LocalPlayer == null)
|
if (Service.ClientState.LocalPlayer == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (Addon == null)
|
if (!Service.Configuration.EnableSynthHelper)
|
||||||
return false;
|
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;
|
return false;
|
||||||
|
|
||||||
// Check if Synthesis addon is visible
|
// Check if Synthesis addon is visible
|
||||||
if (Addon->AtkUnitBase.WindowNode == null)
|
if (Addon->AtkUnitBase.WindowNode == null)
|
||||||
return false;
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user