more stuff

main
Zynh0722 2024-02-06 23:13:53 -08:00
parent 3d75087d9f
commit 907574e436
3 changed files with 59 additions and 39 deletions

View File

@ -1,8 +1,8 @@
using Dalamud.Game.Command;
using System.IO;
using Dalamud.Game.Command;
using Dalamud.Interface.Windowing;
using Dalamud.IoC;
using Dalamud.Plugin;
using System.IO;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin.Services;
using SamplePlugin.Windows;
@ -13,51 +13,59 @@ namespace SamplePlugin
public string Name => "Sample Plugin";
private const string CommandName = "/pmycommand";
private DalamudPluginInterface PluginInterface { get; init; }
private ICommandManager CommandManager { get; init; }
public Configuration Configuration { get; init; }
public WindowSystem WindowSystem = new("SamplePlugin");
private DalamudPluginInterface pluginInterface { get; init; }
private ICommandManager commandManager { get; init; }
public Configuration configuration { get; init; }
internal WindowSystem windowSystem = new("SamplePlugin");
private ConfigWindow ConfigWindow { get; init; }
private MainWindow MainWindow { get; init; }
public Plugin(
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface,
[RequiredVersion("1.0")] ICommandManager commandManager)
[RequiredVersion("1.0")] ICommandManager commandManager
)
{
this.PluginInterface = pluginInterface;
this.CommandManager = commandManager;
this.pluginInterface = pluginInterface;
this.commandManager = commandManager;
this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
this.Configuration.Initialize(this.PluginInterface);
configuration =
pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
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);
var imagePath = Path.Combine(
this.pluginInterface.AssemblyLocation.Directory?.FullName!,
"goat.png"
);
var goatImage = this.pluginInterface.UiBuilder.LoadImage(imagePath);
ConfigWindow = new ConfigWindow(this);
MainWindow = new MainWindow(this, goatImage);
WindowSystem.AddWindow(ConfigWindow);
WindowSystem.AddWindow(MainWindow);
windowSystem.AddWindow(ConfigWindow);
windowSystem.AddWindow(MainWindow);
this.CommandManager.AddHandler(CommandName, new CommandInfo(OnCommand)
_ = 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;
this.pluginInterface.UiBuilder.Draw += DrawUI;
this.pluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
}
public void Dispose()
{
this.WindowSystem.RemoveAllWindows();
this.windowSystem.RemoveAllWindows();
ConfigWindow.Dispose();
MainWindow.Dispose();
this.CommandManager.RemoveHandler(CommandName);
this.commandManager.RemoveHandler(CommandName);
}
private void OnCommand(string command, string args)
@ -68,7 +76,7 @@ namespace SamplePlugin
private void DrawUI()
{
this.WindowSystem.Draw();
this.windowSystem.Draw();
}
public void DrawConfigUI()

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Numerics;
using Dalamud.Interface.Windowing;
using ImGuiNET;
@ -9,15 +9,19 @@ public class ConfigWindow : Window, IDisposable
{
private Configuration Configuration;
public ConfigWindow(Plugin plugin) : base(
public ConfigWindow(Plugin plugin)
: base(
"A Wonderful Configuration Window",
ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoCollapse | ImGuiWindowFlags.NoScrollbar |
ImGuiWindowFlags.NoScrollWithMouse)
ImGuiWindowFlags.NoResize
| ImGuiWindowFlags.NoCollapse
| ImGuiWindowFlags.NoScrollbar
| ImGuiWindowFlags.NoScrollWithMouse
)
{
this.Size = new Vector2(232, 75);
this.SizeCondition = ImGuiCond.Always;
this.Configuration = plugin.Configuration;
this.Configuration = plugin.configuration;
}
public void Dispose() { }

View File

@ -1,4 +1,4 @@
using System;
using System;
using System.Numerics;
using Dalamud.Interface.Internal;
using Dalamud.Interface.Windowing;
@ -11,8 +11,11 @@ public class MainWindow : Window, IDisposable
private IDalamudTextureWrap GoatImage;
private Plugin Plugin;
public MainWindow(Plugin plugin, IDalamudTextureWrap goatImage) : base(
"My Amazing Window", ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse)
public MainWindow(Plugin plugin, IDalamudTextureWrap goatImage)
: base(
"My Amazing Window",
ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse
)
{
this.SizeConstraints = new WindowSizeConstraints
{
@ -31,7 +34,9 @@ public class MainWindow : Window, IDisposable
public override void Draw()
{
ImGui.Text($"The random config bool is {this.Plugin.Configuration.SomePropertyToBeSavedAndWithADefault}");
ImGui.Text(
$"The random config bool is {this.Plugin.configuration.SomePropertyToBeSavedAndWithADefault}"
);
if (ImGui.Button("Show Settings"))
{
@ -42,7 +47,10 @@ public class MainWindow : Window, IDisposable
ImGui.Text("Have a goat:");
ImGui.Indent(55);
ImGui.Image(this.GoatImage.ImGuiHandle, new Vector2(this.GoatImage.Width, this.GoatImage.Height));
ImGui.Image(
this.GoatImage.ImGuiHandle,
new Vector2(this.GoatImage.Width, this.GoatImage.Height)
);
ImGui.Unindent(55);
}
}