Try:
Code:
local _, class = UnitClass("player")
if class ~= "ROGUE" and class ~= "SHAMAN" then return end
local addonName = ...
local tooltip = CreateFrame("GameTooltip", addonName .. "TempEnchantScanner", UIParent, "GameTooltipTemplate")
tooltip:Hide()
local tempEnchants
if class == "ROGUE" then
tempEnchants = {
["Mind-Numbing Poison"] = GetSpellTexture(5761),
["Crippling Poison"] = GetSpellTexture(3408),
["Paralytic Poison"] = GetSpellTexture(108215),
["Leeching Poison"] = GetSpellTexture(108211),
["Deadly Poison"] = GetSpellTexture(2823),
["Wound Poison"] = GetSpellTexture(8679),
}
elseif class == "SHAMAN" then
tempEnchants = {
["Earthliving"] = GetSpellTexture(51730),
["Flametongue"] = GetSpellTexture(8024),
["Frostbrand"] = GetSpellTexture(8033),
["Rockbiter"] = GetSpellTexture(8017),
["Windfury"] = GetSpellTexture(8232),
}
end
local tooltipLine = addonName .. "TempEnchantScannerTextLeft"
tooltip:SetScript("OnTooltipSetItem", function(self)
for lineNum = 1, self:NumLines() do
local texture = tempEnchants[_G[tooltipLine .. lineNum]:GetText():match("^(.+) %(")]
if texture then
self.texture = texture
return
end
end
self.texture = nil
end)
hooksecurefunc("TemporaryEnchantFrame_Update", function(_, mainhand, _, _, offhand)
if mainhand then
tooltip:SetInventoryItem("player", 16)
mainhand = tooltip.texture
end
if offhand then
tooltip:SetInventoryItem("player", 17)
offhand = tooltip.texture
end
if mainhand then
if offhand then
TempEnchant2Icon:SetTexture(mainhand)
TempEnchant1Icon:SetTexture(offhand)
else
TempEnchant1Icon:SetTexture(mainhand)
end
elseif offhand then
TempEnchant1Icon:SetTexture(offhand)
end
end)