garbage UI code

This commit is contained in:
NotNite 2023-03-18 19:57:19 -04:00
parent de4ffd23c9
commit 7d5dd11a42
No known key found for this signature in database
GPG key ID: BD91A5402CCEB08A
2 changed files with 34 additions and 6 deletions

View file

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using Dalamud.Fools.Plugins; using Dalamud.Fools.Plugins;
using Dalamud.Interface;
using Dalamud.Logging.Internal; using Dalamud.Logging.Internal;
namespace Dalamud.Fools; namespace Dalamud.Fools;
@ -18,9 +19,14 @@ internal class FoolsManager : IDisposable, IServiceType
private static readonly ModuleLog Log = new("FOOLS"); private static readonly ModuleLog Log = new("FOOLS");
private UiBuilder uiBuilder;
[ServiceManager.ServiceConstructor] [ServiceManager.ServiceConstructor]
private FoolsManager() private FoolsManager()
{ {
this.uiBuilder = new UiBuilder("fools");
this.uiBuilder.Draw += this.DrawUI;
// reflect over all IFoolsPlugin implementations // reflect over all IFoolsPlugin implementations
this.FoolsPlugins = new List<FoolsPluginMetadata> this.FoolsPlugins = new List<FoolsPluginMetadata>
{ {
@ -47,6 +53,18 @@ internal class FoolsManager : IDisposable, IServiceType
this.ActivatedPlugins.Add(plugin, pluginInstance); 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) public bool IsPluginActivated(string plugin)
{ {
return this.ActivatedPlugins.ContainsKey(plugin); return this.ActivatedPlugins.ContainsKey(plugin);
@ -65,13 +83,11 @@ internal class FoolsManager : IDisposable, IServiceType
this.ActivatedPlugins.Remove(plugin); this.ActivatedPlugins.Remove(plugin);
} }
public void Dispose() private void DrawUI()
{ {
foreach (var plugin in this.ActivatedPlugins.Values) foreach (var plugin in this.ActivatedPlugins.Values)
{ {
plugin.Dispose(); plugin.DrawUI();
} }
this.ActivatedPlugins.Clear();
} }
} }

View file

@ -1,4 +1,6 @@
namespace Dalamud.Fools.Plugins; using ImGuiNET;
namespace Dalamud.Fools.Plugins;
public class TestFoolPlugin : IFoolsPlugin public class TestFoolPlugin : IFoolsPlugin
{ {
@ -12,5 +14,15 @@ public class TestFoolPlugin : IFoolsPlugin
public TestFoolPlugin() { } public TestFoolPlugin() { }
public void DrawUI()
{
if (ImGui.Begin("Nuts"))
{
ImGui.Text("balls");
}
ImGui.End();
}
public void Dispose() { } public void Dispose() { }
} }