using System; using Dalamud.Data; using Dalamud.Game; using Dalamud.Game.ClientState; using Dalamud.Game.ClientState.Conditions; using Dalamud.Game.Command; using Dalamud.Game.Gui; using Dalamud.IoC; using Dalamud.Plugin; using HUD_Manager.Configuration; using HUD_Manager.Ui; using Resourcer; using YamlDotNet.Serialization; using YamlDotNet.Serialization.NamingConventions; namespace HUD_Manager { public class Plugin : IDalamudPlugin { public string Name => "HUD Manager"; [PluginService] internal DalamudPluginInterface Interface { get; init; } = null!; [PluginService] internal ClientState ClientState { get; init; } = null!; [PluginService] internal CommandManager CommandManager { get; init; } = null!; [PluginService] internal Condition Condition { get; init; } = null!; [PluginService] internal DataManager DataManager { get; init; } = null!; [PluginService] internal Framework Framework { get; init; } = null!; [PluginService] internal GameGui GameGui { get; init; } = null!; [PluginService] internal SigScanner SigScanner { get; init; } = null!; private Swapper Swapper { get; } private Commands Commands { get; } public Interface Ui { get; } public Hud Hud { get; } public Statuses Statuses { get; } public GameFunctions GameFunctions { get; } public Config Config { get; } public HelpFile Help { get; } public Plugin() { this.Config = Migrator.LoadConfig(this); this.Config.Initialize(this.Interface); this.Config.Save(); var deserializer = new DeserializerBuilder() .WithNamingConvention(UnderscoredNamingConvention.Instance) .Build(); this.Help = deserializer.Deserialize(Resource.AsString("help.yaml")); this.Ui = new Interface(this); this.Hud = new Hud(this); this.Statuses = new Statuses(this); this.GameFunctions = new GameFunctions(this); this.Swapper = new Swapper(this); this.Commands = new Commands(this); if (!this.Config.FirstRun) { return; } this.Config.FirstRun = false; if (this.Config.Layouts.Count == 0) { foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) { this.Hud.ImportSlot($"Auto-import {(int) slot + 1}", slot, false); } } this.Config.Save(); } public void Dispose() { this.Commands.Dispose(); this.Ui.Dispose(); this.Swapper.Dispose(); } } }