diff Modules/Config.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 a12d22ef3f39
children 6ae44d372360
line wrap: on
line diff
--- a/Modules/Config.lua	Sun Jan 09 01:34:05 2011 +0100
+++ b/Modules/Config.lua	Sun Jan 09 17:49:33 2011 +0100
@@ -104,7 +104,7 @@
 			local groupName = groupIdToName[groupId];
 			
 			if not itemData:AddToGroup(groupName) then
-				print("|cffff0000Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.|r");
+				addon:Print("Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.", addon.Colors.Red);
 			end
 			
 			if AceConfigRegistry then
@@ -893,14 +893,14 @@
 									local itemData = addon.ItemData:New(itemId);
 									
 									if itemData:AddToGroup(groupName) then
-										addon.Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green);
+										addon:Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green);
 										
 										if AceConfigRegistry then
 											-- Now rebuild the list
 											AceConfigRegistry:NotifyChange("InventoriumOptions");
 										end
 									else
-										addon.Print(("%s is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red);
+										addon:Print(("%s is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red);
 									end
 								end
 							end,
@@ -923,12 +923,13 @@
 										local itemData = addon.ItemData:New(itemId);
 										
 										if itemData:InGroup() then
-											addon.Print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(itemData.link or "Unknown", itemId, itemData:InGroup()), addon.Colors.Red);
+											addon:Print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(itemData.link or "Unknown", itemId, itemData:InGroup()), addon.Colors.Red);
+											addon:Print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(itemData.link or "Unknown", itemId, itemData:InGroup()), addon.Colors.Red);
 										elseif itemData:AddToGroup(groupName) then
-											addon.Print(("Added %s to the group |cfffed000%s|r."):format(itemData.link or unknownItemName:format(itemId), groupName), addon.Colors.Green);
+											addon:Print(("Added %s to the group |cfffed000%s|r."):format(itemData.link or unknownItemName:format(itemId), groupName), addon.Colors.Green);
 										end
 									else
-										addon.Print(("\"%s\" is not a number."):format(value), addon.Colors.Red);
+										addon:Print(("\"%s\" is not a number."):format(value), addon.Colors.Red);
 									end
 								end
 								
@@ -955,7 +956,7 @@
 							set = function(info, value)
 								local groupName = groupIdToName[info[2]];
 								
-								print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(value));
+								addon:Print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(value));
 								
 								-- Remember we imported this group and it's version so if it is ever changed, people can be notified
 								if not addon.db.profile.groups[groupName].premadeGroups then
@@ -971,11 +972,11 @@
 										local itemData = addon.ItemData:New(itemId);
 										
 										if not itemId then
-											addon.Print(("\"|cfffed000%s|r\" is not a number."):format(value), addon.Colors.Red);
+											addon:Print(("\"|cfffed000%s|r\" is not a number."):format(value), addon.Colors.Red);
 										elseif itemData:InGroup() then
-											addon.Print(("Skipping |cfffed000%s|r as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red);
+											addon:Print(("Skipping |cfffed000%s|r as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red);
 										elseif itemData:AddToGroup(groupName) then
-											addon.Print(("Added %s to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), groupName ), addon.Colors.Green);
+											addon:Print(("Added %s to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), groupName ), addon.Colors.Green);
 										end
 									end
 								end
@@ -1020,9 +1021,9 @@
 										
 										if itemData.name:lower():find(value) then
 									    	if itemData:AddToGroup(groupName) then
-												addon.Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green);
+												addon:Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green);
 									    	else
-									    		addon.Print(("Couldn't add %s because it is already in a group."):format(itemData.link or unknownItemName:format(itemId)), addon.Colors.Red);
+									    		addon:Print(("Couldn't add %s because it is already in a group."):format(itemData.link or unknownItemName:format(itemId)), addon.Colors.Red);
 									    	end
 										end
 									end
@@ -1120,7 +1121,7 @@
 										if itemData.name:lower():find(value) then
 											itemData:RemoveFromGroup(groupName);
 											
-											addon.Print(("Removed %s from the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Red);
+											addon:Print(("Removed %s from the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Red);
 										end
 									end
 								end
@@ -1157,7 +1158,7 @@
 							    	
 							    	addon.db.profile.groups[groupName].premadeGroups[value] = nil;
 							    	
-							    	print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value));
+							    	addon:Print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value));
 						    	end
 							end,
 							get = false,
@@ -1959,13 +1960,13 @@
 								local result, temp = AceSerializer:Deserialize(current);
 								
 								if not temp.name then
-									print("|cffff0000The provided data is not supported.|r");
+									addon:Print("The provided data is not supported.", addon.Colors.Red);
 								elseif ValidateGroupName(nil, temp.name) ~= true then
-									print(("|cffff0000Aborting: A group named \"%s\" already exists.|r"):format(temp.name));
+									addon:Print(("Aborting: A group named \"%s\" already exists."):format(temp.name), addon.Colors.Red);
 								else
 									local name = temp.name;
 									temp.name = nil;
-									print(("Importing %s..."):format(name));
+									addon:Print(("Importing %s..."):format(name));
 									
 									if temp.items then
 										-- Remove items that are already in another group
@@ -1975,10 +1976,10 @@
 											local itemData = addon.ItemData:New(itemId);
 											
 											if not itemId then
-												print(("\"%s\" is not a number."):format(value));
+												addon:Print(("\"%s\" is not a number."):format(value), addon.Colors.Red);
 												temp.items[value] = nil;
 											elseif itemData:InGroup() then
-												print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
+												addon:Print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red);
 												temp.items[value] = nil;
 											else
 												-- Ensure the keys are numeric
@@ -2066,17 +2067,17 @@
 									-- This item was added in a more recent version than this group: Add item
 									
 									if itemData:InGroup() then
-										print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
+										addon:Print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
 									elseif itemData:AddToGroup(groupName) then
-										addon.Print(("Added %s found in the premade group |cfffed000%s|r to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), premadeGroupName, itemData:InGroup() ), addon.Colors.Green);
+										addon:Print(("Added %s found in the premade group |cfffed000%s|r to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), premadeGroupName, itemData:InGroup() ), addon.Colors.Green);
 									end
 								elseif ( version * -1 ) > values.premadeGroups[premadeGroupName] then
 									if itemData:InGroup() == groupName then
 										itemData:RemoveFromGroup(groupName);
 										
-										addon.Print(("Removed %s from the group |cfffed000%s|r as it was removed from the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup(), premadeGroupName ), addon.Colors.Red);
+										addon:Print(("Removed %s from the group |cfffed000%s|r as it was removed from the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup(), premadeGroupName ), addon.Colors.Red);
 									else
-										print(("Skipping the removal of %s as it isn't in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
+										addon:Print(("Skipping the removal of %s as it isn't in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
 									end
 								end
 							end
@@ -2100,7 +2101,7 @@
 								if version > values.premadeGroups[premadeGroupName] then
 									-- This item was added in a more recent version than this group: don't add (since we clicked no), but announce it
 									
-									print(("Skipping %s found in the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
+									addon:Print(("Skipping %s found in the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
 								end
 							end