static services, lets go
This commit is contained in:
parent
ccaf9e11ca
commit
e07d69fcce
1 changed files with 17 additions and 19 deletions
|
@ -11,43 +11,41 @@ namespace CommandReference
|
||||||
{
|
{
|
||||||
public sealed class Plugin : IDalamudPlugin
|
public sealed class Plugin : IDalamudPlugin
|
||||||
{
|
{
|
||||||
public static string Name => "Sample Plugin";
|
private const string CommandName = "/commands";
|
||||||
private const string CommandName = "/pmycommand";
|
|
||||||
|
|
||||||
[PluginService]
|
[PluginService]
|
||||||
private DalamudPluginInterface pluginInterface { get; set; } = null!;
|
private static DalamudPluginInterface pluginInterface { get; set; } = null!;
|
||||||
private ICommandManager commandManager { get; init; }
|
|
||||||
|
[PluginService]
|
||||||
|
private static ICommandManager commandManager { get; set; } = null!;
|
||||||
|
|
||||||
|
[PluginService]
|
||||||
|
private static IPluginLog log { get; set; } = null!;
|
||||||
|
|
||||||
public Configuration configuration { get; init; }
|
public Configuration configuration { get; init; }
|
||||||
internal WindowSystem windowSystem = new("CommandReference");
|
internal WindowSystem windowSystem = new("CommandReference");
|
||||||
|
|
||||||
private ConfigWindow ConfigWindow { get; init; }
|
private ConfigWindow ConfigWindow { get; init; }
|
||||||
private MainWindow MainWindow { get; init; }
|
private MainWindow MainWindow { get; init; }
|
||||||
|
|
||||||
public Plugin(
|
public Plugin()
|
||||||
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface,
|
|
||||||
[RequiredVersion("1.0")] ICommandManager commandManager,
|
|
||||||
[RequiredVersion("1.0")] IPluginLog log
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
this.pluginInterface = pluginInterface;
|
|
||||||
this.commandManager = commandManager;
|
|
||||||
|
|
||||||
var pluginList = pluginInterface.InstalledPlugins;
|
var pluginList = pluginInterface.InstalledPlugins;
|
||||||
foreach (var command in commandManager.Commands)
|
foreach (var command in commandManager.Commands)
|
||||||
{
|
{
|
||||||
log.Information($"{command}");
|
log.Information($"{command.Key} -> {command.Value.Handler.Method}");
|
||||||
}
|
}
|
||||||
|
|
||||||
configuration =
|
configuration =
|
||||||
pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
pluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
||||||
configuration.Initialize(this.pluginInterface);
|
configuration.Initialize(pluginInterface);
|
||||||
|
|
||||||
// you might normally want to embed resources and load them from the manifest stream
|
// you might normally want to embed resources and load them from the manifest stream
|
||||||
var imagePath = Path.Combine(
|
var imagePath = Path.Combine(
|
||||||
this.pluginInterface.AssemblyLocation.Directory?.FullName!,
|
pluginInterface.AssemblyLocation.Directory?.FullName!,
|
||||||
"goat.png"
|
"goat.png"
|
||||||
);
|
);
|
||||||
var goatImage = this.pluginInterface.UiBuilder.LoadImage(imagePath);
|
var goatImage = pluginInterface.UiBuilder.LoadImage(imagePath);
|
||||||
|
|
||||||
ConfigWindow = new ConfigWindow(this);
|
ConfigWindow = new ConfigWindow(this);
|
||||||
MainWindow = new MainWindow(this, goatImage);
|
MainWindow = new MainWindow(this, goatImage);
|
||||||
|
@ -55,7 +53,7 @@ namespace CommandReference
|
||||||
windowSystem.AddWindow(ConfigWindow);
|
windowSystem.AddWindow(ConfigWindow);
|
||||||
windowSystem.AddWindow(MainWindow);
|
windowSystem.AddWindow(MainWindow);
|
||||||
|
|
||||||
_ = this.commandManager.AddHandler(
|
_ = commandManager.AddHandler(
|
||||||
CommandName,
|
CommandName,
|
||||||
new CommandInfo(OnCommand)
|
new CommandInfo(OnCommand)
|
||||||
{
|
{
|
||||||
|
@ -63,8 +61,8 @@ namespace CommandReference
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
this.pluginInterface.UiBuilder.Draw += DrawUI;
|
pluginInterface.UiBuilder.Draw += DrawUI;
|
||||||
this.pluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
|
pluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
|
Loading…
Reference in a new issue