Is there an "easy," or at least non-convoluted way to remove a single line from the game tooltip? I can't seem to find any documentation on wowwiki or wowprogramming. I've managed to accomplish what I want, but I basically have to rebuild the entire tooltip every time its OnShow is called, which is annoying.
It's not really relevant to the question, but the code is below.
Code:
local FAP = "Moonkin forms only."
local function UpdateTooltip(tooltip)
local _, item = tooltip:GetItem()
-- Ignore all of this unless our tooltip belongs to an item.
if not item then return end
-- Also ignore if our item isn't a weapon.
if select(6, GetItemInfo(item)) ~= "Weapon" then return end
local lines = {}
-- Iterate through all of the lines on our tooltip.
for i = 1, tooltip:NumLines() do
local left = _G[tooltip:GetName().."TextLeft"..i]
local lText = left:GetText()
local lR, lG, lB = left:GetTextColor()
-- Ignore any lines that have "Feral Attack Power" in them. Add everything else to a table used to reconstruct our tooltip later on.
if not lText:find(FAP) then
tinsert(lines, {line = lText, r = lR, g = lG, b = lB})
end
end
-- We're going to clear the tooltip and reconstruct it without the feral attack power text. Is there a cleaner way to remove a line from the GameTooltip?
tooltip:ClearLines()
for k, v in pairs(lines) do
tooltip:AddLine(v.line)
_G[tooltip:GetName().."TextLeft"..k]:SetTextColor(v.r, v.g, v.b)
end
end
-- Hook our GameTooltip and ItemRefTooltip OnShow
GameTooltip:HookScript("OnShow", function()
UpdateTooltip(GameTooltip)
end)
ItemRefTooltip:HookScript("OnShow", function()
UpdateTooltip(ItemRefTooltip)
end)