comparison Modules/Config.lua @ 172:e31b68c119df

Inventorium should now also appear in the Blizzard options frame.
author Zerotorescue
date Thu, 27 Jan 2011 22:48:17 +0100
parents fcc95c62d232
children 26c750a10b14
comparison
equal deleted inserted replaced
171:5f405272cdd4 172:e31b68c119df
107 addon:Print("Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.", addon.Colors.Red); 107 addon:Print("Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.", addon.Colors.Red);
108 end 108 end
109 109
110 if AceConfigRegistry then 110 if AceConfigRegistry then
111 -- Now rebuild the list 111 -- Now rebuild the list
112 AceConfigRegistry:NotifyChange("InventoriumOptions"); 112 AceConfigRegistry:NotifyChange("Inventorium");
113 end 113 end
114 end 114 end
115 end, 115 end,
116 width = "double", 116 width = "double",
117 dialogControl = "ConfigItemLinkButton", 117 dialogControl = "ConfigItemLinkButton",
135 135
136 itemData:RemoveFromGroup(groupName); 136 itemData:RemoveFromGroup(groupName);
137 137
138 if AceConfigRegistry then 138 if AceConfigRegistry then
139 -- Now rebuild the list 139 -- Now rebuild the list
140 AceConfigRegistry:NotifyChange("InventoriumOptions"); 140 AceConfigRegistry:NotifyChange("Inventorium");
141 end 141 end
142 end 142 end
143 end, 143 end,
144 width = "double", 144 width = "double",
145 dialogControl = "ConfigItemLinkButton", 145 dialogControl = "ConfigItemLinkButton",
954 if itemData:AddToGroup(groupName) then 954 if itemData:AddToGroup(groupName) then
955 addon:Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green); 955 addon:Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green);
956 956
957 if AceConfigRegistry then 957 if AceConfigRegistry then
958 -- Now rebuild the list 958 -- Now rebuild the list
959 AceConfigRegistry:NotifyChange("InventoriumOptions"); 959 AceConfigRegistry:NotifyChange("Inventorium");
960 end 960 end
961 else 961 else
962 addon:Print(("%s is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red); 962 addon:Print(("%s is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red);
963 end 963 end
964 end 964 end
992 end 992 end
993 end 993 end
994 994
995 if AceConfigRegistry then 995 if AceConfigRegistry then
996 -- Now rebuild the list 996 -- Now rebuild the list
997 AceConfigRegistry:NotifyChange("InventoriumOptions"); 997 AceConfigRegistry:NotifyChange("Inventorium");
998 end 998 end
999 end, 999 end,
1000 get = false, 1000 get = false,
1001 }, 1001 },
1002 importPremadeData = { 1002 importPremadeData = {
1026 ImportPremadeItemsGroup(groupName, value); 1026 ImportPremadeItemsGroup(groupName, value);
1027 end 1027 end
1028 1028
1029 if AceConfigRegistry then 1029 if AceConfigRegistry then
1030 -- Now rebuild the list 1030 -- Now rebuild the list
1031 AceConfigRegistry:NotifyChange("InventoriumOptions"); 1031 AceConfigRegistry:NotifyChange("Inventorium");
1032 end 1032 end
1033 end, 1033 end,
1034 get = false, 1034 get = false,
1035 }, 1035 },
1036 }, 1036 },
1075 end 1075 end
1076 end 1076 end
1077 1077
1078 if AceConfigRegistry then 1078 if AceConfigRegistry then
1079 -- Now rebuild the list 1079 -- Now rebuild the list
1080 AceConfigRegistry:NotifyChange("InventoriumOptions"); 1080 AceConfigRegistry:NotifyChange("Inventorium");
1081 end 1081 end
1082 end, 1082 end,
1083 get = false, 1083 get = false,
1084 }, 1084 },
1085 minItemLevel = { 1085 minItemLevel = {
1173 end 1173 end
1174 end 1174 end
1175 1175
1176 if AceConfigRegistry then 1176 if AceConfigRegistry then
1177 -- Now rebuild the list 1177 -- Now rebuild the list
1178 AceConfigRegistry:NotifyChange("InventoriumOptions"); 1178 AceConfigRegistry:NotifyChange("Inventorium");
1179 end 1179 end
1180 end, 1180 end,
1181 get = false, 1181 get = false,
1182 }, 1182 },
1183 premadeGroups = { 1183 premadeGroups = {
1286 end 1286 end
1287 1287
1288 this:GetModule("Config"):Show(); 1288 this:GetModule("Config"):Show();
1289 end, { "c", "config", "conf", "option", "options", "opt", "setting", "settings" }, "|Hfunction:InventoriumCommandHandler:config|h|cff00fff7/im config|r|h (or /im c) - Open the config window to change the settings and manage groups."); 1289 end, { "c", "config", "conf", "option", "options", "opt", "setting", "settings" }, "|Hfunction:InventoriumCommandHandler:config|h|cff00fff7/im config|r|h (or /im c) - Open the config window to change the settings and manage groups.");
1290 1290
1291 self:Load(false);
1292
1291 -- Whenever the profile is changed, update the groups | args: (object for the functionName, eventName, functionName) 1293 -- Whenever the profile is changed, update the groups | args: (object for the functionName, eventName, functionName)
1292 addon.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig"); 1294 addon.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig");
1293 addon.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig"); 1295 addon.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig");
1294 addon.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig"); 1296 addon.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig");
1295 1297
1317 self:PremadeGroupsCheck(); 1319 self:PremadeGroupsCheck();
1318 1320
1319 self:FillGroupOptions(); 1321 self:FillGroupOptions();
1320 end 1322 end
1321 1323
1322 function mod:Load() 1324 function mod:Load(premadeGroupsCheck)
1325 if premadeGroupsCheck then
1326 self:PremadeGroupsCheck();
1327 end
1328
1323 if not AceConfigDialog and not AceConfigRegistry then 1329 if not AceConfigDialog and not AceConfigRegistry then
1324 self:PremadeGroupsCheck();
1325
1326 self:FillOptions(); 1330 self:FillOptions();
1327 1331
1328 -- Build options dialog 1332 -- Build options dialog
1329 AceConfigDialog = LibStub("AceConfigDialog-3.0"); 1333 AceConfigDialog = LibStub("AceConfigDialog-3.0");
1330 AceConfigRegistry = LibStub("AceConfigRegistry-3.0"); 1334 AceConfigRegistry = LibStub("AceConfigRegistry-3.0");
1331 -- Register options table 1335 -- Register options table
1332 LibStub("AceConfig-3.0"):RegisterOptionsTable("InventoriumOptions", options); 1336 LibStub("AceConfig-3.0"):RegisterOptionsTable("Inventorium", options);
1333 -- Set a nice default size (so that 4 normal sized elements fit next to eachother) 1337 -- Set a nice default size (so that 4 normal sized elements fit next to eachother)
1334 AceConfigDialog:SetDefaultSize("InventoriumOptions", 975, 600); 1338 AceConfigDialog:SetDefaultSize("Inventorium", 975, 600);
1335 1339
1336 -- In case the addon is loaded from another condition, always call the remove interface options 1340 -- In case the addon is loaded from another condition, always call the remove interface options
1337 if AddonLoader and AddonLoader.RemoveInterfaceOptions then 1341 if AddonLoader and AddonLoader.RemoveInterfaceOptions then
1338 AddonLoader:RemoveInterfaceOptions("Inventorium"); 1342 AddonLoader:RemoveInterfaceOptions("Inventorium");
1339 end 1343 end
1340 1344
1341 -- Add to the blizzard addons options thing 1345 -- Add to the blizzard addons options thing
1342 AceConfigDialog:AddToBlizOptions("InventoriumOptions"); 1346 AceConfigDialog:AddToBlizOptions("Inventorium", "Inventorium");
1343 end 1347 end
1344 end 1348 end
1345 1349
1346 function mod:Show() 1350 function mod:Show()
1347 self:Load(); 1351 self:Load(true);
1348 1352
1349 AceConfigDialog:Open("InventoriumOptions"); 1353 AceConfigDialog:Open("Inventorium");
1350 end 1354 end
1351 1355
1352 function mod:FillOptions() 1356 function mod:FillOptions()
1353 options = { 1357 options = {
1354 type = "group", 1358 type = "group",
2329 end 2333 end
2330 end 2334 end
2331 2335
2332 if AceConfigRegistry then 2336 if AceConfigRegistry then
2333 -- Now rebuild the list 2337 -- Now rebuild the list
2334 AceConfigRegistry:NotifyChange("InventoriumOptions"); 2338 AceConfigRegistry:NotifyChange("Inventorium");
2335 end 2339 end
2336 2340
2337 -- Remember the new version 2341 -- Remember the new version
2338 values.premadeGroups[premadeGroupName] = groupInfo.version; 2342 values.premadeGroups[premadeGroupName] = groupInfo.version;
2339 else 2343 else