Add /craftaction command
This commit is contained in:
@@ -78,6 +78,10 @@ public sealed class Plugin : IDalamudPlugin
|
||||
{
|
||||
HelpMessage = "Open the crafting macro editor.",
|
||||
});
|
||||
Service.CommandManager.AddHandler("/craftaction", new CommandInfo((_, _) => ExecuteSuggestedSynthHelperAction())
|
||||
{
|
||||
HelpMessage = "Execute the suggested action in the synthesis helper. This command mostly exists for controller players.",
|
||||
});
|
||||
}
|
||||
|
||||
public (CharacterStats? Character, RecipeData? Recipe, MacroEditor.CrafterBuffs? Buffs) GetOpenedStats()
|
||||
@@ -122,6 +126,9 @@ public sealed class Plugin : IDalamudPlugin
|
||||
EditorWindow = new(characterStats, recipeData, buffs, actions, setter);
|
||||
}
|
||||
|
||||
public void ExecuteSuggestedSynthHelperAction() =>
|
||||
SynthHelperWindow.QueueSuggestedActionExecution();
|
||||
|
||||
public void OpenSettingsWindow()
|
||||
{
|
||||
if (SettingsWindow.IsOpen ^= true)
|
||||
@@ -159,6 +166,7 @@ public sealed class Plugin : IDalamudPlugin
|
||||
Service.CommandManager.RemoveHandler("/craftimizer");
|
||||
Service.CommandManager.RemoveHandler("/craftmacros");
|
||||
Service.CommandManager.RemoveHandler("/crafteditor");
|
||||
Service.CommandManager.RemoveHandler("/craftaction");
|
||||
SettingsWindow.Dispose();
|
||||
RecipeNoteWindow.Dispose();
|
||||
SynthHelperWindow.Dispose();
|
||||
|
||||
@@ -59,6 +59,8 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
private SimulationState currentState;
|
||||
private SimulatedMacro Macro { get; } = new();
|
||||
|
||||
private bool IsSuggestedActionExecutionQueued { get; set; }
|
||||
|
||||
private CancellationTokenSource? HelperTaskTokenSource { get; set; }
|
||||
private Exception? HelperTaskException { get; set; }
|
||||
private Solver.Solver? HelperTaskObject { get; set; }
|
||||
@@ -86,7 +88,6 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
Service.WindowSystem.AddWindow(this);
|
||||
}
|
||||
|
||||
|
||||
private bool wasOpen;
|
||||
public override bool DrawConditions()
|
||||
{
|
||||
@@ -99,6 +100,8 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
HelperTaskTokenSource?.Cancel();
|
||||
}
|
||||
}
|
||||
if (!isOpen)
|
||||
IsSuggestedActionExecutionQueued = false;
|
||||
|
||||
wasOpen = isOpen;
|
||||
return isOpen;
|
||||
@@ -114,7 +117,8 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
return false;
|
||||
|
||||
if (Service.Configuration.DisableSynthHelperOnMacro &&
|
||||
RaptureShellModule.Instance()->MacroCurrentLine >= 0)
|
||||
RaptureShellModule.Instance()->MacroCurrentLine >= 0 &&
|
||||
!IsSuggestedActionExecutionQueued)
|
||||
return false;
|
||||
|
||||
Addon = (AddonSynthesis*)Service.GameGui.GetAddonByName("Synthesis");
|
||||
@@ -160,6 +164,11 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
Position = ImGuiHelpers.MainViewport.Pos + pos + new Vector2(size.X, offset * scale);
|
||||
}
|
||||
|
||||
public override void PostDraw()
|
||||
{
|
||||
IsSuggestedActionExecutionQueued = false;
|
||||
}
|
||||
|
||||
public override void Draw()
|
||||
{
|
||||
DrawMacro();
|
||||
@@ -226,7 +235,7 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
isPressed = ImGuiExtras.ButtonBehavior(bb, id, out isHovered, out isHeld, ImGuiButtonFlags.None);
|
||||
}
|
||||
ImGui.ImageButton(action.GetIcon(RecipeData!.ClassJob).ImGuiHandle, new(imageSize), default, Vector2.One, 0, default, failedAction ? new(1, 1, 1, ImGui.GetStyle().DisabledAlpha) : Vector4.One);
|
||||
if (isPressed)
|
||||
if (isPressed || IsSuggestedActionExecutionQueued)
|
||||
{
|
||||
if (canExecute && i == 0)
|
||||
{
|
||||
@@ -562,6 +571,11 @@ public sealed unsafe class SynthHelper : Window, IDisposable
|
||||
HelperTaskTokenSource?.Cancel();
|
||||
}
|
||||
|
||||
public void QueueSuggestedActionExecution()
|
||||
{
|
||||
IsSuggestedActionExecutionQueued = true;
|
||||
}
|
||||
|
||||
private static Sim CreateSim(in SimulationState state) =>
|
||||
Service.Configuration.ConditionRandomness ? new Sim() { State = state } : new SimNoRandom() { State = state };
|
||||
|
||||
|
||||
Reference in New Issue
Block a user