comparison Modules/Config.lua @ 84:3bec0ea44607

Cleaned the Inventorium folder; moved all classes to classes directory, modules to modules directory and support addons to plugins directory. In addition support addons are now references within XML files rather than inside the TOC. Fixed the default local item count setting, you can now exclude bag and AH data from it. Fixed some mover algorithm bugs. Mover can no longer freeze the game but instead will terminate the process after a 1000 passes. Now reversing the moves table after making it, rather than every single time it is used. Fixed guild bank support. Now displaying the amount of items moved. Scanner now scans all guild bank tabs rather than only the current. Fixed a bug with local item data not being retrieved properly. Disabled ?enterClicksFirstButton? within dialogs as this causes the dialog to consume all keypress. Events are now at the addon object rather than local.
author Zerotorescue
date Thu, 06 Jan 2011 20:05:30 +0100
parents Config.lua@f885805da5d6
children a12d22ef3f39
comparison
equal deleted inserted replaced
83:6b60f7a1410c 84:3bec0ea44607
1 local addon = select(2, ...);
2 local mod = addon:NewModule("Config");
3
4 local options, groupIdToName, groupIsVirtual, temp, count, includeTradeSkillItems, currentGroupType = {}, {}, {}, {}, 0, 500, "Normal";
5 local AceConfigDialog, AceConfigRegistry, AceSerializer;
6
7 local unknownItemName = "Unknown (#%d)";
8
9 -- Private functions and tables
10
11 local function SetOption(info, value, multiSelectEnabled)
12 local groupName = groupIdToName[info[2]];
13 local optionName = info[#info];
14
15 -- Special treatment for override toggle boxes
16 if optionName:find("override") then
17 if not value and info.arg then
18 -- If this override was disabled and a saved variable name was provided, set it to nil rather than false
19
20 value = nil;
21
22 -- If this is an override toggler then also set the related field to nil
23 addon.db.profile.groups[groupName][info.arg] = nil;
24 elseif value and info.arg then
25 -- If this override is now enabled, we need to copy the default into this field (unless it is not nil (which is supposed to be impossible), in which case we'll use the already selected value)
26
27 local inheritedValue = addon:GetOptionByKey(groupName, info.arg);
28
29 addon.db.profile.groups[groupName][info.arg] = (type(inheritedValue) == "table" and CopyTable(inheritedValue)) or inheritedValue; -- copying defaults by reference would let one (unintendedly) change the defaults
30 end
31 end
32
33 if multiSelectEnabled ~= nil then
34 -- The saved vars for a multiselect will always be an array, it may not yet exist in which case it must be created.
35 if not addon.db.profile.groups[groupName][optionName] then
36 addon.db.profile.groups[groupName][optionName] = {};
37 end
38
39 addon.db.profile.groups[groupName][optionName][value] = multiSelectEnabled or nil;
40 else
41 addon.db.profile.groups[groupName][optionName] = value;
42 end
43 end
44
45 local function GetOption(info)
46 local groupName = groupIdToName[info[2]];
47 local optionName = info[#info];
48
49 local noDefault;
50
51 if optionName:find("override") then
52 noDefault = true;
53 end
54
55 return addon:GetOptionByKey(groupName, optionName, noDefault);
56 end
57
58 local function GetMultiOption(info, value)
59 local groupName = groupIdToName[info[2]];
60 local optionName = info[#info];
61
62 local multiSelectValue = addon:GetOptionByKey(groupName, optionName);
63
64 return multiSelectValue and multiSelectValue[value];
65 end
66
67 local function GetDisabled(info)
68 local groupName = groupIdToName[info[2]];
69 local optionName = info[#info];
70
71 if optionName:find("override") or not info.arg then
72 return false;
73 end
74
75 return (addon:GetOptionByKey(groupName, info.arg, true) == nil);
76 end
77
78 local function ValidateGroupName(_, value)
79 value = string.lower(string.trim(value or ""));
80
81 for name, _ in pairs(addon.db.profile.groups) do
82 if string.lower(name) == value then
83 return ("A group named \"%s\" already exists."):format(name);
84 end
85 end
86
87 return true;
88 end
89
90 local tblAddItemTemplate = {
91 order = 0,
92 type = "input",
93 name = function(info)
94 local itemName, _, itemRarity = GetItemInfo(info[#info]);
95 return tostring( 7 - (itemRarity or 0) ) .. (itemName or "");
96 end,
97 get = function(info)
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
99 end,
100 set = function(groupId, itemData)
101 -- This is NOT a real "set", we pass the widget reference to this function which contains similar, but not the same, info.
102
103 if itemData then
104 local groupName = groupIdToName[groupId];
105
106 if not itemData:AddToGroup(groupName) then
107 print("|cffff0000Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.|r");
108 end
109
110 if AceConfigRegistry then
111 -- Now rebuild the list
112 AceConfigRegistry:NotifyChange("InventoriumOptions");
113 end
114 end
115 end,
116 width = "double",
117 dialogControl = "ConfigItemLinkButton",
118 };
119
120 local tblRemoveItemTemplate = {
121 order = 0,
122 type = "input",
123 name = function(info)
124 local itemName, _, itemRarity = GetItemInfo(info[#info]);
125 return tostring( 7 - (itemRarity or 0) ) .. (itemName or "");
126 end,
127 get = function(info)
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
129 end,
130 set = function(groupId, itemData)
131 -- This is NOT a real "set", we pass the widget reference to this function which contains similar, but not the same, info.
132
133 if itemData then
134 local groupName = groupIdToName[groupId];
135
136 itemData:RemoveFromGroup(groupName);
137
138 if AceConfigRegistry then
139 -- Now rebuild the list
140 AceConfigRegistry:NotifyChange("InventoriumOptions");
141 end
142 end
143 end,
144 width = "double",
145 dialogControl = "ConfigItemLinkButton",
146 };
147
148 local function UpdateAddItemList(info)
149 local groupName = groupIdToName[info[2]];
150
151 if not addon.db.profile.groups[groupName].items then
152 addon.db.profile.groups[groupName].items = {};
153 end
154
155 -- Merge all items from all groups together
156 local items = {};
157 for groupName, values in pairs(addon.db.profile.groups) do
158 if values.items then
159 for itemId, _ in pairs(values.items) do
160 items[itemId] = true;
161 end
162 end
163 end
164
165 local ref = options.args.groups.args[info[2]].args.add.args.list.args;
166
167 -- Remaking the list, so out with the old, in with the new
168 table.wipe(ref);
169
170 -- Parse bags and show these
171 for bagID = 4, 0, -1 do
172 for slot = 1, GetContainerNumSlots(bagID) do
173 local itemId = addon:GetItemId(GetContainerItemLink(bagID, slot));
174
175 if itemId then
176 if not items[itemId] then
177 -- If this item isn't used in any group yet
178 ref[itemId] = tblAddItemTemplate;
179 else
180 -- It's already used in a group, don't show it
181 ref[itemId] = nil;
182 end
183 end
184 end
185 end
186
187 if includeTradeSkillItems ~= 500 then
188 -- Include tradeskill items
189
190 -- Go through all trade skills for the profession
191 for i = 1, GetNumTradeSkills() do
192 -- Try to retrieve the itemlink, this will be nil if current item is a group instead
193 local itemLink = GetTradeSkillItemLink(i);
194
195 if itemLink then
196 local itemId = addon:GetItemId(itemLink);
197 if not itemId then
198 -- If this isn't an item, it can only be an enchant instead
199 itemId = tonumber(itemLink:match("|Henchant:([-0-9]+)|h"));
200
201 itemId = addon.scrollIds[itemId]; -- change enchantIds into scrollIds
202 end
203
204 if itemId then
205 local itemLevel = select(4, GetItemInfo(itemId)) or 0;
206
207 if includeTradeSkillItems == 0 or itemLevel >= includeTradeSkillItems then
208 if not items[itemId] then
209 -- If this item isn't used in any group yet
210 ref[itemId] = tblAddItemTemplate;
211 else
212 -- It's already used in a group, don't show it
213 ref[itemId] = nil;
214 end
215 end
216 else
217 addon:Debug("|cffff0000ERROR|r: Couldn't find proper item id for " .. itemLink);
218 end
219 end
220 end
221 end
222 end
223
224 local function UpdateRemoveItemList(info)
225 local groupName = groupIdToName[info[2]];
226
227 if not addon.db.profile.groups[groupName].items then
228 addon.db.profile.groups[groupName].items = {};
229 end
230
231 local ref = options.args.groups.args[info[2]].args.remove.args.list.args;
232
233 -- Unset all
234 for itemId, _ in pairs(ref) do
235 ref[itemId] = nil;
236 end
237
238 -- Parse items in group and show these
239 for itemId, _ in pairs(addon.db.profile.groups[groupName].items) do
240 ref[itemId] = tblRemoveItemTemplate;
241 end
242 end
243
244 -- Default group
245 local defaultGroup = {
246 order = 0,
247 type = "group",
248 childGroups = "tab",
249 name = function(info)
250 local groupId = info[#info];
251 if groupIsVirtual[groupId] then
252 return ("%s |cfffed000Virtual|r"):format(groupIdToName[groupId]);
253 else
254 return groupIdToName[groupId];
255 end
256 end,
257 desc = function(info)
258 local groupId = info[#info];
259 if groupIsVirtual[groupId] then
260 return "This is a virtual group, you can use it to override the defaults for other groups.";
261 end
262 end,
263 args = {
264 general = {
265 order = 10,
266 type = "group",
267 name = "General",
268 desc = "Change the general settings for just this group.",
269 args = {
270 general = {
271 order = 0,
272 type = "group",
273 inline = true,
274 name = "General",
275 set = SetOption,
276 get = GetOption,
277 disabled = GetDisabled,
278 args = {
279 description = {
280 order = 0,
281 type = "description",
282 name = function(info)
283 local groupName = groupIdToName[info[2]];
284
285 local t = "Here you can set general settings for the currently selected group. If you do not wish to override a setting, the default setting specified in the general group will be used.\n\n";
286
287 local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
288 local preferedAddon = addon:GetOptionByKey(groupName, "itemCountAddon");
289
290 if currentAddon then
291 --GetCharacterCount
292 --addon.supportedAddons.itemCount[selectedExternalAddon]
293 t = t .. "Currently using |cfffed000" .. selectedAddonName .. "|r as your item count addon. This addon is " .. ((currentAddon.IsEnabled() and "|cff00ff00enabled|r") or "|cffff0000disabled|r") .. ".";
294
295 if currentAddon.GetTotalCount and currentAddon.GetCharacterCount then
296 t = t .. " This addon supports |cfffed000both total as local|r item counts.";
297 elseif currentAddon.GetTotalCount then
298 t = t .. " This addon supports |cfffed000only total|r item counts.";
299 elseif currentAddon.GetCharacterCount then
300 t = t .. " This addon supports |cfffed000only local|r item counts.";
301 end
302
303 if preferedAddon ~= selectedAddonName then
304 t = t .. "\n\n|cffff0000You have selected |cfffed000" .. preferedAddon .. "|r|cffff0000 as your item count addon, but this appears to be disabled and thus a random alternative was selected.|r";
305 end
306 end
307
308 return t;
309 end,
310 },
311 header = {
312 order = 5,
313 type = "header",
314 name = "",
315 },
316 overrideAuctionPricingAddon = {
317 order = 9,
318 type = "toggle",
319 name = "Override pricing addon",
320 desc = "Allows you to override the pricing addon setting for this group.",
321 arg = "auctionPricingAddon",
322 },
323 auctionPricingAddon = {
324 order = 10,
325 type = "select",
326 name = "Prefered pricing addon",
327 desc = "Select the addon you prefer data for this group to be retrieved from. A random supported addon will be used if the selected addon can not be found.",
328 values = function()
329 local temp = {};
330 for name, value in pairs(addon.supportedAddons.auctionPricing) do
331 temp[name] = name;
332 end
333
334 return temp;
335 end,
336 set = function(info, value)
337 local groupName = groupIdToName[info[2]];
338 local optionName = info[#info];
339
340 addon.db.profile.groups[groupName][optionName] = value ~= "" and value;
341
342 if addon.supportedAddons.auctionPricing[value].OnSelect then
343 addon.supportedAddons.auctionPricing[value].OnSelect();
344 end
345 end,
346 arg = "overrideAuctionPricingAddon",
347 },
348 overrideItemCountAddon = {
349 order = 19,
350 type = "toggle",
351 name = "Override item count addon",
352 desc = "Allows you to override the item count addon setting for this group.",
353 arg = "itemCountAddon",
354 },
355 itemCountAddon = {
356 order = 20,
357 type = "select",
358 name = "Prefered item count addon",
359 desc = "Select the addon you prefer data for this group to be retrieved from. A random supported addon will be used if the selected addon can not be found.",
360 values = function()
361 local temp = {};
362 for name, value in pairs(addon.supportedAddons.itemCount) do
363 temp[name] = name;
364 end
365
366 return temp;
367 end,
368 set = function(info, value)
369 local groupName = groupIdToName[info[2]];
370 local optionName = info[#info];
371
372 addon.db.profile.groups[groupName][optionName] = value ~= "" and value;
373
374 if addon.supportedAddons.itemCount[value].OnSelect then
375 addon.supportedAddons.itemCount[value].OnSelect();
376 end
377 end,
378 arg = "overrideItemCountAddon",
379 },
380 overrideCraftingAddon = {
381 order = 29,
382 type = "toggle",
383 name = "Override crafting addon",
384 desc = "Allows you to override the crafting addon setting for this group.",
385 arg = "craftingAddon",
386 },
387 craftingAddon = {
388 order = 30,
389 type = "select",
390 name = "Prefered crafting addon",
391 desc = "Select the addon you prefer data from this group to be queued into. A random supported addon will be used if the selected addon can not be found.",
392 values = function()
393 local temp = {};
394 for name, value in pairs(addon.supportedAddons.crafting) do
395 temp[name] = name;
396 end
397
398 return temp;
399 end,
400 set = function(info, value)
401 local groupName = groupIdToName[info[2]];
402 local optionName = info[#info];
403
404 addon.db.profile.groups[groupName][optionName] = value ~= "" and value;
405
406 if addon.supportedAddons.crafting[value].OnSelect then
407 addon.supportedAddons.crafting[value].OnSelect();
408 end
409 end,
410 arg = "overrideCraftingAddon",
411 },
412 overrideLocalItemData = {
413 order = 39,
414 type = "toggle",
415 name = "Override local item data",
416 desc = "Allows you to override the local item data setting for this group.",
417 arg = "localItemData",
418 },
419 localItemData = {
420 order = 40,
421 type = "multiselect",
422 name = "Include in local item data",
423 desc = "Select which data should be included in the local item data.",
424 values = {
425 ["Bag"] = "Bag",
426 ["Bank"] = "Bank",
427 ["Auction House"] = "Auction House",
428 ["Mailbox"] = "Mailbox",
429 },
430 get = GetMultiOption,
431 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.
432 arg = "overrideLocalItemData",
433 },
434 virtualGroup = {
435 order = 50,
436 type = "select",
437 name = "Use virtual group settings",
438 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.",
439 values = function(info)
440 local groupName = groupIdToName[info[2]];
441
442 local temp = {};
443
444 temp[""] = "";
445 for name, values in pairs(addon.db.profile.groups) do
446 if values.isVirtual and name ~= groupName then
447 temp[name] = name;
448 end
449 end
450
451 return temp;
452 end,
453 set = function(info, value)
454 local groupName = groupIdToName[info[2]];
455 local optionName = info[#info];
456
457 addon.db.profile.groups[groupName][optionName] = value ~= "" and value;
458 end,
459 disabled = false,
460 },
461 },
462 },
463 minimumStock = {
464 order = 10,
465 type = "group",
466 inline = true,
467 name = "Minimum stock",
468 set = SetOption,
469 get = GetOption,
470 disabled = GetDisabled,
471 args = {
472 description = {
473 order = 0,
474 type = "description",
475 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.",
476 },
477 header = {
478 order = 5,
479 type = "header",
480 name = "",
481 },
482
483 overrideMinLocalStock = {
484 order = 10,
485 type = "toggle",
486 name = "Override min local stock",
487 desc = "Allows you to override the minimum local stock setting for this group.",
488 arg = "minLocalStock",
489 },
490 minLocalStock = {
491 order = 11,
492 type = "range",
493 min = 0,
494 max = 100000,
495 softMax = 100,
496 step = 1,
497 name = "Minimum local stock",
498 desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
499 arg = "overrideMinLocalStock",
500 },
501 overrideAlertBelowLocalMinimum = {
502 order = 15,
503 type = "toggle",
504 name = "Override local minimum alert",
505 desc = "Allows you to override wether an alert should be shown when an item in this group gets below the local minimum stock threshold.",
506 arg = "alertBelowLocalMinimum",
507 },
508 alertBelowLocalMinimum = {
509 order = 16,
510 type = "toggle",
511 name = "Alert when below local minimum (NYI)",
512 desc = "Show an alert when an item in this group gets below the local minimum stock threshold.",
513 arg = "overrideAlertBelowLocalMinimum",
514 },
515 overrideAutoRefill = {
516 order = 17,
517 type = "toggle",
518 name = "Override auto refill",
519 desc = "Allows you to override wether you want to automatically refill items when below the minimum local stock.",
520 arg = "autoRefill",
521 },
522 autoRefill = {
523 order = 18,
524 type = "toggle",
525 name = "Auto refill from (guild) bank",
526 desc = "Automatically refill items from the bank (unless this is included in the local count) or guild bank when below the minimum local stock.",
527 arg = "overrideAutoRefill",
528 },
529
530 overrideMinGlobalStock = {
531 order = 20,
532 type = "toggle",
533 name = "Override min global stock",
534 desc = "Allows you to override the minimum global stock setting for this group.",
535 arg = "minGlobalStock",
536 },
537 minGlobalStock = {
538 order = 21,
539 type = "range",
540 min = 0,
541 max = 100000,
542 softMax = 100,
543 step = 1,
544 name = "Minimum global stock",
545 desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
546 arg = "overrideMinGlobalStock",
547 },
548 overrideAlertBelowGlobalMinimum = {
549 order = 25,
550 type = "toggle",
551 name = "Override global minimum alert",
552 desc = "Allows you to override wether an alert should be shown when an item in this group gets below the global minimum stock threshold.",
553 arg = "alertBelowGlobalMinimum",
554 },
555 alertBelowGlobalMinimum = {
556 order = 26,
557 type = "toggle",
558 name = "Alert when below global minimum (NYI)",
559 desc = "Show an alert when an item in this group gets below the global minimum stock threshold.",
560 arg = "overrideAlertBelowGlobalMinimum",
561 },
562
563 overrideSummaryThresholdShow = {
564 order = 34,
565 type = "toggle",
566 name = "Override summary showing",
567 desc = "Allows you to override when this group should appear in the summary.",
568 arg = "summaryThresholdShow",
569 },
570 summaryThresholdShow = {
571 order = 35,
572 type = "range",
573 min = 0,
574 max = 10,
575 softMax = 100,
576 step = 0.05,
577 isPercent = true,
578 name = "Show in summary when below",
579 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.",
580 arg = "overrideSummaryThresholdShow",
581 },
582 overrideTrackAtCharacters = {
583 order = 39,
584 type = "toggle",
585 name = "Override track at",
586 desc = "Allows you to override at which characters items in this group should appear in the summary and generate alerts.",
587 arg = "trackAtCharacters",
588 },
589 trackAtCharacters = {
590 order = 40,
591 type = "multiselect",
592 name = "Track at",
593 desc = "Select at which characters this should appear in the summary and generate alerts.",
594 values = function()
595 local temp = {};
596 for charName in pairs(addon.db.factionrealm.characters) do
597 temp[charName] = charName;
598 end
599
600 return temp;
601 end,
602 get = GetMultiOption,
603 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.
604 arg = "overrideTrackAtCharacters",
605 },
606 },
607 },
608 refill = {
609 order = 20,
610 type = "group",
611 inline = true,
612 name = "Replenishing stock",
613 set = SetOption,
614 get = GetOption,
615 disabled = GetDisabled,
616 args = {
617 description = {
618 order = 0,
619 type = "description",
620 name = function(info)
621 local groupName = groupIdToName[info[2]];
622 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";
623
624 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. ";
625
626 if addon:GetOptionByKey(groupName, "priceThreshold") == 0 then
627 r = r .. "Queueing items at |cfffed000any|r auction value.";
628 else
629 r = r .. "Queueing items worth |cfffed000" .. addon:ReadableMoney(addon:GetOptionByKey(groupName, "priceThreshold")) .. "|r or more.";
630 end
631
632 return r;
633 end,
634 },
635 header = {
636 order = 5,
637 type = "header",
638 name = "",
639 },
640 overrideRestockTarget = {
641 order = 9,
642 type = "toggle",
643 name = "Override restock target",
644 desc = "Allows you to override the restock target setting for this group.",
645 arg = "restockTarget",
646 },
647 restockTarget = {
648 order = 10,
649 type = "range",
650 min = 0,
651 max = 100000,
652 softMax = 100,
653 step = 1,
654 name = "Restock target",
655 desc = "You can manually enter a value between 100 and 100.000 in the edit box if the provided range is insufficient.",
656 arg = "overrideRestockTarget",
657 },
658 overrideMinCraftingQueue = {
659 order = 19,
660 type = "toggle",
661 name = "Override min queue",
662 desc = "Allows you to override the minimum craftable items queue setting for this group.",
663 arg = "minCraftingQueue",
664 },
665 minCraftingQueue = {
666 order = 20,
667 type = "range",
668 min = 0,
669 max = 1,
670 step = 0.01,
671 isPercent = true,
672 name = "Don't queue if I only miss",
673 desc = "Don't add a craftable item to the queue if I only miss this much or less of the restock target.\n\nExample: if your restock target is set to 60 and this is set to 5%, an item won't be queued unless you are missing more than 3 of it.",
674 arg = "overrideMinCraftingQueue",
675 },
676 overrideBonusQueue = {
677 order = 29,
678 type = "toggle",
679 name = "Override bonus queue",
680 desc = "Allows you to override the bonus craftable items queue setting for this group.",
681 arg = "bonusQueue",
682 },
683 bonusQueue = {
684 order = 30,
685 type = "range",
686 min = 0,
687 max = 10, -- 1000%
688 step = 0.01, -- 1%
689 isPercent = true,
690 name = "Bonus queue",
691 desc = "Get additional items when there are none left.\n\nExample: if your restock target is set to 60 and this is set to 10%, you will get 66 items instead of just 60 if you end up with none left while queueing.",
692 arg = "overrideBonusQueue",
693 },
694 overridePriceThreshold = {
695 order = 39,
696 type = "toggle",
697 name = "Override price threshold",
698 desc = "Allows you to override the price threshold setting for this group.",
699 arg = "priceThreshold",
700 },
701 priceThreshold = {
702 order = 40,
703 type = "input",
704 name = "Price threshold",
705 desc = "Only queue craftable items when they are worth at least this much according to your auction house addon.\n\nSet to 0 to ignore auction prices.",
706 validate = function(info, value) return addon:ValidateReadableMoney(info, value); end,
707 get = function(i) return addon:ReadableMoney(GetOption(i)); end,
708 set = function(i, v) SetOption(i, addon:ReadableMoneyToCopper(v)); end,
709 arg = "overridePriceThreshold",
710 },
711 overrideSummaryHidePriceThreshold = {
712 order = 49,
713 type = "toggle",
714 name = "Override summary showing",
715 desc = "Allows you to override if items in this group should be hidden from the summary while their value is below the price threshold.",
716 arg = "summaryHidePriceThreshold",
717 },
718 summaryHidePriceThreshold = {
719 order = 50,
720 type = "toggle",
721 name = "Hide when below threshold",
722 desc = "Hide items from the summary when their value is below the set price threshold.",
723 arg = "overrideSummaryHidePriceThreshold",
724 },
725 overrideAlwaysGetAuctionValue = {
726 order = 59,
727 type = "toggle",
728 name = "Override auction value showing",
729 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.",
730 arg = "alwaysGetAuctionValue",
731 },
732 alwaysGetAuctionValue = {
733 order = 60,
734 type = "toggle",
735 name = "Always show auction value",
736 desc = "Always cache and show the auction value of items in this group, even if the price threshold is set to 0|cffeda55fc|r.",
737 arg = "overrideAlwaysGetAuctionValue",
738 },
739 },
740 },
741 },
742 },
743 group = {
744 order = 20,
745 type = "group",
746 name = "Management",
747 desc = "Rename, delete, duplicate or export this group.",
748 args = {
749 actions = {
750 order = 10,
751 type = "group",
752 name = "Actions",
753 inline = true,
754 args = {
755 rename = {
756 order = 10,
757 type = "input",
758 name = "Rename group - New name",
759 desc = "Change the name of this group to something else. You can also use item links here as you wish.",
760 validate = ValidateGroupName,
761 set = function(info, value)
762 local oldGroupName = groupIdToName[info[2]];
763
764 addon.db.profile.groups[value] = CopyTable(addon.db.profile.groups[oldGroupName]);
765 addon.db.profile.groups[oldGroupName] = nil;
766
767 groupIdToName[info[2]] = value;
768 groupIdToName[value] = true;
769 groupIdToName[oldGroupName] = nil;
770
771 mod:FillGroupOptions();
772 end,
773 get = function(info)
774 return groupIdToName[info[2]];
775 end,
776 },
777 duplicate = {
778 order = 20,
779 type = "input",
780 name = "Duplicate group - New name",
781 desc = "Duplicate this group. You can also use item links here as you wish.\n\nAll item data will be erased.",
782 validate = ValidateGroupName,
783 set = function(info, value)
784 local oldGroupName = groupIdToName[info[2]];
785
786 addon.db.profile.groups[value] = CopyTable(addon.db.profile.groups[oldGroupName]);
787
788 -- Reset item data (duplicate items me no want)
789 addon.db.profile.groups[value].items = nil;
790
791 mod:FillGroupOptions();
792 end,
793 get = false,
794 },
795 delete = {
796 order = 30,
797 type = "execute",
798 name = "Delete group",
799 desc = "Delete the currently selected group.",
800 confirm = true,
801 confirmText = "Are you sure you wish to |cffff0000DELETE|r this group? This action is not reversable!",
802 func = function(info)
803 local groupName = groupIdToName[info[2]];
804
805 addon.db.profile.groups[groupName] = nil;
806
807 mod:FillGroupOptions();
808 end,
809 },
810 },
811 },
812 export = {
813 order = 40,
814 type = "group",
815 name = "Export",
816 inline = true,
817 args = {
818 input = {
819 order = 10,
820 type = "input",
821 multiline = true,
822 name = "Group data",
823 width = "full",
824 desc = "Export the group data for the currently selected group. Press CTRL-A to select all and CTRL-C to copy the text.",
825 set = false,
826 get = function(info)
827 local groupName = groupIdToName[info[2]];
828
829 -- We want to include the group name, so we copy the table then set another value
830 local temp = CopyTable(addon.db.profile.groups[groupName]);
831 temp.name = groupName;
832 temp.trackAtCharacters = nil;
833 temp.overrideTrackAtCharacters = nil;
834
835 if not AceSerializer then
836 AceSerializer = LibStub("AceSerializer-3.0");
837 end
838
839 return AceSerializer:Serialize(temp);
840 end,
841 },
842 },
843 },
844 },
845 },
846 add = {
847 order = 30,
848 type = "group",
849 name = "Add items",
850 desc = "Add new items to this group.",
851 hidden = function(info) return groupIsVirtual[info[2]]; end,
852 args = {
853 singleAdd = {
854 order = 10,
855 type = "group",
856 inline = true,
857 name = "Add items",
858 args = {
859 help = {
860 order = 10,
861 type = "description",
862 name = "You can add a single item to this group at a time by pasting the item-id or an item-link in the field to the left or you can also import multiple items at once by pasting exported item data in the field to the right. Scroll further down to add items based on your inventory contents.",
863 },
864 itemLink = {
865 order = 20,
866 type = "input",
867 name = "Single item add (item-link or item-id)",
868 desc = "Shift-click an item-link or enter an item-id to add the related item to this group. You can only add one item link or item id at a time.",
869 validate = function(info, value)
870 -- If the value is empty we'll allow passing to clear the carret
871 if value == "" then return true; end
872
873 local groupName = groupIdToName[info[2]];
874
875 local itemId = (addon:GetItemId(string.trim(value)) or tonumber(string.trim(value)));
876
877 local itemData = addon.ItemData:New(itemId);
878
879 if not itemId then
880 return "This is not a valid item link or id.";
881 elseif itemData:InGroup() then
882 return ("This item is already in the group |cfffed000%s|r."):format(itemData:InGroup());
883 end
884
885 return true;
886 end,
887 set = function(info, value)
888 if value and value ~= "" then
889 local groupName = groupIdToName[info[2]];
890
891 local itemId = (addon:GetItemId(string.trim(value)) or tonumber(string.trim(value)));
892
893 local itemData = addon.ItemData:New(itemId);
894
895 if itemData:AddToGroup(groupName) then
896 addon.Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green);
897
898 if AceConfigRegistry then
899 -- Now rebuild the list
900 AceConfigRegistry:NotifyChange("InventoriumOptions");
901 end
902 else
903 addon.Print(("%s is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red);
904 end
905 end
906 end,
907 get = false,
908 },
909 importItemData = {
910 order = 30,
911 type = "input",
912 name = "Import item data",
913 desc = "Import item data from an exported item data-string. Any items already grouped will be skipped.",
914 set = function(info, value)
915 local groupName = groupIdToName[info[2]];
916
917 local allItemIds = { string.split(";", value or "") };
918
919 for _, value in pairs(allItemIds) do
920 local itemId = tonumber(value);
921
922 if itemId then
923 local itemData = addon.ItemData:New(itemId);
924
925 if itemData:InGroup() then
926 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);
927 elseif itemData:AddToGroup(groupName) then
928 addon.Print(("Added %s to the group |cfffed000%s|r."):format(itemData.link or unknownItemName:format(itemId), groupName), addon.Colors.Green);
929 end
930 else
931 addon.Print(("\"%s\" is not a number."):format(value), addon.Colors.Red);
932 end
933 end
934
935 if AceConfigRegistry then
936 -- Now rebuild the list
937 AceConfigRegistry:NotifyChange("InventoriumOptions");
938 end
939 end,
940 get = false,
941 },
942 importPremadeData = {
943 order = 40,
944 type = "select",
945 name = "Import premade data",
946 desc = "Import item data from a premade item-group. Any items already grouped will be skipped.",
947 values = function()
948 local temp = {};
949 for key, group in pairs(addon.defaultGroups) do
950 temp[key] = key;
951 end
952
953 return temp;
954 end,
955 set = function(info, value)
956 local groupName = groupIdToName[info[2]];
957
958 print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(value));
959
960 -- Remember we imported this group and it's version so if it is ever changed, people can be notified
961 if not addon.db.profile.groups[groupName].premadeGroups then
962 addon.db.profile.groups[groupName].premadeGroups = {};
963 end
964 addon.db.profile.groups[groupName].premadeGroups[value] = addon.defaultGroups[value].version;
965
966 for itemId, version in pairs(addon.defaultGroups[value].items) do
967 if version > 0 then
968 -- Sanity check
969 itemId = itemId and tonumber(itemId);
970
971 local itemData = addon.ItemData:New(itemId);
972
973 if not itemId then
974 addon.Print(("\"|cfffed000%s|r\" is not a number."):format(value), addon.Colors.Red);
975 elseif itemData:InGroup() then
976 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);
977 elseif itemData:AddToGroup(groupName) then
978 addon.Print(("Added %s to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), groupName ), addon.Colors.Green);
979 end
980 end
981 end
982
983 if AceConfigRegistry then
984 -- Now rebuild the list
985 AceConfigRegistry:NotifyChange("InventoriumOptions");
986 end
987 end,
988 get = false,
989 },
990 },
991 },
992 massAdd = {
993 order = 20,
994 type = "group",
995 inline = true,
996 name = "Mass add",
997 args = {
998 help = {
999 order = 10,
1000 type = "description",
1001 name = "Click the items you wish to add to this group or add multiple of these items at once by providing a name filter in the field below.",
1002 },
1003 massAdd = {
1004 order = 20,
1005 type = "input",
1006 name = "Add all items matching...",
1007 desc = "Add every item in your inventory matching the name entered in this field. If you enter \"Glyph\" as a filter, any items in your inventory containing this in their name will be added to this group.",
1008 set = function(info, value)
1009 local groupName = groupIdToName[info[2]];
1010
1011 if not value then return; end
1012
1013 value = value:lower();
1014
1015 local ref = options.args.groups.args[info[2]].args.add.args.list.args;
1016
1017 for itemId, test in pairs(ref) do
1018 if test then
1019 local itemData = addon.ItemData:New(itemId);
1020
1021 if itemData.name:lower():find(value) then
1022 if itemData:AddToGroup(groupName) then
1023 addon.Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green);
1024 else
1025 addon.Print(("Couldn't add %s because it is already in a group."):format(itemData.link or unknownItemName:format(itemId)), addon.Colors.Red);
1026 end
1027 end
1028 end
1029 end
1030
1031 if AceConfigRegistry then
1032 -- Now rebuild the list
1033 AceConfigRegistry:NotifyChange("InventoriumOptions");
1034 end
1035 end,
1036 get = false,
1037 },
1038 minItemLevel = {
1039 order = 40,
1040 type = "select",
1041 values = function()
1042 local temp = {};
1043
1044 temp[0] = "Include everything";
1045
1046 local itemLevelTemplate = "Itemlevel >= %d";
1047
1048 for i = 1, 49 do
1049 temp[( i * 10 )] = itemLevelTemplate:format(( i * 10 ));
1050 end
1051
1052 temp[500] = "Include nothing";
1053
1054 return temp;
1055 end,
1056 name = "Include tradeskill items",
1057 desc = "Include all items above this item level from the currently opened tradeskill window in the below item list.\n\nSetting this very low this might considerably slow down this config window.\n\nSet to 500 to disable showing of items completely.",
1058 set = function(i, v) includeTradeSkillItems = v; end,
1059 get = function() return includeTradeSkillItems; end,
1060 disabled = function()
1061 if GetTradeSkillLine() == "UNKNOWN" then
1062 includeTradeSkillItems = 500;
1063 return true; -- disabled
1064 else
1065 return false;
1066 end
1067 end,
1068 },
1069 },
1070 },
1071 list = {
1072 order = 30,
1073 type = "group",
1074 inline = true,
1075 name = "Item list",
1076 hidden = UpdateAddItemList,
1077 args = {
1078
1079 },
1080 },
1081 },
1082 },
1083 remove = {
1084 order = 40,
1085 type = "group",
1086 name = "Current items",
1087 desc = "View, export or remove items from this group.",
1088 hidden = function(info) return groupIsVirtual[info[2]]; end,
1089 args = {
1090 help = {
1091 order = 10,
1092 type = "group",
1093 inline = true,
1094 name = "Help",
1095 hidden = false,
1096 args = {
1097 help = {
1098 order = 10,
1099 type = "description",
1100 name = "Click the items you wish to remove from this group.",
1101 },
1102 massRemove = {
1103 order = 20,
1104 type = "input",
1105 name = "Remove all items matching...",
1106 desc = "Remove every item in this group matching the name entered in this field. If you enter \"Glyph\" as a filter, any items in this group containing this in their name will be removed from this group.",
1107 set = function(info, value)
1108 local groupName = groupIdToName[info[2]];
1109
1110 if not value then return; end
1111
1112 value = value:lower();
1113
1114 local ref = options.args.groups.args[info[2]].args.remove.args.list.args;
1115
1116 for itemId, test in pairs(ref) do
1117 if test then
1118 local itemData = addon.ItemData:New(itemId);
1119
1120 if itemData.name:lower():find(value) then
1121 itemData:RemoveFromGroup(groupName);
1122
1123 addon.Print(("Removed %s from the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Red);
1124 end
1125 end
1126 end
1127
1128 if AceConfigRegistry then
1129 -- Now rebuild the list
1130 AceConfigRegistry:NotifyChange("InventoriumOptions");
1131 end
1132 end,
1133 get = false,
1134 },
1135 premadeGroups = {
1136 order = 30,
1137 type = "select",
1138 name = "Imported premade groups",
1139 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.",
1140 values = function(info)
1141 local groupName = groupIdToName[info[2]];
1142
1143 local temp = {};
1144 temp[""] = "";
1145 if addon.db.profile.groups[groupName].premadeGroups then
1146 for name, version in pairs(addon.db.profile.groups[groupName].premadeGroups) do
1147 temp[name] = name;
1148 end
1149 end
1150
1151 return temp;
1152 end,
1153 set = function(info, value)
1154 if value and value ~= "" then
1155 -- Remove premade group from this group
1156 local groupName = groupIdToName[info[2]];
1157
1158 addon.db.profile.groups[groupName].premadeGroups[value] = nil;
1159
1160 print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value));
1161 end
1162 end,
1163 get = false,
1164 disabled = function(info)
1165 local groupName = groupIdToName[info[2]];
1166
1167 return (not addon.db.profile.groups[groupName].premadeGroups);
1168 end,
1169 },
1170 },
1171 },
1172 list = {
1173 order = 20,
1174 type = "group",
1175 inline = true,
1176 name = "Item list",
1177 hidden = UpdateRemoveItemList,
1178 args = {
1179
1180 },
1181 },
1182 export = {
1183 order = 30,
1184 type = "group",
1185 name = "Export",
1186 inline = true,
1187 args = {
1188 input = {
1189 order = 10,
1190 type = "input",
1191 name = "Item data",
1192 width = "full",
1193 desc = "Export the item data for the currently selected group. Press CTRL-A to select all and CTRL-C to copy the text.",
1194 set = false,
1195 get = function(info)
1196 local groupName = groupIdToName[info[2]];
1197
1198 local combinedItemIds;
1199 -- Parse items in group and show these
1200 for itemId, _ in pairs(addon.db.profile.groups[groupName].items) do
1201 if not combinedItemIds then
1202 combinedItemIds = tostring(itemId);
1203 else
1204 combinedItemIds = combinedItemIds .. (";%d"):format(itemId);
1205 end
1206 end
1207
1208 return combinedItemIds; -- We don't serialize this because we actually DO want people to be able to manually modify it - besides, parsing it isn't going to be hard
1209 end,
1210 },
1211 },
1212 },
1213 },
1214 },
1215 },
1216 };
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226 -- Object functions
1227
1228 function mod:OnEnable()
1229 -- Register our config slash command
1230 -- /im config
1231 addon:RegisterSlash(function(this)
1232 -- We don't want any other windows open at this time.
1233 for name, module in this:IterateModules() do
1234 if module.CloseFrame then
1235 module:CloseFrame();
1236 end
1237 end
1238
1239 this:GetModule("Config"):Show();
1240 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.");
1241
1242 -- Whenever the profile is changed, update the groups | args: (object for the functionName, eventName, functionName)
1243 addon.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig");
1244 addon.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig");
1245 addon.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig");
1246
1247 -- Register our custom widgets
1248 local Widgets = addon:GetModule("Widgets");
1249 Widgets:ItemLinkButton();
1250 Widgets:ConfigItemLinkButton();
1251 end
1252
1253 function mod:RefreshConfig()
1254 self:PremadeGroupsCheck();
1255
1256 self:FillGroupOptions();
1257 end
1258
1259 function mod:Load()
1260 if not AceConfigDialog and not AceConfigRegistry then
1261 self:PremadeGroupsCheck();
1262
1263 self:FillOptions();
1264
1265 -- Build options dialog
1266 AceConfigDialog = LibStub("AceConfigDialog-3.0");
1267 AceConfigRegistry = LibStub("AceConfigRegistry-3.0");
1268 -- Register options table
1269 LibStub("AceConfig-3.0"):RegisterOptionsTable("InventoriumOptions", options);
1270 -- Set a nice default size (so that 4 normal sized elements fit next to eachother)
1271 AceConfigDialog:SetDefaultSize("InventoriumOptions", 975, 600);
1272
1273 -- In case the addon is loaded from another condition, always call the remove interface options
1274 if AddonLoader and AddonLoader.RemoveInterfaceOptions then
1275 AddonLoader:RemoveInterfaceOptions("Inventorium");
1276 end
1277
1278 -- Add to the blizzard addons options thing
1279 AceConfigDialog:AddToBlizOptions("InventoriumOptions");
1280 end
1281 end
1282
1283 function mod:Show()
1284 self:Load();
1285
1286 AceConfigDialog:Open("InventoriumOptions");
1287 end
1288
1289 function mod:FillOptions()
1290 options = {
1291 type = "group",
1292 name = "Inventorium Config",
1293 childGroups = "tree",
1294 args = {
1295 },
1296 };
1297
1298 -- General
1299 self:FillGeneralOptions();
1300
1301 -- Help
1302 self:FillHelpOptions();
1303
1304 -- Profile
1305 options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(addon.db, true);
1306 options.args.profiles.order = 200;
1307
1308 -- Groups
1309 self:MakeGroupOptions();
1310
1311 -- Groups-contents
1312 self:FillGroupOptions();
1313 end
1314
1315 function mod:FillGeneralOptions()
1316 options.args.general = {
1317 order = 100,
1318 type = "group",
1319 name = "General",
1320 desc = "Change general Inventorium settings.",
1321 args = {
1322 general = {
1323 order = 1,
1324 type = "group",
1325 inline = true,
1326 name = "General",
1327 args = {
1328 description = {
1329 order = 0,
1330 type = "description",
1331 name = function()
1332 local t = "Here you can set general settings. The settings entered here will be used when you choose not to override the settings within an individual group.\n\n";
1333
1334 local currentAddon, selectedAddonName = addon:GetItemCountAddon();
1335 local preferedAddon = addon.db.profile.defaults.itemCountAddon;
1336
1337 if currentAddon then
1338 t = t .. "Currently using |cfffed000" .. selectedAddonName .. "|r as your item count addon. This addon is " .. ((currentAddon.IsEnabled() and "|cff00ff00enabled|r") or "|cffff0000disabled|r") .. ".";
1339
1340 if currentAddon.GetTotalCount and currentAddon.GetCharacterCount then
1341 t = t .. " This addon supports |cfffed000both total as local|r item counts.";
1342 elseif currentAddon.GetTotalCount then
1343 t = t .. " This addon supports |cfffed000only total|r item counts.";
1344 elseif currentAddon.GetCharacterCount then
1345 t = t .. " This addon supports |cfffed000only local|r item counts.";
1346 end
1347
1348 if preferedAddon ~= selectedAddonName then
1349 t = t .. "\n\n|cffff0000You have selected |cfffed000" .. preferedAddon .. "|r|cffff0000 as your item count addon, but this appears to be disabled and thus a random alternative was selected.|r";
1350 end
1351 end
1352
1353 return t;
1354 end,
1355 },
1356 header = {
1357 order = 5,
1358 type = "header",
1359 name = "",
1360 },
1361 auctionPricingAddon = {
1362 order = 10,
1363 type = "select",
1364 name = "Prefered pricing addon",
1365 desc = "Select the addon you prefer data to be retrieved from. A random supported addon will be used if the selected addon can not be found.",
1366 values = function()
1367 local temp = {};
1368 for name, value in pairs(addon.supportedAddons.auctionPricing) do
1369 temp[name] = name;
1370 end
1371
1372 return temp;
1373 end,
1374 get = function() return addon.db.profile.defaults.auctionPricingAddon; end,
1375 set = function(i, v)
1376 addon.db.profile.defaults.auctionPricingAddon = v;
1377
1378 if addon.supportedAddons.auctionPricing[v].OnSelect then
1379 addon.supportedAddons.auctionPricing[v].OnSelect();
1380 end
1381 end,
1382 },
1383 itemCountAddon = {
1384 order = 20,
1385 type = "select",
1386 name = "Prefered item count addon",
1387 desc = "Select the addon you prefer data to be retrieved from. A random supported addon will be used if the selected addon can not be found.",
1388 values = function()
1389 local temp = {};
1390 for name, value in pairs(addon.supportedAddons.itemCount) do
1391 temp[name] = name;
1392 end
1393
1394 return temp;
1395 end,
1396 get = function() return addon.db.profile.defaults.itemCountAddon; end,
1397 set = function(i, v)
1398 addon.db.profile.defaults.itemCountAddon = v;
1399
1400 if addon.supportedAddons.itemCount[v].OnSelect then
1401 addon.supportedAddons.itemCount[v].OnSelect();
1402 end
1403 end,
1404 },
1405 craftingAddon = {
1406 order = 30,
1407 type = "select",
1408 name = "Prefered crafting addon",
1409 desc = "Select the addon you prefer data to be queued into. A random supported addon will be used if the selected addon can not be found.",
1410 values = function()
1411 local temp = {};
1412 for name, value in pairs(addon.supportedAddons.crafting) do
1413 temp[name] = name;
1414 end
1415
1416 return temp;
1417 end,
1418 get = function() return addon.db.profile.defaults.craftingAddon; end,
1419 set = function(i, v)
1420 addon.db.profile.defaults.craftingAddon = v;
1421
1422 if addon.supportedAddons.crafting[v].OnSelect then
1423 addon.supportedAddons.crafting[v].OnSelect();
1424 end
1425 end,
1426 },
1427 localItemData = {
1428 order = 40,
1429 type = "multiselect",
1430 name = "Include in local item data",
1431 desc = "Select which data should be included in the local item data.",
1432 values = {
1433 ["Bag"] = "Bag",
1434 ["Bank"] = "Bank",
1435 ["Auction House"] = "Auction House",
1436 ["Mailbox"] = "Mailbox",
1437 },
1438 get = function(i, v) return addon.db.profile.defaults.localItemData and addon.db.profile.defaults.localItemData[v]; end,
1439 set = function(i, v, e) addon.db.profile.defaults.localItemData[v] = e; end, -- can't be nil or the defaults will be used
1440 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.
1441 },
1442 },
1443 },
1444 minimumStock = {
1445 order = 10,
1446 type = "group",
1447 inline = true,
1448 name = "Minimum stock",
1449 args = {
1450 description = {
1451 order = 0,
1452 type = "description",
1453 name = "Here you can specify the default minimum amount of items you wish to keep in stock and related settings. The settings entered here will be used when you choose not to override the settings within an individual group.",
1454 },
1455 header = {
1456 order = 5,
1457 type = "header",
1458 name = "",
1459 },
1460 minLocalStock = {
1461 order = 10,
1462 type = "range",
1463 min = 0,
1464 max = 100000,
1465 softMax = 100,
1466 step = 1,
1467 name = "Minimum local stock",
1468 desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
1469 get = function() return addon.db.profile.defaults.minLocalStock; end,
1470 set = function(i, v) addon.db.profile.defaults.minLocalStock = v; end,
1471 },
1472 alertBelowLocalMinimum = {
1473 order = 11,
1474 type = "toggle",
1475 name = "Alert when below local minimum (NYI)",
1476 desc = "Show an alert when this item gets below this threshold.",
1477 get = function() return addon.db.profile.defaults.alertBelowLocalMinimum; end,
1478 set = function(i, v) addon.db.profile.defaults.alertBelowLocalMinimum = v; end,
1479 },
1480 autoRefill = {
1481 order = 12,
1482 type = "toggle",
1483 name = "Auto refill from (guild) bank",
1484 desc = "Automatically refill items from the bank (unless this is included in the local count) or guild bank when below the minimum local stock.",
1485 get = function() return addon.db.profile.defaults.autoRefill; end,
1486 set = function(i, v) addon.db.profile.defaults.autoRefill = v; end,
1487 },
1488 minGlobalStock = {
1489 order = 20,
1490 type = "range",
1491 min = 0,
1492 max = 100000,
1493 softMax = 100,
1494 step = 1,
1495 name = "Minimum global stock",
1496 desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
1497 get = function() return addon.db.profile.defaults.minGlobalStock; end,
1498 set = function(i, v) addon.db.profile.defaults.minGlobalStock = v; end,
1499 },
1500 alertBelowGlobalMinimum = {
1501 order = 21,
1502 type = "toggle",
1503 name = "Alert when below global minimum (NYI)",
1504 desc = "Show an alert when this item gets below this threshold.",
1505 get = function() return addon.db.profile.defaults.alertBelowGlobalMinimum; end,
1506 set = function(i, v) addon.db.profile.defaults.alertBelowGlobalMinimum = v; end,
1507 },
1508 summaryThresholdShow = {
1509 order = 30,
1510 type = "range",
1511 min = 0,
1512 max = 10,
1513 softMax = 100,
1514 step = 0.05,
1515 isPercent = true,
1516 name = "Show in summary when below",
1517 desc = "Show items in the summary when below this percentage of the minimum stock. This can be either below the minimum or the global stock.\n\nYou can manually enter a value between 1.000% and 10.000% in the edit box if the provided range is insufficient.",
1518 get = function() return addon.db.profile.defaults.summaryThresholdShow; end,
1519 set = function(i, v) addon.db.profile.defaults.summaryThresholdShow = v; end,
1520 },
1521 trackAtCharacters = {
1522 order = 40,
1523 type = "multiselect",
1524 name = "Track at",
1525 desc = "Select at which characters this should appear in the summary and generate alerts.",
1526 values = function()
1527 local temp = {};
1528 for charName in pairs(addon.db.factionrealm.characters) do
1529 temp[charName] = charName;
1530 end
1531
1532 return temp;
1533 end,
1534 get = function(i, v)
1535 return addon.db.profile.defaults.trackAtCharacters[v];
1536 end,
1537 set = function(i, v, e)
1538 addon.db.profile.defaults.trackAtCharacters[v] = e or nil;
1539 end,
1540 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.
1541 },
1542 },
1543 },
1544 refill = {
1545 order = 20,
1546 type = "group",
1547 inline = true,
1548 name = "Replenishing stock",
1549 args = {
1550 description = {
1551 order = 0,
1552 type = "description",
1553 name = function()
1554 local r = "Here you can specify the default amount of items to which you wish to restock when you are collecting new items. This may be higher than the minimum stock. The settings entered here will be used when you choose not to override the settings within an individual group.\n\n";
1555
1556 r = r .. "When restocking the target amount is |cfffed000" .. addon.db.profile.defaults.restockTarget .. "|r of every item. Not queueing craftable items when only missing |cfffed000" .. floor( addon.db.profile.defaults.minCraftingQueue * addon.db.profile.defaults.restockTarget ) .. "|r (|cfffed000" .. ( addon.db.profile.defaults.minCraftingQueue * 100 ) .. "%|r) of the restock target.";
1557
1558 return r;
1559 end,
1560 },
1561 header = {
1562 order = 5,
1563 type = "header",
1564 name = "",
1565 },
1566 restockTarget = {
1567 order = 10,
1568 type = "range",
1569 min = 0,
1570 max = 100000,
1571 softMax = 100,
1572 step = 1,
1573 name = "Restock target",
1574 desc = "You can manually enter a value between 100 and 100.000 in the edit box if the provided range is insufficient.",
1575 get = function() return addon.db.profile.defaults.restockTarget; end,
1576 set = function(i, v) addon.db.profile.defaults.restockTarget = v; end,
1577 },
1578 minCraftingQueue = {
1579 order = 20,
1580 type = "range",
1581 min = 0,
1582 max = 1,
1583 step = 0.01, -- 1%
1584 isPercent = true,
1585 name = "Don't queue if I only miss",
1586 desc = "Don't add a craftable item to the queue if I only miss this much or less of the restock target.\n\nExample: if your restock target is set to 60 and this is set to 5%, an item won't be queued unless you are missing more than 3 of it.",
1587 get = function() return addon.db.profile.defaults.minCraftingQueue; end,
1588 set = function(i, v) addon.db.profile.defaults.minCraftingQueue = v; end,
1589 },
1590 bonusQueue = {
1591 order = 30,
1592 type = "range",
1593 min = 0,
1594 max = 10, -- 1000%
1595 step = 0.01, -- 1%
1596 isPercent = true,
1597 name = "Bonus queue",
1598 desc = "Get additional items when there are none left.\n\nExample: if your restock target is set to 60 and this is set to 10%, you will get 66 items instead of just 60 if you end up with none left while queueing.",
1599 get = function() return addon.db.profile.defaults.bonusQueue; end,
1600 set = function(i, v) addon.db.profile.defaults.bonusQueue = v; end,
1601 },
1602 priceThreshold = {
1603 order = 40,
1604 type = "input",
1605 name = "Price threshold",
1606 desc = "Only queue craftable items when they are worth at least this much according to your auction house addon.\n\nSet to 0 to ignore auction prices.",
1607 validate = function(info, value) return addon:ValidateReadableMoney(info, value); end,
1608 get = function() return addon:ReadableMoney(addon.db.profile.defaults.priceThreshold); end,
1609 set = function(i, v) addon.db.profile.defaults.priceThreshold = addon:ReadableMoneyToCopper(v); end,
1610 },
1611 summaryHidePriceThreshold = {
1612 order = 50,
1613 type = "toggle",
1614 name = "Hide when below threshold",
1615 desc = "Hide items from the summary when their value is below the set price threshold.",
1616 get = function() return addon.db.profile.defaults.summaryHidePriceThreshold; end,
1617 set = function(i, v) addon.db.profile.defaults.summaryHidePriceThreshold = v; end,
1618 },
1619 alwaysGetAuctionValue = {
1620 order = 60,
1621 type = "toggle",
1622 name = "Always show auction value",
1623 desc = "Always cache and show the auction value of items, even if the price threshold is set to 0|cffeda55fc|r.",
1624 get = function() return addon.db.profile.defaults.alwaysGetAuctionValue; end,
1625 set = function(i, v) addon.db.profile.defaults.alwaysGetAuctionValue = v; end,
1626 },
1627 },
1628 },
1629 colorCodes = {
1630 order = 30,
1631 type = "group",
1632 inline = true,
1633 name = "Color codes",
1634 args = {
1635 description = {
1636 order = 0,
1637 type = "description",
1638 name = "Change the color code thresholds based on the current stock remaining of the required minimum stock.",
1639 },
1640 header = {
1641 order = 5,
1642 type = "header",
1643 name = "",
1644 },
1645 green = {
1646 order = 10,
1647 type = "range",
1648 min = 0,
1649 max = 1,
1650 step = 0.01,
1651 isPercent = true,
1652 name = "|cff00ff00Green|r",
1653 desc = "Show quantity in green when at least this much of the minimum stock is available.",
1654 get = function() return addon.db.profile.defaults.colors.green; end,
1655 set = function(i, v) addon.db.profile.defaults.colors.green = v; end,
1656 },
1657 yellow = {
1658 order = 20,
1659 type = "range",
1660 min = 0,
1661 max = 1,
1662 step = 0.01,
1663 isPercent = true,
1664 name = "|cffffff00Yellow|r",
1665 desc = "Show quantity in yellow when at least this much of the minimum stock is available.",
1666 get = function() return addon.db.profile.defaults.colors.yellow; end,
1667 set = function(i, v) addon.db.profile.defaults.colors.yellow = v; end,
1668 },
1669 orange = {
1670 order = 30,
1671 type = "range",
1672 min = 0,
1673 max = 1,
1674 step = 0.01,
1675 isPercent = true,
1676 name = "|cffff9933Orange|r",
1677 desc = "Show quantity in orange when at least this much of the minimum stock is available.",
1678 get = function() return addon.db.profile.defaults.colors.orange; end,
1679 set = function(i, v) addon.db.profile.defaults.colors.orange = v; end,
1680 },
1681 red = {
1682 order = 40,
1683 type = "range",
1684 min = 0,
1685 max = 1,
1686 step = 0.01,
1687 isPercent = true,
1688 name = "|cffff0000Red|r",
1689 desc = "Show quantity in red when at least this much of the minimum stock is available.",
1690 get = function() return addon.db.profile.defaults.colors.red; end,
1691 set = function(i, v) addon.db.profile.defaults.colors.red = v; end,
1692 },
1693 },
1694 },
1695 extra = {
1696 order = 40,
1697 type = "group",
1698 inline = true,
1699 name = "Extra",
1700 args = {
1701 description = {
1702 order = 0,
1703 type = "description",
1704 name = "Additional optional settings.",
1705 },
1706 header = {
1707 order = 5,
1708 type = "header",
1709 name = "",
1710 },
1711 removeCharacter = {
1712 order = 40,
1713 type = "select",
1714 name = "Forget character",
1715 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.",
1716 values = function()
1717 local temp = {};
1718
1719 temp[""] = "";
1720
1721 local playerName = UnitName("player");
1722 for charName in pairs(addon.db.factionrealm.characters) do
1723 if playerName ~= charName then
1724 temp[charName] = charName;
1725 end
1726 end
1727
1728 return temp;
1729 end,
1730 set = function(i, value)
1731 if value and value ~= "" then
1732 addon.db.factionrealm.characters[value] = nil;
1733 addon.db.profile.defaults.trackAtCharacters[value] = nil;
1734 for name, values in pairs(addon.db.profile.groups) do
1735 if values.trackAtCharacters then
1736 values.trackAtCharacters[name] = nil;
1737 end
1738 end
1739 end
1740 end,
1741 },
1742 },
1743 },
1744 },
1745 };
1746 end
1747
1748 function mod:FillHelpOptions()
1749 options.args.help = {
1750 order = 150,
1751 type = "group",
1752 childGroups = "tab",
1753 name = "Help",
1754 desc = "Useful information for if you're unfamiliar with a part of the addon.",
1755 args = {
1756 general = {
1757 order = 1,
1758 type = "group",
1759 name = "General",
1760 args = {
1761 description = {
1762 order = 0,
1763 type = "description",
1764 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" ..
1765 "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" ..
1766 "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" ..
1767 "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" ..
1768 "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 |cfffed000version 1.1|r or a little later (which is after the initial release).",
1769 },
1770 },
1771 },
1772 manual = {
1773 order = 2,
1774 type = "group",
1775 name = "Manual",
1776 args = {
1777 intro = {
1778 order = 1,
1779 type = "group",
1780 inline = true,
1781 name = "Intro",
1782 args = {
1783 description = {
1784 order = 0,
1785 type = "description",
1786 name = "|cfffed000Inventorium|r is an inventory tracking and restocking addon aimed towards making it extremely easy to keep enough stock of specific items at your characters. It provides a quick overview where you can see your current stock compared to the required stock and the current item value at the auction house whenever you find this relevant. From this overview you can queue craftable items into your favorite crafting profession addon and even restock from a vendor.",
1787 },
1788 },
1789 },
1790 Overview = {
1791 order = 2,
1792 type = "group",
1793 inline = true,
1794 name = "Overview",
1795 args = {
1796 description = {
1797 order = 0,
1798 type = "description",
1799 name = "In the stock overview, which is called the summary, you can view a list with all items relevant to your current character with their updated stock and auction house values. You can sort this list on item quality, current stock, percentage of stock missing, and item values and this way easily manually find the items you wish to process. If you prefer to automate the process, you can also configure the groups exactly as you wish and hit the queue button to process everything in that group.\n\n" ..
1800
1801 "The item count data can be retrieved from most popular item count addons. This includes |cfffed000ItemCount|r and |cfffed000DataStore|r, but also |cfffed000Altoholic|r (even though this is not really a proper item count addon).\n" ..
1802 "The auction house values data can also be retrieved from most popular auction house addons. This includes |cfffed000Auctionator|r, |cfffed000Auctioneer|r, |cfffed000AuctionLite|r, |cfffed000AuctionMaster|r and any other addon implementing the standard for retrieving item values. Item values from the summary windows of |cfffed000AuctionProfitMaster|r and |cfffed000ZeroAuctions|r are also supported, but not recommended.",
1803 },
1804 },
1805 },
1806 Groups = {
1807 order = 3,
1808 type = "group",
1809 inline = true,
1810 name = "Groups",
1811 args = {
1812 description = {
1813 order = 0,
1814 type = "description",
1815 name = "All items can be distributed over multiple groups to configure them exactly as you want. You can put all your glyphs in one group, gems in another and scrolls in a third with every single one of them having it's own set of unique settings. Per group you can set a price threshold, required item count, relevant characters and much more. The setup will feel very familiar to anyone that has used Quick Auctions to some extend as it uses a similar standard (though with many enhancements).",
1816 },
1817 },
1818 },
1819 Queueing = {
1820 order = 4,
1821 type = "group",
1822 inline = true,
1823 name = "Queueing",
1824 args = {
1825 description = {
1826 order = 0,
1827 type = "description",
1828 name = "Queueing items into your crafting profession addon can be done per group or for all visible groups at once. This requires the relevant profession window to be open. All queueing is done based on the filters set in the config for the related group, any items falling outside will be ignored.\n\n" ..
1829
1830 "The queueing can be done into most popular crafting profession window replacing addons. This includes |cfffed000AdvancedTradeSkillWindow|r, |cfffed000GnomeWorks|r and |cfffed000Skillet|r.",
1831 },
1832 },
1833 },
1834 Configuring = {
1835 order = 5,
1836 type = "group",
1837 inline = true,
1838 name = "Configuring",
1839 args = {
1840 description = {
1841 order = 0,
1842 type = "description",
1843 name = "The system resources used by this addon while it is stand-by are at a minimum, so you can just leave it enabled for all your characters unless you wish otherwise.\n\n" ..
1844
1845 "To start using Inventorium write |cfffed000/im|r in your chat. This will show a list of all available commands; |cfffed000/im config|r, |cfffed000summary|r and some others. Tip: Most of these commands have short alternatives, such as |cfffed000c|r for |cfffed000config|r and |cfffed000s|r for |cfffed000summary|r.\n\n" ..
1846
1847 "Write |cfffed000/im c|r to open the config window to start configuring your groups. The first tab you will find opened is the |cfffed000General|r config. Go ahead and select your prefered item count, crafting and pricing addons. Scroll down and quickly take note of all other options there, you won't really need everything (yet) but knowing it is available will save you from searching later on.\n\n" ..
1848
1849 "Click on the |cfffed000Groups|r tab. Here you will see a view handy options, in the future you might be able to find complete groups to import at popular blogs or forums making Inventorium very easy to import and initially setup, but for now we will have to make one manually. Quickly think about an easy-to-use and handy naming pattern and enter a name for your new group (e.g. |cfffed000Glyphs (Hunter)|r) and hit enter (leave the group type to the default). This group will be created and added to the list under the groups tab. Open the config for this group by clicking the group name.\n\n" ..
1850
1851 "You are now seeing a copy of the general config with override boxes next to everything. Configure this as you wish, for example override the |cfffed000minimum global stock|r to 20, |cfffed000track at|r to your banker and crafter (ensure your current char is also included) and the |cfffed000price threshold|r to 5g or so. Once done go to the \"add items\" tab to add items to this group so this group manages them. Again observice the available functionality so you know what you can do. Based on our previous example of Hunter glyphs we have three possibilities: one is to get all Hunter glyphs in our bags and add these, the second is to open the profession window and include everything above or equal to an item level of 0 and the third and in this case best possibility is to add items from a premade group. Select |cfffed000Glyphs (Hunter)|r from the |cfffed000premade groups|r select box to import all Hunter glyphs into this group. After doing so you can close the config window to check the results. Write |cfffed000/im s|r to view the summary window.\n\n" ..
1852
1853 "You can now copy this group and repeat the same steps to add all other groups you require. Think of things like one group per class for glyphs, one group per color for gems, one group per type of scroll (e.g. Heirloom, Twinks and Popular), one group for craftable epics, one group for flasks, one group for inks, one for parchments, etc.",
1854 },
1855 },
1856 },
1857 VirtualGroups = {
1858 order = 6,
1859 type = "group",
1860 inline = true,
1861 name = "Virtual groups",
1862 args = {
1863 description = {
1864 order = 0,
1865 type = "description",
1866 name = "|cffccccccThis is advanced optional functionality. I recommend skipping this paragraph if you are new to Inventorium.|r\n\n" ..
1867
1868 "To allow changing the settings of multiple groups at once you can make virtual groups. These groups are basically like the general tab as their values are used when you aren't overriding a setting in a more specific group. After making a virtual group you still have to select it in all the \"child\"-groups so these groups know where to look for their settings when they are empty. Going back to our |cfffed000Glyphs (Hunter)|r group, we could make a virtual group called |cfffed000Glyphs|r which contained info like a default price threshold of 5g and a minimum crafting queue for all glyph groups. In each specific group you can then further specify that you would - for example - want 20 Hunter glyphs but 40 Druid glyphs as these might just sell a lot more often.",
1869 },
1870 },
1871 },
1872 },
1873 },
1874 FAQ = {
1875 order = 3,
1876 type = "group",
1877 name = "FAQ",
1878 args = {
1879 description = {
1880 order = 0,
1881 type = "description",
1882 name = "|cfffed000My groups don't appear in the summary window.|r\nPlease ensure your current character is toggled on at the \"track at\" option beneath the \"minimum stock\" category within a group or the defaults.\n\n" ..
1883 "|cfffed000The auction value collumn always shows a \"-\".|r\nThe auction value will not be cached when you set the \"price threshold\" beneath the \"replenishing stock\" category to |cfffed0000c|r. You can change this behavior by adjusting this value or toggling the \"Always show auction value\" option on.\n\n" ..
1884 "|cfffed000What relation does Inventorium have to ZeroAuctions or AuctionProfitMaster?|r\nNone. ZA/APM and IM are two completely seperate addons and do not interfere with eachother. At best you can use the auction pricing data displayed at the ZA/APM summary window as pricing source by selecting either addon as pricing addon, but neither IM nor ZA/APM will adjust any settings nor execute any other actions at one another. ZA/APM is an auction house addon. IM is a stock management addon. We are not related. We do not work together. We probably never will.\n\n" ..
1885 "|cfffed000What use do profiles have?|r\nBecause there is already the \"track at\" option, profiles may not be useful to anyone. Nevertheless someone might find a use for it in some way and thus it is left available. You can use it to test certain things for example without the risk of your main groups being destroyed (although this should never be an excuse not to back up your settings from time to time).\n\n" ..
1886 "|cfffed000Can you provide me with a sample scenario for virtual groups?|r\nNot really. If you are just getting to know Inventorium then I suggest leaving this functionality for the moment. It only makes things more complicated.\n\nAnyway, the simplest (and possibly most popular) setup to imagine are glyphs. There are over 300 glyphs available distributed over 10 classes. Glyphs for certain classes (such as the tribrids; Druids & Paladins) might sell a lot more often than those for others (such as pure DPS; Hunters, etc.).\n\nTo get an easily adjustable setup you can make one virtual group, called \"Glyphs\" and override all your prefered settings in there. After you are done, make a glyph-group for each class (such as \"Glyphs (Death Knight)\" etc.) and select \"Glyphs\" as virtual group for every one of them (you can easily insert item data to these class specific groups by selecting premade data).\n\nNow, to change the settings for all glyph groups you can just change the settings within the virtual \"Glyph\" group. To change the settings for one class in particular, such as Paladins because they sell more often than others, you can click this group and override the appropriate settings for just that group. There are many more possibilities for you to find out.\n\n" ..
1887 "",
1888 },
1889 },
1890 },
1891 },
1892 };
1893 end
1894
1895 function mod:MakeGroupOptions()
1896 options.args.groups = {
1897 order = 1100,
1898 type = "group",
1899 name = "Groups",
1900 desc = "Change a group.",
1901 args = {
1902 create = {
1903 order = 10,
1904 type = "group",
1905 inline = true,
1906 name = "Create a brand new group",
1907 args = {
1908 name = {
1909 order = 10,
1910 type = "input",
1911 name = "Group name",
1912 desc = "The name of the group. You can also use item links as you wish.",
1913 validate = ValidateGroupName,
1914 set = function(_, value)
1915 addon.db.profile.groups[value] = {};
1916 if currentGroupType == "Virtual" then
1917 addon.db.profile.groups[value].isVirtual = true;
1918 end
1919
1920 mod:FillGroupOptions();
1921 end,
1922 get = false,
1923 width = "double",
1924 },
1925 type = {
1926 order = 20,
1927 type = "select",
1928 name = "Type (advanced)",
1929 desc = "The type of the new group. This can not be changed at a later time.\n\n|cffff9933This is an advanced option, you will probably not need it unless you manage a lot of groups.|r\n\n|cfffed000Normal|r: A normal group with complete functionality.\n\n|cfffed000Virtual|r: A virtual group which you can use to override the defaults for a set of groups. You can not add items to virtual groups.",
1930 values = {
1931 ["Normal"] = "Normal",
1932 ["Virtual"] = "Virtual",
1933 },
1934 set = function(_, value) currentGroupType = value; end,
1935 get = function() return currentGroupType; end,
1936 },
1937 },
1938 },
1939 import = {
1940 order = 20,
1941 type = "group",
1942 inline = true,
1943 name = "Import a group",
1944 args = {
1945 input = {
1946 order = 10,
1947 type = "input",
1948 multiline = true,
1949 name = "Group data",
1950 desc = "Paste the group data as provided by a group export. If you are trying to import multiple groups at the same time, make sure to use newlines to seperate them.",
1951 set = function(info, value)
1952 local data = { string.split("\n", value or "") };
1953
1954 for _, current in pairs(data) do
1955 if not AceSerializer then
1956 AceSerializer = LibStub("AceSerializer-3.0");
1957 end
1958
1959 local result, temp = AceSerializer:Deserialize(current);
1960
1961 if not temp.name then
1962 print("|cffff0000The provided data is not supported.|r");
1963 elseif ValidateGroupName(nil, temp.name) ~= true then
1964 print(("|cffff0000Aborting: A group named \"%s\" already exists.|r"):format(temp.name));
1965 else
1966 local name = temp.name;
1967 temp.name = nil;
1968 print(("Importing %s..."):format(name));
1969
1970 if temp.items then
1971 -- Remove items that are already in another group
1972 for value, _ in pairs(temp.items) do
1973 local itemId = tonumber(value);
1974
1975 local itemData = addon.ItemData:New(itemId);
1976
1977 if not itemId then
1978 print(("\"%s\" is not a number."):format(value));
1979 temp.items[value] = nil;
1980 elseif itemData:InGroup() then
1981 print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
1982 temp.items[value] = nil;
1983 else
1984 -- Ensure the keys are numeric
1985 temp.items[value] = nil;
1986 temp.items[itemId] = true;
1987 end
1988 end
1989 end
1990
1991 -- Ensure this data isn't received (this would be silly/buggy as exports from other accounts - with different characters - won't know what to do with this)
1992 temp.trackAtCharacters = nil;
1993 temp.overrideTrackAtCharacters = nil;
1994
1995 addon.db.profile.groups[name] = temp;
1996 end
1997 end
1998
1999 self:FillGroupOptions();
2000 end,
2001 get = false,
2002 width = "full",
2003 },
2004 },
2005 },
2006 },
2007 };
2008 end
2009
2010 function mod:FillGroupOptions()
2011 for id, name in pairs(groupIdToName) do
2012 if type(name) == "string" and not addon.db.profile.groups[name] then
2013 options.args.groups.args[id] = nil;
2014 groupIdToName[id] = nil;
2015 groupIdToName[name] = nil;
2016 groupIsVirtual[id] = nil;
2017 end
2018 end
2019
2020 for name, values in pairs(addon.db.profile.groups) do
2021 if not groupIdToName[name] then
2022 options.args.groups.args[tostring(count)] = defaultGroup;
2023
2024 groupIdToName[tostring(count)] = name;
2025 groupIdToName[name] = true;
2026 if values.isVirtual then
2027 groupIsVirtual[tostring(count)] = true;
2028 end
2029
2030 count = ( count + 1 );
2031 end
2032 end
2033 end
2034
2035
2036
2037
2038
2039
2040 -- Verify premade groups
2041
2042 function mod:PremadeGroupsCheck(updateGroupName, updateKey, accept)
2043 -- Compare the current premade groups with those used, notify about changes
2044 if addon.defaultGroups then
2045 for premadeGroupName, groupInfo in pairs(addon.defaultGroups) do
2046 -- Go through all default groups
2047
2048 for groupName, values in pairs(addon.db.profile.groups) do
2049 -- Go through all groups to find those with this premade group
2050
2051 if values.premadeGroups and values.premadeGroups[premadeGroupName] and values.premadeGroups[premadeGroupName] < groupInfo.version then
2052 -- Outdated group
2053
2054 if updateGroupName and updateKey then
2055 -- This function was called after pressing yes or no in a confirm box
2056
2057 if accept then
2058 -- Yes was clicked
2059
2060 for itemId, version in pairs(groupInfo.items) do
2061 -- Go through all items in this premade group
2062
2063 local itemData = addon.ItemData:New(itemId);
2064
2065 if version > values.premadeGroups[premadeGroupName] then
2066 -- This item was added in a more recent version than this group: Add item
2067
2068 if itemData:InGroup() then
2069 print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
2070 elseif itemData:AddToGroup(groupName) then
2071 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);
2072 end
2073 elseif ( version * -1 ) > values.premadeGroups[premadeGroupName] then
2074 if itemData:InGroup() == groupName then
2075 itemData:RemoveFromGroup(groupName);
2076
2077 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);
2078 else
2079 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() ));
2080 end
2081 end
2082 end
2083
2084 if AceConfigRegistry then
2085 -- Now rebuild the list
2086 AceConfigRegistry:NotifyChange("InventoriumOptions");
2087 end
2088
2089 -- Remember the new version
2090 values.premadeGroups[premadeGroupName] = groupInfo.version;
2091 else
2092 -- No was clicked
2093
2094 -- Let user know what was not added
2095 for itemId, version in pairs(groupInfo.items) do
2096 -- Go through all items in this premade group
2097
2098 local itemData = addon.ItemData:New(itemId);
2099
2100 if version > values.premadeGroups[premadeGroupName] then
2101 -- This item was added in a more recent version than this group: don't add (since we clicked no), but announce it
2102
2103 print(("Skipping %s found in the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
2104 end
2105 end
2106
2107 -- Remember the new version
2108 values.premadeGroups[premadeGroupName] = groupInfo.version;
2109 end
2110 else
2111 StaticPopupDialogs["InventoriumConfirmUpdatePremadeGroup"] = {
2112 text = "The premade group |cfffed000%s|r used in the group |cfffed000%s|r has been changed. Do you wish to copy these changes?",
2113 button1 = YES,
2114 button2 = NO,
2115 OnAccept = function()
2116 addon:PremadeGroupsCheck(groupName, premadeGroupName, true);
2117 end,
2118 OnCancel = function(_, _, reason)
2119 if reason == "clicked" then
2120 addon:PremadeGroupsCheck(groupName, premadeGroupName, false);
2121 end
2122 end,
2123 timeout = 0,
2124 whileDead = 1,
2125 hideOnEscape = 1,
2126 };
2127 StaticPopup_Show("InventoriumConfirmUpdatePremadeGroup", premadeGroupName, groupName);
2128
2129 return;
2130 end
2131 end
2132 end
2133 end
2134 end
2135 end