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 static string Name => "Sample Plugin";
|
||||
private const string CommandName = "/pmycommand";
|
||||
private const string CommandName = "/commands";
|
||||
|
||||
[PluginService]
|
||||
private DalamudPluginInterface pluginInterface { get; set; } = null!;
|
||||
private ICommandManager commandManager { get; init; }
|
||||
private static DalamudPluginInterface pluginInterface { get; set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
private static ICommandManager commandManager { get; set; } = null!;
|
||||
|
||||
[PluginService]
|
||||
private static IPluginLog log { get; set; } = null!;
|
||||
|
||||
public Configuration configuration { get; init; }
|
||||
internal WindowSystem windowSystem = new("CommandReference");
|
||||
|
||||
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")] IPluginLog log
|
||||
)
|
||||
public Plugin()
|
||||
{
|
||||
this.pluginInterface = pluginInterface;
|
||||
this.commandManager = commandManager;
|
||||
|
||||
var pluginList = pluginInterface.InstalledPlugins;
|
||||
foreach (var command in commandManager.Commands)
|
||||
{
|
||||
log.Information($"{command}");
|
||||
log.Information($"{command.Key} -> {command.Value.Handler.Method}");
|
||||
}
|
||||
|
||||
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
|
||||
var imagePath = Path.Combine(
|
||||
this.pluginInterface.AssemblyLocation.Directory?.FullName!,
|
||||
pluginInterface.AssemblyLocation.Directory?.FullName!,
|
||||
"goat.png"
|
||||
);
|
||||
var goatImage = this.pluginInterface.UiBuilder.LoadImage(imagePath);
|
||||
var goatImage = pluginInterface.UiBuilder.LoadImage(imagePath);
|
||||
|
||||
ConfigWindow = new ConfigWindow(this);
|
||||
MainWindow = new MainWindow(this, goatImage);
|
||||
|
@ -55,7 +53,7 @@ namespace CommandReference
|
|||
windowSystem.AddWindow(ConfigWindow);
|
||||
windowSystem.AddWindow(MainWindow);
|
||||
|
||||
_ = this.commandManager.AddHandler(
|
||||
_ = commandManager.AddHandler(
|
||||
CommandName,
|
||||
new CommandInfo(OnCommand)
|
||||
{
|
||||
|
@ -63,8 +61,8 @@ namespace CommandReference
|
|||
}
|
||||
);
|
||||
|
||||
this.pluginInterface.UiBuilder.Draw += DrawUI;
|
||||
this.pluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
|
||||
pluginInterface.UiBuilder.Draw += DrawUI;
|
||||
pluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
|
|
Loading…
Reference in a new issue