diff --git a/Dalamud/Interface/InterfaceManager.cs b/Dalamud/Interface/InterfaceManager.cs
index f134275d3..4b1be233f 100644
--- a/Dalamud/Interface/InterfaceManager.cs
+++ b/Dalamud/Interface/InterfaceManager.cs
@@ -32,7 +32,7 @@ namespace Dalamud.Interface
private RawDX11Scene scene;
///
- /// This event gets called when ImGUI is ready to draw your UI.
+ /// This event gets called by a plugin UiBuilder when read
///
public event RawDX11Scene.BuildUIDelegate OnDraw;
@@ -109,14 +109,7 @@ namespace Dalamud.Interface
// Doing this here because it's somewhat application-specific behavior
ImGui.GetIO().MouseDrawCursor = ImGui.GetIO().WantCaptureMouse;
- // invoke all our external ui handlers, giving each a custom id to prevent name collisions
- // because ImGui control names are globally shared
- foreach (var del in this.OnDraw?.GetInvocationList())
- {
- //ImGui.PushID(someId);
- del.DynamicInvoke();
- //ImGui.PopID();
- }
+ OnDraw?.Invoke();
}
}
}
diff --git a/Dalamud/Interface/UiBuilder.cs b/Dalamud/Interface/UiBuilder.cs
new file mode 100644
index 000000000..5e47b3fdb
--- /dev/null
+++ b/Dalamud/Interface/UiBuilder.cs
@@ -0,0 +1,35 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using ImGuiNET;
+using ImGuiScene;
+
+namespace Dalamud.Interface
+{
+ public class UiBuilder : IDisposable {
+ private readonly string namespaceName;
+
+ public event RawDX11Scene.BuildUIDelegate OnBuildUi;
+
+ private InterfaceManager interfaceManager;
+
+ public UiBuilder(InterfaceManager interfaceManager, string namespaceName) {
+ this.namespaceName = namespaceName;
+
+ this.interfaceManager = interfaceManager;
+ this.interfaceManager.OnDraw += OnDraw;
+ }
+
+ public void Dispose() {
+ this.interfaceManager.OnDraw -= OnDraw;
+ }
+
+ private void OnDraw() {
+ ImGui.PushID(this.namespaceName);
+ OnBuildUi?.Invoke();
+ ImGui.PopID();
+ }
+ }
+}
diff --git a/Dalamud/Plugin/DalamudPluginInterface.cs b/Dalamud/Plugin/DalamudPluginInterface.cs
index eda4b9e35..99c9a5e1a 100644
--- a/Dalamud/Plugin/DalamudPluginInterface.cs
+++ b/Dalamud/Plugin/DalamudPluginInterface.cs
@@ -18,7 +18,7 @@ namespace Dalamud.Plugin
///
/// This class acts as an interface to various objects needed to interact with Dalamud and the game.
///
- public class DalamudPluginInterface {
+ public class DalamudPluginInterface : IDisposable {
///
/// The CommandManager object that allows you to add and remove custom chat commands.
///
@@ -35,9 +35,9 @@ namespace Dalamud.Plugin
public readonly Framework Framework;
///
- /// A InterfaceManager instance which allows you to draw UI into the game via ImGui draw calls.
+ /// A UiBuilder instance which allows you to draw UI into the game via ImGui draw calls.
///
- public readonly InterfaceManager Interface;
+ public readonly UiBuilder UiBuilder;
/// A SigScanner instance targeting the main module of the FFXIV process.
///
@@ -54,13 +54,17 @@ namespace Dalamud.Plugin
this.CommandManager = dalamud.CommandManager;
this.Framework = dalamud.Framework;
this.ClientState = dalamud.ClientState;
- this.Interface = dalamud.InterfaceManager;
+ this.UiBuilder = new UiBuilder(dalamud.InterfaceManager, pluginName);
this.TargetModuleScanner = new SigScanner(dalamud.TargetModule);
this.dalamud = dalamud;
this.pluginName = pluginName;
}
+ public void Dispose() {
+ this.UiBuilder.Dispose();
+ }
+
///
/// Save a plugin configuration(inheriting IPluginConfiguration).
///