Mercurial > wow > inventory
changeset 46:87d68ccf0a8f
The premade group update processor should now properly add items when they were added to a premade group.
Items can now be indicated as removed in premade groups by setting the version number to a negative value of the latest version.
Removed Enchanted Spellthread from the Cataclysm enchants premade group.
author | Zerotorescue |
---|---|
date | Sun, 12 Dec 2010 17:18:19 +0100 |
parents | 0d1f8282a43e |
children | d2966f688a6e |
files | Core.lua Data/PremadeGroups.lua |
diffstat | 2 files changed, 71 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/Core.lua Sun Dec 12 16:40:15 2010 +0100 +++ b/Core.lua Sun Dec 12 17:18:19 2010 +0100 @@ -154,16 +154,47 @@ return; end +local function AddToGroup(groupName, itemId) + if InGroup(itemId) then + return false; + end + + if not addon.db.global.groups[groupName].items then + addon.db.global.groups[groupName].items = {}; + end + + -- Set this item + addon.db.global.groups[groupName].items[itemId] = true; + + if AceConfigRegistry then + -- Now rebuild the list + AceConfigRegistry:NotifyChange("InventoriumOptions"); + end + + return true; +end + +local function RemoveFromGroup(groupName, itemId) + if InGroup(itemId) ~= groupName then + return false; + end + + -- Unset this item + addon.db.global.groups[groupName].items[itemId] = nil; + + return true; +end + function addon:PremadeGroupsCheck(updateGroupName, updateKey, accept) -- Compare the current premade groups with those used, notify about changes if addon.defaultGroups then - for key, groupInfo in pairs(addon.defaultGroups) do + for premadeGroupName, groupInfo in pairs(addon.defaultGroups) do -- Go through all default groups for groupName, values in pairs(addon.db.global.groups) do -- Go through all groups to find those with this premade group - if values.premadeGroups and values.premadeGroups[key] and values.premadeGroups[key] < groupInfo.version then + if values.premadeGroups and values.premadeGroups[premadeGroupName] and values.premadeGroups[premadeGroupName] < groupInfo.version then -- Outdated group if updateGroupName and updateKey then @@ -175,19 +206,26 @@ for itemId, version in pairs(groupInfo.items) do -- Go through all items in this premade group - if version > values.premadeGroups[key] then + if version > values.premadeGroups[premadeGroupName] then -- This item was added in a more recent version than this group: Add item if 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))); elseif AddToGroup(groupName, itemId) then - print(("Added %s (#%d) found in the premade group |cfffed000%s|r to the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, InGroup(itemId))); + print(("|cff00ff00Added|r %s (#%d) found in the premade group |cfffed000%s|r to the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, premadeGroupName, InGroup(itemId))); + end + elseif ( version * -1 ) > values.premadeGroups[premadeGroupName] then + if InGroup(itemId) == groupName then + print(("|cffff0000Removed|r %s (#%d) from the group |cfffed000%s|r as it was removed from the premade group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, InGroup(itemId), premadeGroupName)); + RemoveFromGroup(groupName, itemId); + else + print(("Skipping the removal of %s (#%d) as it isn't in this group."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, InGroup(itemId))); end end end -- Remember the new version - values.premadeGroups[key] = groupInfo.version; + values.premadeGroups[premadeGroupName] = groupInfo.version; else -- No was clicked @@ -195,7 +233,7 @@ for itemId, version in pairs(groupInfo.items) do -- Go through all items in this premade group - if version > values.premadeGroups[key] then + if version > values.premadeGroups[premadeGroupName] then -- This item was added in a more recent version than this group: don't add (since we clicked no), but announce it print(("Skipping %s (#%d) found in the premade group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, InGroup(itemId))); @@ -203,7 +241,7 @@ end -- Remember the new version - values.premadeGroups[key] = groupInfo.version; + values.premadeGroups[premadeGroupName] = groupInfo.version; end else StaticPopupDialogs["InventoriumConfirmUpdatePremadeGroup"] = { @@ -211,18 +249,18 @@ button1 = YES, button2 = NO, OnAccept = function(self) - addon:PremadeGroupsCheck(groupName, key, true); + addon:PremadeGroupsCheck(groupName, premadeGroupName, true); end, OnCancel = function(self, _, reason) if reason == "clicked" then - addon:PremadeGroupsCheck(groupName, key, false); + addon:PremadeGroupsCheck(groupName, premadeGroupName, false); end end, timeout = 0, whileDead = 1, hideOnEscape = 1, }; - StaticPopup_Show("InventoriumConfirmUpdatePremadeGroup", key, groupName); + StaticPopup_Show("InventoriumConfirmUpdatePremadeGroup", premadeGroupName, groupName); return; end @@ -969,24 +1007,6 @@ return true; end -local function AddToGroup(groupName, itemId) - if InGroup(itemId) then - return false; - end - - if not addon.db.global.groups[groupName].items then - addon.db.global.groups[groupName].items = {}; - end - - -- Set this item - addon.db.global.groups[groupName].items[itemId] = true; - - -- Now rebuild the list - AceConfigRegistry:NotifyChange("InventoriumOptions"); - - return true; -end - local tblAddItemTemplate = { order = 0, type = "input", @@ -1028,11 +1048,10 @@ if itemId then local groupName = groupIdToName[groupId]; - -- Unset this item - addon.db.global.groups[groupName].items[itemId] = nil; - - -- Now rebuild the list - AceConfigRegistry:NotifyChange("InventoriumOptions"); + RemoveFromGroup(groupName, itemId); + + -- Now rebuild the list + AceConfigRegistry:NotifyChange("InventoriumOptions"); end end, width = "double", @@ -1770,15 +1789,18 @@ 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); + for itemId, version in pairs(addon.defaultGroups[value].items) do + if version > 0 then + itemId = itemId and tonumber(itemId); + + if not itemId then + print(("\"|cfffed000%s|r\" is not a number."):format(value)); + elseif InGroup(itemId) then + print(("|cffff0000Skipping|r |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); + print(("|cff00ff00Added|r |cfffed000%s|r (#%d) to the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, groupName)); + end end end end, @@ -1908,11 +1930,14 @@ local itemName = GetItemInfo(itemId); if itemName:lower():find(value) then - -- Unset this item - addon.db.global.groups[groupName].items[itemId] = nil; + RemoveFromGroup(groupName, itemId); + print(("|cffff0000Removed|r %s (#%d)."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId)); end end end + + -- Now rebuild the list + AceConfigRegistry:NotifyChange("InventoriumOptions"); end, get = false, },
--- a/Data/PremadeGroups.lua Sun Dec 12 16:40:15 2010 +0100 +++ b/Data/PremadeGroups.lua Sun Dec 12 17:18:19 2010 +0100 @@ -767,10 +767,10 @@ }, -- Source: http://www.wowhead.com/items=0.6?filter=na=enchant;cr=82;crs=1;crv=30300 ["Enchants (Cataclysm)"] = { - version = 1, + version = 2, items = { [52747] = 1, -- Enchant Weapon - Mending - [54447] = 1, -- Enchanted Spellthread + [54447] = -2, -- Enchanted Spellthread Removed in version 2 as this isn't a real enchant [38916] = 1, -- Scroll of Enchant Weapon - Major Spirit [52687] = 1, -- Enchant Gloves - Mastery [52743] = 1, -- Enchant Boots - Earthen Vitality