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
+38 -21
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,7 +42,16 @@ 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)
OnActionUsed?.Invoke(simActionType.Value); {
try
{
OnActionUsed?.Invoke(simActionType.Value);
}
catch (Exception e)
{
Log.Error(e, "Failed to invoke OnActionUsed");
}
}
} }
} }
return ret; return ret;
@@ -52,29 +61,37 @@ public sealed unsafe class Hooks : IDisposable
{ {
var ret = IsActionHighlightedHook.Original(manager, actionType, actionId); var ret = IsActionHighlightedHook.Original(manager, actionType, actionId);
if (!Service.Configuration.SynthHelperAbilityAnts) try
return ret; {
if (!Service.Configuration.SynthHelperAbilityAnts)
return ret;
if (!Service.Plugin.SynthHelperWindow.ShouldDrawAnts) if (!Service.Plugin.SynthHelperWindow.ShouldDrawAnts)
return ret; return ret;
if (actionType is not (CSActionType.CraftAction or CSActionType.Action)) if (actionType is not (CSActionType.CraftAction or CSActionType.Action))
return ret; return ret;
var jobId = Service.ClientState.LocalPlayer?.ClassJob.Id; var jobId = Service.ClientState.LocalPlayer?.ClassJob.Id;
if (jobId == null) if (jobId == null)
return ret; return ret;
var classJob = ClassJobUtils.GetClassJobFromIdx((byte)jobId.Value); var classJob = ClassJobUtils.GetClassJobFromIdx((byte)jobId.Value);
if (classJob == null) if (classJob == null)
return ret; return ret;
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)
return ret; return ret;
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);
} }