Originally Posted by wiMp
Both the icons work if the weapon enchant is the same, if you're using two different ones though, only the one on TempEnchant2Icon sticks.
|
I leveled an enhancement shaman up to get Flametongue Weapon and Windfury Weapon on two different weapons at the same time and they both showed up fine for me using the code I posted earlier. Not sure what's going on if it is only working on one for you.
I also level a rogue up to get Deadly Poison and Crippling Poison but that was all for naught because those aren't even temporary enchants any more. With the addon disabled they still showed up with the correct spell icons. So you can completely remove the rogue stuff, unless some of the higher level poisons are still temp enchants, then just remove the ones that aren't.
Here is the code again with the rogue stuff removed and a slight change to make it easier on you if you localize it later:
Code:
local _, class = UnitClass("player")
if class ~= "SHAMAN" then return end
local addonName = ...
local tooltip = CreateFrame("GameTooltip", addonName .. "TempEnchantScanner", UIParent, "GameTooltipTemplate")
tooltip:Hide()
local tempEnchants = {
["Earthliving"] = GetSpellTexture(51730),
["Flametongue"] = GetSpellTexture(8024),
["Frostbrand"] = GetSpellTexture(8033),
["Rockbiter"] = GetSpellTexture(8017),
["Windfury"] = GetSpellTexture(8232),
}
local tooltipText = setmetatable({ }, { __index = function(self, index)
self[index] = _G[addonName .. "TempEnchantScannerTextLeft" .. index]
return self[index]
end })
tooltip:SetScript("OnTooltipSetItem", function(self)
for index = 1, self:NumLines() do
local texture = tempEnchants[tooltipText[index]:GetText():gsub("%s*%(.-%)%s*", "")]
if texture then
self.texture = texture
return
end
end
self.texture = nil
end)
local enchant = { }
for index = 1, NUM_TEMP_ENCHANT_FRAMES do
enchant[index] = _G["TempEnchant" .. index]
enchant[index].icon = _G["TempEnchant" .. index .. "Icon"]
tooltip[index] = _G[addonName .. "TempEnchantScannerTexture" .. index]
end
hooksecurefunc("TemporaryEnchantFrame_Update", function()
for index = 1, NUM_TEMP_ENCHANT_FRAMES do
if enchant[index]:IsShown() then
tooltip:SetInventoryItem("player", enchant[index]:GetID())
if tooltip.texture then
tooltip[index]:SetTexture(tooltip.texture) -- ugly hack fix
enchant[index].icon:SetTexture(tooltip.texture)
end
end
end
end)
The only reason I can think this happens is that the textures for the temp enchant frames don't count when checking to remove unused textures from memory.