aboutsummaryrefslogtreecommitdiffstats
path: root/SamplePlugin/Plugin.cs
diff options
context:
space:
mode:
authorPinapelz <donaldshan1@outlook.com>2024-09-14 13:48:51 -0700
committerGitHub <noreply@github.com>2024-09-14 13:48:51 -0700
commit610015a68d7ad9580c7ac9dc427ccace650a9b9e (patch)
treedb3e449a3fd039b4935359eafb1f3ee9f61f5df7 /SamplePlugin/Plugin.cs
Initial commit
Diffstat (limited to 'SamplePlugin/Plugin.cs')
-rw-r--r--SamplePlugin/Plugin.cs73
1 files changed, 73 insertions, 0 deletions
diff --git a/SamplePlugin/Plugin.cs b/SamplePlugin/Plugin.cs
new file mode 100644
index 0000000..b8e859b
--- /dev/null
+++ b/SamplePlugin/Plugin.cs
@@ -0,0 +1,73 @@
+using Dalamud.Game.Command;
+using Dalamud.IoC;
+using Dalamud.Plugin;
+using System.IO;
+using Dalamud.Interface.Windowing;
+using Dalamud.Plugin.Services;
+using SamplePlugin.Windows;
+
+namespace SamplePlugin;
+
+public sealed class Plugin : IDalamudPlugin
+{
+ [PluginService] internal static IDalamudPluginInterface PluginInterface { get; private set; } = null!;
+ [PluginService] internal static ITextureProvider TextureProvider { get; private set; } = null!;
+ [PluginService] internal static ICommandManager CommandManager { get; private set; } = null!;
+
+ private const string CommandName = "/pmycommand";
+
+ public Configuration Configuration { get; init; }
+
+ public readonly WindowSystem WindowSystem = new("SamplePlugin");
+ private ConfigWindow ConfigWindow { get; init; }
+ private MainWindow MainWindow { get; init; }
+
+ public Plugin()
+ {
+ Configuration = PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
+
+ // you might normally want to embed resources and load them from the manifest stream
+ var goatImagePath = Path.Combine(PluginInterface.AssemblyLocation.Directory?.FullName!, "goat.png");
+
+ ConfigWindow = new ConfigWindow(this);
+ MainWindow = new MainWindow(this, goatImagePath);
+
+ WindowSystem.AddWindow(ConfigWindow);
+ WindowSystem.AddWindow(MainWindow);
+
+ CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
+ {
+ HelpMessage = "A useful message to display in /xlhelp"
+ });
+
+ PluginInterface.UiBuilder.Draw += DrawUI;
+
+ // This adds a button to the plugin installer entry of this plugin which allows
+ // to toggle the display status of the configuration ui
+ PluginInterface.UiBuilder.OpenConfigUi += ToggleConfigUI;
+
+ // Adds another button that is doing the same but for the main ui of the plugin
+ PluginInterface.UiBuilder.OpenMainUi += ToggleMainUI;
+ }
+
+ public void Dispose()
+ {
+ WindowSystem.RemoveAllWindows();
+
+ ConfigWindow.Dispose();
+ MainWindow.Dispose();
+
+ CommandManager.RemoveHandler(CommandName);
+ }
+
+ private void OnCommand(string command, string args)
+ {
+ // in response to the slash command, just toggle the display status of our main ui
+ ToggleMainUI();
+ }
+
+ private void DrawUI() => WindowSystem.Draw();
+
+ public void ToggleConfigUI() => ConfigWindow.Toggle();
+ public void ToggleMainUI() => MainWindow.Toggle();
+}
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage