comparison ReagentMaker.lua @ 115:5a3fb8fea026

Throttle count display
author contrebasse
date Wed, 15 Jun 2011 00:05:35 +0200
parents c79ab5443ee5
children 7ce304c296b0
comparison
equal deleted inserted replaced
114:c770f969ffa2 115:5a3fb8fea026
53 t_throttle = SCAN_DELAY 53 t_throttle = SCAN_DELAY
54 self:SetScript("OnUpdate", throttleScan) 54 self:SetScript("OnUpdate", throttleScan)
55 end 55 end
56 56
57 -- Show makables reagents 57 -- Show makables reagents
58 A.updateCounts(GetTradeSkillSelectionIndex()) 58 A.updateCount_throttle()
59 end 59 end
60 end 60 end
61 A.EventsFrame:SetScript("OnEvent", function(self, event) 61 A.EventsFrame:SetScript("OnEvent", function(self, event)
62 --print("Throttle Scan :",event)
62 if event == "TRADE_SKILL_UPDATE" then 63 if event == "TRADE_SKILL_UPDATE" then
63 t_throttle = SCAN_DELAY 64 t_throttle = SCAN_DELAY
64 self:SetScript("OnUpdate", throttleScan) 65 self:SetScript("OnUpdate", throttleScan)
65 A.ManageCampFireBtn() 66 A.ManageCampFireBtn()
66 67
163 btn.textureHighlight:Hide() 164 btn.textureHighlight:Hide()
164 A.tooltipRecipe:Hide() 165 A.tooltipRecipe:Hide()
165 end -- function 166 end -- function
166 167
167 -- Show counts on buttons 168 -- Show counts on buttons
168 function A.updateCounts(recipeIndex) 169 local CountThrottleFrame = CreateFrame("Frame")
170 local COUNT_DELAY = 0.1
171 local t_throttleCount = SCAN_DELAY
172 function UpdateCounts(recipeIndex)
169 -- Needs an argument 173 -- Needs an argument
170 if not recipeIndex then return end 174 if not recipeIndex then return end
171 175
172 -- Do not manage guild tradeskill 176 -- Do not manage guild tradeskill
173 if IsTradeSkillGuild() or IsTradeSkillLinked() then 177 if IsTradeSkillGuild() or IsTradeSkillLinked() then
208 label:Show() 212 label:Show()
209 end -- if 213 end -- if
210 end -- if 214 end -- if
211 end -- for 215 end -- for
212 end -- function 216 end -- function
213 hooksecurefunc("SelectTradeSkill",A.updateCounts) 217 local function throttleCount(self, t_elapsed)
218 t_throttle = t_throttle - t_elapsed
219 if t_throttle<0 then
220 self:SetScript("OnUpdate", nil)
221
222 -- Show makables reagents
223 UpdateCounts(GetTradeSkillSelectionIndex())
224 end
225 end
226 function A.updateCount_throttle(self,event)
227 if not TradeSkillFrame or not TradeSkillFrame:IsVisible() or event=="TRADE_SKILL_CLOSE" then
228 CountThrottleFrame:UnregisterEvent("BAG_UPDATE")
229 t_throttleCount = 0
230 CountThrottleFrame:SetScript("OnUpdate", nil)
231 return
232 else
233 CountThrottleFrame:RegisterEvent("BAG_UPDATE")
234 end
235 t_throttleCount = SCAN_DELAY
236 CountThrottleFrame:SetScript("OnUpdate", throttleCount)
237
238 A.MenuFrame.updateCounts()
239 end
240 CountThrottleFrame:SetScript("OnEvent", A.updateCount_throttle)
241 CountThrottleFrame:RegisterEvent("TRADE_SKILL_SHOW")
242 CountThrottleFrame:RegisterEvent("TRADE_SKILL_UPDATE")
243 CountThrottleFrame:RegisterEvent("TRADE_SKILL_CLOSE")
244 hooksecurefunc("SelectTradeSkill",A.updateCount_throttle)