2020-04-28 20:21:51 +00:00
|
|
|
|
using Dalamud.Game.Command;
|
2021-08-26 14:11:18 +00:00
|
|
|
|
using Dalamud.IoC;
|
2020-04-28 20:21:51 +00:00
|
|
|
|
using Dalamud.Plugin;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
2021-12-11 13:27:58 +00:00
|
|
|
|
namespace CurrencyAlert
|
2020-04-28 20:21:51 +00:00
|
|
|
|
{
|
2021-08-26 14:11:18 +00:00
|
|
|
|
public sealed class Plugin : IDalamudPlugin
|
2020-04-28 20:21:51 +00:00
|
|
|
|
{
|
2021-12-11 11:02:01 +00:00
|
|
|
|
public string Name => "Currency Alert";
|
2020-04-28 20:21:51 +00:00
|
|
|
|
|
2021-12-11 11:02:01 +00:00
|
|
|
|
private const string commandName = "/currencyalert";
|
2020-04-28 20:21:51 +00:00
|
|
|
|
|
2021-08-26 14:11:18 +00:00
|
|
|
|
private DalamudPluginInterface PluginInterface { get; init; }
|
|
|
|
|
private CommandManager CommandManager { get; init; }
|
|
|
|
|
private Configuration Configuration { get; init; }
|
|
|
|
|
private PluginUI PluginUi { get; init; }
|
2020-04-28 20:21:51 +00:00
|
|
|
|
|
2021-08-26 14:11:18 +00:00
|
|
|
|
public Plugin(
|
|
|
|
|
[RequiredVersion("1.0")] DalamudPluginInterface pluginInterface,
|
|
|
|
|
[RequiredVersion("1.0")] CommandManager commandManager)
|
2020-04-28 20:21:51 +00:00
|
|
|
|
{
|
2021-08-26 14:11:18 +00:00
|
|
|
|
this.PluginInterface = pluginInterface;
|
|
|
|
|
this.CommandManager = commandManager;
|
|
|
|
|
|
|
|
|
|
this.Configuration = this.PluginInterface.GetPluginConfig() as Configuration ?? new Configuration();
|
|
|
|
|
this.Configuration.Initialize(this.PluginInterface);
|
2020-04-28 20:21:51 +00:00
|
|
|
|
|
|
|
|
|
// you might normally want to embed resources and load them from the manifest stream
|
2021-08-26 14:11:18 +00:00
|
|
|
|
var assemblyLocation = Assembly.GetExecutingAssembly().Location;
|
2021-12-11 11:02:01 +00:00
|
|
|
|
this.PluginUi = new PluginUI(this.Configuration);
|
2020-04-28 20:21:51 +00:00
|
|
|
|
|
2021-08-26 14:11:18 +00:00
|
|
|
|
this.CommandManager.AddHandler(commandName, new CommandInfo(OnCommand)
|
2020-04-28 20:21:51 +00:00
|
|
|
|
{
|
|
|
|
|
HelpMessage = "A useful message to display in /xlhelp"
|
|
|
|
|
});
|
|
|
|
|
|
2021-08-26 14:11:18 +00:00
|
|
|
|
this.PluginInterface.UiBuilder.Draw += DrawUI;
|
|
|
|
|
this.PluginInterface.UiBuilder.OpenConfigUi += DrawConfigUI;
|
2020-04-28 20:21:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose()
|
|
|
|
|
{
|
2021-08-26 14:11:18 +00:00
|
|
|
|
this.PluginUi.Dispose();
|
|
|
|
|
this.CommandManager.RemoveHandler(commandName);
|
2020-04-28 20:21:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCommand(string command, string args)
|
|
|
|
|
{
|
2021-12-11 13:27:58 +00:00
|
|
|
|
this.DrawConfigUI();
|
2020-04-28 20:21:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawUI()
|
|
|
|
|
{
|
2021-08-26 14:11:18 +00:00
|
|
|
|
this.PluginUi.Draw();
|
2020-04-28 20:21:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void DrawConfigUI()
|
|
|
|
|
{
|
2021-08-26 14:11:18 +00:00
|
|
|
|
this.PluginUi.SettingsVisible = true;
|
2020-04-28 20:21:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|