From 89509e8c306431144cf75a2b4922d510f188cd46 Mon Sep 17 00:00:00 2001 From: Tuller Date: Wed, 12 Jan 2011 19:38:33 -0500 Subject: [PATCH] there, I fixed it --- Tipachu.lua | 59 +++++++++++++++++++++++++++++++++++++---------------------- Tipachu.toc | 4 ++-- 2 files changed, 39 insertions(+), 24 deletions(-) diff --git a/Tipachu.lua b/Tipachu.lua index 0293a85..b3f8ac9 100644 --- a/Tipachu.lua +++ b/Tipachu.lua @@ -5,39 +5,54 @@ local DEFAULT_ICON_SIZE = 24 -local function AddIcon(self, icon) - if icon then - local title = _G[self:GetName() .. 'TextLeft1'] - if title and not title:GetText():find('|T' .. icon) then --make sure the icon does not display twice on recipies, which fire OnTooltipSetItem twice - title:SetFormattedText('|T%s:%d|t %s', icon, _G['TipachuSize'] or DEFAULT_ICON_SIZE, title:GetText()) - end +local function addIcon(self, icon) + local title = icon and _G[self:GetName() .. 'TextLeft1'] + if title then + title:SetFormattedText('|T%s:%d|t %s', icon, _G['TipachuSize'] or DEFAULT_ICON_SIZE, title:GetText()) end end ---[[ - Item Hooking ---]] +--[[ tooltip hooking ]]-- local function hookItem(tip) + local tooltipModified = false + + tip:HookScript('OnTooltipCleared', function(self, ...) + tooltipModified = false + end) + tip:HookScript('OnTooltipSetItem', function(self, ...) - local name, link = self:GetItem() - local icon = link and GetItemIcon(link) - AddIcon(self, icon) + if not tooltipModified then + tooltipModified = true + + local name, link = self:GetItem() + local icon = link and GetItemIcon(link) + addIcon(self, icon) + end end) end -hookItem(_G['GameTooltip']) -hookItem(_G['ItemRefTooltip']) +local function hookSpell(tip) + local tooltipModified = false ---[[ - Spell Hooking ---]] + tip:HookScript('OnTooltipCleared', function(self, ...) + tooltipModified = false + end) -local function hookSpell(tip) tip:HookScript('OnTooltipSetSpell', function(self, ...) - local name, rank, icon = GetSpellInfo(self:GetSpell()) - AddIcon(self, icon) + if not tooltipModified then + tooltipModified = true + + local spellName, spellRank, spellID = GameTooltip:GetSpell() + if spellId then + local icon = select(3, GetSpellInfo(spellID)) + addIcon(self, icon) + end + end end) end -hookSpell(_G['GameTooltip']) -hookSpell(_G['ItemRefTooltip']) \ No newline at end of file + +for _, tooltip in pairs{GameTooltip, ItemRefTooltip} do + hookItem(tooltip) + hookSpell(tooltip) +end \ No newline at end of file diff --git a/Tipachu.toc b/Tipachu.toc index 06629e2..8b1d242 100644 --- a/Tipachu.toc +++ b/Tipachu.toc @@ -1,7 +1,7 @@ -## Interface: 30200 +## Interface: 40000 ## Title: Tipachu ## Author: Tuller ## Notes: Adds an items icon to its tooltip ## SavedVariables: TipachuSize -## Version: 7 +## Version: 1.0 Tipachu.lua \ No newline at end of file -- 1.7.9.5