Originally Posted by Tonyleila
Because you are such a warm-hearted talented and smart person and your code is always awesome!
|
I don't know about that first adjective... but here you go, totally untested.
Code:
local showLinkType = {
-- Normal tooltip things:
achievement = true,
enchant = true,
glyph = true,
item = true,
instancelock = true,
quest = true,
spell = true,
talent = true,
unit = true,
-- Special tooltip things:
battlepet = false,
battlePetAbil = false,
garrfollowerability = false,
garrfollower = false,
garrmission = false,
}
local function OnHyperlinkEnter(frame, link, text)
local normal = showLinkType[linkData:match("^(.-):")]
if normal == true then
GameTooltip:SetOwner(WorldFrame, "ANCHOR_BOTTOMLEFT", 30, 310)
GameTooltip:SetHyperlink(link)
GameTooltip:Show()
elseif normal == false then
-- Uses a special tooltip, just let the default function handle it.
SetItemRef(link, text, "LeftButton", frame)
end
end
local function OnHyperlinkLeave(frame, linkData, link)
local normal = showLinkType[linkData:match("^(.-):")]
if normal == true then
GameTooltip:Hide()
elseif normal == false then
-- Uses a special tooltip, just let the default function handle it.
SetItemRef(link, text, "LeftButton", frame)
end
end
local function RegisterFrame(frame)
frame:SetScript("OnHyperlinkEnter", OnHyperlinkEnter)
frame:SetScript("OnHyperlinkLeave", OnHyperlinkLeave)
end
local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function(self, event, name)
if event == "PLAYER_LOGIN" then
for i = 1, NUM_CHAT_FRAMES do
RegisterFrame(_G["ChatFrame"..i])
end
end
if GuildBankMessageFrame then
RegisterFrame(GuildBankMessageFrame)
self:UnregisterAllEvents()
self:SetScript("OnEvent", nil)
RegisterFrame = nil
else
self:RegisterEvent("ADDON_LOADED")
end
end)