Mercurial > wow > inventory
diff 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 |
line wrap: on
line diff
--- a/Core.lua Mon Oct 18 19:37:43 2010 +0200 +++ b/Core.lua Wed Oct 20 01:30:51 2010 +0200 @@ -1,5 +1,6 @@ -- You can access this addon's object through: LibStub("AceAddon-3.0"):GetAddon("Inventorium") -local addon = LibStub("AceAddon-3.0"):NewAddon("Inventorium", "AceEvent-3.0"); +local addon = select(2, ...); +addon = LibStub("AceAddon-3.0"):NewAddon(addon, "Inventorium", "AceEvent-3.0"); local AceGUI = LibStub("AceGUI-3.0"); @@ -41,10 +42,10 @@ height = 600, }, colors = { - red = 0; - orange = 0.3; - yellow = 0.6; - green = 0.95; + red = 0, + orange = 0.3, + yellow = 0.6, + green = 0.95, }, }, }, @@ -497,10 +498,10 @@ type = "range", min = 0, max = 100000, - softMax = 1000, + softMax = 100, step = 1, name = "Minimum stock", - desc = "You can manually enter a value between 1.000 and 100.000 in the edit box if the provided range is insufficient.", + desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.", get = function() return self.db.global.defaults.minimumStock; end, set = function(i, v) self.db.global.defaults.minimumStock = v; end, }, @@ -915,19 +916,23 @@ -- If this isn't an item, it can only be an enchant instead itemId = tonumber(itemLink:match("|Henchant:([-0-9]+)|h")); - itemId = scrollIds[itemId]; -- change enchantIds into scrollIds + itemId = addon.scrollIds[itemId]; -- change enchantIds into scrollIds end - local itemLevel = select(4, GetItemInfo(itemId)) or 0; - - if includeTradeSkillItems == 0 or itemLevel >= includeTradeSkillItems then - if not items[itemId] then - -- If this item isn't used in any group yet - ref[itemId] = tblAddItemTemplate; - else - -- It's already used in a group, don't show it - ref[itemId] = nil; + if itemId then + local itemLevel = select(4, GetItemInfo(itemId)) or 0; + + if includeTradeSkillItems == 0 or itemLevel >= includeTradeSkillItems then + if not items[itemId] then + -- If this item isn't used in any group yet + ref[itemId] = tblAddItemTemplate; + else + -- It's already used in a group, don't show it + ref[itemId] = nil; + end end + else + addon:Debug("|cffff0000ERROR|r: Couldn't find proper item id for " .. itemLink); end end end @@ -1007,10 +1012,10 @@ type = "range", min = 0, max = 100000, - softMax = 1000, + softMax = 100, step = 1, name = "Minimum stock", - desc = "You can manually enter a value between 1.000 and 100.000 in the edit box if the provided range is insufficient.", + desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.", arg = "overrideMinimumStock", }, overrideSummaryThresholdShow = { @@ -1096,7 +1101,7 @@ local groupName = groupIdToName[info[2]]; 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"; - 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."; + 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."; return r; end, @@ -1348,8 +1353,8 @@ end, get = false, }, - import = { - order = 40, + importItemData = { + order = 30, type = "input", name = "Import item data", desc = "Import item data from an exported item data-string. Any items already grouped will be skipped.", @@ -1372,6 +1377,44 @@ end, get = false, }, + importPremadeData = { + order = 40, + type = "select", + name = "Import premade data", + desc = "Import item data from a premade item-group. Any items already grouped will be skipped.", + values = function() + local temp = {}; + for key, group in pairs(addon.defaultGroups) do + temp[key] = key; + end + + return temp; + end, + set = function(info, value) + local groupName = groupIdToName[info[2]]; + + 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.global.groups[groupName].premadeGroups then + addon.db.global.groups[groupName].premadeGroups = {}; + end + addon.db.global.groups[groupName].premadeGroups[value] = addon.defaultGroups[value].version; + + for itemId, _ in pairs(addon.defaultGroups[value].items) do + itemId = itemId and tonumber(itemId); + + if not itemId then + print(("\"|cfffed000%s|r\" is not a number."):format(value)); + elseif InGroup(itemId) then + 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))); + else + AddToGroup(groupName, itemId); + end + end + end, + get = false, + }, }, }, massAdd = { @@ -1391,6 +1434,8 @@ name = "Add all items matching...", 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.", set = function(info, value) + local groupName = groupIdToName[info[2]]; + if not value then return; end value = value:lower(); @@ -1402,8 +1447,6 @@ local itemName = GetItemInfo(itemId); if itemName:lower():find(value) then - local groupName = groupIdToName[info[2]]; - if not AddToGroup(groupName, itemId) then print("|cffff0000Couldn't add the item with itemId (" .. itemId .. ") because it is already in a group.|r"); end @@ -1475,6 +1518,65 @@ type = "description", name = "Click the items you wish to remove from this group.", }, + massRemove = { + order = 20, + type = "input", + name = "Remove all items matching...", + 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.", + set = function(info, value) + local groupName = groupIdToName[info[2]]; + + if not value then return; end + + value = value:lower(); + + local ref = options.args.groups.args[info[2]].args.remove.args.list.args; + + for itemId, test in pairs(ref) do + if test then + local itemName = GetItemInfo(itemId); + + if itemName:lower():find(value) then + -- Unset this item + addon.db.global.groups[groupName].items[itemId] = nil; + end + end + end + end, + get = false, + }, + premadeGroups = { + order = 30, + type = "select", + name = "Imported premade groups", + 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.", + values = function(info) + local groupName = groupIdToName[info[2]]; + + local temp = {}; + if addon.db.global.groups[groupName].premadeGroups then + for name, version in pairs(addon.db.global.groups[groupName].premadeGroups) do + temp[name] = name; + end + end + + return temp; + end, + set = function(info, value) + -- Remove premade group from this group + local groupName = groupIdToName[info[2]]; + + addon.db.global.groups[groupName].premadeGroups[value] = nil; + + print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value)); + end, + get = false, + disabled = function(info) + local groupName = groupIdToName[info[2]]; + + return (not addon.db.global.groups[groupName].premadeGroups); + end, + }, }, }, list = { @@ -1585,7 +1687,7 @@ -- Remove items that are already in another group for value, _ in pairs(temp.items) do - local itemId = tonumber(itemid); + local itemId = tonumber(value); if not itemId then print(("\"%s\" is not a number."):format(value)); @@ -1652,13 +1754,13 @@ if self.supportedAddons.itemCount[self.db.global.defaults.itemCountAddon] then -- Try to use the default item count addon - return self.supportedAddons.itemCount[self.db.global.defaults.itemCountAddon].GetCount(itemId); + return self.supportedAddons.itemCount[self.db.global.defaults.itemCountAddon].GetTotalCount(itemId); else -- Default not available, get the first one then for name, value in pairs(self.supportedAddons.itemCount) do if value.IsEnabled() then - return value.GetCount(itemId); + return value.GetTotalCount(itemId); end end end @@ -1697,9 +1799,10 @@ }; end -function IMRegisterItemCountAddon(name, get, enabled) +function IMRegisterItemCountAddon(name, getTotal, getCharacter, enabled) addon.supportedAddons.itemCount[name] = { - GetCount = get, + GetTotalCount = getTotal, + GetCharacterCount = getCharacter, IsEnabled = enabled, }; end