RoleplayersToolbox/RoleplayersToolbox/Plugin.cs

107 lines
3.0 KiB
C#
Raw Permalink Normal View History

2021-05-30 20:22:26 +00:00
using System;
using System.Collections.Generic;
using Dalamud.ContextMenu;
2021-08-24 05:17:42 +00:00
using Dalamud.Data;
using Dalamud.Game;
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.IoC;
2021-05-30 20:22:26 +00:00
using Dalamud.Plugin;
using RoleplayersToolbox.Tools;
using RoleplayersToolbox.Tools.Housing;
using RoleplayersToolbox.Tools.Targeting;
using XivCommon;
#if ILLEGAL
using RoleplayersToolbox.Tools.Illegal.Emote;
using RoleplayersToolbox.Tools.Illegal.EmoteSnap;
#endif
namespace RoleplayersToolbox {
2021-08-24 05:17:42 +00:00
internal class Plugin : IDalamudPlugin {
2021-11-09 23:13:03 +00:00
#if DEBUG
public string Name => "The Roleplayer's Toolbox (Debug)";
#else
2021-08-24 05:17:42 +00:00
public string Name => "The Roleplayer's Toolbox";
2021-11-09 23:13:03 +00:00
#endif
2021-08-24 05:17:42 +00:00
[PluginService]
internal DalamudPluginInterface Interface { get; init; } = null!;
[PluginService]
internal ChatGui ChatGui { get; init; } = null!;
[PluginService]
internal ClientState ClientState { get; init; } = null!;
[PluginService]
internal CommandManager CommandManager { get; init; } = null!;
// [PluginService]
// internal ContextMenu ContextMenu { get; init; } = null!;
internal DalamudContextMenu ContextMenu { get; }
2021-08-24 05:17:42 +00:00
[PluginService]
internal DataManager DataManager { get; init; } = null!;
[PluginService]
internal Framework Framework { get; init; } = null!;
[PluginService]
internal GameGui GameGui { get; init; } = null!;
[PluginService]
internal ObjectTable ObjectTable { get; init; } = null!;
[PluginService]
internal SigScanner SigScanner { get; init; } = null!;
2021-05-30 20:22:26 +00:00
internal Configuration Config { get; }
internal XivCommonBase Common { get; }
internal List<ITool> Tools { get; } = new();
internal PluginUi Ui { get; }
private Commands Commands { get; }
2021-08-24 05:17:42 +00:00
public Plugin() {
2021-05-30 20:22:26 +00:00
this.Config = this.Interface.GetPluginConfig() as Configuration ?? new Configuration();
2022-06-06 20:35:29 +00:00
this.Common = new XivCommonBase(Hooks.PartyFinderListings);
2021-05-30 20:22:26 +00:00
this.ContextMenu = new DalamudContextMenu();
2021-05-30 20:22:26 +00:00
this.Tools.Add(new HousingTool(this));
this.Tools.Add(new TargetingTool(this));
#if ILLEGAL
this.Tools.Add(new EmoteTool(this));
this.Tools.Add(new EmoteSnapTool(this));
#endif
this.Ui = new PluginUi(this);
2021-05-30 20:22:26 +00:00
this.Commands = new Commands(this);
}
public void Dispose() {
this.Commands.Dispose();
this.Ui.Dispose();
foreach (var tool in this.Tools) {
if (tool is IDisposable disposable) {
disposable.Dispose();
}
}
this.Tools.Clear();
this.Common.Dispose();
}
internal void SaveConfig() {
this.Interface.SavePluginConfig(this.Config);
}
}
}