2021-01-16 01:12:46 +00:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Dalamud.Game.Command;
|
|
|
|
|
|
|
|
|
|
namespace BetterPartyFinder {
|
|
|
|
|
public class Commands : IDisposable {
|
|
|
|
|
private static readonly Dictionary<string, string> CommandNames = new() {
|
|
|
|
|
["/betterpartyfinder"] = "Opens the main interface. Use with args \"c\" or \"config\" to open the settings.",
|
|
|
|
|
["/bpf"] = "Alias for /betterpartyfinder",
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
private Plugin Plugin { get; }
|
|
|
|
|
|
|
|
|
|
internal Commands(Plugin plugin) {
|
|
|
|
|
this.Plugin = plugin;
|
|
|
|
|
|
2021-08-24 18:00:42 +00:00
|
|
|
|
foreach (var (name, help) in CommandNames) {
|
|
|
|
|
this.Plugin.CommandManager.AddHandler(name, new CommandInfo(this.OnCommand) {
|
|
|
|
|
HelpMessage = help,
|
2021-01-16 01:12:46 +00:00
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Dispose() {
|
|
|
|
|
foreach (var name in CommandNames.Keys) {
|
2021-08-24 18:00:42 +00:00
|
|
|
|
this.Plugin.CommandManager.RemoveHandler(name);
|
2021-01-16 01:12:46 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void OnCommand(string command, string args) {
|
2021-05-02 03:06:28 +00:00
|
|
|
|
if (args is "c" or "config") {
|
2021-01-16 01:12:46 +00:00
|
|
|
|
this.Plugin.Ui.SettingsVisible = !this.Plugin.Ui.SettingsVisible;
|
|
|
|
|
} else {
|
|
|
|
|
this.Plugin.Ui.Visible = !this.Plugin.Ui.Visible;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|