comparison 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
comparison
equal deleted inserted replaced
183:2443cee61262 184:679d3664849d
10 -- /im alert 10 -- /im alert
11 addon:RegisterSlash(function(this) 11 addon:RegisterSlash(function(this)
12 mod:Scan(true); 12 mod:Scan(true);
13 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."); 13 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.");
14 14
15 self:RegisterEvent("PLAYER_LOGIN", function() 15 mod:Scan(false);
16 mod:Scan(false);
17 end);
18 16
19 --[[if addon.db.profile.defaults.scanInterval["00Login"] then 17 --[[if addon.db.profile.defaults.scanInterval["00Login"] then
20 self:RegisterEvent("PLAYER_LOGIN", "Scan"); 18 self:RegisterEvent("PLAYER_LOGIN", "Scan");
21 end 19 end
22 20
106 function mod:HasQueue() 104 function mod:HasQueue()
107 return (#queue > 0); 105 return (#queue > 0);
108 end 106 end
109 107
110 function mod:ProcessScan(verbal) 108 function mod:ProcessScan(verbal)
111 local thisItem = table.remove(queue, 1);
112
113 if not thisItem then
114 self:ScanFinished();
115 return;
116 end
117
118 if thisItem.type == scanTypes.Global then
119 local globalCount = addon:GetItemCount(thisItem.itemId, thisItem.group.name);
120
121 if not cache[thisItem.itemId] then
122 cache[thisItem.itemId] = {
123 ["itemId"] = thisItem.itemId, -- needed later for displaying
124 ["group"] = thisItem.group,
125 ["globalCount"] = globalCount,
126 };
127 else
128 cache[thisItem.itemId].globalCount = globalCount;
129 end
130 elseif thisItem.type == scanTypes.Local then
131 local localCount = addon:GetLocalItemCount(thisItem.itemId, thisItem.group.name);
132
133 if not cache[thisItem.itemId] then
134 cache[thisItem.itemId] = {
135 ["itemId"] = thisItem.itemId, -- needed later for displaying
136 ["group"] = thisItem.group,
137 ["localCount"] = localCount,
138 };
139 else
140 cache[thisItem.itemId].globalCount = localCount;
141 end
142 end
143
144 local nextScanDelay = (tonumber(addon.db.profile.defaults.scanInterval) or .1); 109 local nextScanDelay = (tonumber(addon.db.profile.defaults.scanInterval) or .1);
145 110 local runs = (0.1 / nextScanDelay); -- 0.01 = 10, 0.05 = 2, 0.1 and smaller = 1
146 if nextScanDelay == 0 then 111 runs = (runs < 1 and 1) or runs;
112 runs = (nextScanDelay == 0 and 100) or runs;
113
114 for no = 1, runs do
115 -- Get the last item added to the queue
116 local thisItem = table.remove(queue, 1);
117
118 if not thisItem then
119 -- If no item exists then we processed everything, show summary
120 self:ScanFinished();
121 return;
122 end
123
124 if thisItem.type == scanTypes.Global then
125 -- Global scan
126 local globalCount = addon:GetItemCount(thisItem.itemId, thisItem.group.name);
127
128 if not cache[thisItem.itemId] then
129 cache[thisItem.itemId] = {
130 ["itemId"] = thisItem.itemId, -- needed later for displaying
131 ["group"] = thisItem.group,
132 ["globalCount"] = globalCount,
133 };
134 else
135 cache[thisItem.itemId].globalCount = globalCount;
136 end
137 elseif thisItem.type == scanTypes.Local then
138 -- Local scan
139 local localCount = addon:GetLocalItemCount(thisItem.itemId, thisItem.group.name);
140
141 if not cache[thisItem.itemId] then
142 cache[thisItem.itemId] = {
143 ["itemId"] = thisItem.itemId, -- needed later for displaying
144 ["group"] = thisItem.group,
145 ["localCount"] = localCount,
146 };
147 else
148 cache[thisItem.itemId].globalCount = localCount;
149 end
150 end
151 end
152
153 self:ScheduleTimer(function()
147 mod:ProcessScan(verbal); 154 mod:ProcessScan(verbal);
148 else 155 end, nextScanDelay); -- scan next item in nextScanDelay seconds
149 self:ScheduleTimer(function()
150 mod:ProcessScan(verbal);
151 end, nextScanDelay); -- scan next item in nextScanDelay seconds
152 end
153 end 156 end
154 157
155 local function OnProceed() 158 local function OnProceed()
156 InventoriumCommandHandler("summary"); 159 InventoriumCommandHandler("summary");
157 160