Fix macro clipboard behavior

This commit is contained in:
Asriel Camora
2024-07-26 12:08:16 -07:00
parent ee7772a287
commit 4708a83020
2 changed files with 42 additions and 22 deletions
+20 -3
View File
@@ -14,7 +14,7 @@ public sealed unsafe class Hooks : IDisposable
public event OnActionUsedDelegate? OnActionUsed; public event OnActionUsedDelegate? OnActionUsed;
public delegate bool UseActionDelegate(ActionManager* manager, CSActionType actionType, uint actionId, ulong targetId, uint param, uint useType, int pvp, nint a8); public delegate bool UseActionDelegate(ActionManager* manager, CSActionType actionType, uint actionId, ulong targetId, uint extraParam, ActionManager.UseActionMode mode, uint comboRouteId, bool* outOptAreaTargeted);
public readonly Hook<UseActionDelegate> UseActionHook = null!; public readonly Hook<UseActionDelegate> UseActionHook = null!;
@@ -31,10 +31,10 @@ public sealed unsafe class Hooks : IDisposable
IsActionHighlightedHook.Enable(); IsActionHighlightedHook.Enable();
} }
private bool UseActionDetour(ActionManager* manager, CSActionType actionType, uint actionId, ulong targetId, uint param, uint useType, int pvp, nint a8) private bool UseActionDetour(ActionManager* manager, CSActionType actionType, uint actionId, ulong targetId, uint extraParam, ActionManager.UseActionMode mode, uint comboRouteId, bool* optOutAreaTargeted)
{ {
var canCast = manager->GetActionStatus(actionType, actionId) == 0; var canCast = manager->GetActionStatus(actionType, actionId) == 0;
var ret = UseActionHook.Original(manager, actionType, actionId, targetId, param, useType, pvp, a8); var ret = UseActionHook.Original(manager, actionType, actionId, targetId, extraParam, mode, comboRouteId, optOutAreaTargeted);
if (canCast && ret && actionType is CSActionType.CraftAction or CSActionType.Action) if (canCast && ret && actionType is CSActionType.CraftAction or CSActionType.Action)
{ {
var classJob = ClassJobUtils.GetClassJobFromIdx((byte)(Service.ClientState.LocalPlayer?.ClassJob.Id ?? 0)); var classJob = ClassJobUtils.GetClassJobFromIdx((byte)(Service.ClientState.LocalPlayer?.ClassJob.Id ?? 0));
@@ -42,8 +42,17 @@ public sealed unsafe class Hooks : IDisposable
{ {
var simActionType = ActionUtils.GetActionTypeFromId(actionId, classJob.Value, actionType == CSActionType.CraftAction); var simActionType = ActionUtils.GetActionTypeFromId(actionId, classJob.Value, actionType == CSActionType.CraftAction);
if (simActionType != null) if (simActionType != null)
{
try
{
OnActionUsed?.Invoke(simActionType.Value); OnActionUsed?.Invoke(simActionType.Value);
} }
catch (Exception e)
{
Log.Error(e, "Failed to invoke OnActionUsed");
}
}
}
} }
return ret; return ret;
} }
@@ -52,6 +61,8 @@ public sealed unsafe class Hooks : IDisposable
{ {
var ret = IsActionHighlightedHook.Original(manager, actionType, actionId); var ret = IsActionHighlightedHook.Original(manager, actionType, actionId);
try
{
if (!Service.Configuration.SynthHelperAbilityAnts) if (!Service.Configuration.SynthHelperAbilityAnts)
return ret; return ret;
@@ -75,6 +86,12 @@ public sealed unsafe class Hooks : IDisposable
if (Service.Plugin.SynthHelperWindow.NextAction != simActionType) if (Service.Plugin.SynthHelperWindow.NextAction != simActionType)
return 0; return 0;
}
catch (Exception ex)
{
Log.Error(ex, "Failed to check if action should be highlighted");
return ret;
}
return 1; return 1;
} }
+4 -1
View File
@@ -13,7 +13,7 @@ namespace Craftimizer.Windows;
public sealed class MacroClipboard : Window, IDisposable public sealed class MacroClipboard : Window, IDisposable
{ {
private const ImGuiWindowFlags WindowFlags = ImGuiWindowFlags.None; private const ImGuiWindowFlags WindowFlags = ImGuiWindowFlags.NoCollapse;
private List<string> Macros { get; } private List<string> Macros { get; }
@@ -22,6 +22,9 @@ public sealed class MacroClipboard : Window, IDisposable
Macros = new(macros); Macros = new(macros);
IsOpen = true; IsOpen = true;
AllowPinning = false;
AllowClickthrough = false;
BringToFront();
Service.WindowSystem.AddWindow(this); Service.WindowSystem.AddWindow(this);
} }