Mercurial > wow > inventory
comparison Config.lua @ 76:958aba5f3297
Moved the group functions to the item data class.
Added a new subgroup under the general config group called ?extra? which will provide features such as database character removal and perhaps guild selecting.
Added a new custom .Print function to the addon object which takes two parameters: (string)text, (Color)color. The latter can be retrieved from the addon.Colors var (e.g. addon.Colors.Red).
The ItemId parameter of the ItemData class constructor is now optional.
author | Zerotorescue |
---|---|
date | Sat, 25 Dec 2010 22:07:07 +0100 |
parents | 2127ab01ed4a |
children | f885805da5d6 |
comparison
equal
deleted
inserted
replaced
75:2127ab01ed4a | 76:958aba5f3297 |
---|---|
1 local addon = select(2, ...); | 1 local addon = select(2, ...); |
2 local mod = addon:NewModule("Config"); | 2 local mod = addon:NewModule("Config"); |
3 | 3 |
4 local options, groupIdToName, groupIsVirtual, temp, count, includeTradeSkillItems, currentGroupType = {}, {}, {}, {}, 0, 500, "Normal"; | 4 local options, groupIdToName, groupIsVirtual, temp, count, includeTradeSkillItems, currentGroupType = {}, {}, {}, {}, 0, 500, "Normal"; |
5 local AceConfigDialog, AceConfigRegistry, AceSerializer; | 5 local AceConfigDialog, AceConfigRegistry, AceSerializer; |
6 | |
7 local unknownItemName = "Unknown (#%d)"; | |
6 | 8 |
7 -- Private functions and tables | 9 -- Private functions and tables |
8 | 10 |
9 local function SetOption(info, value, multiSelectEnabled) | 11 local function SetOption(info, value, multiSelectEnabled) |
10 local groupName = groupIdToName[info[2]]; | 12 local groupName = groupIdToName[info[2]]; |
96 return tostring(info[#info]); -- Ace is going to be anal about this if it's a numeric value, so we transmute it into a string here then back to a number on the other side | 98 return tostring(info[#info]); -- Ace is going to be anal about this if it's a numeric value, so we transmute it into a string here then back to a number on the other side |
97 end, | 99 end, |
98 set = function(groupId, itemData) | 100 set = function(groupId, itemData) |
99 -- This is NOT a real "set", we pass the widget reference to this function which contains similar, but not the same, info. | 101 -- This is NOT a real "set", we pass the widget reference to this function which contains similar, but not the same, info. |
100 | 102 |
101 if itemData and itemData.id then | 103 if itemData then |
102 local groupName = groupIdToName[groupId]; | 104 local groupName = groupIdToName[groupId]; |
103 | 105 |
104 if not mod:AddItemToGroup(groupName, itemData.id) then | 106 if not itemData:AddToGroup(groupName) then |
105 print("|cffff0000Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.|r"); | 107 print("|cffff0000Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.|r"); |
106 end | 108 end |
109 | |
110 if AceConfigRegistry then | |
111 -- Now rebuild the list | |
112 AceConfigRegistry:NotifyChange("InventoriumOptions"); | |
113 end | |
107 end | 114 end |
108 end, | 115 end, |
109 width = "double", | 116 width = "double", |
110 dialogControl = "ConfigItemLinkButton", | 117 dialogControl = "ConfigItemLinkButton", |
111 }; | 118 }; |
121 return tostring(info[#info]); -- Ace is going to be anal about this if it's a numeric value, so we transmute it into a string here then back to a number on the other side | 128 return tostring(info[#info]); -- Ace is going to be anal about this if it's a numeric value, so we transmute it into a string here then back to a number on the other side |
122 end, | 129 end, |
123 set = function(groupId, itemData) | 130 set = function(groupId, itemData) |
124 -- This is NOT a real "set", we pass the widget reference to this function which contains similar, but not the same, info. | 131 -- This is NOT a real "set", we pass the widget reference to this function which contains similar, but not the same, info. |
125 | 132 |
126 if itemData and itemData.id then | 133 if itemData then |
127 local groupName = groupIdToName[groupId]; | 134 local groupName = groupIdToName[groupId]; |
128 | 135 |
129 mod:RemoveItemFromGroup(groupName, itemData.id); | 136 itemData:RemoveFromGroup(groupName); |
130 | 137 |
131 -- Now rebuild the list | 138 if AceConfigRegistry then |
132 AceConfigRegistry:NotifyChange("InventoriumOptions"); | 139 -- Now rebuild the list |
140 AceConfigRegistry:NotifyChange("InventoriumOptions"); | |
141 end | |
133 end | 142 end |
134 end, | 143 end, |
135 width = "double", | 144 width = "double", |
136 dialogControl = "ConfigItemLinkButton", | 145 dialogControl = "ConfigItemLinkButton", |
137 }; | 146 }; |
847 -- If the value is empty we'll allow passing to clear the carret | 856 -- If the value is empty we'll allow passing to clear the carret |
848 if value == "" then return true; end | 857 if value == "" then return true; end |
849 | 858 |
850 local groupName = groupIdToName[info[2]]; | 859 local groupName = groupIdToName[info[2]]; |
851 | 860 |
852 local itemId = addon:GetItemId(string.trim(value or "")) or tonumber(string.trim(value or "")); | 861 local itemId = (addon:GetItemId(string.trim(value)) or tonumber(string.trim(value))); |
862 | |
863 local itemData = addon.ItemData:New(itemId); | |
853 | 864 |
854 if not itemId then | 865 if not itemId then |
855 return "This is not a valid item link."; | 866 return "This is not a valid item link or id."; |
856 elseif mod:InGroup(itemId) then | 867 elseif itemData:InGroup() then |
857 return ("This item is already in the group \"%s\"."):format(mod:InGroup(itemId)); | 868 return ("This item is already in the group |cfffed000%s|r."):format(itemData:InGroup()); |
858 end | 869 end |
859 | 870 |
860 return true; | 871 return true; |
861 end, | 872 end, |
862 set = function(info, value) | 873 set = function(info, value) |
863 if value and value ~= "" then | 874 if value and value ~= "" then |
864 local groupName = groupIdToName[info[2]]; | 875 local groupName = groupIdToName[info[2]]; |
865 | 876 |
866 local itemId = addon:GetItemId(string.trim(value or "")) or tonumber(string.trim(value or "")); | 877 local itemId = (addon:GetItemId(string.trim(value)) or tonumber(string.trim(value))); |
867 | 878 |
868 mod:AddItemToGroup(groupName, itemId); | 879 local itemData = addon.ItemData:New(itemId); |
869 | 880 |
870 print(("Added %s"):format(select(2, GetItemInfo(itemId)) or ("Unknown (#%d)"):format(itemId))); | 881 if itemData:AddToGroup(groupName) then |
882 addon.Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green); | |
883 | |
884 if AceConfigRegistry then | |
885 -- Now rebuild the list | |
886 AceConfigRegistry:NotifyChange("InventoriumOptions"); | |
887 end | |
888 else | |
889 addon.Print(("%s is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red); | |
890 end | |
871 end | 891 end |
872 end, | 892 end, |
873 get = false, | 893 get = false, |
874 }, | 894 }, |
875 importItemData = { | 895 importItemData = { |
883 local allItemIds = { string.split(";", value or "") }; | 903 local allItemIds = { string.split(";", value or "") }; |
884 | 904 |
885 for _, value in pairs(allItemIds) do | 905 for _, value in pairs(allItemIds) do |
886 local itemId = tonumber(value); | 906 local itemId = tonumber(value); |
887 | 907 |
888 if not itemId then | 908 if itemId then |
889 print(("\"%s\" is not a number."):format(value)); | 909 local itemData = addon.ItemData:New(itemId); |
890 elseif mod:InGroup(itemId) then | 910 |
891 print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, mod:InGroup(itemId))); | 911 if itemData:InGroup() then |
912 addon.Print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(itemData.link or "Unknown", itemId, itemData:InGroup()), addon.Colors.Red); | |
913 elseif itemData:AddToGroup(groupName) then | |
914 addon.Print(("Added %s to the group |cfffed000%s|r."):format(itemData.link or unknownItemName:format(itemId), groupName), addon.Colors.Green); | |
915 end | |
892 else | 916 else |
893 mod:AddItemToGroup(groupName, itemId); | 917 addon.Print(("\"%s\" is not a number."):format(value), addon.Colors.Red); |
894 end | 918 end |
919 end | |
920 | |
921 if AceConfigRegistry then | |
922 -- Now rebuild the list | |
923 AceConfigRegistry:NotifyChange("InventoriumOptions"); | |
895 end | 924 end |
896 end, | 925 end, |
897 get = false, | 926 get = false, |
898 }, | 927 }, |
899 importPremadeData = { | 928 importPremadeData = { |
920 end | 949 end |
921 addon.db.profile.groups[groupName].premadeGroups[value] = addon.defaultGroups[value].version; | 950 addon.db.profile.groups[groupName].premadeGroups[value] = addon.defaultGroups[value].version; |
922 | 951 |
923 for itemId, version in pairs(addon.defaultGroups[value].items) do | 952 for itemId, version in pairs(addon.defaultGroups[value].items) do |
924 if version > 0 then | 953 if version > 0 then |
954 -- Sanity check | |
925 itemId = itemId and tonumber(itemId); | 955 itemId = itemId and tonumber(itemId); |
926 | 956 |
957 local itemData = addon.ItemData:New(itemId); | |
958 | |
927 if not itemId then | 959 if not itemId then |
928 print(("\"|cfffed000%s|r\" is not a number."):format(value)); | 960 addon.Print(("\"|cfffed000%s|r\" is not a number."):format(value), addon.Colors.Red); |
929 elseif mod:InGroup(itemId) then | 961 elseif itemData:InGroup() then |
930 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, mod:InGroup(itemId))); | 962 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); |
931 else | 963 elseif itemData:AddToGroup(groupName) then |
932 mod:AddItemToGroup(groupName, itemId); | 964 addon.Print(("Added %s to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), groupName ), addon.Colors.Green); |
933 print(("|cff00ff00Added|r |cfffed000%s|r (#%d) to the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, groupName)); | |
934 end | 965 end |
935 end | 966 end |
967 end | |
968 | |
969 if AceConfigRegistry then | |
970 -- Now rebuild the list | |
971 AceConfigRegistry:NotifyChange("InventoriumOptions"); | |
936 end | 972 end |
937 end, | 973 end, |
938 get = false, | 974 get = false, |
939 }, | 975 }, |
940 }, | 976 }, |
964 | 1000 |
965 local ref = options.args.groups.args[info[2]].args.add.args.list.args; | 1001 local ref = options.args.groups.args[info[2]].args.add.args.list.args; |
966 | 1002 |
967 for itemId, test in pairs(ref) do | 1003 for itemId, test in pairs(ref) do |
968 if test then | 1004 if test then |
969 local itemName = GetItemInfo(itemId); | 1005 local itemData = addon.ItemData:New(itemId); |
970 | 1006 |
971 if itemName:lower():find(value) then | 1007 if itemData.name:lower():find(value) then |
972 if not mod:AddItemToGroup(groupName, itemId) then | 1008 if itemData:AddToGroup(groupName) then |
973 print("|cffff0000Couldn't add the item with itemId (" .. itemId .. ") because it is already in a group.|r"); | 1009 addon.Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green); |
1010 else | |
1011 addon.Print(("Couldn't add %s because it is already in a group."):format(itemData.link or unknownItemName:format(itemId)), addon.Colors.Red); | |
974 end | 1012 end |
975 end | 1013 end |
976 end | 1014 end |
1015 end | |
1016 | |
1017 if AceConfigRegistry then | |
1018 -- Now rebuild the list | |
1019 AceConfigRegistry:NotifyChange("InventoriumOptions"); | |
977 end | 1020 end |
978 end, | 1021 end, |
979 get = false, | 1022 get = false, |
980 }, | 1023 }, |
981 minItemLevel = { | 1024 minItemLevel = { |
1056 | 1099 |
1057 local ref = options.args.groups.args[info[2]].args.remove.args.list.args; | 1100 local ref = options.args.groups.args[info[2]].args.remove.args.list.args; |
1058 | 1101 |
1059 for itemId, test in pairs(ref) do | 1102 for itemId, test in pairs(ref) do |
1060 if test then | 1103 if test then |
1061 local itemName = GetItemInfo(itemId); | 1104 local itemData = addon.ItemData:New(itemId); |
1062 | 1105 |
1063 if itemName:lower():find(value) then | 1106 if itemData.name:lower():find(value) then |
1064 mod:RemoveItemFromGroup(groupName, itemId); | 1107 itemData:RemoveFromGroup(groupName); |
1065 print(("|cffff0000Removed|r %s (#%d)."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId)); | 1108 |
1109 addon.Print(("Removed %s from the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Red); | |
1066 end | 1110 end |
1067 end | 1111 end |
1068 end | 1112 end |
1069 | 1113 |
1070 -- Now rebuild the list | 1114 if AceConfigRegistry then |
1071 AceConfigRegistry:NotifyChange("InventoriumOptions"); | 1115 -- Now rebuild the list |
1116 AceConfigRegistry:NotifyChange("InventoriumOptions"); | |
1117 end | |
1072 end, | 1118 end, |
1073 get = false, | 1119 get = false, |
1074 }, | 1120 }, |
1075 premadeGroups = { | 1121 premadeGroups = { |
1076 order = 30, | 1122 order = 30, |
1079 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 stop reminding you of changes to the premade group (the item list will be unaffected). Doing so will require you to manually update this when new items are added to the game.", | 1125 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 stop reminding you of changes to the premade group (the item list will be unaffected). Doing so will require you to manually update this when new items are added to the game.", |
1080 values = function(info) | 1126 values = function(info) |
1081 local groupName = groupIdToName[info[2]]; | 1127 local groupName = groupIdToName[info[2]]; |
1082 | 1128 |
1083 local temp = {}; | 1129 local temp = {}; |
1130 temp[""] = ""; | |
1084 if addon.db.profile.groups[groupName].premadeGroups then | 1131 if addon.db.profile.groups[groupName].premadeGroups then |
1085 for name, version in pairs(addon.db.profile.groups[groupName].premadeGroups) do | 1132 for name, version in pairs(addon.db.profile.groups[groupName].premadeGroups) do |
1086 temp[name] = name; | 1133 temp[name] = name; |
1087 end | 1134 end |
1088 end | 1135 end |
1089 | 1136 |
1090 return temp; | 1137 return temp; |
1091 end, | 1138 end, |
1092 set = function(info, value) | 1139 set = function(info, value) |
1093 -- Remove premade group from this group | 1140 if value and value ~= "" then |
1094 local groupName = groupIdToName[info[2]]; | 1141 -- Remove premade group from this group |
1095 | 1142 local groupName = groupIdToName[info[2]]; |
1096 addon.db.profile.groups[groupName].premadeGroups[value] = nil; | 1143 |
1097 | 1144 addon.db.profile.groups[groupName].premadeGroups[value] = nil; |
1098 print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value)); | 1145 |
1146 print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value)); | |
1147 end | |
1099 end, | 1148 end, |
1100 get = false, | 1149 get = false, |
1101 disabled = function(info) | 1150 disabled = function(info) |
1102 local groupName = groupIdToName[info[2]]; | 1151 local groupName = groupIdToName[info[2]]; |
1103 | 1152 |
1616 isPercent = true, | 1665 isPercent = true, |
1617 name = "|cffff0000Red|r", | 1666 name = "|cffff0000Red|r", |
1618 desc = "Show quantity in red when at least this much of the minimum stock is available.", | 1667 desc = "Show quantity in red when at least this much of the minimum stock is available.", |
1619 get = function() return addon.db.profile.defaults.colors.red; end, | 1668 get = function() return addon.db.profile.defaults.colors.red; end, |
1620 set = function(i, v) addon.db.profile.defaults.colors.red = v; end, | 1669 set = function(i, v) addon.db.profile.defaults.colors.red = v; end, |
1670 }, | |
1671 }, | |
1672 }, | |
1673 extra = { | |
1674 order = 40, | |
1675 type = "group", | |
1676 inline = true, | |
1677 name = "Extra", | |
1678 args = { | |
1679 description = { | |
1680 order = 0, | |
1681 type = "description", | |
1682 name = "Additional optional settings.", | |
1683 }, | |
1684 header = { | |
1685 order = 5, | |
1686 type = "header", | |
1687 name = "", | |
1688 }, | |
1689 removeCharacter = { | |
1690 order = 40, | |
1691 type = "select", | |
1692 name = "Forget character", | |
1693 desc = "Select a character to remove all traces of it from Inventorium's memory.\n\nYour current character can not be removed, you must login to a different character to do so.", | |
1694 values = function() | |
1695 local temp = {}; | |
1696 | |
1697 temp[""] = ""; | |
1698 | |
1699 local playerName = UnitName("player"); | |
1700 for charName in pairs(addon.db.factionrealm.characters) do | |
1701 if playerName ~= charName then | |
1702 temp[charName] = charName; | |
1703 end | |
1704 end | |
1705 | |
1706 return temp; | |
1707 end, | |
1708 set = function(i, value) | |
1709 if value and value ~= "" then | |
1710 addon.db.factionrealm.characters[value] = nil; | |
1711 addon.db.profile.defaults.trackAtCharacters[value] = nil; | |
1712 for name, values in pairs(addon.db.profile.groups) do | |
1713 if values.trackAtCharacters then | |
1714 values.trackAtCharacters[name] = nil; | |
1715 end | |
1716 end | |
1717 end | |
1718 end, | |
1621 }, | 1719 }, |
1622 }, | 1720 }, |
1623 }, | 1721 }, |
1624 }, | 1722 }, |
1625 }; | 1723 }; |
1850 if temp.items then | 1948 if temp.items then |
1851 -- Remove items that are already in another group | 1949 -- Remove items that are already in another group |
1852 for value, _ in pairs(temp.items) do | 1950 for value, _ in pairs(temp.items) do |
1853 local itemId = tonumber(value); | 1951 local itemId = tonumber(value); |
1854 | 1952 |
1953 local itemData = addon.ItemData:New(itemId); | |
1954 | |
1855 if not itemId then | 1955 if not itemId then |
1856 print(("\"%s\" is not a number."):format(value)); | 1956 print(("\"%s\" is not a number."):format(value)); |
1857 temp.items[value] = nil; | 1957 temp.items[value] = nil; |
1858 elseif mod:InGroup(itemId) then | 1958 elseif itemData:InGroup() then |
1859 print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, mod:InGroup(itemId))); | 1959 print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); |
1860 temp.items[value] = nil; | 1960 temp.items[value] = nil; |
1861 else | 1961 else |
1862 -- Ensure the keys are numeric | 1962 -- Ensure the keys are numeric |
1863 temp.items[value] = nil; | 1963 temp.items[value] = nil; |
1864 temp.items[itemId] = true; | 1964 temp.items[itemId] = true; |
1906 end | 2006 end |
1907 | 2007 |
1908 count = ( count + 1 ); | 2008 count = ( count + 1 ); |
1909 end | 2009 end |
1910 end | 2010 end |
1911 end | |
1912 | |
1913 | |
1914 | |
1915 | |
1916 | |
1917 -- Group functions | |
1918 | |
1919 function mod:InGroup(itemId) | |
1920 -- Go through all groups to see if this item is already somewhere | |
1921 for groupName, values in pairs(addon.db.profile.groups) do | |
1922 if values.items and values.items[itemId] then | |
1923 return groupName; | |
1924 end | |
1925 end | |
1926 | |
1927 return; | |
1928 end | |
1929 | |
1930 function mod:AddItemToGroup(groupName, itemId) | |
1931 if self:InGroup(itemId) then | |
1932 return false; | |
1933 end | |
1934 | |
1935 if not addon.db.profile.groups[groupName].items then | |
1936 addon.db.profile.groups[groupName].items = {}; | |
1937 end | |
1938 | |
1939 -- Set this item | |
1940 addon.db.profile.groups[groupName].items[itemId] = true; | |
1941 | |
1942 if AceConfigRegistry then | |
1943 -- Now rebuild the list | |
1944 AceConfigRegistry:NotifyChange("InventoriumOptions"); | |
1945 end | |
1946 | |
1947 return true; | |
1948 end | |
1949 | |
1950 function mod:RemoveItemFromGroup(groupName, itemId) | |
1951 if self:InGroup(itemId) ~= groupName then | |
1952 return false; | |
1953 end | |
1954 | |
1955 -- Unset this item | |
1956 addon.db.profile.groups[groupName].items[itemId] = nil; | |
1957 | |
1958 return true; | |
1959 end | 2011 end |
1960 | 2012 |
1961 | 2013 |
1962 | 2014 |
1963 | 2015 |
1984 -- Yes was clicked | 2036 -- Yes was clicked |
1985 | 2037 |
1986 for itemId, version in pairs(groupInfo.items) do | 2038 for itemId, version in pairs(groupInfo.items) do |
1987 -- Go through all items in this premade group | 2039 -- Go through all items in this premade group |
1988 | 2040 |
2041 local itemData = addon.ItemData:New(itemId); | |
2042 | |
1989 if version > values.premadeGroups[premadeGroupName] then | 2043 if version > values.premadeGroups[premadeGroupName] then |
1990 -- This item was added in a more recent version than this group: Add item | 2044 -- This item was added in a more recent version than this group: Add item |
1991 | 2045 |
1992 if mod:InGroup(itemId) then | 2046 if itemData:InGroup() then |
1993 print(("Skipping %s (#%d) as it is already in the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, mod:InGroup(itemId))); | 2047 print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); |
1994 elseif mod:AddItemToGroup(groupName, itemId) then | 2048 elseif itemData:AddToGroup(groupName) then |
1995 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, mod:InGroup(itemId))); | 2049 addon.Print(("Added %s found in the premade group |cfffed000%s|r to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), premadeGroupName, itemData:InGroup() ), addon.Colors.Green); |
1996 end | 2050 end |
1997 elseif ( version * -1 ) > values.premadeGroups[premadeGroupName] then | 2051 elseif ( version * -1 ) > values.premadeGroups[premadeGroupName] then |
1998 if mod:InGroup(itemId) == groupName then | 2052 if itemData:InGroup() == groupName then |
1999 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, mod:InGroup(itemId), premadeGroupName)); | 2053 itemData:RemoveFromGroup(groupName); |
2000 mod:RemoveItemFromGroup(groupName, itemId); | 2054 |
2055 addon.Print(("Removed %s from the group |cfffed000%s|r as it was removed from the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup(), premadeGroupName ), addon.Colors.Red); | |
2001 else | 2056 else |
2002 print(("Skipping the removal of %s (#%d) as it isn't in this group."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, mod:InGroup(itemId))); | 2057 print(("Skipping the removal of %s as it isn't in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); |
2003 end | 2058 end |
2004 end | 2059 end |
2060 end | |
2061 | |
2062 if AceConfigRegistry then | |
2063 -- Now rebuild the list | |
2064 AceConfigRegistry:NotifyChange("InventoriumOptions"); | |
2005 end | 2065 end |
2006 | 2066 |
2007 -- Remember the new version | 2067 -- Remember the new version |
2008 values.premadeGroups[premadeGroupName] = groupInfo.version; | 2068 values.premadeGroups[premadeGroupName] = groupInfo.version; |
2009 else | 2069 else |
2011 | 2071 |
2012 -- Let user know what was not added | 2072 -- Let user know what was not added |
2013 for itemId, version in pairs(groupInfo.items) do | 2073 for itemId, version in pairs(groupInfo.items) do |
2014 -- Go through all items in this premade group | 2074 -- Go through all items in this premade group |
2015 | 2075 |
2076 local itemData = addon.ItemData:New(itemId); | |
2077 | |
2016 if version > values.premadeGroups[premadeGroupName] then | 2078 if version > values.premadeGroups[premadeGroupName] then |
2017 -- This item was added in a more recent version than this group: don't add (since we clicked no), but announce it | 2079 -- This item was added in a more recent version than this group: don't add (since we clicked no), but announce it |
2018 | 2080 |
2019 print(("Skipping %s (#%d) found in the premade group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, mod:InGroup(itemId))); | 2081 print(("Skipping %s found in the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() )); |
2020 end | 2082 end |
2021 end | 2083 end |
2022 | 2084 |
2023 -- Remember the new version | 2085 -- Remember the new version |
2024 values.premadeGroups[premadeGroupName] = groupInfo.version; | 2086 values.premadeGroups[premadeGroupName] = groupInfo.version; |