Refactor Addon Lifecycle

This commit is contained in:
MidoriKami 2025-11-25 17:27:48 -08:00
parent a31dda7865
commit 54bac7f32a
19 changed files with 543 additions and 825 deletions

View file

@ -1,10 +1,8 @@
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using Dalamud.Bindings.ImGui;
using Dalamud.Game.Addon.Lifecycle;
using Dalamud.Interface.Colors;
using Dalamud.Interface.Utility;
namespace Dalamud.Interface.Internal.Windows.Data.Widgets;
@ -54,13 +52,6 @@ public class AddonLifecycleWidget : IDataWindowWidget
this.DrawEventListeners();
ImGui.Unindent();
}
if (ImGui.CollapsingHeader("ReceiveEvent Hooks"u8))
{
ImGui.Indent();
this.DrawReceiveEventHooks();
ImGui.Unindent();
}
}
private void DrawEventListeners()
@ -100,46 +91,4 @@ public class AddonLifecycleWidget : IDataWindowWidget
}
}
}
private void DrawReceiveEventHooks()
{
if (!this.Ready) return;
var listeners = this.AddonLifecycle.ReceiveEventListeners;
if (listeners.Count == 0)
{
ImGui.Text("No ReceiveEvent Hooks are Registered"u8);
}
foreach (var receiveEventListener in this.AddonLifecycle.ReceiveEventListeners)
{
if (ImGui.CollapsingHeader(string.Join(", ", receiveEventListener.AddonNames)))
{
ImGui.Columns(2);
var functionAddress = receiveEventListener.FunctionAddress;
ImGui.Text("Hook Address"u8);
ImGui.NextColumn();
ImGui.Text($"0x{functionAddress:X} (ffxiv_dx11.exe+{functionAddress - Process.GetCurrentProcess().MainModule!.BaseAddress:X})");
ImGui.NextColumn();
ImGui.Text("Hook Status"u8);
ImGui.NextColumn();
if (receiveEventListener.Hook is null)
{
ImGui.Text("Hook is null"u8);
}
else
{
var color = receiveEventListener.Hook.IsEnabled ? ImGuiColors.HealerGreen : ImGuiColors.DalamudRed;
var text = receiveEventListener.Hook.IsEnabled ? "Enabled"u8 : "Disabled"u8;
ImGui.TextColored(color, text);
}
ImGui.Columns(1);
}
}
}
}