View Single Post
08-16-14, 05:31 AM   #1
Talyrius
An Onyxian Warder
 
Talyrius's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 363
AchievementFrame_SelectAchievement()'s Odd Behavior

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:
  1. local origOnHyperlinkShow = ChatFrame_OnHyperlinkShow
  2. ChatFrame_OnHyperlinkShow = function(self, linkData, ...)
  3.     local linkType = strmatch(linkData, "^([^:]+)")
  4.     if not linkType then
  5.         return
  6.     end
  7.    
  8.     if linkType == "achievement" and IsControlKeyDown() then
  9.         local _, achievementID = strsplit(":", linkData)
  10.         local category = GetAchievementCategory(achievementID)
  11.         local _, parentID = GetCategoryInfo(category)
  12.        
  13.         if not AchievementFrame or not AchievementFrame:IsShown() then
  14.             ToggleAchievementFrame()
  15.         end
  16.         AchievementFrame_SelectAchievement(achievementID)
  17.         print("achievementID", achievementID)
  18.         -- expand category list to achievement's location
  19.         if parentID == -1 then
  20.             for i, entry in next, ACHIEVEMENTUI_CATEGORIES do
  21.                 if entry.id == category then
  22.                     entry.collapsed = false
  23.                 elseif entry.parent == category then
  24.                     entry.hidden = false
  25.                 end
  26.             end
  27.             AchievementFrameCategories_Update()
  28.         end
  29.     end
  30.    
  31.     return origOnHyperlinkShow(self, linkData, ...)
  32. end
  Reply With Quote