Thread Tools Display Modes
06-02-16, 11:15 AM   #1
Rhianidd
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2005
Posts: 9
Exclamation SetHyperlink... broken with a patch?

I have been using the abandoned add-on ProfessionsVault. It stopped working (showing what recipes my characters had/needed (13 chars on "1" server)), so I thought I broke something updating the list of items/spell ids... and so I started digging into the code. By placing a ton of debug statements, I found that it appears that SetHyperlink (which is hooked to colorize the icon and add to the tooltip) isn't actually setting it to the tooltip. It has the GetName() correct, but GetItem() has empty strings (not nil, empty).

Was something changed with SetHyperlink/GetItem? I even tried the TradeskillInfo addon, but don't get any results -- which I hadn't realized that was connected until today.

Rhianidd
  Reply With Quote
06-02-16, 02:56 PM   #2
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
tooltip:GetItem() has been bugged on live for a while. There really isn't much of a workaround that'll work on a global scale and securely. It should fine with tooltip:SetHyperlink(), but the bug occurs when using the more UI-specialized functions like tooltip:SetMerchantItem(), tooltip:SetTradeSkillItem(), and others.

On a side note, while Legion is suffering from this bug as well, it does have a new profession window that has a tab that lists unlearned recipes. This mirrors the online Armory's profession page on a selected character. Example here.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-02-16 at 03:00 PM.
  Reply With Quote
06-02-16, 03:33 PM   #3
Rhianidd
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2005
Posts: 9
Originally Posted by SDPhantom View Post
tooltip:GetItem() has been bugged on live for a while. There really isn't much of a workaround that'll work on a global scale and securely. It should fine with tooltip:SetHyperlink(), but the bug occurs when using the more UI-specialized functions like tooltip:SetMerchantItem(), tooltip:SetTradeSkillItem(), and others.

On a side note, while Legion is suffering from this bug as well, it does have a new profession window that has a tab that lists unlearned recipes. This mirrors the online Armory's profession page on a selected character. Example here.
So, if GetItem() doesn't work, how can we prove that SetHyperlink() was set properly? And does GetSpell() work? And do the GetLine() calls work? I might be able to work around the GetItem() if GetLine() does.

And it's not just the current char that I want to know if they have a recipe -- it's my whole horde (on alliance )... I would like to buy multiples if I find a new cooking recipe -- or get an engy schematic on my leatherworker... etc etc etc. As well as knowing at a glance if I need to be worried about the merchant or AH list or can continue on.

Rhianidd

Last edited by Rhianidd : 06-02-16 at 04:11 PM.
  Reply With Quote
06-02-16, 04:48 PM   #4
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
I reiterate.
Originally Posted by SDPhantom View Post
It should fine with tooltip:SetHyperlink(), but the bug occurs when using the more UI-specialized functions like tooltip:SetMerchantItem(), tooltip:SetTradeSkillItem(), and others.
My custom development addon securely hooks all tooltips to add a tag at the bottom showing item/spell/unit IDs. It also shows additional info for specific tooltips. Items show AH category, stack size, required and item levels, vendor price, and quantity on hand. Spells show their /cast string (used to be useful when we had ranks). Units show their GUID.

I noticed this bug when it came out and did the work to track down which tooltip:Set*() functions triggered it. I have workarounds implemented, but they're not by any means secure and could spread taint.
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote
06-02-16, 06:55 PM   #5
Rhianidd
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2005
Posts: 9
Originally Posted by SDPhantom View Post
My custom development addon securely hooks all tooltips to add a tag at the bottom showing item/spell/unit IDs. It also shows additional info for specific tooltips. Items show AH category, stack size, required and item levels, vendor price, and quantity on hand. Spells show their /cast string (used to be useful when we had ranks). Units show their GUID.
Which addon? It'll save me a bit of trouble deciphering ProfessionsVault (abandoned over an expansion ago).

Thanks SDPhantom.

Rhianidd
  Reply With Quote
06-02-16, 08:14 PM   #6
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
"Custom" meaning it's unreleased code that I wrote for my own use. I can still post the tooltip code used in it.

