diff --git a/GlamourBrowser/Interop/AT.cs b/GlamourBrowser/Interop/AT.cs new file mode 100644 index 0000000..8c9ee9a --- /dev/null +++ b/GlamourBrowser/Interop/AT.cs @@ -0,0 +1,60 @@ +using Dalamud.Plugin; +using Dalamud.Plugin.Ipc; +using Dalamud.Plugin.Services; +using HeightAdjuster.Interop.Glamourer; +using System; +using System.Collections.Generic; + +namespace GlamourBrowser.Interop { + internal class AT { + + private static bool Initialized { get; set; } = false; + private static bool Available { get; set; } = false; + private static ICommandManager _commandManager; + private static IChatGui _chatGui; + + + public static void Initialize(ICommandManager commandManager, IDalamudPluginInterface pluginInterface, IChatGui chatGui) { + if (Initialized) + return; + + _commandManager = commandManager; + _chatGui = chatGui; + + Initialized = true; + + RefreshStatus(pluginInterface); + } + + public static void RefreshStatus(IDalamudPluginInterface pluginInterface) { + var prev = Available; + + Available = false; + + foreach (var plugin in pluginInterface.InstalledPlugins) { + if (plugin.InternalName == "InventoryTools") { + Available = plugin.IsLoaded; + break; + } + } + + if (prev == Available) + return; + } + + + public static void OpenMoreInformationSub(string itemId) { + if (IsAvailable()) { + _commandManager.ProcessCommand("/moreinfo " + itemId); + } else { + _chatGui.PrintError("Allagan Tools was not detected, please install it to get more information about this item."); + } + } + + + public static bool IsAvailable() { + return Available; + } + + } +} diff --git a/GlamourBrowser/Plugin.cs b/GlamourBrowser/Plugin.cs index f6d459c..8bbef13 100644 --- a/GlamourBrowser/Plugin.cs +++ b/GlamourBrowser/Plugin.cs @@ -22,6 +22,7 @@ namespace GlamourBrowser { this.Commands = new Commands(this); Interop.Glamourer.Initialize(Service.Interface); + Interop.AT.Initialize(Service.CommandManager, Service.Interface, Service.ChatGui); Service.Framework.Update += OnFrameworkUpdate; } diff --git a/GlamourBrowser/Ui/MainInterface.cs b/GlamourBrowser/Ui/MainInterface.cs index 5f123d2..4dd9136 100644 --- a/GlamourBrowser/Ui/MainInterface.cs +++ b/GlamourBrowser/Ui/MainInterface.cs @@ -230,6 +230,19 @@ namespace GlamourBrowser.Ui { ImGui.TextUnformatted(label); + ImGui.SameLine(); + ImGui.PushStyleVar(ImGuiStyleVar.FramePadding, new Vector2(2, 2)); + if (ImGui.Button($"?##info-{label}", new Vector2(20, 20))) { + if (selectedItem.HasValue) { + Interop.AT.OpenMoreInformationSub(selectedItem.Value.RowId.ToString()); + } + } + ImGui.PopStyleVar(); + + if (ImGui.IsItemHovered()) { + ImGui.SetTooltip("Click to see item location"); + } + var drawCursor = ImGui.GetCursorScreenPos(); var slotSize = SelectedGearIconSize + SelectedGearPaddingSize; var borderColour = *ImGui.GetStyleColorVec4(ImGuiCol.Border); @@ -274,6 +287,7 @@ namespace GlamourBrowser.Ui { } ImGui.PopItemWidth(); + } else { ImGui.SetCursorPos(cursorAfter); ImGui.TextUnformatted("(empty)");