From cafb3dbe92dfbb71cdbce2521e6516ff1618e4eb Mon Sep 17 00:00:00 2001 From: torhal Date: Fri, 11 Dec 2009 00:21:36 +0000 Subject: [PATCH] In addon:OnEnable(): Register for TRADE_SKILL_UPDATE Added addon:TRADE_SKILL_UPDATE() which re-scans (on a throttle so the client doesn't lock up) the recipes so the list automatically updates when you learn a new recipe. Only works if the tradeskill frame is open. --- ARL.lua | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/ARL.lua b/ARL.lua index b3bbf3d..3df26a6 100644 --- a/ARL.lua +++ b/ARL.lua @@ -536,6 +536,7 @@ end function addon:OnEnable() self:RegisterEvent("TRADE_SKILL_SHOW") -- Make addon respond to the tradeskill windows being shown self:RegisterEvent("TRADE_SKILL_CLOSE") -- Addon responds to tradeskill windows being closed. + self:RegisterEvent("TRADE_SKILL_UPDATE") if addon.db.profile.scantrainers then self:RegisterEvent("TRAINER_SHOW") @@ -786,6 +787,33 @@ function addon:TRADE_SKILL_CLOSE() end end +do + local last_update = 0 + local updater = CreateFrame("Frame", nil, UIParent) + + updater:Hide() + updater:SetScript("OnUpdate", + function(self, elapsed) + last_update = last_update + elapsed + + if last_update >= 0.5 then + addon:Scan(false) + self:Hide() + end + end) + + function addon:TRADE_SKILL_UPDATE() + if not self.Frame:IsVisible() then + return + end + + if not updater:IsVisible() then + last_update = 0 + updater:Show() + end + end +end + ------------------------------------------------------------------------------- -- Tradeskill functions -- Recipe DB Structures are defined in Documentation.lua -- 1.7.9.5