annotate Modules/Config.lua @ 89:a12d22ef3f39

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