diff Modules/Mover.lua @ 98:252292b703ce

All print(...) function calls are now handled by addon:Print(text, color). The cursor will be cleared of any items/spells before moving as well as when aborting.
author Zerotorescue
date Sun, 09 Jan 2011 17:49:33 +0100
parents 31493364b163
children 6ae44d372360
line wrap: on
line diff
--- a/Modules/Mover.lua	Sun Jan 09 01:34:05 2011 +0100
+++ b/Modules/Mover.lua	Sun Jan 09 17:49:33 2011 +0100
@@ -49,7 +49,7 @@
 	for _, singleMove in pairs(queuedMoves) do
 		local sourceItem = sourceContents[singleMove.id];
 		if not sourceItem then
-			print("Can't move " .. IdToItemLink(singleMove.id) .. ", non-existant in source");
+			addon:Print("Can't move " .. IdToItemLink(singleMove.id) .. ", this doesn't exist in the source.", addon.Colors.Red);
 		else
 			-- We want to move the smallest stacks first to keep stuff pretty (and minimize space usage, splitting a stack takes 2 slots, moving something only 1)
 			table.sort(sourceItem.locations, function(a, b)
@@ -132,7 +132,7 @@
 					local firstAvailableSlot = emptySlots[1];
 					
 					if not firstAvailableSlot then
-						print("Bags are full. Skipping " .. IdToItemLink(outgoingMove.itemId) .. ".");
+						addon:Print(("Bags are full. Skipping %s."):format(IdToItemLink(outgoingMove.itemId)), addon.Colors.Orange);
 						
 						outgoingMove.itemId = nil; -- remove this record from the outgoingMoves-table
 					else
@@ -260,14 +260,16 @@
 	addon:Debug("ProcessMove");
 	
 	if #combinedMoves == 0 then
-		print("Nothing to move.");
+		addon:Print("Nothing to move.");
 		
 		self:Abort();
 		
 		return;
 	end
 	
-	--self:RegisterEvent("BAG_UPDATE");
+	-- Make sure nothing is at the mouse
+	ClearCursor();
+	
 	self:RegisterEvent("ITEM_LOCK_CHANGED");
 	self:RegisterEvent("UI_ERROR_MESSAGE");
 	
@@ -298,7 +300,7 @@
 		
 		if move and not isSourceLocked and not isTargetLocked then
 			
-			print(("Moving %dx%s."):format(move.num, IdToItemLink(move.itemId)));
+			addon:Print(("Moving %dx%s."):format(move.num, IdToItemLink(move.itemId)));
 			
 			addon:Debug("Moving %dx%s from (%d,%d) to (%d,%d)", move.num, IdToItemLink(move.itemId), move.sourceContainer, move.sourceSlot, move.targetContainer, move.targetSlot);
 			
@@ -352,7 +354,7 @@
 	addon:Debug("%d moves processed. %d moves remaining.", (combinedMovesOriginalLength - #combinedMoves), #combinedMoves);
 	
 	if #combinedMoves == 0 then
-		print("Finished.");
+		addon:Print("Finished.", addon.Colors.Green);
 		
 		self:Abort();
 		
@@ -383,11 +385,14 @@
 		addon:Debug("Aborting:%s", debugMsg);
 	end
 	if simple then
-		print("|cffff0000Aborting: " .. simple .. ".|r");
+		addon:Print(("Aborting: %s."):format(simple), addon.Colors.Red);
 	end
 	table.wipe(combinedMoves);
 	movesSource = nil;
 	
+	-- Make sure nothing is at the mouse
+	ClearCursor();
+	
 	-- Stop timer
 	self:UnregisterEvent("ITEM_LOCK_CHANGED");
 	self:CancelTimer(tmrProcessNext, true); -- silent