f72031ae60
Co-authored-by: Cursor <cursoragent@cursor.com>
69 lines
2.4 KiB
C#
69 lines
2.4 KiB
C#
using System;
|
|
using Dalamud.Game.Command;
|
|
using Dalamud.Interface.Windowing;
|
|
using Dalamud.Plugin;
|
|
using Dalamud.Plugin.Services;
|
|
|
|
namespace ConfigurableCombo;
|
|
|
|
public sealed class ConfigurableComboPlugin : IDalamudPlugin
|
|
{
|
|
private const string Command = "/ccombo";
|
|
private readonly WindowSystem _windowSystem;
|
|
private readonly ConfigWindow _configWindow;
|
|
|
|
public ConfigurableComboPlugin(
|
|
IDalamudPluginInterface pluginInterface,
|
|
ISigScanner sigScanner,
|
|
IGameInteropProvider gameInteropProvider)
|
|
{
|
|
pluginInterface.Create<Service>();
|
|
|
|
Service.Configuration = pluginInterface.GetPluginConfig() as PluginConfiguration ?? new PluginConfiguration();
|
|
Service.Address = new PluginAddressResolver();
|
|
Service.Address.Setup(sigScanner);
|
|
Service.IconReplacer = new IconReplacer(gameInteropProvider);
|
|
|
|
_configWindow = new ConfigWindow();
|
|
_windowSystem = new WindowSystem("ConfigurableCombo");
|
|
_windowSystem.AddWindow(_configWindow);
|
|
|
|
pluginInterface.UiBuilder.OpenConfigUi += OnOpenConfigUi;
|
|
pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
|
|
|
|
Service.CommandManager.AddHandler(Command, new CommandInfo(OnCommand)
|
|
{
|
|
HelpMessage = "Open ConfigurableCombo settings. Use '/ccombo debug' to toggle debug logging (for support).",
|
|
ShowInHelp = true,
|
|
});
|
|
}
|
|
|
|
public string Name => "ConfigurableCombo";
|
|
|
|
public void Dispose()
|
|
{
|
|
Service.CommandManager.RemoveHandler(Command);
|
|
Service.Interface.UiBuilder.OpenConfigUi -= OnOpenConfigUi;
|
|
Service.Interface.UiBuilder.Draw -= _windowSystem.Draw;
|
|
Service.IconReplacer?.Dispose();
|
|
}
|
|
|
|
private void OnOpenConfigUi() => _configWindow.Toggle();
|
|
|
|
private void OnCommand(string command, string args)
|
|
{
|
|
var arg = args.Trim();
|
|
if (arg.Equals("debug", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
Service.Configuration.EnableDebugLogging = !Service.Configuration.EnableDebugLogging;
|
|
Service.Configuration.Save();
|
|
Service.ChatGui.Print(
|
|
$"ConfigurableCombo: Debug logging is now {(Service.Configuration.EnableDebugLogging ? "ON" : "OFF")}. Check the plugin log (Dalamud → Log) when reporting issues.",
|
|
"ConfigurableCombo");
|
|
return;
|
|
}
|
|
|
|
_configWindow.Toggle();
|
|
}
|
|
}
|