I'm hooking the chat frame's hyperlink function to allow control-clicks to take you directly to linked achievements in the achievement frame. However, it's not working properly.
If I control-click
Shave and a Haircut in-game, it takes me to the correct category, but it doesn't actually select the achievement. If I use the following command, it works. Does anyone have any idea what's happening here?
Code:
/run if not AchievementFrame or not AchievementFrame:IsShown() then ToggleAchievementFrame() end AchievementFrame_SelectAchievement(545)
Lua Code:
local origOnHyperlinkShow = ChatFrame_OnHyperlinkShow
ChatFrame_OnHyperlinkShow = function(self, linkData, ...)
local linkType = strmatch(linkData, "^([^:]+)")
if not linkType then
return
end
if linkType == "achievement" and IsControlKeyDown() then
local _, achievementID = strsplit(":", linkData)
local category = GetAchievementCategory(achievementID)
local _, parentID = GetCategoryInfo(category)
if not AchievementFrame or not AchievementFrame:IsShown() then
ToggleAchievementFrame()
end
AchievementFrame_SelectAchievement(achievementID)
print("achievementID", achievementID)
-- expand category list to achievement's location
if parentID == -1 then
for i, entry in next, ACHIEVEMENTUI_CATEGORIES do
if entry.id == category then
entry.collapsed = false
elseif entry.parent == category then
entry.hidden = false
end
end
AchievementFrameCategories_Update()
end
end
return origOnHyperlinkShow(self, linkData, ...)
end