fix: handle key items and collectibles
This commit is contained in:
parent
da1d8e7236
commit
6f71ac920a
|
@ -11,6 +11,8 @@ using Dalamud.Logging;
|
||||||
using Dalamud.Utility;
|
using Dalamud.Utility;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using ImGuiScene;
|
using ImGuiScene;
|
||||||
|
using Lumina.Excel.GeneratedSheets;
|
||||||
|
using Action = System.Action;
|
||||||
|
|
||||||
namespace ChatTwo;
|
namespace ChatTwo;
|
||||||
|
|
||||||
|
@ -95,11 +97,11 @@ internal sealed class PayloadHandler {
|
||||||
}
|
}
|
||||||
case ItemPayload item: {
|
case ItemPayload item: {
|
||||||
if (this.Ui.Plugin.Config.NativeItemTooltips) {
|
if (this.Ui.Plugin.Config.NativeItemTooltips) {
|
||||||
GameFunctions.GameFunctions.OpenItemTooltip(item.ItemId);
|
GameFunctions.GameFunctions.OpenItemTooltip(item.RawItemId);
|
||||||
|
|
||||||
this._handleTooltips = true;
|
this._handleTooltips = true;
|
||||||
if (this._hoveredItem != item.ItemId) {
|
if (this._hoveredItem != item.RawItemId) {
|
||||||
this._hoveredItem = item.ItemId;
|
this._hoveredItem = item.RawItemId;
|
||||||
this._hoverCounter = this._lastHoverCounter = 0;
|
this._hoverCounter = this._lastHoverCounter = 0;
|
||||||
} else {
|
} else {
|
||||||
this._lastHoverCounter = this._hoverCounter;
|
this._lastHoverCounter = this._hoverCounter;
|
||||||
|
@ -235,27 +237,37 @@ internal sealed class PayloadHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DrawItemPopup(ItemPayload item) {
|
private void DrawItemPopup(ItemPayload payload) {
|
||||||
if (item.Item == null) {
|
if (payload.Kind == ItemPayload.ItemKind.EventItem) {
|
||||||
|
this.DrawEventItemPopup(payload);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.Ui.Plugin.TextureCache.GetItem(item.Item, item.IsHQ) is { } icon) {
|
var item = this.Ui.Plugin.DataManager.GetExcelSheet<Item>()?.GetRow(payload.ItemId);
|
||||||
|
if (item == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hq = payload.Kind == ItemPayload.ItemKind.Hq;
|
||||||
|
|
||||||
|
if (this.Ui.Plugin.TextureCache.GetItem(item, hq) is { } icon) {
|
||||||
InlineIcon(icon);
|
InlineIcon(icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
var name = item.Item.Name.ToDalamudString();
|
var name = item.Name.ToDalamudString();
|
||||||
if (item.IsHQ) {
|
if (hq) {
|
||||||
// hq symbol
|
// hq symbol
|
||||||
name.Payloads.Add(new TextPayload(" "));
|
name.Payloads.Add(new TextPayload(" "));
|
||||||
|
} else if (payload.Kind == ItemPayload.ItemKind.Collectible) {
|
||||||
|
name.Payloads.Add(new TextPayload(" "));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.Log.DrawChunks(ChunkUtil.ToChunks(name, null).ToList(), false);
|
this.Log.DrawChunks(ChunkUtil.ToChunks(name, null).ToList(), false);
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
|
|
||||||
var realItemId = (uint) (item.ItemId + (item.IsHQ ? GameFunctions.GameFunctions.HqItemOffset : 0));
|
var realItemId = payload.RawItemId;
|
||||||
|
|
||||||
if (item.Item.EquipSlotCategory.Row != 0) {
|
if (item.EquipSlotCategory.Row != 0) {
|
||||||
if (ImGui.Selectable("Try On")) {
|
if (ImGui.Selectable("Try On")) {
|
||||||
this.Ui.Plugin.Functions.Context.TryOn(realItemId, 0);
|
this.Ui.Plugin.Functions.Context.TryOn(realItemId, 0);
|
||||||
}
|
}
|
||||||
|
@ -265,9 +277,9 @@ internal sealed class PayloadHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (item.Item.ItemSearchCategory.Value?.Category == 3) {
|
if (item.ItemSearchCategory.Value?.Category == 3) {
|
||||||
if (ImGui.Selectable("Search Recipes Using This Material")) {
|
if (ImGui.Selectable("Search Recipes Using This Material")) {
|
||||||
this.Ui.Plugin.Functions.Context.SearchForRecipesUsingItem(item.ItemId);
|
this.Ui.Plugin.Functions.Context.SearchForRecipesUsingItem(payload.ItemId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -284,6 +296,35 @@ internal sealed class PayloadHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void DrawEventItemPopup(ItemPayload payload) {
|
||||||
|
if (payload.Kind != ItemPayload.ItemKind.EventItem) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var item = this.Ui.Plugin.DataManager.GetExcelSheet<EventItem>()?.GetRow(payload.ItemId);
|
||||||
|
if (item == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.Ui.Plugin.TextureCache.GetEventItem(item) is { } icon) {
|
||||||
|
InlineIcon(icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
var name = item.Name.ToDalamudString();
|
||||||
|
this.Log.DrawChunks(ChunkUtil.ToChunks(name, null).ToList(), false);
|
||||||
|
ImGui.Separator();
|
||||||
|
|
||||||
|
var realItemId = payload.RawItemId;
|
||||||
|
|
||||||
|
if (ImGui.Selectable("Link")) {
|
||||||
|
this.Ui.Plugin.Functions.Context.LinkItem(realItemId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ImGui.Selectable("Copy Item Name")) {
|
||||||
|
ImGui.SetClipboardText(name.TextValue);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void DrawPlayerPopup(Chunk chunk, PlayerPayload player) {
|
private void DrawPlayerPopup(Chunk chunk, PlayerPayload player) {
|
||||||
var name = player.PlayerName;
|
var name = player.PlayerName;
|
||||||
if (player.World.IsPublic) {
|
if (player.World.IsPublic) {
|
||||||
|
@ -373,7 +414,7 @@ internal sealed class PayloadHandler {
|
||||||
|
|
||||||
private static string? PopupId(Payload payload) => payload switch {
|
private static string? PopupId(Payload payload) => payload switch {
|
||||||
PlayerPayload player => $"###player-{player.PlayerName}@{player.World}",
|
PlayerPayload player => $"###player-{player.PlayerName}@{player.World}",
|
||||||
ItemPayload item => $"###item-{item.ItemId}{item.IsHQ}",
|
ItemPayload item => $"###item-{item.RawItemId}",
|
||||||
_ => null,
|
_ => null,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,11 @@ internal class TextureCache : IDisposable {
|
||||||
|
|
||||||
private readonly Dictionary<(uint, bool), TextureWrap> _itemIcons = new();
|
private readonly Dictionary<(uint, bool), TextureWrap> _itemIcons = new();
|
||||||
private readonly Dictionary<(uint, bool), TextureWrap> _statusIcons = new();
|
private readonly Dictionary<(uint, bool), TextureWrap> _statusIcons = new();
|
||||||
|
private readonly Dictionary<(uint, bool), TextureWrap> _eventItemIcons = new();
|
||||||
|
|
||||||
internal IReadOnlyDictionary<(uint, bool), TextureWrap> ItemIcons => this._itemIcons;
|
internal IReadOnlyDictionary<(uint, bool), TextureWrap> ItemIcons => this._itemIcons;
|
||||||
internal IReadOnlyDictionary<(uint, bool), TextureWrap> StatusIcons => this._statusIcons;
|
internal IReadOnlyDictionary<(uint, bool), TextureWrap> StatusIcons => this._statusIcons;
|
||||||
|
internal IReadOnlyDictionary<(uint, bool), TextureWrap> EventItemIcons => this._eventItemIcons;
|
||||||
|
|
||||||
internal TextureCache(DataManager data) {
|
internal TextureCache(DataManager data) {
|
||||||
this.Data = data;
|
this.Data = data;
|
||||||
|
@ -47,6 +49,10 @@ internal class TextureCache : IDisposable {
|
||||||
this.AddIcon(this._statusIcons, status.Icon);
|
this.AddIcon(this._statusIcons, status.Icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void AddEventItem(EventItem item) {
|
||||||
|
this.AddIcon(this._eventItemIcons, item.Icon);
|
||||||
|
}
|
||||||
|
|
||||||
internal TextureWrap? GetItem(Item item, bool hq = false) {
|
internal TextureWrap? GetItem(Item item, bool hq = false) {
|
||||||
this.AddItem(item, hq);
|
this.AddItem(item, hq);
|
||||||
this.ItemIcons.TryGetValue((item.Icon, hq), out var icon);
|
this.ItemIcons.TryGetValue((item.Icon, hq), out var icon);
|
||||||
|
@ -58,4 +64,10 @@ internal class TextureCache : IDisposable {
|
||||||
this.StatusIcons.TryGetValue((status.Icon, false), out var icon);
|
this.StatusIcons.TryGetValue((status.Icon, false), out var icon);
|
||||||
return icon;
|
return icon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal TextureWrap? GetEventItem(EventItem item) {
|
||||||
|
this.AddEventItem(item);
|
||||||
|
this.EventItemIcons.TryGetValue((item.Icon, false), out var icon);
|
||||||
|
return icon;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user