70 lines
2.4 KiB
C#
70 lines
2.4 KiB
C#
|
using Dalamud.Game.Command;
|
||
|
using Dalamud.IoC;
|
||
|
using Dalamud.Plugin;
|
||
|
using System.IO;
|
||
|
using System.Reflection;
|
||
|
using Dalamud.Interface.Windowing;
|
||
|
using FFXIV_Plugin_Vibe.Windows;
|
||
|
|
||
|
namespace FFXIV_Plugin_Vibe
|
||
|
{
|
||
|
public sealed class Plugin : IDalamudPlugin
|
||
|
{
|
||
|
public string Name => "Sample Plugin";
|
||
|
private const string CommandName = "/pmycommand";
|
||
|
|
||
|
private DalamudPluginInterface PluginInterface { get; init; }
|
||
|
private CommandManager CommandManager { get; init; }
|
||
|
public Configuration Configuration { get; init; }
|
||
|
public WindowSystem WindowSystem = new("SamplePlugin");
|
||
|
|
||
|
public Plugin(
|
||
|
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface,
|
||
|
[RequiredVersion("1.0")] CommandManager commandManager)
|
||
|
{
|
||
|
this.PluginInterface = pluginInterface;
|
||
|
this.CommandManager = commandManager;
|
||
|
|
||
|
this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||
|
this.Configuration.Initialize(this.PluginInterface);
|
||
|
|
||
|
// you might normally want to embed resources and load them from the manifest stream
|
||
|
var imagePath = Path.Combine(PluginInterface.AssemblyLocation.Directory?.FullName!, "goat.png");
|
||
|
var goatImage = this.PluginInterface.UiBuilder.LoadImage(imagePath);
|
||
|
|
||
|
WindowSystem.AddWindow(new ConfigWindow(this));
|
||
|
WindowSystem.AddWindow(new MainWindow(this, goatImage));
|
||
|
|
||
|
this.CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
|
||
|
{
|
||
|
HelpMessage = "A useful message to display in /xlhelp"
|
||
|
});
|
||
|
|
||
|
this.PluginInterface.UiBuilder.Draw += DrawUI;
|
||
|
this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
|
||
|
}
|
||
|
|
||
|
public void Dispose()
|
||
|
{
|
||
|
this.WindowSystem.RemoveAllWindows();
|
||
|
this.CommandManager.RemoveHandler(CommandName);
|
||
|
}
|
||
|
|
||
|
private void OnCommand(string command, string args)
|
||
|
{
|
||
|
// in response to the slash command, just display our main ui
|
||
|
WindowSystem.GetWindow("My Amazing Window").IsOpen = true;
|
||
|
}
|
||
|
|
||
|
private void DrawUI()
|
||
|
{
|
||
|
this.WindowSystem.Draw();
|
||
|
}
|
||
|
|
||
|
public void DrawConfigUI()
|
||
|
{
|
||
|
WindowSystem.GetWindow("A Wonderful Configuration Window").IsOpen = true;
|
||
|
}
|
||
|
}
|
||
|
}
|