1
Serverside Modding / Re: Eluna AIO - Addon - Showing a spell tooltip
« on: December 08, 2016, 09:56:33 pm »Quote from: "Grymskvll"
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.I used GameTooltip:SetHyperlink("spell:"..SPELL_ID) and it worked for me
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
end
To 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)