Mercurial > wow > inventory
comparison Core.lua @ 17:8f5c02113c5c
Reduced the softmax of most ranges from 1.000 to 100. This should make them actually useful. You can still manually enter an amount below the sliders of up to 100.000.
The help text for the ?Replenishing stock? category now includes bonus queue information.
Added an option to the ?add items? tab called ?Import premade data? which allows a user to import item data from a premade group shipped with the addon. If this premade data ever changes, the user will be notified and queried for an update.
Added a ?mass remove? option to the ?current items? tab.
Item data should be imported again when importing a complete group.
Added ?DataStore (current account only)?, ?DataStore (with guilds)? and ?DataStore (without guilds)? item count options. One might prefer these over Altoholic for a few reasons.
Scroll IDs are now stored in a seperate file in a new ?data? folder. Premade groups data can be found there too.
Bonus queue and min crafting queue options should now be fully functional.
Enchanting scrolls should now work properly.
Text in the summary of the value of items below the price threshold window will now be colored completely grey.
author | Zerotorescue |
---|---|
date | Wed, 20 Oct 2010 01:30:51 +0200 |
parents | 5006cb0e97c6 |
children | 7d7aaa3fbe94 |
comparison
equal
deleted
inserted
replaced
16:68958c55c43d | 17:8f5c02113c5c |
---|---|
1 -- You can access this addon's object through: LibStub("AceAddon-3.0"):GetAddon("Inventorium") | 1 -- You can access this addon's object through: LibStub("AceAddon-3.0"):GetAddon("Inventorium") |
2 local addon = LibStub("AceAddon-3.0"):NewAddon("Inventorium", "AceEvent-3.0"); | 2 local addon = select(2, ...); |
3 addon = LibStub("AceAddon-3.0"):NewAddon(addon, "Inventorium", "AceEvent-3.0"); | |
3 | 4 |
4 local AceGUI = LibStub("AceGUI-3.0"); | 5 local AceGUI = LibStub("AceGUI-3.0"); |
5 | 6 |
6 local AceConfigDialog, AceConfigRegistry, AceSerializer; | 7 local AceConfigDialog, AceConfigRegistry, AceSerializer; |
7 local groupIdToName = {}; | 8 local groupIdToName = {}; |
39 speed = 5, | 40 speed = 5, |
40 width = 650, | 41 width = 650, |
41 height = 600, | 42 height = 600, |
42 }, | 43 }, |
43 colors = { | 44 colors = { |
44 red = 0; | 45 red = 0, |
45 orange = 0.3; | 46 orange = 0.3, |
46 yellow = 0.6; | 47 yellow = 0.6, |
47 green = 0.95; | 48 green = 0.95, |
48 }, | 49 }, |
49 }, | 50 }, |
50 }, | 51 }, |
51 factionrealm = { | 52 factionrealm = { |
52 characters = {}, | 53 characters = {}, |
495 minimumStock = { | 496 minimumStock = { |
496 order = 10, | 497 order = 10, |
497 type = "range", | 498 type = "range", |
498 min = 0, | 499 min = 0, |
499 max = 100000, | 500 max = 100000, |
500 softMax = 1000, | 501 softMax = 100, |
501 step = 1, | 502 step = 1, |
502 name = "Minimum stock", | 503 name = "Minimum stock", |
503 desc = "You can manually enter a value between 1.000 and 100.000 in the edit box if the provided range is insufficient.", | 504 desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.", |
504 get = function() return self.db.global.defaults.minimumStock; end, | 505 get = function() return self.db.global.defaults.minimumStock; end, |
505 set = function(i, v) self.db.global.defaults.minimumStock = v; end, | 506 set = function(i, v) self.db.global.defaults.minimumStock = v; end, |
506 }, | 507 }, |
507 summaryThresholdShow = { | 508 summaryThresholdShow = { |
508 order = 20, | 509 order = 20, |
913 local itemId = addon:GetItemId(itemLink); | 914 local itemId = addon:GetItemId(itemLink); |
914 if not itemId then | 915 if not itemId then |
915 -- If this isn't an item, it can only be an enchant instead | 916 -- If this isn't an item, it can only be an enchant instead |
916 itemId = tonumber(itemLink:match("|Henchant:([-0-9]+)|h")); | 917 itemId = tonumber(itemLink:match("|Henchant:([-0-9]+)|h")); |
917 | 918 |
918 itemId = scrollIds[itemId]; -- change enchantIds into scrollIds | 919 itemId = addon.scrollIds[itemId]; -- change enchantIds into scrollIds |
919 end | 920 end |
920 | 921 |
921 local itemLevel = select(4, GetItemInfo(itemId)) or 0; | 922 if itemId then |
922 | 923 local itemLevel = select(4, GetItemInfo(itemId)) or 0; |
923 if includeTradeSkillItems == 0 or itemLevel >= includeTradeSkillItems then | 924 |
924 if not items[itemId] then | 925 if includeTradeSkillItems == 0 or itemLevel >= includeTradeSkillItems then |
925 -- If this item isn't used in any group yet | 926 if not items[itemId] then |
926 ref[itemId] = tblAddItemTemplate; | 927 -- If this item isn't used in any group yet |
927 else | 928 ref[itemId] = tblAddItemTemplate; |
928 -- It's already used in a group, don't show it | 929 else |
929 ref[itemId] = nil; | 930 -- It's already used in a group, don't show it |
931 ref[itemId] = nil; | |
932 end | |
930 end | 933 end |
934 else | |
935 addon:Debug("|cffff0000ERROR|r: Couldn't find proper item id for " .. itemLink); | |
931 end | 936 end |
932 end | 937 end |
933 end | 938 end |
934 end | 939 end |
935 end | 940 end |
1005 minimumStock = { | 1010 minimumStock = { |
1006 order = 10, | 1011 order = 10, |
1007 type = "range", | 1012 type = "range", |
1008 min = 0, | 1013 min = 0, |
1009 max = 100000, | 1014 max = 100000, |
1010 softMax = 1000, | 1015 softMax = 100, |
1011 step = 1, | 1016 step = 1, |
1012 name = "Minimum stock", | 1017 name = "Minimum stock", |
1013 desc = "You can manually enter a value between 1.000 and 100.000 in the edit box if the provided range is insufficient.", | 1018 desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.", |
1014 arg = "overrideMinimumStock", | 1019 arg = "overrideMinimumStock", |
1015 }, | 1020 }, |
1016 overrideSummaryThresholdShow = { | 1021 overrideSummaryThresholdShow = { |
1017 order = 19, | 1022 order = 19, |
1018 type = "toggle", | 1023 type = "toggle", |
1094 type = "description", | 1099 type = "description", |
1095 name = function(info) | 1100 name = function(info) |
1096 local groupName = groupIdToName[info[2]]; | 1101 local groupName = groupIdToName[info[2]]; |
1097 local r = "Here you can specify the amount of items to which you wish to restock when you are collecting new items for the currently selected group. This may be higher than the minimum stock.\n\n"; | 1102 local r = "Here you can specify the amount of items to which you wish to restock when you are collecting new items for the currently selected group. This may be higher than the minimum stock.\n\n"; |
1098 | 1103 |
1099 r = r .. "When restocking the target amount is |cfffed000" .. addon:GetOptionByKey(groupName, "restockTarget") .. "|r of every item. Not queueing craftable items when only missing |cfffed000" .. floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * addon:GetOptionByKey(groupName, "restockTarget") ) .. "|r (|cfffed000" .. ( addon:GetOptionByKey(groupName, "minCraftingQueue") * 100 ) .. "%|r) of the restock target."; | 1104 r = r .. "When restocking the target amount is |cfffed000" .. addon:GetOptionByKey(groupName, "restockTarget") .. "|r of every item. Not queueing craftable items when only missing |cfffed000" .. floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * addon:GetOptionByKey(groupName, "restockTarget") ) .. "|r (|cfffed000" .. ( addon:GetOptionByKey(groupName, "minCraftingQueue") * 100 ) .. "%|r) of the restock target and making |cfffed000" .. floor( ( addon:GetOptionByKey(groupName, "bonusQueue") * addon:GetOptionByKey(groupName, "restockTarget") ) + .5 ) .. "|r (|cfffed000" .. ( addon:GetOptionByKey(groupName, "bonusQueue") * 100 ) .. "%|r) extra items when you completely ran out."; |
1100 | 1105 |
1101 return r; | 1106 return r; |
1102 end, | 1107 end, |
1103 }, | 1108 }, |
1104 header = { | 1109 header = { |
1346 print(("Added %s"):format(select(2, GetItemInfo(itemId)) or ("Unknown (#%d)"):format(itemId))); | 1351 print(("Added %s"):format(select(2, GetItemInfo(itemId)) or ("Unknown (#%d)"):format(itemId))); |
1347 end | 1352 end |
1348 end, | 1353 end, |
1349 get = false, | 1354 get = false, |
1350 }, | 1355 }, |
1351 import = { | 1356 importItemData = { |
1352 order = 40, | 1357 order = 30, |
1353 type = "input", | 1358 type = "input", |
1354 name = "Import item data", | 1359 name = "Import item data", |
1355 desc = "Import item data from an exported item data-string. Any items already grouped will be skipped.", | 1360 desc = "Import item data from an exported item data-string. Any items already grouped will be skipped.", |
1356 set = function(info, value) | 1361 set = function(info, value) |
1357 local groupName = groupIdToName[info[2]]; | 1362 local groupName = groupIdToName[info[2]]; |
1370 end | 1375 end |
1371 end | 1376 end |
1372 end, | 1377 end, |
1373 get = false, | 1378 get = false, |
1374 }, | 1379 }, |
1380 importPremadeData = { | |
1381 order = 40, | |
1382 type = "select", | |
1383 name = "Import premade data", | |
1384 desc = "Import item data from a premade item-group. Any items already grouped will be skipped.", | |
1385 values = function() | |
1386 local temp = {}; | |
1387 for key, group in pairs(addon.defaultGroups) do | |
1388 temp[key] = key; | |
1389 end | |
1390 | |
1391 return temp; | |
1392 end, | |
1393 set = function(info, value) | |
1394 local groupName = groupIdToName[info[2]]; | |
1395 | |
1396 print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(value)); | |
1397 | |
1398 -- Remember we imported this group and it's version so if it is ever changed, people can be notified | |
1399 if not addon.db.global.groups[groupName].premadeGroups then | |
1400 addon.db.global.groups[groupName].premadeGroups = {}; | |
1401 end | |
1402 addon.db.global.groups[groupName].premadeGroups[value] = addon.defaultGroups[value].version; | |
1403 | |
1404 for itemId, _ in pairs(addon.defaultGroups[value].items) do | |
1405 itemId = itemId and tonumber(itemId); | |
1406 | |
1407 if not itemId then | |
1408 print(("\"|cfffed000%s|r\" is not a number."):format(value)); | |
1409 elseif InGroup(itemId) then | |
1410 print(("Skipping |cfffed000%s|r (#%d) as it is already in the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, InGroup(itemId))); | |
1411 else | |
1412 AddToGroup(groupName, itemId); | |
1413 end | |
1414 end | |
1415 end, | |
1416 get = false, | |
1417 }, | |
1375 }, | 1418 }, |
1376 }, | 1419 }, |
1377 massAdd = { | 1420 massAdd = { |
1378 order = 20, | 1421 order = 20, |
1379 type = "group", | 1422 type = "group", |
1389 order = 20, | 1432 order = 20, |
1390 type = "input", | 1433 type = "input", |
1391 name = "Add all items matching...", | 1434 name = "Add all items matching...", |
1392 desc = "Add every item in your inventory matching the name entered in this field. If you enter \"Glyph\" as a filter, any items in your inventory containing this in their name will be added to this group.", | 1435 desc = "Add every item in your inventory matching the name entered in this field. If you enter \"Glyph\" as a filter, any items in your inventory containing this in their name will be added to this group.", |
1393 set = function(info, value) | 1436 set = function(info, value) |
1437 local groupName = groupIdToName[info[2]]; | |
1438 | |
1394 if not value then return; end | 1439 if not value then return; end |
1395 | 1440 |
1396 value = value:lower(); | 1441 value = value:lower(); |
1397 | 1442 |
1398 local ref = options.args.groups.args[info[2]].args.add.args.list.args; | 1443 local ref = options.args.groups.args[info[2]].args.add.args.list.args; |
1400 for itemId, test in pairs(ref) do | 1445 for itemId, test in pairs(ref) do |
1401 if test then | 1446 if test then |
1402 local itemName = GetItemInfo(itemId); | 1447 local itemName = GetItemInfo(itemId); |
1403 | 1448 |
1404 if itemName:lower():find(value) then | 1449 if itemName:lower():find(value) then |
1405 local groupName = groupIdToName[info[2]]; | |
1406 | |
1407 if not AddToGroup(groupName, itemId) then | 1450 if not AddToGroup(groupName, itemId) then |
1408 print("|cffff0000Couldn't add the item with itemId (" .. itemId .. ") because it is already in a group.|r"); | 1451 print("|cffff0000Couldn't add the item with itemId (" .. itemId .. ") because it is already in a group.|r"); |
1409 end | 1452 end |
1410 end | 1453 end |
1411 end | 1454 end |
1472 args = { | 1515 args = { |
1473 help = { | 1516 help = { |
1474 order = 10, | 1517 order = 10, |
1475 type = "description", | 1518 type = "description", |
1476 name = "Click the items you wish to remove from this group.", | 1519 name = "Click the items you wish to remove from this group.", |
1520 }, | |
1521 massRemove = { | |
1522 order = 20, | |
1523 type = "input", | |
1524 name = "Remove all items matching...", | |
1525 desc = "Remove every item in this group matching the name entered in this field. If you enter \"Glyph\" as a filter, any items in this group containing this in their name will be removed from this group.", | |
1526 set = function(info, value) | |
1527 local groupName = groupIdToName[info[2]]; | |
1528 | |
1529 if not value then return; end | |
1530 | |
1531 value = value:lower(); | |
1532 | |
1533 local ref = options.args.groups.args[info[2]].args.remove.args.list.args; | |
1534 | |
1535 for itemId, test in pairs(ref) do | |
1536 if test then | |
1537 local itemName = GetItemInfo(itemId); | |
1538 | |
1539 if itemName:lower():find(value) then | |
1540 -- Unset this item | |
1541 addon.db.global.groups[groupName].items[itemId] = nil; | |
1542 end | |
1543 end | |
1544 end | |
1545 end, | |
1546 get = false, | |
1547 }, | |
1548 premadeGroups = { | |
1549 order = 30, | |
1550 type = "select", | |
1551 name = "Imported premade groups", | |
1552 desc = "This is a list of all premade groups that were imported into this group. You will be notified when any of these premade groups have changed and you will be able to import these changes.\n\nSelect a group to remove it from this list and prevent notifications about changes made to this group. This will require you to manually update this when new items are added to the game.", | |
1553 values = function(info) | |
1554 local groupName = groupIdToName[info[2]]; | |
1555 | |
1556 local temp = {}; | |
1557 if addon.db.global.groups[groupName].premadeGroups then | |
1558 for name, version in pairs(addon.db.global.groups[groupName].premadeGroups) do | |
1559 temp[name] = name; | |
1560 end | |
1561 end | |
1562 | |
1563 return temp; | |
1564 end, | |
1565 set = function(info, value) | |
1566 -- Remove premade group from this group | |
1567 local groupName = groupIdToName[info[2]]; | |
1568 | |
1569 addon.db.global.groups[groupName].premadeGroups[value] = nil; | |
1570 | |
1571 print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value)); | |
1572 end, | |
1573 get = false, | |
1574 disabled = function(info) | |
1575 local groupName = groupIdToName[info[2]]; | |
1576 | |
1577 return (not addon.db.global.groups[groupName].premadeGroups); | |
1578 end, | |
1477 }, | 1579 }, |
1478 }, | 1580 }, |
1479 }, | 1581 }, |
1480 list = { | 1582 list = { |
1481 order = 20, | 1583 order = 20, |
1583 temp.name = nil; | 1685 temp.name = nil; |
1584 print(("Importing %s..."):format(name)); | 1686 print(("Importing %s..."):format(name)); |
1585 | 1687 |
1586 -- Remove items that are already in another group | 1688 -- Remove items that are already in another group |
1587 for value, _ in pairs(temp.items) do | 1689 for value, _ in pairs(temp.items) do |
1588 local itemId = tonumber(itemid); | 1690 local itemId = tonumber(value); |
1589 | 1691 |
1590 if not itemId then | 1692 if not itemId then |
1591 print(("\"%s\" is not a number."):format(value)); | 1693 print(("\"%s\" is not a number."):format(value)); |
1592 temp.items[value] = nil; | 1694 temp.items[value] = nil; |
1593 elseif InGroup(itemId) then | 1695 elseif InGroup(itemId) then |
1650 if not itemId then return; end | 1752 if not itemId then return; end |
1651 | 1753 |
1652 if self.supportedAddons.itemCount[self.db.global.defaults.itemCountAddon] then | 1754 if self.supportedAddons.itemCount[self.db.global.defaults.itemCountAddon] then |
1653 -- Try to use the default item count addon | 1755 -- Try to use the default item count addon |
1654 | 1756 |
1655 return self.supportedAddons.itemCount[self.db.global.defaults.itemCountAddon].GetCount(itemId); | 1757 return self.supportedAddons.itemCount[self.db.global.defaults.itemCountAddon].GetTotalCount(itemId); |
1656 else | 1758 else |
1657 -- Default not available, get the first one then | 1759 -- Default not available, get the first one then |
1658 | 1760 |
1659 for name, value in pairs(self.supportedAddons.itemCount) do | 1761 for name, value in pairs(self.supportedAddons.itemCount) do |
1660 if value.IsEnabled() then | 1762 if value.IsEnabled() then |
1661 return value.GetCount(itemId); | 1763 return value.GetTotalCount(itemId); |
1662 end | 1764 end |
1663 end | 1765 end |
1664 end | 1766 end |
1665 | 1767 |
1666 return -1; | 1768 return -1; |
1695 GetValue = get, | 1797 GetValue = get, |
1696 IsEnabled = enabled, | 1798 IsEnabled = enabled, |
1697 }; | 1799 }; |
1698 end | 1800 end |
1699 | 1801 |
1700 function IMRegisterItemCountAddon(name, get, enabled) | 1802 function IMRegisterItemCountAddon(name, getTotal, getCharacter, enabled) |
1701 addon.supportedAddons.itemCount[name] = { | 1803 addon.supportedAddons.itemCount[name] = { |
1702 GetCount = get, | 1804 GetTotalCount = getTotal, |
1805 GetCharacterCount = getCharacter, | |
1703 IsEnabled = enabled, | 1806 IsEnabled = enabled, |
1704 }; | 1807 }; |
1705 end | 1808 end |
1706 | 1809 |
1707 function IMRegisterCraftingAddon(name, queue, enabled) | 1810 function IMRegisterCraftingAddon(name, queue, enabled) |