Base Code:
Lua Code:
  1. local Hooked={};
  2. local Hooks={
  3.     OnTooltipSetItem=function(self)
  4.         local _,link=self:GetItem();
  5.         if link then
  6.             local _,_,quality,ilvl,clvl,mcat,scat,stack,_,_,price=GetItemInfo(link);
  7.  
  8.             self:AddLine(" ");
  9.             self:AddDoubleLine(("%sLv %s %s|r"):format(ITEM_QUALITY_COLORS[quality or 1].hex,ilvl or "???",_G["ITEM_QUALITY"..(quality or 1).."_DESC"]),(stack or "??").." Stack");
  10.  
  11.             local count,total=GetItemCount(link),GetItemCount(link,true);
  12.             if total>0 then
  13.                 local firstline=true;
  14.                 if count>0 then     self:AddDoubleLine(firstline and "On Hand" or " ",("Bags: %d"):format(count));      firstline=false; end
  15.                 if count<total then self:AddDoubleLine(firstline and "On Hand" or " ",("Bank: %d"):format(total-count));    firstline=false; end
  16.                 self:AddDoubleLine(" ",("Total: %d"):format(total));
  17.             else
  18.                 self:AddDoubleLine("On Hand","Total: 0");
  19.             end
  20.             self:AddLine(" ");
  21.  
  22.             self:AddDoubleLine("Vendor:",price and GetCoinTextureString(price) or "???");
  23.             self:AddDoubleLine("Req/Item Level:",("%s/%s"):format(clvl or "???",ilvl or "???"));
  24.             self:AddDoubleLine("Category:",("%s - %s"):format(mcat or "???",scat or "???"));
  25.             self:AddLine(link:match("|H(.-)|h"));
  26.         end
  27.     end;
  28.     OnTooltipSetUnit=function(self)
  29.         local _,unit=self:GetUnit();
  30.         if unit then
  31.             self:AddDoubleLine(" ",("unit:%s"):format(unit));
  32.             self:AddLine(UnitGUID(unit));
  33.         end
  34.     end;
  35.     OnTooltipSetSpell=function(self)
  36.         local sname,srank,sid=self:GetSpell();
  37.         if sid then
  38.             self:AddDoubleLine(("%s(%s)"):format(sname,srank),("spell:%d"):format(sid));
  39.         end
  40.     end;
  41. };
  42.  
  43. local function HookTooltip(tooltip)
  44.     if Hooked[tooltip] then return; end
  45.     for i,j in pairs(Hooks) do tooltip:HookScript(i,j); end
  46.     Hooked[tooltip]=true;
  47. end
  48.  
  49. hooksecurefunc(getmetatable(GameTooltip).__index,"SetOwner",function(self) if not Hooked[self] then HookTooltip(self); end end);

Insecure workaround:
Lua Code:
  1. local LinkFuncs={
  2.     SetQuestItem=GetQuestItemLink;
  3.     SetQuestLogItem=GetQuestLogItemLink;
  4.     SetMerchantItem=GetMerchantItemLink;
  5.     SetTradeSkillItem=function(skill,reagent) return reagent and GetTradeSkillReagentItemLink(skill,reagent) or GetTradeSkillItemLink(skill); end;
  6. };
  7.  
  8. local ItemLink;
  9. local Meta=getmetatable(GameTooltip).__index;
  10.  
  11. do  local GetItem=Meta.GetItem;
  12.     function Meta:GetItem(...)
  13.         local name,link=GetItem(self,...);
  14.         if link and link:match("|Hitem:0[:|]") and ItemLink then link=ItemLink; end
  15.         if name and link and #name<=0 then name=link:match("|h%[(.-)%]|h") or ""; end
  16.         return name,link;
  17.     end
  18. end
  19.  
  20. for i,j in pairs(LinkFuncs) do
  21.     local func=Meta[i];
  22.     if func then
  23.         Meta[i]=function(self,...)
  24.             ItemLink=j(...);
  25.             func(self,...);--   Script hooks run here
  26.             ItemLink=nil;
  27.         end
  28.     end
  29. end
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)

Last edited by SDPhantom : 06-02-16 at 08:17 PM.
  Reply With Quote
06-03-16, 07:22 AM   #7
Rhianidd
A Murloc Raider
AddOn Author - Click to view addons
Join Date: Apr 2005
Posts: 9
Thank you so much.
  Reply With Quote
06-03-16, 11:40 AM   #8
SDPhantom
A Pyroguard Emberseer
 
SDPhantom's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2006
Posts: 2,326
Some of the API changed in Legion, requiring a modification of the workaround. They split tooltip:SetTradeSkillItem() into tooltip:SetRecipeResultItem() and tooltip:SetRecipeReagentItem(). They also moved some of the old tradeskill functions into C_TradeSkillUI. I included the new LinkFuncs table for Legion below.

Code:
local LinkFuncs={
	SetQuestItem=GetQuestItemLink;
	SetQuestLogItem=GetQuestLogItemLink;
	SetMerchantItem=GetMerchantItemLink;
	SetRecipeReagentItem=C_TradeSkillUI.GetRecipeReagentItemLink;
	SetRecipeResultItem=C_TradeSkillUI.GetRecipeItemLink;
};
__________________
WoWInterface AddOns
"All I want is a pretty girl, a decent meal, and the right to shoot lightning at fools."
-Anders (Dragon Age: Origins - Awakening)
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » SetHyperlink... broken with a patch?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off