Mercurial > wow > inventory
comparison 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 | 
   comparison
  equal
  deleted
  inserted
  replaced
| 8:1f30a9ac9027 | 9:3bac0bdd59e2 | 
|---|---|
| 264 function addon:CommandHandler(message) | 264 function addon:CommandHandler(message) | 
| 265 local cmd, arg = string.split(" ", (message or ""), 2); | 265 local cmd, arg = string.split(" ", (message or ""), 2); | 
| 266 cmd = string.lower(cmd); | 266 cmd = string.lower(cmd); | 
| 267 | 267 | 
| 268 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 | 268 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 | 
| 269 -- We don't want any other windows open at this time. | |
| 270 for name, module in self:IterateModules() do | |
| 271 if module.CloseFrame then | |
| 272 module:CloseFrame(); | |
| 273 end | |
| 274 end | |
| 275 | |
| 269 self:Show(); | 276 self:Show(); | 
| 270 elseif cmd == "d" or cmd == "debug" then | 277 elseif cmd == "d" or cmd == "debug" then | 
| 271 self.debugChannel = false; | 278 self.debugChannel = false; | 
| 272 for i = 1, NUM_CHAT_WINDOWS do | 279 for i = 1, NUM_CHAT_WINDOWS do | 
| 273 local name = GetChatWindowInfo(i); | 280 local name = GetChatWindowInfo(i); | 
| 289 print("New debug channel created."); | 296 print("New debug channel created."); | 
| 290 end | 297 end | 
| 291 elseif slashArgs[cmd] then | 298 elseif slashArgs[cmd] then | 
| 292 slashArgs[cmd](); | 299 slashArgs[cmd](); | 
| 293 else | 300 else | 
| 294 print("Wrong command, available: /inventory config (or /inventory c)"); | 301 print("Wrong command, available: /inventory config (or /iy c) and /inventory summary (or /iy s)"); | 
| 295 end | 302 end | 
| 296 end | 303 end | 
| 297 | 304 | 
| 298 function addon:Load() | 305 function addon:Load() | 
| 299 if not AceConfigDialog and not AceConfigRegistry then | 306 if not AceConfigDialog and not AceConfigRegistry then | 
| 1208 local groupName = groupIdToName[info[2]]; | 1215 local groupName = groupIdToName[info[2]]; | 
| 1209 | 1216 | 
| 1210 -- We want to include the group name, so we copy the table then set another value | 1217 -- We want to include the group name, so we copy the table then set another value | 
| 1211 local temp = CopyTable(addon.db.global.groups[groupName]); | 1218 local temp = CopyTable(addon.db.global.groups[groupName]); | 
| 1212 temp.name = groupName; | 1219 temp.name = groupName; | 
| 1220 temp.trackAtCharacters = nil; | |
| 1221 temp.overrideTrackAtCharacters = nil; | |
| 1213 | 1222 | 
| 1214 if not AceSerializer then | 1223 if not AceSerializer then | 
| 1215 AceSerializer = LibStub("AceSerializer-3.0"); | 1224 AceSerializer = LibStub("AceSerializer-3.0"); | 
| 1216 end | 1225 end | 
| 1217 | 1226 | 
| 1436 type = "input", | 1445 type = "input", | 
| 1437 multiline = true, | 1446 multiline = true, | 
| 1438 name = "Group data", | 1447 name = "Group data", | 
| 1439 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.", | 1448 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.", | 
| 1440 set = function(info, value) | 1449 set = function(info, value) | 
| 1441 local temp = { string.split("\n", value or "") }; | 1450 local data = { string.split("\n", value or "") }; | 
| 1442 | 1451 | 
| 1443 for no, current in pairs(temp) do | 1452 for _, current in pairs(data) do | 
| 1444 if not AceSerializer then | 1453 if not AceSerializer then | 
| 1445 AceSerializer = LibStub("AceSerializer-3.0"); | 1454 AceSerializer = LibStub("AceSerializer-3.0"); | 
| 1446 end | 1455 end | 
| 1447 | 1456 | 
| 1448 local result, temp = AceSerializer:Deserialize(current); | 1457 local result, temp = AceSerializer:Deserialize(current); | 
| 1452 print("|cffff0000The provided data is not supported.|r"); | 1461 print("|cffff0000The provided data is not supported.|r"); | 
| 1453 return; | 1462 return; | 
| 1454 else | 1463 else | 
| 1455 name = temp.name; | 1464 name = temp.name; | 
| 1456 temp.name = nil; | 1465 temp.name = nil; | 
| 1466 print(("Importing %s..."):format(name)); | |
| 1457 end | 1467 end | 
| 1458 | 1468 | 
| 1459 local newGroupName = string.trim(string.lower(name or "")); | 1469 local newGroupName = string.trim(string.lower(name or "")); | 
| 1460 | 1470 | 
| 1461 for name in pairs(self.db.global.groups) do | 1471 for name in pairs(self.db.global.groups) do | 
| 1462 if string.lower(name) == newGroupName then | 1472 if string.lower(name) == newGroupName then | 
| 1463 print(("|cffff0000A group named \"%s\" already exists.|r"):format(name)); | 1473 print(("|cffff0000Aborting: A group named \"%s\" already exists.|r"):format(name)); | 
| 1464 return; | 1474 return; | 
| 1465 end | 1475 end | 
| 1466 end | 1476 end | 
| 1467 | 1477 | 
| 1478 -- Remove items that are already in another group | |
| 1479 for value, _ in pairs(temp.items) do | |
| 1480 local itemId = tonumber(itemid); | |
| 1481 | |
| 1482 if not itemId then | |
| 1483 print(("\"%s\" is not a number."):format(value)); | |
| 1484 temp.items[value] = nil; | |
| 1485 elseif InGroup(itemId) then | |
| 1486 print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, InGroup(itemId))); | |
| 1487 temp.items[value] = nil; | |
| 1488 else | |
| 1489 -- Ensure the keys are numeric | |
| 1490 temp.items[value] = nil; | |
| 1491 temp.items[itemId] = true; | |
| 1492 end | |
| 1493 end | |
| 1494 | |
| 1495 -- Ensure this data isn't received (this would be buggy as exports from other accounts won't know what to do with this) | |
| 1496 temp.trackAtCharacters = nil; | |
| 1497 temp.overrideTrackAtCharacters = nil; | |
| 1498 | |
| 1468 self.db.global.groups[name] = temp; | 1499 self.db.global.groups[name] = temp; | 
| 1469 | 1500 | 
| 1470 self:FillGroupOptions(); | 1501 self:FillGroupOptions(); | 
| 1471 end | 1502 end | 
| 1472 end, | 1503 end, | 
