Added the private.quest_names memoizing table so ARL only tooltip-scans for quest names when they're asked for.
James D. Callahan III [04-01-10 - 00:16]
Added the private.quest_names memoizing table so ARL only tooltip-scans for quest names when they're asked for.
diff --git a/Database/Quest.lua b/Database/Quest.lua
index 964dab4..d249659 100644
--- a/Database/Quest.lua
+++ b/Database/Quest.lua
@@ -17,15 +17,43 @@ This source code is released under All Rights Reserved.
************************************************************************
]]--
+-------------------------------------------------------------------------------
+-- AddOn namespace.
+-------------------------------------------------------------------------------
local MODNAME = "Ackis Recipe List"
-local addon = LibStub("AceAddon-3.0"):GetAddon(MODNAME)
-local L = LibStub("AceLocale-3.0"):GetLocale(MODNAME)
-local BZ = LibStub("LibBabble-Zone-3.0"):GetLookupTable()
+local addon = LibStub("AceAddon-3.0"):GetAddon(MODNAME)
+local L = LibStub("AceLocale-3.0"):GetLocale(MODNAME)
+local BZ = LibStub("LibBabble-Zone-3.0"):GetLookupTable()
+-- Set up the private intra-file namespace.
+local private = select(2, ...)
+
+------------------------------------------------------------------------------
+-- Constants.
+------------------------------------------------------------------------------
local NEUTRAL = 0
local ALLIANCE = 1
local HORDE = 2
+------------------------------------------------------------------------------
+-- Memoizing table for quest names.
+------------------------------------------------------------------------------
+private.quest_names = setmetatable({}, {
+ __index = function(t, id_num)
+ GameTooltip:SetOwner(UIParent, ANCHOR_NONE)
+ GameTooltip:SetHyperlink("quest:"..tostring(id_num))
+
+ local quest_name = _G["GameTooltipTextLeft1"]:GetText()
+ GameTooltip:Hide()
+
+ if not quest_name then
+ return _G.UNKNOWN
+ end
+ t[id_num] = quest_name
+ return quest_name
+ end,
+})
+
function addon:InitQuest(DB)
local function AddQuest(QuestID, Zone, X, Y, Faction)
addon:addLookupList(DB, QuestID, nil, Zone, X, Y, Faction)
diff --git a/Frame.lua b/Frame.lua
index ddabcf8..c2c6cbe 100644
--- a/Frame.lua
+++ b/Frame.lua
@@ -672,7 +672,7 @@ do
if quest.coord_x ~= 0 and quest.coord_y ~= 0 then
coord_text = "(" .. quest.coord_x .. ", " .. quest.coord_y .. ")"
end
- ttAdd(0, -1, false, L["Quest"], type_color, quest.name, name_color)
+ ttAdd(0, -1, false, L["Quest"], type_color, private.quest_names[id_num], name_color)
ttAdd(1, -2, true, quest.location, CATEGORY_COLORS["location"], coord_text, CATEGORY_COLORS["coords"])
else
ttAdd(0, -1, false, quest.faction.." "..L["Quest"], type_color)
@@ -3275,7 +3275,7 @@ do
return entry_index
end
- local name = ColorNameByFaction(quest.name, quest.faction)
+ local name = ColorNameByFaction(private.quest_names[id_num], quest.faction)
local coord_text = ""
if quest.coord_x ~= 0 and quest.coord_y ~= 0 then