Mercurial > wow > inventory
diff Modules/Alerts.lua @ 184:679d3664849d
The stock alert should now properly scan immediately after a login.
Setting the stock scan speed at fast or higher now properly speeds things up when your FPS is below 100.
Renamed ?instant? speed to ?(Near) instant? and changed it to 100 steps per scan rather than everything at once.
author | Zerotorescue |
---|---|
date | Sun, 30 Jan 2011 20:53:13 +0100 |
parents | 26c750a10b14 |
children | 5cee31b1418a |
line wrap: on
line diff
--- a/Modules/Alerts.lua Sun Jan 30 15:48:18 2011 +0100 +++ b/Modules/Alerts.lua Sun Jan 30 20:53:13 2011 +0100 @@ -12,9 +12,7 @@ mod:Scan(true); end, { "a", "alert" }, "|Hfunction:InventoriumCommandHandler:alert|h|cff00fff7/im alert|r|h (or /im a) - Rescan the items within all tracked groups and show item alerts for those items missing."); - self:RegisterEvent("PLAYER_LOGIN", function() - mod:Scan(false); - end); + mod:Scan(false); --[[if addon.db.profile.defaults.scanInterval["00Login"] then self:RegisterEvent("PLAYER_LOGIN", "Scan"); @@ -108,48 +106,53 @@ end function mod:ProcessScan(verbal) - local thisItem = table.remove(queue, 1); + local nextScanDelay = (tonumber(addon.db.profile.defaults.scanInterval) or .1); + local runs = (0.1 / nextScanDelay); -- 0.01 = 10, 0.05 = 2, 0.1 and smaller = 1 + runs = (runs < 1 and 1) or runs; + runs = (nextScanDelay == 0 and 100) or runs; - if not thisItem then - self:ScanFinished(); - return; - end - - if thisItem.type == scanTypes.Global then - local globalCount = addon:GetItemCount(thisItem.itemId, thisItem.group.name); + for no = 1, runs do + -- Get the last item added to the queue + local thisItem = table.remove(queue, 1); - if not cache[thisItem.itemId] then - cache[thisItem.itemId] = { - ["itemId"] = thisItem.itemId, -- needed later for displaying - ["group"] = thisItem.group, - ["globalCount"] = globalCount, - }; - else - cache[thisItem.itemId].globalCount = globalCount; + if not thisItem then + -- If no item exists then we processed everything, show summary + self:ScanFinished(); + return; end - elseif thisItem.type == scanTypes.Local then - local localCount = addon:GetLocalItemCount(thisItem.itemId, thisItem.group.name); - if not cache[thisItem.itemId] then - cache[thisItem.itemId] = { - ["itemId"] = thisItem.itemId, -- needed later for displaying - ["group"] = thisItem.group, - ["localCount"] = localCount, - }; - else - cache[thisItem.itemId].globalCount = localCount; + if thisItem.type == scanTypes.Global then + -- Global scan + local globalCount = addon:GetItemCount(thisItem.itemId, thisItem.group.name); + + if not cache[thisItem.itemId] then + cache[thisItem.itemId] = { + ["itemId"] = thisItem.itemId, -- needed later for displaying + ["group"] = thisItem.group, + ["globalCount"] = globalCount, + }; + else + cache[thisItem.itemId].globalCount = globalCount; + end + elseif thisItem.type == scanTypes.Local then + -- Local scan + local localCount = addon:GetLocalItemCount(thisItem.itemId, thisItem.group.name); + + if not cache[thisItem.itemId] then + cache[thisItem.itemId] = { + ["itemId"] = thisItem.itemId, -- needed later for displaying + ["group"] = thisItem.group, + ["localCount"] = localCount, + }; + else + cache[thisItem.itemId].globalCount = localCount; + end end end - local nextScanDelay = (tonumber(addon.db.profile.defaults.scanInterval) or .1); - - if nextScanDelay == 0 then + self:ScheduleTimer(function() mod:ProcessScan(verbal); - else - self:ScheduleTimer(function() - mod:ProcessScan(verbal); - end, nextScanDelay); -- scan next item in nextScanDelay seconds - end + end, nextScanDelay); -- scan next item in nextScanDelay seconds end local function OnProceed()