Integrate Allagan Tools for item info in UI
Added AT interop to check plugin availability and trigger `/moreinfo` command for selected items. UI now displays a button next to each item category label to open more information via AT, with tooltips and error handling if AT is not installed. Initialization for AT interop added to plugin startup.
This commit is contained in:
60
GlamourBrowser/Interop/AT.cs
Normal file
60
GlamourBrowser/Interop/AT.cs
Normal file
@@ -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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -22,6 +22,7 @@ namespace GlamourBrowser {
|
|||||||
this.Commands = new Commands(this);
|
this.Commands = new Commands(this);
|
||||||
|
|
||||||
Interop.Glamourer.Initialize(Service.Interface);
|
Interop.Glamourer.Initialize(Service.Interface);
|
||||||
|
Interop.AT.Initialize(Service.CommandManager, Service.Interface, Service.ChatGui);
|
||||||
Service.Framework.Update += OnFrameworkUpdate;
|
Service.Framework.Update += OnFrameworkUpdate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -230,6 +230,19 @@ namespace GlamourBrowser.Ui {
|
|||||||
|
|
||||||
ImGui.TextUnformatted(label);
|
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 drawCursor = ImGui.GetCursorScreenPos();
|
||||||
var slotSize = SelectedGearIconSize + SelectedGearPaddingSize;
|
var slotSize = SelectedGearIconSize + SelectedGearPaddingSize;
|
||||||
var borderColour = *ImGui.GetStyleColorVec4(ImGuiCol.Border);
|
var borderColour = *ImGui.GetStyleColorVec4(ImGuiCol.Border);
|
||||||
@@ -274,6 +287,7 @@ namespace GlamourBrowser.Ui {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ImGui.PopItemWidth();
|
ImGui.PopItemWidth();
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
ImGui.SetCursorPos(cursorAfter);
|
ImGui.SetCursorPos(cursorAfter);
|
||||||
ImGui.TextUnformatted("(empty)");
|
ImGui.TextUnformatted("(empty)");
|
||||||
|
|||||||
Reference in New Issue
Block a user