mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-23 08:17:47 +01:00
Compare commits
No commits in common. "5dd121dfcc866d7838768729772259996adb6302" and "832edaf005e0afa75ae0bf10aa5ff5ef9505bcb5" have entirely different histories.
5dd121dfcc
...
832edaf005
5 changed files with 19 additions and 80 deletions
|
|
@ -1,34 +0,0 @@
|
|||
using FFXIVClientStructs.FFXIV.Client.UI.Agent;
|
||||
|
||||
namespace Dalamud.Game.Gui;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a flag set by the game used by agents to conditionally update their addons.
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum AgentUpdateFlag : byte
|
||||
{
|
||||
/// <summary> Set when an inventory has been updated. </summary>
|
||||
InventoryUpdate = 1 << 0,
|
||||
|
||||
/// <summary> Set when a hotbar slot has been executed, or a Gearset or Macro has been changed. </summary>
|
||||
ActionBarUpdate = 1 << 1,
|
||||
|
||||
/// <summary> Set when the RetainerMarket inventory has been updated. </summary>
|
||||
RetainerMarketInventoryUpdate = 1 << 2,
|
||||
|
||||
// /// <summary> Unknown use case. </summary>
|
||||
// NameplateUpdate = 1 << 3,
|
||||
|
||||
/// <summary> Set when the player unlocked collectibles, contents or systems. </summary>
|
||||
UnlocksUpdate = 1 << 4,
|
||||
|
||||
/// <summary> Set when <see cref="AgentHUD.SetMainCommandEnabledState"/> was called. </summary>
|
||||
MainCommandEnabledStateUpdate = 1 << 5,
|
||||
|
||||
/// <summary> Set when any housing inventory has been updated. </summary>
|
||||
HousingInventoryUpdate = 1 << 6,
|
||||
|
||||
/// <summary> Set when any content inventory has been updated. </summary>
|
||||
ContentInventoryUpdate = 1 << 7,
|
||||
}
|
||||
|
|
@ -43,7 +43,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
|||
private readonly Hook<HandleImmDelegate> handleImmHook;
|
||||
private readonly Hook<RaptureAtkModule.Delegates.SetUiVisibility> setUiVisibilityHook;
|
||||
private readonly Hook<Utf8String.Delegates.Ctor_FromSequence> utf8StringFromSequenceHook;
|
||||
private readonly Hook<RaptureAtkModule.Delegates.Update> raptureAtkModuleUpdateHook;
|
||||
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private GameGui(TargetSigScanner sigScanner)
|
||||
|
|
@ -66,10 +65,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
|||
|
||||
this.utf8StringFromSequenceHook = Hook<Utf8String.Delegates.Ctor_FromSequence>.FromAddress(Utf8String.Addresses.Ctor_FromSequence.Value, this.Utf8StringFromSequenceDetour);
|
||||
|
||||
this.raptureAtkModuleUpdateHook = Hook<RaptureAtkModule.Delegates.Update>.FromFunctionPointerVariable(
|
||||
new(&RaptureAtkModule.StaticVirtualTablePointer->Update),
|
||||
this.RaptureAtkModuleUpdateDetour);
|
||||
|
||||
this.handleItemHoverHook.Enable();
|
||||
this.handleItemOutHook.Enable();
|
||||
this.handleImmHook.Enable();
|
||||
|
|
@ -77,7 +72,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
|||
this.handleActionHoverHook.Enable();
|
||||
this.handleActionOutHook.Enable();
|
||||
this.utf8StringFromSequenceHook.Enable();
|
||||
this.raptureAtkModuleUpdateHook.Enable();
|
||||
}
|
||||
|
||||
// Hooked delegates
|
||||
|
|
@ -94,9 +88,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
|||
/// <inheritdoc/>
|
||||
public event EventHandler<HoveredAction>? HoveredActionChanged;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event Action<AgentUpdateFlag> AgentUpdate;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool GameUiHidden { get; private set; }
|
||||
|
||||
|
|
@ -247,7 +238,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
|||
this.handleActionHoverHook.Dispose();
|
||||
this.handleActionOutHook.Dispose();
|
||||
this.utf8StringFromSequenceHook.Dispose();
|
||||
this.raptureAtkModuleUpdateHook.Dispose();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -364,21 +354,6 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
|||
|
||||
return thisPtr; // this function shouldn't need to return but the original asm moves this into rax before returning so be safe?
|
||||
}
|
||||
|
||||
private void RaptureAtkModuleUpdateDetour(RaptureAtkModule* thisPtr, float delta)
|
||||
{
|
||||
// The game clears the AgentUpdateFlag in the original function, but it also updates agents in it too.
|
||||
// We'll make a copy of the flags, so that we can fire events after the agents have been updated.
|
||||
|
||||
var agentUpdateFlag = thisPtr->AgentUpdateFlag;
|
||||
|
||||
this.raptureAtkModuleUpdateHook.Original(thisPtr, delta);
|
||||
|
||||
if (agentUpdateFlag != RaptureAtkModule.AgentUpdateFlags.None)
|
||||
{
|
||||
this.AgentUpdate.InvokeSafely((AgentUpdateFlag)agentUpdateFlag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -402,7 +377,6 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
|||
this.gameGuiService.UiHideToggled += this.UiHideToggledForward;
|
||||
this.gameGuiService.HoveredItemChanged += this.HoveredItemForward;
|
||||
this.gameGuiService.HoveredActionChanged += this.HoveredActionForward;
|
||||
this.gameGuiService.AgentUpdate += this.AgentUpdateForward;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
|
|
@ -414,9 +388,6 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
|||
/// <inheritdoc/>
|
||||
public event EventHandler<HoveredAction>? HoveredActionChanged;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event Action<AgentUpdateFlag> AgentUpdate;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public bool GameUiHidden => this.gameGuiService.GameUiHidden;
|
||||
|
||||
|
|
@ -436,7 +407,6 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
|||
this.gameGuiService.UiHideToggled -= this.UiHideToggledForward;
|
||||
this.gameGuiService.HoveredItemChanged -= this.HoveredItemForward;
|
||||
this.gameGuiService.HoveredActionChanged -= this.HoveredActionForward;
|
||||
this.gameGuiService.AgentUpdate -= this.AgentUpdateForward;
|
||||
|
||||
this.UiHideToggled = null;
|
||||
this.HoveredItemChanged = null;
|
||||
|
|
@ -488,6 +458,4 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
|||
private void HoveredItemForward(object sender, ulong itemId) => this.HoveredItemChanged?.Invoke(sender, itemId);
|
||||
|
||||
private void HoveredActionForward(object sender, HoveredAction hoverAction) => this.HoveredActionChanged?.Invoke(sender, hoverAction);
|
||||
|
||||
private void AgentUpdateForward(AgentUpdateFlag agentUpdateFlag) => this.AgentUpdate.InvokeSafely(agentUpdateFlag);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,16 @@ using System.Collections;
|
|||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using Dalamud.Game.Gui;
|
||||
using Dalamud.Game.Inventory.InventoryEventArgTypes;
|
||||
using Dalamud.Hooking;
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using Dalamud.Logging.Internal;
|
||||
using Dalamud.Plugin.Internal;
|
||||
using Dalamud.Plugin.Services;
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Client.UI;
|
||||
|
||||
namespace Dalamud.Game.Inventory;
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -31,8 +33,7 @@ internal class GameInventory : IInternalDisposableService
|
|||
[ServiceManager.ServiceDependency]
|
||||
private readonly Framework framework = Service<Framework>.Get();
|
||||
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly GameGui gameGui = Service<GameGui>.Get();
|
||||
private readonly Hook<RaptureAtkModuleUpdateDelegate> raptureAtkModuleUpdateHook;
|
||||
|
||||
private readonly GameInventoryType[] inventoryTypes;
|
||||
private readonly GameInventoryItem[]?[] inventoryItems;
|
||||
|
|
@ -46,9 +47,18 @@ internal class GameInventory : IInternalDisposableService
|
|||
this.inventoryTypes = Enum.GetValues<GameInventoryType>();
|
||||
this.inventoryItems = new GameInventoryItem[this.inventoryTypes.Length][];
|
||||
|
||||
this.gameGui.AgentUpdate += this.OnAgentUpdate;
|
||||
unsafe
|
||||
{
|
||||
this.raptureAtkModuleUpdateHook = Hook<RaptureAtkModuleUpdateDelegate>.FromFunctionPointerVariable(
|
||||
new(&RaptureAtkModule.StaticVirtualTablePointer->Update),
|
||||
this.RaptureAtkModuleUpdateDetour);
|
||||
}
|
||||
|
||||
this.raptureAtkModuleUpdateHook.Enable();
|
||||
}
|
||||
|
||||
private unsafe delegate void RaptureAtkModuleUpdateDelegate(RaptureAtkModule* ram, float f1);
|
||||
|
||||
/// <inheritdoc/>
|
||||
void IInternalDisposableService.DisposeService()
|
||||
{
|
||||
|
|
@ -58,7 +68,7 @@ internal class GameInventory : IInternalDisposableService
|
|||
this.subscribersPendingChange.Clear();
|
||||
this.subscribersChanged = false;
|
||||
this.framework.Update -= this.OnFrameworkUpdate;
|
||||
this.gameGui.AgentUpdate -= this.OnAgentUpdate;
|
||||
this.raptureAtkModuleUpdateHook.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -309,9 +319,10 @@ internal class GameInventory : IInternalDisposableService
|
|||
return items;
|
||||
}
|
||||
|
||||
private void OnAgentUpdate(AgentUpdateFlag agentUpdateFlag)
|
||||
private unsafe void RaptureAtkModuleUpdateDetour(RaptureAtkModule* ram, float f1)
|
||||
{
|
||||
this.inventoriesMightBeChanged |= true;
|
||||
this.inventoriesMightBeChanged |= ram->AgentUpdateFlag != 0;
|
||||
this.raptureAtkModuleUpdateHook.Original(ram, f1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
|||
|
|
@ -26,12 +26,6 @@ public unsafe interface IGameGui
|
|||
/// </summary>
|
||||
public event EventHandler<HoveredAction> HoveredActionChanged;
|
||||
|
||||
/// <summary>
|
||||
/// Fired when the game sets one or more <see cref="AgentUpdateFlag"/> values,
|
||||
/// used by agents to conditionally update their addons.
|
||||
/// </summary>
|
||||
event Action<AgentUpdateFlag> AgentUpdate;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the game UI is hidden.
|
||||
/// </summary>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 5d01489c34f33a3d645f49085d7fc0065a1ac801
|
||||
Subproject commit a37961c453463f0f60a96f27aa278ef139841857
|
||||
Loading…
Add table
Add a link
Reference in a new issue