changeset 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 2443cee61262
children 2d8afaa4fb9d
files Modules/Alerts.lua Modules/Config.lua
diffstat 2 files changed, 52 insertions(+), 40 deletions(-) [+]
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()
--- a/Modules/Config.lua	Sun Jan 30 15:48:18 2011 +0100
+++ b/Modules/Config.lua	Sun Jan 30 20:53:13 2011 +0100
@@ -492,6 +492,11 @@
 							desc = "Automatically refill items from your storage (bank/mailbox - unless this is included in the local count - or the guild bank) when below the minimum local stock.",
 							arg = "overrideAutoRefill",
 						},
+						spacer = {
+							order = 19,
+							type = "description",
+							name = "",
+						},
 						
 						overrideMinGlobalStock = {
 							order = 20,
@@ -1562,6 +1567,11 @@
 						get = function() return addon.db.profile.defaults.autoRefill; end,
 						set = function(i, v) addon.db.profile.defaults.autoRefill = v; end,
 					},
+					spacer = {
+						order = 19,
+						type = "description",
+						name = "",
+					},
 					
 					minGlobalStock = {
 						order = 20,
@@ -1888,8 +1898,8 @@
 						name = "Stock scan speed",
 						desc = "Select the speed at which items should be scanned for stock alerts. Faster requires more resources and may drastically reduce your frame rate during a scan.",
 						values = {
-							["0"] = "Instant", -- chains everything, no delay used
-							["0.01"] = "Very fast", -- < 100 fps: once every frame, >= 100 fps, 100 scans per second
+							["0"] = "(Near) instant", -- scans in steps of 100
+							["0.01"] = "Very fast", -- scans in steps of 2
 							["0.05"] = "Fast",
 							["0.1"] = "Default",
 							["0.2"] = "Medium",
@@ -1903,7 +1913,6 @@
 						order = 26,
 						type = "description",
 						name = "",
-						width = "double",
 					},
 					removeCharacter = {
 						order = 30,