comparison Core.lua @ 31:e732843b16d2 v0.1.6-BETA

Added an info box to the top of the general group. Removed the ?Don't queue when below threshold?, this is now default (can?t make it too complicated). Implemented working functionality for virtual groups. ?Include in local item data? can now be overridden in every group. Added help text at the replenishing stock indicating how auction values are used when queueing. The tabs ?add items? and ?current items? will now be hidden rather than disabled when you have a virtual group selected. The auction value/price threshold for items will now be used when queueing items.
author Zerotorescue
date Sat, 30 Oct 2010 23:04:45 +0200
parents 8177b5bcb883
children 31e5da6a2b16
comparison
equal deleted inserted replaced
30:8177b5bcb883 31:e732843b16d2
33 minCraftingQueue = 0.05, 33 minCraftingQueue = 0.05,
34 bonusQueue = 0.1, 34 bonusQueue = 0.1,
35 priceThreshold = 0, 35 priceThreshold = 0,
36 summaryHidePriceThreshold = false, 36 summaryHidePriceThreshold = false,
37 trackAtCharacters = {}, 37 trackAtCharacters = {},
38 localItemData = {
39 ["Bag"] = true,
40 ["Auction House"] = true,
41 },
38 summary = { 42 summary = {
39 speed = 5, 43 speed = 5,
40 width = 650, 44 width = 650,
41 height = 600, 45 height = 600,
42 }, 46 },
501 order = 100, 505 order = 100,
502 type = "group", 506 type = "group",
503 name = "General", 507 name = "General",
504 desc = "Change general Inventorium settings.", 508 desc = "Change general Inventorium settings.",
505 args = { 509 args = {
510 info = {
511 order = 1,
512 type = "group",
513 inline = true,
514 name = "BETA Information",
515 args = {
516 description = {
517 order = 5,
518 type = "description",
519 name = "Please note that all multi-select |cfffed000dropdown|r boxes were turned into multi-select |cfffed000toggle|r boxes. I do not intend to keep it this way, however it can not yet be reverted due to a major bug in one of the libraries used by Inventorium. The layout of this config may look terribly organized in it's current state.\n\n" ..
520 "Since this is a beta some functionality might not be implemented yet while the options are available (usually - but not always - tagged as \"NYI\"). These options are used to indicate a feature is on the way and will be implemented before Inventorium is tagged as a release.\n\n" ..
521 "Please request things you want and report anything that's clunky, weird, vague or otherwise buggy at |cfffed000the Inventorium development addon page|r. You can find this by searching for \"|cfffed000Inventorium|r\" at |cfffed000CurseForge.com|r.\n\n" ..
522 "Tutorials for Inventorium will be created after the first stable release. If you require any help before that you can always contact me in the |cfffed000#JMTC|r IRC channel at |cfffed000QuakeNet.org|r. You may also report issues and request things there if you wish.\n\n" ..
523 "You might notice the summary window currently gets very slow when refreshed once you get over 100-200 items in the list, this is a known issue and will be fixed in version 1.1 (which is after the initial release).",
524 },
525 },
526 },
506 general = { 527 general = {
507 order = 0, 528 order = 1,
508 type = "group", 529 type = "group",
509 inline = true, 530 inline = true,
510 name = "General", 531 name = "General",
511 args = { 532 args = {
512 description = { 533 description = {
568 set = function(i, v) self.db.global.defaults.craftingAddon = v; end, 589 set = function(i, v) self.db.global.defaults.craftingAddon = v; end,
569 }, 590 },
570 localItemData = { 591 localItemData = {
571 order = 40, 592 order = 40,
572 type = "multiselect", 593 type = "multiselect",
573 name = "Include in local item data NYI | PH", 594 name = "Include in local item data",
574 desc = "Select which data should be included in the local item data.", 595 desc = "Select which data should be included in the local item data.",
575 values = { 596 values = {
576 ["Bag"] = "Bag", 597 ["Bag"] = "Bag",
577 ["Bank"] = "Bank", 598 ["Bank"] = "Bank",
578 ["Auction House"] = "Auction House", 599 ["Auction House"] = "Auction House",
725 name = "Hide when below threshold", 746 name = "Hide when below threshold",
726 desc = "Hide items from the summary when their value is below the set price threshold.", 747 desc = "Hide items from the summary when their value is below the set price threshold.",
727 get = function() return self.db.global.defaults.summaryHidePriceThreshold; end, 748 get = function() return self.db.global.defaults.summaryHidePriceThreshold; end,
728 set = function(i, v) self.db.global.defaults.summaryHidePriceThreshold = v; end, 749 set = function(i, v) self.db.global.defaults.summaryHidePriceThreshold = v; end,
729 }, 750 },
730 queueSkipPriceThreshild = {
731 order = 55,
732 type = "toggle",
733 name = "NYI | Don't queue when below threshold",
734 desc = "Do not queue items when their value is below the set price threshold.",
735 get = function() return self.db.global.defaults.queueSkipPriceThreshild; end,
736 set = function(i, v) self.db.global.defaults.queueSkipPriceThreshild = v; end,
737 },
738 alwaysGetAuctionValue = { 751 alwaysGetAuctionValue = {
739 order = 60, 752 order = 60,
740 type = "toggle", 753 type = "toggle",
741 name = "Always show auction value", 754 name = "Always show auction value",
742 desc = "Always cache and show the auction value of items, even if the price threshold is set to 0.", 755 desc = "Always cache and show the auction value of items, even if the price threshold is set to 0|cffeda55fc|r.",
743 get = function() return self.db.global.defaults.alwaysGetAuctionValue; end, 756 get = function() return self.db.global.defaults.alwaysGetAuctionValue; end,
744 set = function(i, v) self.db.global.defaults.alwaysGetAuctionValue = v; end, 757 set = function(i, v) self.db.global.defaults.alwaysGetAuctionValue = v; end,
745 }, 758 },
746 }, 759 },
747 }, 760 },
821 local function SetOption(info, value, multiSelectEnabled) 834 local function SetOption(info, value, multiSelectEnabled)
822 local groupName = groupIdToName[info[2]]; 835 local groupName = groupIdToName[info[2]];
823 local optionName = info[#info]; 836 local optionName = info[#info];
824 837
825 -- Special treatment for override toggle boxes 838 -- Special treatment for override toggle boxes
826 if not info.arg:find("override") then 839 if optionName:find("override") then
827 if not value and info.arg then 840 if not value and info.arg then
828 -- If this override was disabled and a saved variable name was provided, set it to nil rather than false 841 -- If this override was disabled and a saved variable name was provided, set it to nil rather than false
829 842
830 value = nil; 843 value = nil;
831 844
850 end 863 end
851 end 864 end
852 865
853 function addon:GetOptionByKey(groupName, optionName, noDefault) 866 function addon:GetOptionByKey(groupName, optionName, noDefault)
854 if groupName and self.db.global.groups[groupName] and self.db.global.groups[groupName][optionName] ~= nil then 867 if groupName and self.db.global.groups[groupName] and self.db.global.groups[groupName][optionName] ~= nil then
868 -- If this option exists within the settings of this group
869
855 return self.db.global.groups[groupName][optionName]; 870 return self.db.global.groups[groupName][optionName];
871 elseif groupName and self.db.global.groups[groupName] and self.db.global.groups[groupName].virtualGroup ~= "" and not noDefault then
872 -- If a virtual group was selected
873
874 return self:GetOptionByKey(self.db.global.groups[groupName].virtualGroup, optionName, noDefault);
856 elseif self.db.global.defaults[optionName] and not noDefault then 875 elseif self.db.global.defaults[optionName] and not noDefault then
857 return self.db.global.defaults[optionName]; 876 return self.db.global.defaults[optionName];
858 else 877 else
859 return nil; 878 return nil;
860 end 879 end
862 881
863 local function GetOption(info) 882 local function GetOption(info)
864 local groupName = groupIdToName[info[2]]; 883 local groupName = groupIdToName[info[2]];
865 local optionName = info[#info]; 884 local optionName = info[#info];
866 885
867 return addon:GetOptionByKey(groupName, optionName); 886 local noDefault;
887
888 if optionName:find("override") then
889 noDefault = true;
890 end
891
892 return addon:GetOptionByKey(groupName, optionName, noDefault);
868 end 893 end
869 894
870 local function GetMultiOption(info, value) 895 local function GetMultiOption(info, value)
871 local groupName = groupIdToName[info[2]]; 896 local groupName = groupIdToName[info[2]];
872 local optionName = info[#info]; 897 local optionName = info[#info];
879 return nil; 904 return nil;
880 end 905 end
881 end 906 end
882 907
883 local function GetDisabled(info) 908 local function GetDisabled(info)
884 if not info.arg or not info.arg:find("override") then
885 return false;
886 end
887
888 local groupName = groupIdToName[info[2]]; 909 local groupName = groupIdToName[info[2]];
889 local optionName = info[#info]; 910 local optionName = info[#info];
911
912 if optionName:find("override") then
913 return false;
914 end
890 915
891 return (addon:GetOptionByKey(groupName, info.arg, true) == nil); 916 return (addon:GetOptionByKey(groupName, info.arg, true) == nil);
892 end 917 end
893 918
894 local function ValidateGroupName(_, value) 919 local function ValidateGroupName(_, value)
1185 1210
1186 return temp; 1211 return temp;
1187 end, 1212 end,
1188 arg = "overrideCraftingAddon", 1213 arg = "overrideCraftingAddon",
1189 }, 1214 },
1215 overrideLocalItemData = {
1216 order = 39,
1217 type = "toggle",
1218 name = "Override local item data",
1219 desc = "Allows you to override the local item data setting for this group.",
1220 arg = "localItemData",
1221 },
1222 localItemData = {
1223 order = 40,
1224 type = "multiselect",
1225 name = "Include in local item data",
1226 desc = "Select which data should be included in the local item data.",
1227 values = {
1228 ["Bag"] = "Bag",
1229 ["Bank"] = "Bank",
1230 ["Auction House"] = "Auction House",
1231 ["Mailbox"] = "Mailbox",
1232 },
1233 get = GetMultiOption,
1234 --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.
1235 arg = "overrideLocalItemData",
1236 },
1190 virtualGroup = { 1237 virtualGroup = {
1191 order = 40, 1238 order = 50,
1192 type = "select", 1239 type = "select",
1193 name = "Use virtual group settings", 1240 name = "Use virtual group settings",
1194 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.", 1241 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.",
1195 values = function() 1242 values = function(info)
1243 local groupName = groupIdToName[info[2]];
1244
1196 local temp = {}; 1245 local temp = {};
1197 1246
1198 --TODO: Build list based on virtual groups we have, exclude the currently selected virtual group (allow endless linking, e.g. Normal group -> virtual1 -> virtual2 -> virtual3 -> ... -> defaults, do this by calling the "GetOptionByKey" function whenever a virtual group is enabled)
1199 temp[""] = ""; 1247 temp[""] = "";
1200 temp["NYI"] = "Not Yet Implemented"; 1248 for name, values in pairs(addon.db.global.groups) do
1249 if values.isVirtual and name ~= groupName then
1250 temp[name] = name;
1251 end
1252 end
1201 1253
1202 return temp; 1254 return temp;
1255 end,
1256 set = function(info, value)
1257 local groupName = groupIdToName[info[2]];
1258 local optionName = info[#info];
1259
1260 addon.db.global.groups[groupName][optionName] = value ~= "" and value;
1203 end, 1261 end,
1204 }, 1262 },
1205 }, 1263 },
1206 }, 1264 },
1207 minimumStock = { 1265 minimumStock = {
1214 disabled = GetDisabled, 1272 disabled = GetDisabled,
1215 args = { 1273 args = {
1216 description = { 1274 description = {
1217 order = 0, 1275 order = 0,
1218 type = "description", 1276 type = "description",
1219 name = "Here you can specify the minimum amount of items you wish to keep in stock and related settings for the currently selected group.", 1277 name = "Here you can specify the minimum amount of items you wish to keep in stock and related settings for the currently selected group. Please note the values entered here do not affect the queued quantities, you must set settings for that in the area below.",
1220 }, 1278 },
1221 header = { 1279 header = {
1222 order = 5, 1280 order = 5,
1223 type = "header", 1281 type = "header",
1224 name = "", 1282 name = "",
1314 type = "description", 1372 type = "description",
1315 name = function(info) 1373 name = function(info)
1316 local groupName = groupIdToName[info[2]]; 1374 local groupName = groupIdToName[info[2]];
1317 local r = "Here you can specify the amount of items to which you wish to restock when you are collecting new items for the currently selected group. This may be higher than the minimum stock.\n\n"; 1375 local r = "Here you can specify the amount of items to which you wish to restock when you are collecting new items for the currently selected group. This may be higher than the minimum stock.\n\n";
1318 1376
1319 r = r .. "When restocking the target amount is |cfffed000" .. addon:GetOptionByKey(groupName, "restockTarget") .. "|r of every item. Not queueing craftable items when only missing |cfffed000" .. floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * addon:GetOptionByKey(groupName, "restockTarget") ) .. "|r (|cfffed000" .. ( addon:GetOptionByKey(groupName, "minCraftingQueue") * 100 ) .. "%|r) of the restock target and making |cfffed000" .. floor( ( addon:GetOptionByKey(groupName, "bonusQueue") * addon:GetOptionByKey(groupName, "restockTarget") ) + .5 ) .. "|r (|cfffed000" .. ( addon:GetOptionByKey(groupName, "bonusQueue") * 100 ) .. "%|r) extra items when you completely ran out."; 1377 r = r .. "When restocking the target amount is |cfffed000" .. addon:GetOptionByKey(groupName, "restockTarget") .. "|r of every item. Not queueing craftable items when only missing |cfffed000" .. floor( addon:GetOptionByKey(groupName, "minCraftingQueue") * addon:GetOptionByKey(groupName, "restockTarget") ) .. "|r (|cfffed000" .. ( addon:GetOptionByKey(groupName, "minCraftingQueue") * 100 ) .. "%|r) of the restock target and making |cfffed000" .. floor( ( addon:GetOptionByKey(groupName, "bonusQueue") * addon:GetOptionByKey(groupName, "restockTarget") ) + .5 ) .. "|r (|cfffed000" .. ( addon:GetOptionByKey(groupName, "bonusQueue") * 100 ) .. "%|r) extra items when you completely ran out. ";
1378
1379 if addon:GetOptionByKey(groupName, "priceThreshold") == 0 then
1380 r = r .. "Queueing items at |cfffed000any|r auction value.";
1381 else
1382 r = r .. "Queueing items worth |cfffed000" .. addon:ReadableMoney(addon:GetOptionByKey(groupName, "priceThreshold")) .. "|r or more.";
1383 end
1320 1384
1321 return r; 1385 return r;
1322 end, 1386 end,
1323 }, 1387 },
1324 header = { 1388 header = {
1409 type = "toggle", 1473 type = "toggle",
1410 name = "Hide when below threshold", 1474 name = "Hide when below threshold",
1411 desc = "Hide items from the summary when their value is below the set price threshold.", 1475 desc = "Hide items from the summary when their value is below the set price threshold.",
1412 arg = "overrideSummaryHidePriceThreshold", 1476 arg = "overrideSummaryHidePriceThreshold",
1413 }, 1477 },
1414 overrideQueueSkipPriceThreshild = {
1415 order = 54,
1416 type = "toggle",
1417 name = "Override queue skipping",
1418 desc = "Allows you to override if items in this group should be skipped when queueing while their value is below the price threshold.",
1419 arg = "queueSkipPriceThreshild",
1420 },
1421 queueSkipPriceThreshild = {
1422 order = 55,
1423 type = "toggle",
1424 name = "NYI | Don't queue when below threshold",
1425 desc = "Do not queue items when their value is below the set price threshold.",
1426 arg = "overrideQueueSkipPriceThreshild",
1427 },
1428 overrideAlwaysGetAuctionValue = { 1478 overrideAlwaysGetAuctionValue = {
1429 order = 59, 1479 order = 59,
1430 type = "toggle", 1480 type = "toggle",
1431 name = "Override auction value showing", 1481 name = "Override auction value showing",
1432 desc = "Allows you to override if the auction value of items in this group should be cached and displayed even when the price threshold is set to 0.", 1482 desc = "Allows you to override if the auction value of items in this group should be cached and displayed even when the price threshold is set to 0|cffeda55fc|r.",
1433 arg = "alwaysGetAuctionValue", 1483 arg = "alwaysGetAuctionValue",
1434 }, 1484 },
1435 alwaysGetAuctionValue = { 1485 alwaysGetAuctionValue = {
1436 order = 60, 1486 order = 60,
1437 type = "toggle", 1487 type = "toggle",
1438 name = "Always show auction value", 1488 name = "Always show auction value",
1439 desc = "Always cache and show the auction value of items in this group, even if the price threshold is set to 0.", 1489 desc = "Always cache and show the auction value of items in this group, even if the price threshold is set to 0|cffeda55fc|r.",
1440 arg = "overrideAlwaysGetAuctionValue", 1490 arg = "overrideAlwaysGetAuctionValue",
1441 }, 1491 },
1442 }, 1492 },
1443 }, 1493 },
1444 }, 1494 },
1549 add = { 1599 add = {
1550 order = 30, 1600 order = 30,
1551 type = "group", 1601 type = "group",
1552 name = "Add items", 1602 name = "Add items",
1553 desc = "Add new items to this group.", 1603 desc = "Add new items to this group.",
1554 disabled = function(info) return groupIsVirtual[info[2]]; end, 1604 hidden = function(info) return groupIsVirtual[info[2]]; end,
1555 args = { 1605 args = {
1556 singleAdd = { 1606 singleAdd = {
1557 order = 10, 1607 order = 10,
1558 type = "group", 1608 type = "group",
1559 inline = true, 1609 inline = true,
1749 remove = { 1799 remove = {
1750 order = 40, 1800 order = 40,
1751 type = "group", 1801 type = "group",
1752 name = "Current items", 1802 name = "Current items",
1753 desc = "View, export or remove items from this group.", 1803 desc = "View, export or remove items from this group.",
1754 disabled = function(info) return groupIsVirtual[info[2]]; end, 1804 hidden = function(info) return groupIsVirtual[info[2]]; end,
1755 args = { 1805 args = {
1756 help = { 1806 help = {
1757 order = 10, 1807 order = 10,
1758 type = "group", 1808 type = "group",
1759 inline = true, 1809 inline = true,