919b72051f
Co-authored-by: Cursor <cursoragent@cursor.com>
63 lines
2.1 KiB
C#
63 lines
2.1 KiB
C#
using System;
|
|
using Dalamud.Game.Command;
|
|
using Dalamud.Interface.Windowing;
|
|
using Dalamud.Plugin;
|
|
using Dalamud.Plugin.Services;
|
|
|
|
namespace MSQProgress;
|
|
|
|
public sealed class MSQProgressPlugin : IDalamudPlugin
|
|
{
|
|
private const string Command = "/msqprogress";
|
|
private readonly WindowSystem _windowSystem;
|
|
private readonly ProgressWindow _progressWindow;
|
|
|
|
public MSQProgressPlugin(IDalamudPluginInterface pluginInterface)
|
|
{
|
|
pluginInterface.Create<Service>();
|
|
_progressWindow = new ProgressWindow();
|
|
_windowSystem = new WindowSystem("MSQProgress");
|
|
_windowSystem.AddWindow(_progressWindow);
|
|
|
|
pluginInterface.UiBuilder.OpenConfigUi += OnOpenConfigUi;
|
|
pluginInterface.UiBuilder.Draw += _windowSystem.Draw;
|
|
|
|
Service.CommandManager.AddHandler(Command, new CommandInfo(OnCommand)
|
|
{
|
|
HelpMessage = "Open MSQ Progress. Use 'exportdutyunlock' to export CFC→UnlockQuest map to DutyUnlockData.json.",
|
|
ShowInHelp = true,
|
|
});
|
|
}
|
|
|
|
public string Name => "MSQ Progress";
|
|
|
|
public void Dispose()
|
|
{
|
|
Service.CommandManager.RemoveHandler(Command);
|
|
Service.Interface.UiBuilder.OpenConfigUi -= OnOpenConfigUi;
|
|
Service.Interface.UiBuilder.Draw -= _windowSystem.Draw;
|
|
}
|
|
|
|
private void OnOpenConfigUi() => _progressWindow.Toggle();
|
|
|
|
private void OnCommand(string command, string args)
|
|
{
|
|
if (string.Equals(args.Trim(), "exportdutyunlock", StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
OnExportDutyUnlock(command, args);
|
|
return;
|
|
}
|
|
_progressWindow.Toggle();
|
|
}
|
|
|
|
private void OnExportDutyUnlock(string command, string args)
|
|
{
|
|
var path = System.IO.Path.Combine(Service.Interface.AssemblyLocation.DirectoryName ?? "", "DutyUnlockData.json");
|
|
var result = DutyUnlockMap.ExportToJsonFile(Service.DataManager, path);
|
|
if (result != null)
|
|
Service.PluginLog.Info($"Exported duty unlock map to {result}");
|
|
else
|
|
Service.PluginLog.Warning("Export failed or map empty.");
|
|
}
|
|
}
|