2020-08-01 07:43:23 +00:00
|
|
|
|
using Dalamud.Game.Command;
|
|
|
|
|
using Dalamud.Plugin;
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Globetrotter {
|
|
|
|
|
public class GlobetrotterPlugin : IDalamudPlugin {
|
2021-03-19 20:06:45 +00:00
|
|
|
|
private bool _disposedValue;
|
2020-08-01 07:43:23 +00:00
|
|
|
|
|
|
|
|
|
public string Name => "Globetrotter";
|
|
|
|
|
|
2021-03-19 20:06:45 +00:00
|
|
|
|
private DalamudPluginInterface _pi = null!;
|
|
|
|
|
private Configuration _config = null!;
|
|
|
|
|
private PluginUi _ui = null!;
|
|
|
|
|
private TreasureMaps _maps = null!;
|
2020-08-01 07:43:23 +00:00
|
|
|
|
|
|
|
|
|
public void Initialize(DalamudPluginInterface pluginInterface) {
|
2021-03-19 20:06:45 +00:00
|
|
|
|
this._pi = pluginInterface ?? throw new ArgumentNullException(nameof(pluginInterface), "DalamudPluginInterface cannot be null");
|
2020-08-01 07:43:23 +00:00
|
|
|
|
|
2021-03-19 20:06:45 +00:00
|
|
|
|
this._config = this._pi.GetPluginConfig() as Configuration ?? new Configuration();
|
|
|
|
|
this._config.Initialize(this._pi);
|
2020-08-01 07:43:23 +00:00
|
|
|
|
|
2021-03-19 20:06:45 +00:00
|
|
|
|
this._ui = new PluginUi(this._config);
|
|
|
|
|
this._maps = new TreasureMaps(this._pi, this._config);
|
|
|
|
|
|
|
|
|
|
this._pi.UiBuilder.OnBuildUi += this._ui.Draw;
|
|
|
|
|
this._pi.UiBuilder.OnOpenConfigUi += this._ui.OpenSettings;
|
|
|
|
|
this._pi.Framework.Gui.HoveredItemChanged += this._maps.OnHover;
|
|
|
|
|
this._pi.CommandManager.AddHandler("/pglobetrotter", new CommandInfo(this.OnConfigCommand) {
|
|
|
|
|
HelpMessage = "Show the Globetrotter config",
|
2020-08-01 07:43:23 +00:00
|
|
|
|
});
|
2021-03-19 20:06:45 +00:00
|
|
|
|
this._pi.CommandManager.AddHandler("/tmap", new CommandInfo(this.OnCommand) {
|
|
|
|
|
HelpMessage = "Open the map and place a flag at the location of your current treasure map",
|
2020-08-01 07:43:23 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnConfigCommand(string command, string args) {
|
2021-03-19 20:06:45 +00:00
|
|
|
|
this._ui.OpenSettings(null, null);
|
2020-08-01 07:43:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCommand(string command, string args) {
|
2021-03-19 20:06:45 +00:00
|
|
|
|
this._maps.OpenMapLocation();
|
2020-08-01 07:43:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected virtual void Dispose(bool disposing) {
|
2021-03-19 20:06:45 +00:00
|
|
|
|
if (this._disposedValue) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-08-01 07:43:23 +00:00
|
|
|
|
|
2021-03-19 20:06:45 +00:00
|
|
|
|
if (disposing) {
|
|
|
|
|
this._pi.UiBuilder.OnBuildUi -= this._ui.Draw;
|
|
|
|
|
this._pi.UiBuilder.OnOpenConfigUi -= this._ui.OpenSettings;
|
|
|
|
|
this._pi.Framework.Gui.HoveredItemChanged -= this._maps.OnHover;
|
|
|
|
|
this._maps.Dispose();
|
|
|
|
|
this._pi.CommandManager.RemoveHandler("/pglobetrotter");
|
|
|
|
|
this._pi.CommandManager.RemoveHandler("/tmap");
|
2020-08-01 07:43:23 +00:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-19 20:06:45 +00:00
|
|
|
|
this._disposedValue = true;
|
|
|
|
|
}
|
2020-08-01 07:43:23 +00:00
|
|
|
|
|
|
|
|
|
public void Dispose() {
|
|
|
|
|
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
2021-03-19 20:06:45 +00:00
|
|
|
|
this.Dispose(true);
|
2020-08-01 07:43:23 +00:00
|
|
|
|
GC.SuppressFinalize(this);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|