diff Core.lua @ 9:3bac0bdd59e2

Close the summary frame when opening the config. Remove ?track at? data when exporting/importing a group. Don?t add items when importing a group that are already inside a group.
author Zerotorescue
date Sun, 10 Oct 2010 04:37:21 +0200
parents 1a815139e4c3
children c4d0e5d47e10
line wrap: on
line diff
--- a/Core.lua	Fri Oct 08 17:11:05 2010 +0200
+++ b/Core.lua	Sun Oct 10 04:37:21 2010 +0200
@@ -266,6 +266,13 @@
 	cmd = string.lower(cmd);
 	
 	if cmd == "c" or cmd == "config" or cmd == "conf" or cmd == "option" or cmd == "options" or cmd == "opt" or cmd == "setting" or cmd == "settings" then
+		-- We don't want any other windows open at this time.
+		for name, module in self:IterateModules() do
+			if module.CloseFrame then
+				module:CloseFrame();
+			end
+		end
+		
 		self:Show();
 	elseif cmd == "d" or cmd == "debug" then
 		self.debugChannel = false;
@@ -291,7 +298,7 @@
 	elseif slashArgs[cmd] then
 		slashArgs[cmd]();
 	else
-		print("Wrong command, available: /inventory config (or /inventory c)");
+		print("Wrong command, available: /inventory config (or /iy c) and /inventory summary (or /iy s)");
 	end
 end
 
@@ -1210,6 +1217,8 @@
 								-- We want to include the group name, so we copy the table then set another value
 								local temp = CopyTable(addon.db.global.groups[groupName]);
 								temp.name = groupName;
+								temp.trackAtCharacters = nil;
+								temp.overrideTrackAtCharacters = nil;
 								
 								if not AceSerializer then
 									AceSerializer = LibStub("AceSerializer-3.0");
@@ -1438,9 +1447,9 @@
 						name = "Group data",
 						desc = "Paste the group data as provided by a group export. If you are trying to import multiple groups at the same time, make sure to use newlines to seperate them.",
 						set = function(info, value)
-							local temp = { string.split("\n", value or "") };
+							local data = { string.split("\n", value or "") };
 							
-							for no, current in pairs(temp) do
+							for _, current in pairs(data) do
 								if not AceSerializer then
 									AceSerializer = LibStub("AceSerializer-3.0");
 								end
@@ -1454,17 +1463,39 @@
 								else
 									name = temp.name;
 									temp.name = nil;
+									print(("Importing %s..."):format(name));
 								end
 								
 								local newGroupName = string.trim(string.lower(name or ""));
 								
 								for name in pairs(self.db.global.groups) do
 									if string.lower(name) == newGroupName then
-										print(("|cffff0000A group named \"%s\" already exists.|r"):format(name));
+										print(("|cffff0000Aborting: A group named \"%s\" already exists.|r"):format(name));
 										return;
 									end
 								end
-							
+								
+								-- Remove items that are already in another group
+								for value, _ in pairs(temp.items) do
+									local itemId = tonumber(itemid);
+									
+									if not itemId then
+										print(("\"%s\" is not a number."):format(value));
+										temp.items[value] = nil;
+									elseif InGroup(itemId) then
+										print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, InGroup(itemId)));
+										temp.items[value] = nil;
+									else
+										-- Ensure the keys are numeric
+										temp.items[value] = nil;
+										temp.items[itemId] = true;
+									end
+								end
+								
+								-- Ensure this data isn't received (this would be buggy as exports from other accounts won't know what to do with this)
+								temp.trackAtCharacters = nil;
+								temp.overrideTrackAtCharacters = nil;
+								
 								self.db.global.groups[name] = temp;
 								
 								self:FillGroupOptions();