using System; using Dalamud.Game.Command; using Dalamud.Interface.Windowing; using Dalamud.Logging; using Dalamud.Plugin; namespace Dalamud.CorePlugin { /// /// This class is a a plugin testbed for developing new Dalamud features with easy access to Dalamud itself. /// Be careful to not commit anything extra. /// public sealed class PluginImpl : IDalamudPlugin { private readonly WindowSystem windowSystem = new("Dalamud.CorePlugin"); // private Localization localizationManager; /// /// Initializes a new instance of the class. /// /// Dalamud plugin interface. public PluginImpl(DalamudPluginInterface pluginInterface) { try { // this.InitLoc(); this.Interface = pluginInterface; this.windowSystem.AddWindow(new PluginWindow()); this.Interface.UiBuilder.Draw += this.OnDraw; this.Interface.UiBuilder.OpenConfigUi += this.OnOpenConfigUi; Service.Get().AddHandler("/di", new(this.OnCommand) { HelpMessage = $"Access the {this.Name} plugin." }); } catch (Exception ex) { PluginLog.Error(ex, "kaboom"); } } /// public string Name => "Dalamud.CorePlugin"; /// /// Gets the plugin interface. /// internal DalamudPluginInterface Interface { get; private set; } /// public void Dispose() { Service.Get().RemoveHandler("/di"); this.Interface.UiBuilder.Draw -= this.OnDraw; this.windowSystem.RemoveAllWindows(); this.Interface.Dispose(); } // private void InitLoc() // { // // CheapLoc needs to be reinitialized here because it tracks the setup by assembly name. New assembly, new setup. // this.localizationManager = new Localization(Path.Combine(Dalamud.Instance.AssetDirectory.FullName, "UIRes", "loc", "dalamud"), "dalamud_"); // if (!string.IsNullOrEmpty(Dalamud.Instance.Configuration.LanguageOverride)) // { // this.localizationManager.SetupWithLangCode(Dalamud.Instance.Configuration.LanguageOverride); // } // else // { // this.localizationManager.SetupWithUiCulture(); // } // } /// /// Draw the window system. /// private void OnDraw() { try { this.windowSystem.Draw(); } catch (Exception ex) { PluginLog.Error(ex, "Boom"); } } private void OnCommand(string command, string args) { // this.window.IsOpen = true; } private void OnOpenConfigUi(object sender, EventArgs e) { // this.window.IsOpen = true; } } }