mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
Unify agent update events into AgentUpdate
This commit is contained in:
parent
0b6f3b8bcf
commit
8fd49f261a
4 changed files with 46 additions and 70 deletions
34
Dalamud/Game/Gui/AgentUpdateFlag.cs
Normal file
34
Dalamud/Game/Gui/AgentUpdateFlag.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
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,
|
||||||
|
}
|
||||||
|
|
@ -95,16 +95,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
||||||
public event EventHandler<HoveredAction>? HoveredActionChanged;
|
public event EventHandler<HoveredAction>? HoveredActionChanged;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public event Action InventoryUpdate;
|
public event Action<AgentUpdateFlag> AgentUpdate;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public event Action ActionBarUpdate;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public event Action UnlocksUpdate;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public event Action MainCommandEnabledStateUpdate;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool GameUiHidden { get; private set; }
|
public bool GameUiHidden { get; private set; }
|
||||||
|
|
@ -393,20 +384,7 @@ internal sealed unsafe class GameGui : IInternalDisposableService, IGameGui
|
||||||
|
|
||||||
if (agentUpdateFlag != RaptureAtkModule.AgentUpdateFlags.None)
|
if (agentUpdateFlag != RaptureAtkModule.AgentUpdateFlags.None)
|
||||||
{
|
{
|
||||||
if (agentUpdateFlag.HasFlag(RaptureAtkModule.AgentUpdateFlags.InventoryUpdate) ||
|
this.AgentUpdate.InvokeSafely((AgentUpdateFlag)agentUpdateFlag);
|
||||||
agentUpdateFlag.HasFlag(RaptureAtkModule.AgentUpdateFlags.RetainerMarketInventoryUpdate) ||
|
|
||||||
agentUpdateFlag.HasFlag(RaptureAtkModule.AgentUpdateFlags.HousingInventoryUpdate) ||
|
|
||||||
agentUpdateFlag.HasFlag(RaptureAtkModule.AgentUpdateFlags.ContentInventoryUpdate))
|
|
||||||
this.InventoryUpdate.InvokeSafely();
|
|
||||||
|
|
||||||
if (agentUpdateFlag.HasFlag(RaptureAtkModule.AgentUpdateFlags.ActionBarUpdate))
|
|
||||||
this.ActionBarUpdate.InvokeSafely();
|
|
||||||
|
|
||||||
if (agentUpdateFlag.HasFlag(RaptureAtkModule.AgentUpdateFlags.UnlocksUpdate))
|
|
||||||
this.UnlocksUpdate.InvokeSafely();
|
|
||||||
|
|
||||||
if (agentUpdateFlag.HasFlag(RaptureAtkModule.AgentUpdateFlags.MainCommandEnabledStateUpdate))
|
|
||||||
this.MainCommandEnabledStateUpdate.InvokeSafely();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -432,10 +410,7 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
||||||
this.gameGuiService.UiHideToggled += this.UiHideToggledForward;
|
this.gameGuiService.UiHideToggled += this.UiHideToggledForward;
|
||||||
this.gameGuiService.HoveredItemChanged += this.HoveredItemForward;
|
this.gameGuiService.HoveredItemChanged += this.HoveredItemForward;
|
||||||
this.gameGuiService.HoveredActionChanged += this.HoveredActionForward;
|
this.gameGuiService.HoveredActionChanged += this.HoveredActionForward;
|
||||||
this.gameGuiService.InventoryUpdate += this.InventoryUpdateForward;
|
this.gameGuiService.AgentUpdate += this.AgentUpdateForward;
|
||||||
this.gameGuiService.ActionBarUpdate += this.ActionBarUpdateForward;
|
|
||||||
this.gameGuiService.UnlocksUpdate += this.UnlocksUpdateForward;
|
|
||||||
this.gameGuiService.MainCommandEnabledStateUpdate += this.MainCommandEnabledStateUpdateForward;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
@ -448,16 +423,7 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
||||||
public event EventHandler<HoveredAction>? HoveredActionChanged;
|
public event EventHandler<HoveredAction>? HoveredActionChanged;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public event Action InventoryUpdate;
|
public event Action<AgentUpdateFlag> AgentUpdate;
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public event Action ActionBarUpdate;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public event Action UnlocksUpdate;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
|
||||||
public event Action MainCommandEnabledStateUpdate;
|
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
public bool GameUiHidden => this.gameGuiService.GameUiHidden;
|
public bool GameUiHidden => this.gameGuiService.GameUiHidden;
|
||||||
|
|
@ -478,10 +444,7 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
||||||
this.gameGuiService.UiHideToggled -= this.UiHideToggledForward;
|
this.gameGuiService.UiHideToggled -= this.UiHideToggledForward;
|
||||||
this.gameGuiService.HoveredItemChanged -= this.HoveredItemForward;
|
this.gameGuiService.HoveredItemChanged -= this.HoveredItemForward;
|
||||||
this.gameGuiService.HoveredActionChanged -= this.HoveredActionForward;
|
this.gameGuiService.HoveredActionChanged -= this.HoveredActionForward;
|
||||||
this.gameGuiService.InventoryUpdate -= this.InventoryUpdateForward;
|
this.gameGuiService.AgentUpdate -= this.AgentUpdateForward;
|
||||||
this.gameGuiService.ActionBarUpdate -= this.ActionBarUpdateForward;
|
|
||||||
this.gameGuiService.UnlocksUpdate -= this.UnlocksUpdateForward;
|
|
||||||
this.gameGuiService.MainCommandEnabledStateUpdate -= this.MainCommandEnabledStateUpdateForward;
|
|
||||||
|
|
||||||
this.UiHideToggled = null;
|
this.UiHideToggled = null;
|
||||||
this.HoveredItemChanged = null;
|
this.HoveredItemChanged = null;
|
||||||
|
|
@ -534,11 +497,5 @@ internal class GameGuiPluginScoped : IInternalDisposableService, IGameGui
|
||||||
|
|
||||||
private void HoveredActionForward(object sender, HoveredAction hoverAction) => this.HoveredActionChanged?.Invoke(sender, hoverAction);
|
private void HoveredActionForward(object sender, HoveredAction hoverAction) => this.HoveredActionChanged?.Invoke(sender, hoverAction);
|
||||||
|
|
||||||
private void InventoryUpdateForward() => this.InventoryUpdate.InvokeSafely();
|
private void AgentUpdateForward(AgentUpdateFlag agentUpdateFlag) => this.AgentUpdate.InvokeSafely(agentUpdateFlag);
|
||||||
|
|
||||||
private void ActionBarUpdateForward() => this.ActionBarUpdate.InvokeSafely();
|
|
||||||
|
|
||||||
private void UnlocksUpdateForward() => this.UnlocksUpdate.InvokeSafely();
|
|
||||||
|
|
||||||
private void MainCommandEnabledStateUpdateForward() => this.MainCommandEnabledStateUpdate.InvokeSafely();
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ internal class GameInventory : IInternalDisposableService
|
||||||
this.inventoryTypes = Enum.GetValues<GameInventoryType>();
|
this.inventoryTypes = Enum.GetValues<GameInventoryType>();
|
||||||
this.inventoryItems = new GameInventoryItem[this.inventoryTypes.Length][];
|
this.inventoryItems = new GameInventoryItem[this.inventoryTypes.Length][];
|
||||||
|
|
||||||
this.gameGui.InventoryUpdate += this.OnInventoryUpdate;
|
this.gameGui.AgentUpdate += this.OnAgentUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <inheritdoc/>
|
/// <inheritdoc/>
|
||||||
|
|
@ -58,7 +58,7 @@ internal class GameInventory : IInternalDisposableService
|
||||||
this.subscribersPendingChange.Clear();
|
this.subscribersPendingChange.Clear();
|
||||||
this.subscribersChanged = false;
|
this.subscribersChanged = false;
|
||||||
this.framework.Update -= this.OnFrameworkUpdate;
|
this.framework.Update -= this.OnFrameworkUpdate;
|
||||||
this.gameGui.InventoryUpdate -= this.OnInventoryUpdate;
|
this.gameGui.AgentUpdate -= this.OnAgentUpdate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -309,7 +309,7 @@ internal class GameInventory : IInternalDisposableService
|
||||||
return items;
|
return items;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnInventoryUpdate()
|
private void OnAgentUpdate(AgentUpdateFlag agentUpdateFlag)
|
||||||
{
|
{
|
||||||
this.inventoriesMightBeChanged |= true;
|
this.inventoriesMightBeChanged |= true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -27,25 +27,10 @@ public unsafe interface IGameGui
|
||||||
public event EventHandler<HoveredAction> HoveredActionChanged;
|
public event EventHandler<HoveredAction> HoveredActionChanged;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Event that is fired when the inventory has been updated.
|
/// Fired when the game sets one or more <see cref="AgentUpdateFlag"/> values,
|
||||||
|
/// used by agents to conditionally update their addons.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
event Action InventoryUpdate;
|
event Action<AgentUpdateFlag> AgentUpdate;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Fired when the action bar needs to be updated, e.g. after changing Class/Job,
|
|
||||||
/// updating Gear Sets, modifying Macros, or executing a hotbar slot.
|
|
||||||
/// </summary>
|
|
||||||
event Action ActionBarUpdate;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event that is fired when collectibles, content or systems were unlocked.
|
|
||||||
/// </summary>
|
|
||||||
event Action UnlocksUpdate;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Event that is fired when the enable state of MainCommands has been updated.
|
|
||||||
/// </summary>
|
|
||||||
event Action MainCommandEnabledStateUpdate;
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the game UI is hidden.
|
/// Gets a value indicating whether the game UI is hidden.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue