Mercurial > wow > inventory
diff Modules/Config.lua @ 161:fcc95c62d232
Premade groups can now be combined into a single group to allow easier adding of a combination (e.g. all glyphs at once).
author | Zerotorescue |
---|---|
date | Sun, 23 Jan 2011 18:24:00 +0100 |
parents | e136c99fe5bb |
children | e31b68c119df |
line wrap: on
line diff
--- a/Modules/Config.lua Sat Jan 22 21:30:02 2011 +0100 +++ b/Modules/Config.lua Sun Jan 23 18:24:00 2011 +0100 @@ -241,6 +241,35 @@ end end +local function ImportPremadeItemsGroup(groupName, name) + local premadeItemGroup = addon.defaultGroups[name]; + + addon:Print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(name)); + + -- 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 + addon.db.profile.groups[groupName].premadeGroups = {}; + end + addon.db.profile.groups[groupName].premadeGroups[name] = premadeItemGroup.version; + + for itemId, version in pairs(premadeItemGroup.items) do + if version > 0 then + -- Sanity check + itemId = itemId and tonumber(itemId); + + local itemData = addon.ItemData:New(itemId); + + if not itemId then + addon:Print(("\"|cfffed000%s|r\" is not a number."):format(name), 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); + 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); + end + end + end +end + -- Default group local defaultGroup = { order = 0, @@ -987,29 +1016,14 @@ set = function(info, value) local groupName = groupIdToName[info[2]]; - addon:Print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(value)); + local premadeItemGroup = addon.defaultGroups[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 - addon.db.profile.groups[groupName].premadeGroups = {}; - end - addon.db.profile.groups[groupName].premadeGroups[value] = addon.defaultGroups[value].version; - - for itemId, version in pairs(addon.defaultGroups[value].items) do - if version > 0 then - -- Sanity check - itemId = itemId and tonumber(itemId); - - local itemData = addon.ItemData:New(itemId); - - if not itemId then - 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); - 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); - end + if premadeItemGroup.isParent and premadeItemGroup.childs then + for _, premadeItemGroupName in pairs(premadeItemGroup.childs) do + ImportPremadeItemsGroup(groupName, premadeItemGroupName); end + else + ImportPremadeItemsGroup(groupName, value); end if AceConfigRegistry then