Mercurial > wow > reagentmaker
comparison ReagentMaker.lua @ 17:5336b3a19d4f
Throttle the scanning to avoid freezing wow
| author | contrebasse |
|---|---|
| date | Fri, 08 Apr 2011 01:01:00 +0200 |
| parents | cc56799582f2 |
| children | c37c2a46723c |
comparison
equal
deleted
inserted
replaced
| 16:250d01156e21 | 17:5336b3a19d4f |
|---|---|
| 25 --------------------------------------------------- | 25 --------------------------------------------------- |
| 26 -- Manage events | 26 -- Manage events |
| 27 --------------------------------------------------- | 27 --------------------------------------------------- |
| 28 A.EventsFrame = CreateFrame("Frame") | 28 A.EventsFrame = CreateFrame("Frame") |
| 29 | 29 |
| 30 A.EventsFrame:SetScript("OnEvent", function(self, event, ...) | 30 local SCAN_DELAY = 0.2 |
| 31 if event == "TRADE_SKILL_UPDATE" then | 31 local t_throttle = SCAN_DELAY |
| 32 local function throttleScan(self, t_elapsed) | |
| 33 t_throttle = t_throttle - t_elapsed | |
| 34 if t_throttle<0 then | |
| 35 self:SetScript("OnUpdate", nil) | |
| 36 print("go") | |
| 37 | |
| 32 -- Close the external window if the tradeskill changed | 38 -- Close the external window if the tradeskill changed |
| 33 if A.currentTradeSkill ~= GetTradeSkillLine() then | 39 if A.currentTradeSkill ~= GetTradeSkillLine() then |
| 34 A.MenuFrame:Hide() | 40 A.MenuFrame:Hide() |
| 35 end | 41 end |
| 36 | 42 |
| 39 return | 45 return |
| 40 end | 46 end |
| 41 | 47 |
| 42 -- Scan availabe recipes | 48 -- Scan availabe recipes |
| 43 A:ScanSimpleRecipes() | 49 A:ScanSimpleRecipes() |
| 50 end | |
| 51 end | |
| 52 A.EventsFrame:SetScript("OnEvent", function(self, event) | |
| 53 print(self,event) | |
| 54 if event == "TRADE_SKILL_UPDATE" then | |
| 55 t_throttle = SCAN_DELAY | |
| 56 self:SetScript("OnUpdate", throttleScan) | |
| 57 | |
| 58 --[[ | |
| 59 -- Close the external window if the tradeskill changed | |
| 60 if A.currentTradeSkill ~= GetTradeSkillLine() then | |
| 61 A.MenuFrame:Hide() | |
| 62 end | |
| 63 | |
| 64 if IsTradeSkillGuild() or IsTradeSkillLinked() then | |
| 65 A.MenuFrame:Hide() | |
| 66 return | |
| 67 end | |
| 68 | |
| 69 -- Scan availabe recipes | |
| 70 A:ScanSimpleRecipes() | |
| 71 --]] | |
| 44 | 72 |
| 45 elseif event == "TRADE_SKILL_SHOW" then | 73 elseif event == "TRADE_SKILL_SHOW" then |
| 46 if IsTradeSkillGuild() or IsTradeSkillLinked() then | |
| 47 A.MenuFrame:Hide() | |
| 48 return | |
| 49 end | |
| 50 A:Initialize() | 74 A:Initialize() |
| 51 A.EventsFrame:UnregisterEvent("TRADE_SKILL_SHOW") | 75 A.EventsFrame:UnregisterEvent("TRADE_SKILL_SHOW") |
| 52 end -- if | 76 end -- if |
| 53 end) -- function | 77 end) -- function |
| 54 A.EventsFrame:RegisterEvent("TRADE_SKILL_SHOW") | 78 A.EventsFrame:RegisterEvent("TRADE_SKILL_SHOW") |
