From 7d5dd11a429186e94572bf36413d147cedfbc5cd Mon Sep 17 00:00:00 2001 From: NotNite Date: Sat, 18 Mar 2023 19:57:19 -0400 Subject: [PATCH] garbage UI code --- Dalamud/Fools/FoolsManager.cs | 26 ++++++++++++++++++++----- Dalamud/Fools/Plugins/TestFoolPlugin.cs | 14 ++++++++++++- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/Dalamud/Fools/FoolsManager.cs b/Dalamud/Fools/FoolsManager.cs index 8d08e5c39..d71b416e9 100644 --- a/Dalamud/Fools/FoolsManager.cs +++ b/Dalamud/Fools/FoolsManager.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Reflection; using Dalamud.Fools.Plugins; +using Dalamud.Interface; using Dalamud.Logging.Internal; namespace Dalamud.Fools; @@ -15,12 +16,17 @@ internal class FoolsManager : IDisposable, IServiceType { public readonly List FoolsPlugins = new(); public readonly Dictionary ActivatedPlugins = new(); - + private static readonly ModuleLog Log = new("FOOLS"); + private UiBuilder uiBuilder; + [ServiceManager.ServiceConstructor] private FoolsManager() { + this.uiBuilder = new UiBuilder("fools"); + this.uiBuilder.Draw += this.DrawUI; + // reflect over all IFoolsPlugin implementations this.FoolsPlugins = new List { @@ -47,6 +53,18 @@ internal class FoolsManager : IDisposable, IServiceType this.ActivatedPlugins.Add(plugin, pluginInstance); } + public void Dispose() + { + foreach (var plugin in this.ActivatedPlugins.Values) + { + plugin.Dispose(); + } + + this.ActivatedPlugins.Clear(); + + ((IDisposable)this.uiBuilder).Dispose(); + } + public bool IsPluginActivated(string plugin) { return this.ActivatedPlugins.ContainsKey(plugin); @@ -65,13 +83,11 @@ internal class FoolsManager : IDisposable, IServiceType this.ActivatedPlugins.Remove(plugin); } - public void Dispose() + private void DrawUI() { foreach (var plugin in this.ActivatedPlugins.Values) { - plugin.Dispose(); + plugin.DrawUI(); } - - this.ActivatedPlugins.Clear(); } } diff --git a/Dalamud/Fools/Plugins/TestFoolPlugin.cs b/Dalamud/Fools/Plugins/TestFoolPlugin.cs index 1cf2d1d94..4eb36ed7a 100644 --- a/Dalamud/Fools/Plugins/TestFoolPlugin.cs +++ b/Dalamud/Fools/Plugins/TestFoolPlugin.cs @@ -1,4 +1,6 @@ -namespace Dalamud.Fools.Plugins; +using ImGuiNET; + +namespace Dalamud.Fools.Plugins; public class TestFoolPlugin : IFoolsPlugin { @@ -12,5 +14,15 @@ public class TestFoolPlugin : IFoolsPlugin public TestFoolPlugin() { } + public void DrawUI() + { + if (ImGui.Begin("Nuts")) + { + ImGui.Text("balls"); + } + + ImGui.End(); + } + public void Dispose() { } }