From bd3125167cf75f61f777388c0eb3f2a31e438970 Mon Sep 17 00:00:00 2001 From: Ignifazius Date: Sat, 22 Aug 2015 12:17:05 +0200 Subject: [PATCH] (heavy) workaround for missing entry in profession window (fix for issue #21) Since one of Blizzards get-functions sees to be breoken (returning 0 in the profession window), i tryed to fix it with a workaround: Check if ID is 0, then replace it with the resulting link by comparing the MouseOver & SelectedTradeSKill information. --- BagSync.lua | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/BagSync.lua b/BagSync.lua index 026481c..ebcfae9 100644 --- a/BagSync.lua +++ b/BagSync.lua @@ -832,7 +832,25 @@ local function AddCurrencyToTooltip(frame, currencyName) end local function AddItemToTooltip(frame, link) - --if we can't convert the item link then lets just ignore it altogether + if (link) then + local itemId = tonumber(string.match(link, "item:(%d+):")) -- get itemID // itemID seems to be "0" for every reagent in profession window?! + if (itemId == 0) then + local newItemId + if (GetMouseFocus():GetName()) == "TradeSkillSkillIcon" then --replace TradeSkill + newItemId = tonumber(GetTradeSkillItemLink(TradeSkillFrame.selectedSkill):match("item:(%d+):")) + else -- could check if a reagent is under mouse, but since we have to check it 3 lines later again... + for i = 1, 12 do -- how many reagents can a reciepe have? lets assume not more than 12 + if (GetMouseFocus():GetName()) == "TradeSkillReagent"..i then --replace TradeSkillReagents + newItemId = tonumber(GetTradeSkillReagentItemLink(TradeSkillFrame.selectedSkill, i):match("item:(%d+):")) + break --end loop if correct one already found + end + end + end + _, link = GetItemInfo(newItemId) -- replace original link with our found link + end + end + + --if we can't convert the item link then lets just ignore it altogether local itemLink = ToShortLink(link) if not itemLink then frame:Show() @@ -1007,7 +1025,15 @@ local function hookTip(tooltip) local currencyName = GetBackpackCurrencyInfo(index) AddCurrencyToTooltip(self, currencyName) end) + -- hooksecurefunc(tooltip, 'SetTradeSkillReagentInfo', function(self, index) + -- if modified or not BagSyncOpt.enableTooltips then return end + -- modified = true + -- local currencyName = GetTradeSkillReagentInfo(index,1) + -- AddCurrencyToTooltip(self, currencyName) + -- end) end +--GameTooltip:SetTradeSkillItem(skillIndex [, reagentIndex]) + hookTip(GameTooltip) hookTip(ItemRefTooltip) -- 1.7.9.5