local SpellName1,SpellRank1,SpellIcon1,SpellCost1 = GetSpellInfo(168)local imgSpellIcon1 = CreateFrame("Button", "imgSpellIcon1", frameAttributes, nil)imgSpellIcon1:SetSize(50, 50)imgSpellIcon1:SetPoint("TOPLEFT", 30, -69)imgSpellIcon1:EnableMouse(true)imgSpellIcon1:SetNormalTexture(SpellIcon1)local function OnEnter(self, motion) GameTooltip:SetOwner(self, "ANCHOR_BOTTOMRIGHT") GameTooltip:SetText(SpellName1,1,1,1) -- GameTooltip:AddLine(SpellRank1, 1, 1, 1) GameTooltip:AddLine(SpellCost1.." Mana", 1, 1, 1) GameTooltip:Show() end imgSpellIcon1:SetScript("OnEnter", OnEnter) imgSpellIcon1:SetScript("OnLeave", function() GameTooltip:Hide() end)
SetSpellByID(spellid)
SetHyperlink("spell:"..spellid)
local AIO = AIO or require("AIO")AIO.AddAddon()if not AIO.IsServer() then -- Hacky way to set up custom talent tooltips. Creates and reads an ItemRefTooltip from a spellID and returns a table of text with color and wrap data. -- The ItemRefTooltip is shown, read and hidden again without ever appearing on the screen (hopefully) local function GetSpellTooltip(spellID) if (not ItemRefTooltip:IsVisible()) then ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE"); end ItemRefTooltip:ClearLines(); local linky = "124cff71d5ff124Hspell:"..spellID.."124h124h124r" ItemRefTooltip:SetHyperlink(linky) local numLines = ItemRefTooltip:NumLines(); local tmp = {}; local i = 1; for currentLine=1, numLines do local line = {}; local left = _G["ItemRefTooltipTextLeft"..currentLine]; local right = _G["ItemRefTooltipTextRight"..currentLine]; if ( left ) then line.w = left:CanWordWrap(); line.leftR, line.leftG, line.leftB = left:GetTextColor(); line.left = left:GetText(); end if ( right ) then line.rightR, line.rightG, line.rightB = right:GetTextColor(); line.right = right:GetText(); end tmp[i] = line; i = i + 1; end HideUIPanel(ItemRefTooltip); return(tmp) end function GameTooltip:ActuallySetSpellByID(spellID) local tmp = GetSpellTooltip(spellID) GameTooltip:ClearLines() for i=1, #tmp do if ( tmp[i].left and tmp[i].right ) then GameTooltip:AddDoubleLine(tmp[i].left, tmp[i].right, tmp[i].leftR, tmp[i].leftG, tmp[i].leftB, tmp[i].rightR, tmp[i].rightG, tmp[i].rightB); elseif ( tmp[i].left ) then GameTooltip:AddLine(tmp[i].left, tmp[i].leftR, tmp[i].leftG, tmp[i].leftB, tmp[i].w); elseif ( tmp[i].right ) then GameTooltip:AddDoubleLine("", tmp[i].right, 0, 0, 0, tmp[i].rightR, tmp[i].rightG, tmp[i].rightB); end end GameTooltip:Show() end end
/run GameTooltip:ActuallySetSpellByID(10)
I couldn't get GameTooltip:SetSpellByID(ID) to work, so I used a hacky way to populate the gametooltip from a spell hyperlink. The only downside is that if you have a hyperlink popup on screen (the little box that appears when you click a chat link for a spell/talent/item), the popup will disappear.If anyone knows how to actually get GameTooltip:SetSpellByID to work instead of resorting to ghetto magic, please let us know!Code: [Select]local AIO = AIO or require("AIO")AIO.AddAddon()if not AIO.IsServer() then -- Hacky way to set up custom talent tooltips. Creates and reads an ItemRefTooltip from a spellID and returns a table of text with color and wrap data. -- The ItemRefTooltip is shown, read and hidden again without ever appearing on the screen (hopefully) local function GetSpellTooltip(spellID) if (not ItemRefTooltip:IsVisible()) then ItemRefTooltip:SetOwner(UIParent, "ANCHOR_PRESERVE"); end ItemRefTooltip:ClearLines(); local linky = "124cff71d5ff124Hspell:"..spellID.."124h124h124r" ItemRefTooltip:SetHyperlink(linky) local numLines = ItemRefTooltip:NumLines(); local tmp = {}; local i = 1; for currentLine=1, numLines do local line = {}; local left = _G["ItemRefTooltipTextLeft"..currentLine]; local right = _G["ItemRefTooltipTextRight"..currentLine]; if ( left ) then line.w = left:CanWordWrap(); line.leftR, line.leftG, line.leftB = left:GetTextColor(); line.left = left:GetText(); end if ( right ) then line.rightR, line.rightG, line.rightB = right:GetTextColor(); line.right = right:GetText(); end tmp[i] = line; i = i + 1; end HideUIPanel(ItemRefTooltip); return(tmp) end function GameTooltip:ActuallySetSpellByID(spellID) local tmp = GetSpellTooltip(spellID) GameTooltip:ClearLines() for i=1, #tmp do if ( tmp[i].left and tmp[i].right ) then GameTooltip:AddDoubleLine(tmp[i].left, tmp[i].right, tmp[i].leftR, tmp[i].leftG, tmp[i].leftB, tmp[i].rightR, tmp[i].rightG, tmp[i].rightB); elseif ( tmp[i].left ) then GameTooltip:AddLine(tmp[i].left, tmp[i].leftR, tmp[i].leftG, tmp[i].leftB, tmp[i].w); elseif ( tmp[i].right ) then GameTooltip:AddDoubleLine("", tmp[i].right, 0, 0, 0, tmp[i].rightR, tmp[i].rightG, tmp[i].rightB); end end GameTooltip:Show() end endTo test it, enter the game, mouse over a spell in your spellbook and paste this in chat to set the tooltip to Blizzard rank 1:Code: [Select]/run GameTooltip:ActuallySetSpellByID(10)