# HG changeset patch # User contrebasse # Date 1308089135 -7200 # Node ID 5a3fb8fea0265ca8fa72670744a653279581cacb # Parent c770f969ffa2dc0f2056677c54629c4874ab0c23 Throttle count display diff -r c770f969ffa2 -r 5a3fb8fea026 ReagentMaker.lua --- a/ReagentMaker.lua Fri Jun 03 12:24:26 2011 +0200 +++ b/ReagentMaker.lua Wed Jun 15 00:05:35 2011 +0200 @@ -55,10 +55,11 @@ end -- Show makables reagents - A.updateCounts(GetTradeSkillSelectionIndex()) + A.updateCount_throttle() end end A.EventsFrame:SetScript("OnEvent", function(self, event) + --print("Throttle Scan :",event) if event == "TRADE_SKILL_UPDATE" then t_throttle = SCAN_DELAY self:SetScript("OnUpdate", throttleScan) @@ -165,7 +166,10 @@ end -- function -- Show counts on buttons -function A.updateCounts(recipeIndex) +local CountThrottleFrame = CreateFrame("Frame") +local COUNT_DELAY = 0.1 +local t_throttleCount = SCAN_DELAY +function UpdateCounts(recipeIndex) -- Needs an argument if not recipeIndex then return end @@ -210,4 +214,31 @@ end -- if end -- for end -- function -hooksecurefunc("SelectTradeSkill",A.updateCounts) +local function throttleCount(self, t_elapsed) + t_throttle = t_throttle - t_elapsed + if t_throttle<0 then + self:SetScript("OnUpdate", nil) + + -- Show makables reagents + UpdateCounts(GetTradeSkillSelectionIndex()) + end +end +function A.updateCount_throttle(self,event) + if not TradeSkillFrame or not TradeSkillFrame:IsVisible() or event=="TRADE_SKILL_CLOSE" then + CountThrottleFrame:UnregisterEvent("BAG_UPDATE") + t_throttleCount = 0 + CountThrottleFrame:SetScript("OnUpdate", nil) + return + else + CountThrottleFrame:RegisterEvent("BAG_UPDATE") + end + t_throttleCount = SCAN_DELAY + CountThrottleFrame:SetScript("OnUpdate", throttleCount) + + A.MenuFrame.updateCounts() +end +CountThrottleFrame:SetScript("OnEvent", A.updateCount_throttle) +CountThrottleFrame:RegisterEvent("TRADE_SKILL_SHOW") +CountThrottleFrame:RegisterEvent("TRADE_SKILL_UPDATE") +CountThrottleFrame:RegisterEvent("TRADE_SKILL_CLOSE") +hooksecurefunc("SelectTradeSkill",A.updateCount_throttle) diff -r c770f969ffa2 -r 5a3fb8fea026 SecureMenu.lua --- a/SecureMenu.lua Fri Jun 03 12:24:26 2011 +0200 +++ b/SecureMenu.lua Wed Jun 15 00:05:35 2011 +0200 @@ -16,28 +16,11 @@ MenuFrame:SetToplevel(true) -- raised if clicked tinsert(UISpecialFrames,"ReagentMaker_ExternalFrame") -- make it closable with escape -local SCAN_DELAY = 0.2 -local t_throttle = SCAN_DELAY -function MenuFrame.throttleUpdateCounts(self, t_elapsed) - t_throttle = t_throttle - t_elapsed - if t_throttle<0 then - self:SetScript("OnUpdate", nil) +-- Throttling is made in ReagentMaker.lua +MenuFrame:SetScript("OnEvent",function() MenuFrame:Hide() end) +MenuFrame:RegisterEvent("TRADE_SKILL_CLOSE") +MenuFrame:RegisterEvent("PLAYER_REGEN_DISABLED") - -- Update counts - MenuFrame.updateCounts() - end -end -MenuFrame:SetScript("OnEvent",function(self,event,...) - if event == "BAG_UPDATE" then - t_throttle = SCAN_DELAY - self:SetScript("OnUpdate", MenuFrame.throttleUpdateCounts) - elseif event == "TRADE_SKILL_CLOSE" or event == "PLAYER_REGEN_DISABLED" then - MenuFrame:Hide() - end -end) -MenuFrame:RegisterEvent("TRADE_SKILL_CLOSE") -MenuFrame:RegisterEvent("PLAYER_REGEN_ENABLED") -MenuFrame:RegisterEvent("BAG_UPDATE") MenuFrame:SetScript("OnEnter",function(self) if self.reagentLink then GameTooltip:SetOwner(self)