From ea530ec4daa2f3196cec80a3439d0c22876fa124 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?tekkub=20=CA=95=20=C2=B4=E1=B4=A5=60=20=CA=94?= Date: Tue, 6 Sep 2016 19:59:59 -0600 Subject: [PATCH] Red-out lines for recipes that require a rank we don't have yet --- GnomishVendorShrinker.lua | 10 ++++++++++ KnownScanner.lua | 24 ++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/GnomishVendorShrinker.lua b/GnomishVendorShrinker.lua index 071fe57..5dd2419 100644 --- a/GnomishVendorShrinker.lua +++ b/GnomishVendorShrinker.lua @@ -240,6 +240,13 @@ local function Knowable(link) end +local function RecipeNeedsRank(link) + local _, _, _, _, _, class = GetItemInfo(link) + if class ~= RECIPE then return end + return ns.unmet_requirements[link] +end + + local default_grad = {0,1,0,0.75, 0,1,0,0} -- green local grads = setmetatable({ red = {1,0,0,0.75, 1,0,0,0}, @@ -273,6 +280,9 @@ local function ShowMerchantItem(row, i) if ns.knowns[link] then color = quality_colors[0] row.backdrop:Hide() + elseif RecipeNeedsRank(link) then + row.backdrop:SetGradientAlpha("HORIZONTAL", unpack(grads.red)) + row.backdrop:Show() else row.backdrop:SetGradientAlpha("HORIZONTAL", unpack(grads[quality])) row.backdrop:Show() diff --git a/KnownScanner.lua b/KnownScanner.lua index 7d25df1..fc86520 100644 --- a/KnownScanner.lua +++ b/KnownScanner.lua @@ -26,3 +26,27 @@ ns.knowns = setmetatable({}, { end end }) + + +-- "Requires Previous Rank" +local PREV_RANK = TOOLTIP_SUPERCEDING_SPELL_NOT_KNOWN +local function NeedsRank(link) + ns.scantip:SetHyperlink(link) + for i=1,ns.scantip:NumLines() do + print(ns.scantip.L[i], ns.scantip.L[i] == PREV_RANK) + if ns.scantip.L[i] == PREV_RANK then return true end + end +end + + +ns.unmet_requirements = setmetatable({}, { + __index = function(t, i) + local id = ns.ids[i] + if not id then return end + + if NeedsRank(i) then + t[i] = true + return true + end + end +})