mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-28 03:19:19 +01:00
garbage UI code
This commit is contained in:
parent
de4ffd23c9
commit
7d5dd11a42
2 changed files with 34 additions and 6 deletions
|
|
@ -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<FoolsPluginMetadata> FoolsPlugins = new();
|
||||
public readonly Dictionary<string, IFoolsPlugin> 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<FoolsPluginMetadata>
|
||||
{
|
||||
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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() { }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue