Use GetAchievementCriteriaInfoByID to look up the criteria directly, instead of looping over all the criteria, calling GetAchievementCriteriaInfo for each one, and comparing the ID:
Code:
local function GetPinInfo(achievementID, criteriaID)
local name, _, completed = GetAchievementCriteriaInfoByID(achievementID, criteraID)
return name, completed
end
(As an aside, I'm not really sure why this function still requires the achievement ID, since the criteria ID is unique on its own...)
And at this point you might as well just get rid of the helper function entirely.
Also, I implemented Ctrl+Click to set a TomTom waypoint like so:
Code:
local EXPLORE_S = 'Explore: %s'
local CLICK_WAYPOINT = 'Ctrl-Click to set a TomTom waypoint.'
if GetLocale() == 'deDE' then
EXPLORE_S = 'Erkundet: %s'
CLICK_WAYPOINT = 'Strg-Klick, um einen Zielpunkt mit TomTom zu setzen.'
elseif GetLocale():match('es') then
EXPLORE_S = 'Explora: %s'
CLICK_WAYPOINT = 'Ctrl-Clic para establecer un waypoint con TomTom.'
end
local function Pin_OnMouseUp(self)
if TomTom and IsControlKeyDown() then
local mapID, mapFloor = GetCurrentMapAreaID()
local width, height = WorldMapDetailFrame:GetWidth(), WorldMapDetailFrame:GetHeight()
local _, _, _, x, y = self:GetPoint()
x = x / width
y = -y / height
TomTom:AddMFWaypoint(mapID, mapFloor, x, y, {
title = format(EXPLORE_S, self.text),
persistent = false,
})
end
end
Pin_OnEnter:
Code:
WorldMapTooltip:AddLine(self.text)
if TomTom then
WorldMapTooltip:AddLine(CLICK_WAYPOINT, 1, 1, 1, true)
end
WorldMapTooltip:Show()
In GetPin:
Code:
pin:SetScript('OnMouseUp', Pin_OnMouseUp)
Finally, I'm basically blind, but those icons are huuuuuge.