diff Modules/Scanner.lua @ 111:41f0689dfda1

This implementation of vendor buying did not work well. Too many customizations were needed that made the code hard to read and understand and eventually it was found that vendor buying should be based on refill target, not local stock. The mover/refiller is not meant for this, we should just do this somewhere else.
author Zerotorescue
date Fri, 14 Jan 2011 23:31:12 +0100
parents 67bd5057ecb7
children 239e25a058c7
line wrap: on
line diff
--- a/Modules/Scanner.lua	Fri Jan 14 23:25:05 2011 +0100
+++ b/Modules/Scanner.lua	Fri Jan 14 23:31:12 2011 +0100
@@ -18,7 +18,7 @@
 	InventoriumItemMover:Hide();
 end
 
-local function UseStorageRefillST(withPrices)
+local function UseStorageRefillST()
 	local frame = InventoriumItemMover; -- both for speed as code-consistency
 	
 	-- Scrolling table with a list of items to be moved
@@ -26,7 +26,7 @@
 	local headers = {
 		{
 			["name"] = "Item",
-			["width"] = (scrollTableWidth * ((withPrices and .5) or .60)),
+			["width"] = (scrollTableWidth * .60),
 			["defaultsort"] = "asc",
 			["comparesort"] = function(this, aRow, bRow, column)
 				local aName, _, aRarity = GetItemInfo(this:GetRow(aRow).rowData.itemId);
@@ -56,7 +56,7 @@
 		},
 		{
 			["name"] = "Available",
-			["width"] = (scrollTableWidth * ((withPrices and .2) or .25)),
+			["width"] = (scrollTableWidth * .25),
 			["align"] = "RIGHT",
 			["defaultsort"] = "dsc",
 			["sortnext"] = 1,
@@ -74,17 +74,6 @@
 			["tooltip"] = (not addon.db.profile.defaults.hideHelp and "Click to sort the list by the availibility percentage."),
 		},
 	};
-	if withPrices then
-		table.insert(headers, {
-			["name"] = "Price",
-			["width"] = (scrollTableWidth * .15),
-			["align"] = "RIGHT",
-			["defaultsort"] = "dsc",
-			["sortnext"] = 1,
-			["tooltipTitle"] = (not addon.db.profile.defaults.hideHelp and "Price"),
-			["tooltip"] = (not addon.db.profile.defaults.hideHelp and "Click to sort the list by the price of this item at this vendor."),
-		});
-	end
 	
 	local proceedButton = {
 		text = "Move Items",
@@ -211,28 +200,6 @@
 				end
 			end
 		end
-	elseif location == addon.Locations.Merchant then
-		for itemIndex = 1, GetMerchantNumItems() do
-			-- All merchant items
-			
-			local itemLink = GetMerchantItemLink(itemIndex);
-			local itemId = itemLink and addon:GetItemId(itemLink);
-			local _, _, vendorValue, _, numAvailable, _, extendedCost = GetMerchantItemInfo(index);
-			
-			if itemLink and itemId and numAvailable ~= 0 and not extendedCost then
-				local itemMove;
-				if not itemCache[itemId] then
-					-- If this is the first time we see this item, make a new object
-					itemMove = addon.ContainerItem:New();
-					itemCache[itemId] = itemMove;
-				else
-					-- If we had this item in another slot too
-					itemMove = itemCache[itemId];
-				end
-				
-				itemMove:AddLocation(1, itemIndex, numAvailable, vendorValue);
-			end
-		end
 	else
 		error("Invalid location provided for CacheLocation. Must be Bank or Guild.");
 	end
@@ -282,12 +249,12 @@
 					-- Check how many are available
 					local availableItems = ((itemCache[itemId] and itemCache[itemId].totalCount) or 0);
 					-- Calculate how many we'll be moving (less missing than available? use missing, otherwise use available)
-					local moving = (((availableItems == -1 or missingItems <= availableItems) and missingItems) or availableItems);
+					local moving = ((missingItems <= availableItems and missingItems) or availableItems);
 					
-					if availableItems ~= 0 then
-						addon:Debug("Insufficient %s but this location has %s (moving %d)", IdToItemLink(itemId), ((availableItems == -1 and "unlimited") or availableItems), moving);
+					if availableItems > 0 then
+						addon:Debug("Insufficient %s but this location has %d (moving %d)", IdToItemLink(itemId), availableItems, moving);
 						
-						Mover:AddMove(itemId, moving, missingItems, availableItems, itemCache[itemId]:GetVendorPrice());
+						Mover:AddMove(itemId, moving, missingItems, availableItems);
 					end
 				end
 			end
@@ -300,7 +267,7 @@
 		if addon.db.profile.defaults.autoRefillSkipConfirm then
 			OnMoveAccept();
 		else
-			UseStorageRefillST((location == addon.Locations.Merchant));
+			UseStorageRefillST();
 			
 			-- This table is never copied, just referenced. It is the same for every row.
 			local columns = {
@@ -323,13 +290,6 @@
 					end,
 				}, -- missing / available
 			};
-			if location == addon.Locations.Merchant then
-				table.insert(columns, {
-					["value"] = function(data, cols, realrow, column, table)
-						return GetCoinTextureString(data[realrow].rowData.price * data[realrow].rowData.num);
-					end,
-				});
-			end
 			
 			-- Store the list with rows in this
 			local data = {};
@@ -426,25 +386,6 @@
 	self:RegisterEvent("GUILDBANKBAGSLOTS_CHANGED");
 end
 
-function mod:MERCHANT_SHOW()
-	addon:Debug("Scanner:MERCHANT_SHOW");
-	
-	self:RegisterEvent("MERCHANT_CLOSED");
-	
-	self:Scan(addon.Locations.Merchant);
-end
-
-function mod:MERCHANT_CLOSED()
-	addon:Debug("Scanner:MERCHANT_CLOSED");
-	
-	self:ClearCache();
-	
-	self:UnregisterEvent("MERCHANT_CLOSED");
-	
-	InventoriumItemMover:Hide();
-	Mover:ResetQueue();
-end
-
 --local previousMailCount;
 --function mod:MAIL_SHOW()
 --	addon:Debug("Scanner:MAIL_SHOW");
@@ -498,7 +439,6 @@
 	self:RegisterEvent("BANKFRAME_OPENED");
 	self:RegisterEvent("GUILDBANKFRAME_OPENED");
 --	self:RegisterEvent("MAIL_SHOW");
-	self:RegisterEvent("MERCHANT_SHOW");
 	
 	Mover = addon:GetModule("Mover");