From ac5248f9b7a838a4f65d9d375e3bc0ccd322394e Mon Sep 17 00:00:00 2001 From: Ade <923+ade@noreply.octowow.st> Date: Fri, 30 Oct 2026 06:34:25 +0000 Subject: [PATCH] =?UTF-8?q?=D0=97=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=B8?= =?UTF-8?q?=D1=82=D1=8C=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20=D0=B2=20=C2=AB?= =?UTF-8?q?/=C2=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AdeAlts.toc | 2 +- CHANGELOG.md | 3 +++ core.lua | 2 +- tooltip.lua | 73 +++++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 66 insertions(+), 14 deletions(-) diff --git a/AdeAlts.toc b/AdeAlts.toc index 7aaa29a..6521421 100644 --- a/AdeAlts.toc +++ b/AdeAlts.toc @@ -2,7 +2,7 @@ ## Title: Ade Alts ## Notes: Alt manager: cooldowns, inventory, bank, gear, professions and missing recipes of all your characters. /ade ## Author: Ade -## Version: 1.2.3 +## Version: 1.2.4 ## SavedVariables: AdeAltsDB, ProfCDTrackerDB ## OptionalDeps: pfUI, SuperWoW, nampower core.lua diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b33457..fb0a10d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 1.2.4 +- Fixed: recipe items whose name differs from the crafted item (e.g. Pattern: Guardian Bracers -> Guardian Leather Bracers) showed no alt info. Recipes are now identified by item id. + ## 1.2.3 - Guild / party / raid chat sync is now **off by default**; enable it with `/ade chat`. Shared-file sync (SuperWoW) is unaffected. diff --git a/core.lua b/core.lua index 87b1803..54854bb 100644 --- a/core.lua +++ b/core.lua @@ -7,7 +7,7 @@ local AA = AdeAlts -- Command: /pcd Minimap button: auto-docked by pfUI's addon button panel. AA.ADDON = "AdeAlts" -AA.VERSION = "1.2.3" +AA.VERSION = "1.2.4" AA.PREFIX = "PCDT" AA.DAY = 86400 AA.RDATA = {} -- recipe database, filled by the data_*.lua files diff --git a/tooltip.lua b/tooltip.lua index 131158c..f65c0a6 100644 --- a/tooltip.lua +++ b/tooltip.lua @@ -3,19 +3,42 @@ local AA = AdeAlts local PREFIX = { Pattern = 1, Recipe = 1, Plans = 1, Formula = 1, Schematic = 1, Manual = 1, Design = 1, Book = 1, Technique = 1 } +-- finds the craft(s) taught by the item in the tooltip: by item id (from the item link) first, +-- then by the "Teaches you how to craft X" line, finally by the item name +local function FindHits(tt) + local idx = AA.RIndex() + if tt.adeLink then + local _, _, id = string.find(tt.adeLink, "item:(%d+)") + if id and idx.byItem[tonumber(id)] then return idx.byItem[tonumber(id)] end + end + local name = tt:GetName() + local title + for i = 1, tt:NumLines() do + local fs = getglobal(name .. "TextLeft" .. i) + local txt = fs and fs:GetText() + if txt then + if i == 1 then title = txt end + local _, _, id = string.find(txt, "ItemID: (%d+)") + if id and idx.byItem[tonumber(id)] then return idx.byItem[tonumber(id)] end + local _, _, craft = string.find(txt, "Teaches you how to craft (.-)%.?$") + if craft and idx.byAny[string.lower(craft)] then return idx.byAny[string.lower(craft)] end + end + end + if title then + local _, _, pre, nm = string.find(title, "^(%a+): (.+)$") + if pre and PREFIX[pre] and idx.byAny[string.lower(nm)] then return idx.byAny[string.lower(nm)] end + end + return nil +end + function AA.EnhanceTooltip(tt) if not AA.db or not AA.RIndex or tt.adeDone then return end - local l1 = getglobal(tt:GetName() .. "TextLeft1") - local txt = l1 and l1:GetText() - if not txt then return end - local _, _, pre, nm = string.find(txt, "^(%a+): (.+)$") - if not pre or not PREFIX[pre] then return end - local hits = AA.RIndex().byAny[string.lower(nm)] + local hits = FindHits(tt) if not hits then return end tt.adeDone = true - local key = string.lower(nm) local added = false for _, h in ipairs(hits) do + local key = string.lower(h.c[2]) for _, k in ipairs(AA.SortedAlts()) do local ch = AA.db.chars[k] local p = ch and ch.prof and ch.prof[h.prof] @@ -49,16 +72,42 @@ function AA.EnhanceTooltip(tt) if added then tt:Show() end end +-- tooltip functions that show an item: remember the item link, then add our lines +local GETTERS = { + SetBagItem = function(a, b) return GetContainerItemLink(a, b) end, + SetInventoryItem = function(a, b) return GetInventoryItemLink(a, b) end, + SetHyperlink = function(a) return a end, + SetLootItem = function(a) return GetLootSlotLink(a) end, + SetMerchantItem = function(a) return GetMerchantItemLink(a) end, + SetAuctionItem = function(a, b) return GetAuctionItemLink(a, b) end, + SetQuestItem = function(a, b) return GetQuestItemLink(a, b) end, + SetQuestLogItem = function(a, b) return GetQuestLogItemLink(a, b) end, + SetTradePlayerItem = function(a) return GetTradePlayerItemLink(a) end, + SetTradeTargetItem = function(a) return GetTradeTargetItemLink(a) end, + SetInboxItem = function(a) return GetInboxItemLink and GetInboxItemLink(a, 1) end, + SetTradeSkillItem = function(a, b) return GetTradeSkillItemLink and GetTradeSkillItemLink(a) end, +} + local function Hook(tt) if not tt then return end - local oldShow = tt:GetScript("OnShow") - tt:SetScript("OnShow", function() - if oldShow then oldShow() end - AA.EnhanceTooltip(this) - end) + for fname, getter in pairs(GETTERS) do + local orig = tt[fname] + if orig then + tt[fname] = function(self, a, b, c, d) + local r1, r2, r3 = orig(self, a, b, c, d) + self.adeDone = nil + local ok, link = pcall(getter, a, b) + self.adeLink = ok and link or nil + AA.EnhanceTooltip(self) + return r1, r2, r3 + end + end + end + -- forget the item when the tooltip closes local oldHide = tt:GetScript("OnHide") tt:SetScript("OnHide", function() this.adeDone = nil + this.adeLink = nil if oldHide then oldHide() end end) end