fix: remove shitty feature interface stuff, do it in UiBuilder

This commit is contained in:
goat 2020-03-18 12:40:56 +09:00
parent 9acc51ca96
commit 6c7592ec17
5 changed files with 7 additions and 57 deletions

View file

@ -58,6 +58,11 @@ namespace Dalamud.Interface
public TextureWrap LoadImage(byte[] imageData) =>
this.interfaceManager.LoadImage(imageData);
/// <summary>
/// Event that is fired when the plugin should open its configuration interface.
/// </summary>
public EventHandler OnOpenConfigUi;
private void OnDraw() {
ImGui.PushID(this.namespaceName);
OnBuildUi?.Invoke();

View file

@ -1,16 +0,0 @@
using System;
using Dalamud.Interface;
namespace Dalamud.Plugin.Features
{
/// <summary>
/// This interface represents a Dalamud plugin that has a configuration UI which can be triggered.
/// </summary>
public interface IHasConfigUi : IHasUi
{
/// <summary>
/// An event handler that is fired when the plugin should show its configuration interface.
/// </summary>
EventHandler OpenConfigUi { get; }
}
}

View file

@ -1,21 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dalamud.Interface;
namespace Dalamud.Plugin.Features
{
/// <summary>
/// This interface represents a Dalamud plugin that has user interface which can be drawn.
/// </summary>
public interface IHasUi : IDalamudPlugin
{
/// <summary>
/// A function that gets called when Dalamud is ready to draw your UI.
/// </summary>
/// <param name="uiBuilder">An <see cref="UiBuilder"/> object you can use to e.g. load images.</param>
void Draw(UiBuilder uiBuilder);
}
}

View file

@ -10,7 +10,6 @@ using System.Net.Http;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using Dalamud.Plugin.Features;
using ImGuiNET;
using Newtonsoft.Json;
using Serilog;
@ -224,10 +223,10 @@ namespace Dalamud.Plugin
this.errorModalOnNextFrame = true;
}
if (installedPlugin.Plugin is IHasConfigUi v2Plugin && v2Plugin.OpenConfigUi != null) {
if (installedPlugin.PluginInterface.UiBuilder.OnOpenConfigUi != null) {
ImGui.SameLine();
if (ImGui.Button("Open Configuration")) v2Plugin.OpenConfigUi?.Invoke(null, null);
if (ImGui.Button("Open Configuration")) installedPlugin.PluginInterface.UiBuilder.OnOpenConfigUi?.Invoke(null, null);
}
ImGui.SameLine();

View file

@ -3,12 +3,7 @@ using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using Dalamud.Configuration;
using Dalamud.Interface;
using Dalamud.Plugin.Features;
using ImGuiNET;
using Newtonsoft.Json;
using Serilog;
@ -31,18 +26,6 @@ namespace Dalamud.Plugin
this.devPluginDirectory = devPluginDirectory;
this.pluginConfigs = new PluginConfigurations(Path.Combine(Path.GetDirectoryName(dalamud.StartInfo.ConfigurationPath), "pluginConfigs"));
this.dalamud.InterfaceManager.OnDraw += InterfaceManagerOnOnDraw;
}
private void InterfaceManagerOnOnDraw() {
foreach (var plugin in this.Plugins) {
if (plugin.Plugin is IHasUi uiPlugin) {
ImGui.PushID(plugin.Definition.InternalName);
uiPlugin.Draw(plugin.PluginInterface.UiBuilder);
ImGui.PopID();
}
}
}
public void UnloadPlugins() {