From 7a9f2e658bc8d602aa12ed438ca1ad3cc79fa260 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tekkub=20=3Abear=3A=E2=80=82?= Date: Mon, 26 Jan 2015 02:26:17 -0700 Subject: [PATCH] Grey out known heirlooms on 6.1 --- GnomishVendorShrinker.lua | 16 ++++++++++------ GnomishVendorShrinker.toc | 3 +++ KnownScanner.lua | 10 ++++++++++ externals.txt | 2 ++ externals/itemid.lua | 20 ++++++++++++++++++++ externals/ptr.lua | 4 ++++ 6 files changed, 49 insertions(+), 6 deletions(-) create mode 100644 externals.txt create mode 100644 externals/itemid.lua create mode 100644 externals/ptr.lua diff --git a/GnomishVendorShrinker.lua b/GnomishVendorShrinker.lua index 1f5b34a..12819b9 100644 --- a/GnomishVendorShrinker.lua +++ b/GnomishVendorShrinker.lua @@ -246,13 +246,22 @@ local function ShowMerchantItem(row, i) local link = GetMerchantItemLink(i) local color = quality_colors.default row.backdrop:Hide() + + if not isUsable then + row.backdrop:SetGradientAlpha("HORIZONTAL", unpack(grads.red)) + row.backdrop:Show() + end + if link then local name, link2, quality, iLevel, reqLevel, class, subclass, maxStack, equipSlot, texture, vendorPrice = GetItemInfo(link) + local id = ns.ids[link] + local is_heirloom = ns.is_six_one and C_Heirloom.IsItemHeirloom(id) color = quality_colors[quality] - if class == RECIPE or texture:lower():match(GARRISON_ICON) then + if is_heirloom or class == RECIPE or texture:lower():match(GARRISON_ICON) then if ns.knowns[link] then color = quality_colors[0] + row.backdrop:Hide() else row.backdrop:SetGradientAlpha("HORIZONTAL", unpack(grads[quality])) row.backdrop:Show() @@ -260,11 +269,6 @@ local function ShowMerchantItem(row, i) end end - if not isUsable then - row.backdrop:SetGradientAlpha("HORIZONTAL", unpack(grads.red)) - row.backdrop:Show() - end - row.icon:SetTexture(itemTexture) row.ItemName:SetText((numAvailable > -1 and ("["..numAvailable.."] ") or "").. color.. (name or "").. (itemStackCount > 1 and ("|r x"..itemStackCount) or "")) diff --git a/GnomishVendorShrinker.toc b/GnomishVendorShrinker.toc index 26846f4..2adf039 100644 --- a/GnomishVendorShrinker.toc +++ b/GnomishVendorShrinker.toc @@ -13,6 +13,9 @@ ## X-LoadOn-Merchant: true ## X-LoadOn-InterfaceOptions: GnomishVendorShrinker +externals\itemid.lua +externals\ptr.lua + tekFunks\gsc.lua tekKonfig\tekKonfig.xml LibItemSearch-1.0.lua diff --git a/KnownScanner.lua b/KnownScanner.lua index 552ecf4..93eed87 100644 --- a/KnownScanner.lua +++ b/KnownScanner.lua @@ -11,6 +11,16 @@ for i=1,40 do end ns.knowns = setmetatable({}, {__index = function(t, i) + if ns.is_six_one then + local id = ns.ids[i] + if not id then return end + + if C_Heirloom.IsItemHeirloom(id) and C_Heirloom.PlayerHasHeirloom(id) then + t[i] = true + return true + end + end + tip:ClearLines() if not tip:IsOwned(WorldFrame) then tip:SetOwner(WorldFrame, "ANCHOR_NONE") end tip:SetHyperlink(i) diff --git a/externals.txt b/externals.txt new file mode 100644 index 0000000..e30a551 --- /dev/null +++ b/externals.txt @@ -0,0 +1,2 @@ +itemid.lua +ptr.lua diff --git a/externals/itemid.lua b/externals/itemid.lua new file mode 100644 index 0000000..f916e03 --- /dev/null +++ b/externals/itemid.lua @@ -0,0 +1,20 @@ + +local myname, ns = ... + + +-- Creates a memoizing table that converts an itemlink string into an itemID int +ns.ids = setmetatable({}, { + __index = function(t,i) + if type(i) == "number" then + t[i] = i + return i + elseif type(i) ~= "string" then + t[i] = false + return + end + + local id = tonumber(i:match("item:(%d+)")) + t[i] = id + return id + end, +}) diff --git a/externals/ptr.lua b/externals/ptr.lua new file mode 100644 index 0000000..06a215d --- /dev/null +++ b/externals/ptr.lua @@ -0,0 +1,4 @@ + +local myname, ns = ... + +ns.is_six_one = GetBuildInfo() == "6.1.0"