Thread Tools Display Modes
Prev Previous Post   Next Post Next
08-23-15, 03:34 AM   #1
evilbib
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Jun 2010
Posts: 30
GameTooltip:GetItem() empty name and link

Hey there,

so some tooltips return empty values (name = "" and link = []) if you use GameTooltip:GetItem(), for example tooltips from the QuestFrame and I believe the TradeSkillFrame.
My interface has item quality border coloring for tooltips but obviously not for said tooltips.

Lua Code:
  1. GameTooltip:HookScript('OnTooltipSetItem', function(self)
  2.     local name, item = self:GetItem()
  3.     if (item) then
  4.         local quality = select(3, GetItemInfo(item))
  5.         if (quality) then
  6.             local r, g, b = GetItemQualityColor(quality)
  7.             self:SetBeautyBorderTexture('white')
  8.             self:SetBeautyBorderColor(r, g, b)
  9.         else
  10.             self:SetBeautyBorderTexture('white')
  11.             self:SetBeautyBorderColor(1, 1, 1)
  12.         end
  13.     end
  14. end)

I tried it with this function (this probably works only for quest items though)
Lua Code:
  1. name, texture, numItems, quality, isUsable = GetQuestItemInfo("type", index)
but the problem is that I have no idea how to get the index from the item I hover over.
Anyone has an idea how to approach this?

update:
The are six QuestProgressItem buttons according to the QuestFrame.xml, so I just hooked them all.
No idea if this is a good way to do this but it seems to be working.
Lua Code:
  1. for i = 1, 6 do
  2.     local questprog = _G['QuestProgressItem'..i]
  3.     questprog:HookScript('OnEnter', function(self)
  4.         local ID = self:GetID()
  5.         local questitemtype = self.type
  6.         local link = GetQuestItemLink(questitemtype, ID)
  7.         if (link) then
  8.             local quality = select(3, GetItemInfo(link))
  9.             if (quality) then
  10.                 local r, g, b = GetItemQualityColor(quality)
  11.                 GameTooltip:SetBeautyBorderTexture('white')
  12.                 GameTooltip:SetBeautyBorderColor(r, g, b)
  13.             end
  14.         end
  15.     end)
  16. end

update2:
and here for the TradeSkillFrame
Lua Code:
  1. if (not TradeSkillFrame) then
  2.     LoadAddOn('Blizzard_TradeSkillUI')
  3. end
  4. for i = 1, 8 do
  5.     local tsr = _G['TradeSkillReagent'..i]
  6.     tsr:HookScript('OnEnter', function(self)
  7.         local ID = self:GetID()
  8.         local skillindex = TradeSkillFrame.selectedSkill
  9.         local link = GetTradeSkillReagentItemLink(skillindex, ID)
  10.         if (link) then
  11.             local quality = select(3, GetItemInfo(link))
  12.             if (quality) then
  13.                 local r, g, b = GetItemQualityColor(quality)
  14.                 GameTooltip:SetBeautyBorderTexture('white')
  15.                 GameTooltip:SetBeautyBorderColor(r, g, b)
  16.             end
  17.         end
  18.     end)
  19. end
  20. hooksecurefunc('TradeSkillItem_OnEnter', function(self)
  21.     local link = GetTradeSkillItemLink(TradeSkillFrame.selectedSkill)
  22.     if (link) then
  23.         local quality = select(3, GetItemInfo(link))
  24.         if (quality) then
  25.             local r, g, b = GetItemQualityColor(quality)
  26.             GameTooltip:SetBeautyBorderTexture('white')
  27.             GameTooltip:SetBeautyBorderColor(r, g, b)
  28.         end
  29.     end
  30. end)

But still I wonder if this is a good way to do it.

Last edited by evilbib : 08-23-15 at 04:28 AM.
  Reply With Quote
 

WoWInterface » Developer Discussions » Lua/XML Help » GameTooltip:GetItem() empty name and link


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