comparison Core.lua @ 50:9607b3251655

Added OnSelect event support to both item count as crafting addons. Added basic local item count data support. Fixed "Show in summary when below" option to allow a value of up to 10.000%. Summary should now respect virtual groups.
author Zerotorescue
date Sat, 18 Dec 2010 00:22:06 +0100
parents 87d68ccf0a8f
children 03c0610e9c1e
comparison
equal deleted inserted replaced
49:51d85a84b40c 50:9607b3251655
647 end 647 end
648 648
649 return temp; 649 return temp;
650 end, 650 end,
651 get = function() return self.db.global.defaults.itemCountAddon; end, 651 get = function() return self.db.global.defaults.itemCountAddon; end,
652 set = function(i, v) self.db.global.defaults.itemCountAddon = v; end, 652 set = function(i, v)
653 self.db.global.defaults.itemCountAddon = v;
654
655 if self.supportedAddons.itemCount[v].OnSelect then
656 self.supportedAddons.itemCount[v].OnSelect();
657 end
658 end,
653 }, 659 },
654 craftingAddon = { 660 craftingAddon = {
655 order = 30, 661 order = 30,
656 type = "select", 662 type = "select",
657 name = "Prefered crafting addon", 663 name = "Prefered crafting addon",
663 end 669 end
664 670
665 return temp; 671 return temp;
666 end, 672 end,
667 get = function() return self.db.global.defaults.craftingAddon; end, 673 get = function() return self.db.global.defaults.craftingAddon; end,
668 set = function(i, v) self.db.global.defaults.craftingAddon = v; end, 674 set = function(i, v)
669 }, 675 self.db.global.defaults.craftingAddon = v;
670 --[[localItemData = { 676
677 if self.supportedAddons.crafting[v].OnSelect then
678 self.supportedAddons.crafting[v].OnSelect();
679 end
680 end,
681 },
682 localItemData = {
671 order = 40, 683 order = 40,
672 type = "multiselect", 684 type = "multiselect",
673 name = "Include in local item data", 685 name = "Include in local item data",
674 desc = "Select which data should be included in the local item data.", 686 desc = "Select which data should be included in the local item data.",
675 values = { 687 values = {
679 ["Mailbox"] = "Mailbox", 691 ["Mailbox"] = "Mailbox",
680 }, 692 },
681 get = function(i, v) return self.db.global.defaults.localItemData and self.db.global.defaults.localItemData[v]; end, 693 get = function(i, v) return self.db.global.defaults.localItemData and self.db.global.defaults.localItemData[v]; end,
682 set = function(i, v, e) self.db.global.defaults.localItemData[v] = e or nil; end, 694 set = function(i, v, e) self.db.global.defaults.localItemData[v] = e or nil; end,
683 --dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead. 695 --dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead.
684 },]] 696 },
685 }, 697 },
686 }, 698 },
687 minimumStock = { 699 minimumStock = {
688 order = 10, 700 order = 10,
689 type = "group", 701 type = "group",
714 }, 726 },
715 summaryThresholdShow = { 727 summaryThresholdShow = {
716 order = 20, 728 order = 20,
717 type = "range", 729 type = "range",
718 min = 0, 730 min = 0,
719 max = 100, 731 max = 10,
720 softMax = 10, 732 softMax = 100,
721 step = 0.05, 733 step = 0.05,
722 isPercent = true, 734 isPercent = true,
723 name = "Show in summary when below", 735 name = "Show in summary when below",
724 desc = "Show items in the summary when below this percentage of the minimum stock.\n\nYou can manually enter a value between 1.000% and 10.000% in the edit box if the provided range is insufficient.", 736 desc = "Show items in the summary when below this percentage of the minimum stock.\n\nYou can manually enter a value between 1.000% and 10.000% in the edit box if the provided range is insufficient.",
725 get = function() return self.db.global.defaults.summaryThresholdShow; end, 737 get = function() return self.db.global.defaults.summaryThresholdShow; end,
1278 temp[name] = name; 1290 temp[name] = name;
1279 end 1291 end
1280 1292
1281 return temp; 1293 return temp;
1282 end, 1294 end,
1295 set = function(info, value)
1296 local groupName = groupIdToName[info[2]];
1297 local optionName = info[#info];
1298
1299 addon.db.global.groups[groupName][optionName] = value ~= "" and value;
1300
1301 if addon.supportedAddons.itemCount[value].OnSelect then
1302 addon.supportedAddons.itemCount[value].OnSelect();
1303 end
1304 end,
1283 arg = "overrideItemCountAddon", 1305 arg = "overrideItemCountAddon",
1284 }, 1306 },
1285 overrideCraftingAddon = { 1307 overrideCraftingAddon = {
1286 order = 29, 1308 order = 29,
1287 type = "toggle", 1309 type = "toggle",
1300 temp[name] = name; 1322 temp[name] = name;
1301 end 1323 end
1302 1324
1303 return temp; 1325 return temp;
1304 end, 1326 end,
1327 set = function(info, value)
1328 local groupName = groupIdToName[info[2]];
1329 local optionName = info[#info];
1330
1331 addon.db.global.groups[groupName][optionName] = value ~= "" and value;
1332
1333 if addon.supportedAddons.crafting[value].OnSelect then
1334 addon.supportedAddons.crafting[value].OnSelect();
1335 end
1336 end,
1305 arg = "overrideCraftingAddon", 1337 arg = "overrideCraftingAddon",
1306 }, 1338 },
1307 --[[overrideLocalItemData = { 1339 overrideLocalItemData = {
1308 order = 39, 1340 order = 39,
1309 type = "toggle", 1341 type = "toggle",
1310 name = "Override local item data", 1342 name = "Override local item data",
1311 desc = "Allows you to override the local item data setting for this group.", 1343 desc = "Allows you to override the local item data setting for this group.",
1312 arg = "localItemData", 1344 arg = "localItemData",
1323 ["Mailbox"] = "Mailbox", 1355 ["Mailbox"] = "Mailbox",
1324 }, 1356 },
1325 get = GetMultiOption, 1357 get = GetMultiOption,
1326 --dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead. 1358 --dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead.
1327 arg = "overrideLocalItemData", 1359 arg = "overrideLocalItemData",
1328 },]] 1360 },
1329 virtualGroup = { 1361 virtualGroup = {
1330 order = 50, 1362 order = 50,
1331 type = "select", 1363 type = "select",
1332 name = "Use virtual group settings", 1364 name = "Use virtual group settings",
1333 desc = "Use the settings from a virtual group before using the general defaults.\n\n|cffff9933This is an advanced option, you will probably not need it unless you manage a lot of groups.|r\n\n|cfffed000Off|r: Use the overridden options in this group and then the defaults.\n\n|cfffed000On|r: Use the overridden options in this group, then the ones in the selected virtual group and then the defaults.", 1365 desc = "Use the settings from a virtual group before using the general defaults.\n\n|cffff9933This is an advanced option, you will probably not need it unless you manage a lot of groups.|r\n\n|cfffed000Off|r: Use the overridden options in this group and then the defaults.\n\n|cfffed000On|r: Use the overridden options in this group, then the ones in the selected virtual group and then the defaults.",
1401 }, 1433 },
1402 summaryThresholdShow = { 1434 summaryThresholdShow = {
1403 order = 20, 1435 order = 20,
1404 type = "range", 1436 type = "range",
1405 min = 0, 1437 min = 0,
1406 max = 100, 1438 max = 10,
1407 softMax = 10, 1439 softMax = 100,
1408 step = 0.05, 1440 step = 0.05,
1409 isPercent = true, 1441 isPercent = true,
1410 name = "Show in summary when below", 1442 name = "Show in summary when below",
1411 desc = "Show items in the summary when below the specified percentage of the minimum stock.\n\nYou can manually enter a value between 1.000% and 10.000% in the edit box if the provided range is insufficient.", 1443 desc = "Show items in the summary when below the specified percentage of the minimum stock.\n\nYou can manually enter a value between 1.000% and 10.000% in the edit box if the provided range is insufficient.",
1412 arg = "overrideSummaryThresholdShow", 1444 arg = "overrideSummaryThresholdShow",
2190 local itemCountAddon = self:GetItemCountAddon(group); 2222 local itemCountAddon = self:GetItemCountAddon(group);
2191 2223
2192 return (itemCountAddon and itemCountAddon.GetTotalCount(itemId)) or -1; 2224 return (itemCountAddon and itemCountAddon.GetTotalCount(itemId)) or -1;
2193 end 2225 end
2194 2226
2227 function addon:GetLocalItemCount(itemId, group)
2228 itemId = tonumber(itemId);
2229
2230 if not itemId then return; end
2231
2232 local itemCountAddon = self:GetItemCountAddon(group);
2233
2234 local currentItemCount;
2235
2236 if itemCountAddon and itemCountAddon.GetCharacterCount then
2237 local bag, bank, auctionHouse, mail = itemCountAddon.GetCharacterCount(itemId);
2238
2239 local selectedLocalItemCountSources = self:GetOptionByKey(group, "localItemData");
2240
2241 currentItemCount = 0;
2242 if selectedLocalItemCountSources["Bag"] then
2243 currentItemCount = currentItemCount + bag;
2244 end
2245 if selectedLocalItemCountSources["Bank"] then
2246 currentItemCount = currentItemCount + bank;
2247 end
2248 if selectedLocalItemCountSources["Auction House"] then
2249 currentItemCount = currentItemCount + auctionHouse;
2250 end
2251 if selectedLocalItemCountSources["Mailbox"] then
2252 currentItemCount = currentItemCount + mail;
2253 end
2254 end
2255
2256 return currentItemCount or -1;
2257 end
2258
2195 function addon:GetAuctionValue(itemLink, group) 2259 function addon:GetAuctionValue(itemLink, group)
2196 if not itemLink then return -5; end 2260 if not itemLink then return -5; end
2197 2261
2198 local selectedExternalAddon = self:GetOptionByKey(group, "auctionPricingAddon"); 2262 local selectedExternalAddon = self:GetOptionByKey(group, "auctionPricingAddon");
2199 2263
2224 IsEnabled = enabled, 2288 IsEnabled = enabled,
2225 OnSelect = onSelect, 2289 OnSelect = onSelect,
2226 }; 2290 };
2227 end 2291 end
2228 2292
2229 function IMRegisterItemCountAddon(name, getTotal, getCharacter, enabled) 2293 function IMRegisterItemCountAddon(name, getTotal, getCharacter, enabled, onSelect)
2230 addon.supportedAddons.itemCount[name] = { 2294 addon.supportedAddons.itemCount[name] = {
2231 GetTotalCount = getTotal, 2295 GetTotalCount = getTotal,
2232 GetCharacterCount = getCharacter, 2296 GetCharacterCount = getCharacter,
2233 IsEnabled = enabled, 2297 IsEnabled = enabled,
2298 OnSelect = onSelect,
2234 }; 2299 };
2235 end 2300 end
2236 2301
2237 function IMRegisterCraftingAddon(name, queue, enabled) 2302 function IMRegisterCraftingAddon(name, queue, enabled, onSelect)
2238 addon.supportedAddons.crafting[name] = { 2303 addon.supportedAddons.crafting[name] = {
2239 Queue = queue, 2304 Queue = queue,
2240 IsEnabled = enabled, 2305 IsEnabled = enabled,
2306 OnSelect = onSelect,
2241 }; 2307 };
2242 end 2308 end
2243 2309
2244 2310
2245 2311