annotate Modules/Config.lua @ 225:2e4e52a589e5

Added onQueueStart and onQueueEnd events to crafting addon registering. GnomeWorks queue frame should automatically be closed before adding items to the queue and opened afterwards to speed this process up.
author Zerotorescue
date Mon, 07 Feb 2011 15:06:41 +0100
parents 70daa765e275
children 24e71ed0a422
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@140 98 return tostring(info[#info]); -- Ace is going to be bitching 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@98 107 addon:Print("Couldn't add the item with itemId (" .. itemData.id .. ") because it is already in a group.", addon.Colors.Red);
Zerotorescue@76 108 end
Zerotorescue@76 109
Zerotorescue@76 110 if AceConfigRegistry then
Zerotorescue@76 111 -- Now rebuild the list
Zerotorescue@172 112 AceConfigRegistry:NotifyChange("Inventorium");
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@172 140 AceConfigRegistry:NotifyChange("Inventorium");
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@140 155 -- Merge all items from all groups together (we only use this to check if an item is already in a group)
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@140 159 for itemId, count in pairs(values.items) do
Zerotorescue@140 160 items[itemId] = tonumber(count) or 0;
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@161 244 local function ImportPremadeItemsGroup(groupName, name)
Zerotorescue@161 245 local premadeItemGroup = addon.defaultGroups[name];
Zerotorescue@161 246
Zerotorescue@161 247 addon:Print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(name));
Zerotorescue@161 248
Zerotorescue@161 249 -- Remember we imported this group and it's version so if it is ever changed, people can be notified
Zerotorescue@161 250 if not addon.db.profile.groups[groupName].premadeGroups then
Zerotorescue@161 251 addon.db.profile.groups[groupName].premadeGroups = {};
Zerotorescue@161 252 end
Zerotorescue@161 253 addon.db.profile.groups[groupName].premadeGroups[name] = premadeItemGroup.version;
Zerotorescue@161 254
Zerotorescue@161 255 for itemId, version in pairs(premadeItemGroup.items) do
Zerotorescue@161 256 if version > 0 then
Zerotorescue@161 257 -- Sanity check
Zerotorescue@161 258 itemId = itemId and tonumber(itemId);
Zerotorescue@161 259
Zerotorescue@161 260 local itemData = addon.ItemData:New(itemId);
Zerotorescue@161 261
Zerotorescue@161 262 if not itemId then
Zerotorescue@161 263 addon:Print(("\"|cfffed000%s|r\" is not a number."):format(name), addon.Colors.Red);
Zerotorescue@161 264 elseif itemData:InGroup() then
Zerotorescue@161 265 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@161 266 elseif itemData:AddToGroup(groupName) then
Zerotorescue@161 267 addon:Print(("Added %s to the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), groupName ), addon.Colors.Green);
Zerotorescue@161 268 end
Zerotorescue@161 269 end
Zerotorescue@161 270 end
Zerotorescue@161 271 end
Zerotorescue@161 272
Zerotorescue@62 273 -- Default group
Zerotorescue@62 274 local defaultGroup = {
Zerotorescue@62 275 order = 0,
Zerotorescue@62 276 type = "group",
Zerotorescue@62 277 childGroups = "tab",
Zerotorescue@62 278 name = function(info)
Zerotorescue@62 279 local groupId = info[#info];
Zerotorescue@62 280 if groupIsVirtual[groupId] then
Zerotorescue@62 281 return ("%s |cfffed000Virtual|r"):format(groupIdToName[groupId]);
Zerotorescue@62 282 else
Zerotorescue@62 283 return groupIdToName[groupId];
Zerotorescue@62 284 end
Zerotorescue@62 285 end,
Zerotorescue@62 286 desc = function(info)
Zerotorescue@62 287 local groupId = info[#info];
Zerotorescue@62 288 if groupIsVirtual[groupId] then
Zerotorescue@62 289 return "This is a virtual group, you can use it to override the defaults for other groups.";
Zerotorescue@62 290 end
Zerotorescue@62 291 end,
Zerotorescue@62 292 args = {
Zerotorescue@62 293 general = {
Zerotorescue@62 294 order = 10,
Zerotorescue@62 295 type = "group",
Zerotorescue@62 296 name = "General",
Zerotorescue@62 297 desc = "Change the general settings for just this group.",
Zerotorescue@62 298 args = {
Zerotorescue@62 299 general = {
Zerotorescue@62 300 order = 0,
Zerotorescue@62 301 type = "group",
Zerotorescue@62 302 inline = true,
Zerotorescue@62 303 name = "General",
Zerotorescue@62 304 set = SetOption,
Zerotorescue@62 305 get = GetOption,
Zerotorescue@62 306 disabled = GetDisabled,
Zerotorescue@62 307 args = {
Zerotorescue@62 308 description = {
Zerotorescue@62 309 order = 0,
Zerotorescue@62 310 type = "description",
Zerotorescue@62 311 name = function(info)
Zerotorescue@62 312 local groupName = groupIdToName[info[2]];
Zerotorescue@62 313
Zerotorescue@106 314 local t = "";
Zerotorescue@106 315 if not addon.db.profile.defaults.hideHelp then
Zerotorescue@155 316 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.";
Zerotorescue@62 317 end
Zerotorescue@62 318
Zerotorescue@62 319 return t;
Zerotorescue@62 320 end,
Zerotorescue@62 321 },
Zerotorescue@62 322 header = {
Zerotorescue@62 323 order = 5,
Zerotorescue@62 324 type = "header",
Zerotorescue@62 325 name = "",
Zerotorescue@106 326 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@62 327 },
Zerotorescue@155 328 overrideTrackAtCharacters = {
Zerotorescue@155 329 order = 19,
Zerotorescue@62 330 type = "toggle",
Zerotorescue@155 331 name = "Override track at",
Zerotorescue@176 332 desc = "Allows you to override at which characters groups should be tracked, appear in the summary or generate alerts.",
Zerotorescue@155 333 arg = "trackAtCharacters",
Zerotorescue@62 334 },
Zerotorescue@155 335 trackAtCharacters = {
Zerotorescue@155 336 order = 20,
Zerotorescue@155 337 type = "multiselect",
Zerotorescue@155 338 name = "Track at",
Zerotorescue@176 339 desc = "Select at which characters groups should be tracked, appear in the summary or generate alerts.",
Zerotorescue@62 340 values = function()
Zerotorescue@62 341 local temp = {};
Zerotorescue@155 342 for charName in pairs(addon.db.factionrealm.characters) do
Zerotorescue@155 343 temp[charName] = charName;
Zerotorescue@62 344 end
Zerotorescue@62 345
Zerotorescue@62 346 return temp;
Zerotorescue@62 347 end,
Zerotorescue@155 348 get = GetMultiOption,
Zerotorescue@155 349 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@155 350 arg = "overrideTrackAtCharacters",
Zerotorescue@62 351 },
Zerotorescue@176 352 overrideDontAlertAtCharacters = {
Zerotorescue@176 353 order = 29,
Zerotorescue@176 354 type = "toggle",
Zerotorescue@176 355 name = "Override not alerting at",
Zerotorescue@176 356 desc = "Allows you to override at which characters items in groups should |cffff0000not|r generate alerts when they are below the required stock.",
Zerotorescue@176 357 arg = "dontAlertAtCharacters",
Zerotorescue@176 358 },
Zerotorescue@176 359 dontAlertAtCharacters = {
Zerotorescue@176 360 order = 30,
Zerotorescue@176 361 type = "multiselect",
Zerotorescue@176 362 name = "Do |cffff0000not|r alert at",
Zerotorescue@176 363 desc = "Select at which characters items in groups should |cffff0000not|r generate alerts when they are below the required stock.",
Zerotorescue@176 364 values = function()
Zerotorescue@176 365 local temp = {};
Zerotorescue@176 366 for charName in pairs(addon.db.factionrealm.characters) do
Zerotorescue@176 367 temp[charName] = charName;
Zerotorescue@176 368 end
Zerotorescue@176 369
Zerotorescue@176 370 return temp;
Zerotorescue@176 371 end,
Zerotorescue@176 372 get = GetMultiOption,
Zerotorescue@176 373 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@176 374 arg = "overrideDontAlertAtCharacters",
Zerotorescue@176 375 },
Zerotorescue@62 376 overrideLocalItemData = {
Zerotorescue@62 377 order = 39,
Zerotorescue@62 378 type = "toggle",
Zerotorescue@62 379 name = "Override local item data",
Zerotorescue@62 380 desc = "Allows you to override the local item data setting for this group.",
Zerotorescue@62 381 arg = "localItemData",
Zerotorescue@62 382 },
Zerotorescue@62 383 localItemData = {
Zerotorescue@62 384 order = 40,
Zerotorescue@62 385 type = "multiselect",
Zerotorescue@62 386 name = "Include in local item data",
Zerotorescue@62 387 desc = "Select which data should be included in the local item data.",
Zerotorescue@62 388 values = {
Zerotorescue@62 389 ["Bag"] = "Bag",
Zerotorescue@62 390 ["Bank"] = "Bank",
Zerotorescue@62 391 ["Auction House"] = "Auction House",
Zerotorescue@62 392 ["Mailbox"] = "Mailbox",
Zerotorescue@62 393 },
Zerotorescue@62 394 get = GetMultiOption,
Zerotorescue@65 395 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 396 arg = "overrideLocalItemData",
Zerotorescue@62 397 },
Zerotorescue@62 398 virtualGroup = {
Zerotorescue@62 399 order = 50,
Zerotorescue@62 400 type = "select",
Zerotorescue@62 401 name = "Use virtual group settings",
Zerotorescue@62 402 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 403 values = function(info)
Zerotorescue@62 404 local groupName = groupIdToName[info[2]];
Zerotorescue@62 405
Zerotorescue@62 406 local temp = {};
Zerotorescue@62 407
Zerotorescue@62 408 temp[""] = "";
Zerotorescue@62 409 for name, values in pairs(addon.db.profile.groups) do
Zerotorescue@62 410 if values.isVirtual and name ~= groupName then
Zerotorescue@62 411 temp[name] = name;
Zerotorescue@62 412 end
Zerotorescue@62 413 end
Zerotorescue@62 414
Zerotorescue@62 415 return temp;
Zerotorescue@62 416 end,
Zerotorescue@62 417 set = function(info, value)
Zerotorescue@62 418 local groupName = groupIdToName[info[2]];
Zerotorescue@62 419 local optionName = info[#info];
Zerotorescue@62 420
Zerotorescue@62 421 addon.db.profile.groups[groupName][optionName] = value ~= "" and value;
Zerotorescue@62 422 end,
Zerotorescue@62 423 disabled = false,
Zerotorescue@62 424 },
Zerotorescue@62 425 },
Zerotorescue@62 426 },
Zerotorescue@62 427 minimumStock = {
Zerotorescue@62 428 order = 10,
Zerotorescue@62 429 type = "group",
Zerotorescue@62 430 inline = true,
Zerotorescue@62 431 name = "Minimum stock",
Zerotorescue@62 432 set = SetOption,
Zerotorescue@62 433 get = GetOption,
Zerotorescue@62 434 disabled = GetDisabled,
Zerotorescue@62 435 args = {
Zerotorescue@62 436 description = {
Zerotorescue@62 437 order = 0,
Zerotorescue@62 438 type = "description",
Zerotorescue@62 439 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@106 440 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@62 441 },
Zerotorescue@62 442 header = {
Zerotorescue@62 443 order = 5,
Zerotorescue@62 444 type = "header",
Zerotorescue@62 445 name = "",
Zerotorescue@106 446 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@62 447 },
Zerotorescue@62 448
Zerotorescue@62 449 overrideMinLocalStock = {
Zerotorescue@62 450 order = 10,
Zerotorescue@62 451 type = "toggle",
Zerotorescue@62 452 name = "Override min local stock",
Zerotorescue@62 453 desc = "Allows you to override the minimum local stock setting for this group.",
Zerotorescue@62 454 arg = "minLocalStock",
Zerotorescue@62 455 },
Zerotorescue@62 456 minLocalStock = {
Zerotorescue@62 457 order = 11,
Zerotorescue@62 458 type = "range",
Zerotorescue@62 459 min = 0,
Zerotorescue@62 460 max = 100000,
Zerotorescue@62 461 softMax = 100,
Zerotorescue@62 462 step = 1,
Zerotorescue@62 463 name = "Minimum local stock",
Zerotorescue@62 464 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 465 arg = "overrideMinLocalStock",
Zerotorescue@62 466 },
Zerotorescue@62 467 overrideAlertBelowLocalMinimum = {
Zerotorescue@62 468 order = 15,
Zerotorescue@62 469 type = "toggle",
Zerotorescue@62 470 name = "Override local minimum alert",
Zerotorescue@62 471 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 472 arg = "alertBelowLocalMinimum",
Zerotorescue@62 473 },
Zerotorescue@62 474 alertBelowLocalMinimum = {
Zerotorescue@62 475 order = 16,
Zerotorescue@62 476 type = "toggle",
Zerotorescue@181 477 name = "Alert when below local minimum",
Zerotorescue@62 478 desc = "Show an alert when an item in this group gets below the local minimum stock threshold.",
Zerotorescue@62 479 arg = "overrideAlertBelowLocalMinimum",
Zerotorescue@62 480 },
Zerotorescue@82 481 overrideAutoRefill = {
Zerotorescue@82 482 order = 17,
Zerotorescue@82 483 type = "toggle",
Zerotorescue@82 484 name = "Override auto refill",
Zerotorescue@82 485 desc = "Allows you to override wether you want to automatically refill items when below the minimum local stock.",
Zerotorescue@82 486 arg = "autoRefill",
Zerotorescue@82 487 },
Zerotorescue@82 488 autoRefill = {
Zerotorescue@82 489 order = 18,
Zerotorescue@82 490 type = "toggle",
Zerotorescue@131 491 name = "Auto refill from storage",
Zerotorescue@131 492 desc = "Automatically refill items from your storage (bank/mailbox - unless this is included in the local count - or the guild bank) when below the minimum local stock.",
Zerotorescue@82 493 arg = "overrideAutoRefill",
Zerotorescue@82 494 },
Zerotorescue@184 495 spacer = {
Zerotorescue@184 496 order = 19,
Zerotorescue@184 497 type = "description",
Zerotorescue@184 498 name = "",
Zerotorescue@184 499 },
Zerotorescue@62 500
Zerotorescue@62 501 overrideMinGlobalStock = {
Zerotorescue@62 502 order = 20,
Zerotorescue@62 503 type = "toggle",
Zerotorescue@62 504 name = "Override min global stock",
Zerotorescue@62 505 desc = "Allows you to override the minimum global stock setting for this group.",
Zerotorescue@62 506 arg = "minGlobalStock",
Zerotorescue@62 507 },
Zerotorescue@62 508 minGlobalStock = {
Zerotorescue@62 509 order = 21,
Zerotorescue@62 510 type = "range",
Zerotorescue@62 511 min = 0,
Zerotorescue@62 512 max = 100000,
Zerotorescue@62 513 softMax = 100,
Zerotorescue@62 514 step = 1,
Zerotorescue@62 515 name = "Minimum global stock",
Zerotorescue@62 516 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 517 arg = "overrideMinGlobalStock",
Zerotorescue@62 518 },
Zerotorescue@62 519 overrideAlertBelowGlobalMinimum = {
Zerotorescue@62 520 order = 25,
Zerotorescue@62 521 type = "toggle",
Zerotorescue@62 522 name = "Override global minimum alert",
Zerotorescue@62 523 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 524 arg = "alertBelowGlobalMinimum",
Zerotorescue@62 525 },
Zerotorescue@62 526 alertBelowGlobalMinimum = {
Zerotorescue@62 527 order = 26,
Zerotorescue@62 528 type = "toggle",
Zerotorescue@181 529 name = "Alert when below global minimum",
Zerotorescue@62 530 desc = "Show an alert when an item in this group gets below the global minimum stock threshold.",
Zerotorescue@62 531 arg = "overrideAlertBelowGlobalMinimum",
Zerotorescue@62 532 },
Zerotorescue@62 533
Zerotorescue@62 534 overrideSummaryThresholdShow = {
Zerotorescue@62 535 order = 34,
Zerotorescue@62 536 type = "toggle",
Zerotorescue@62 537 name = "Override summary showing",
Zerotorescue@62 538 desc = "Allows you to override when this group should appear in the summary.",
Zerotorescue@62 539 arg = "summaryThresholdShow",
Zerotorescue@62 540 },
Zerotorescue@62 541 summaryThresholdShow = {
Zerotorescue@62 542 order = 35,
Zerotorescue@62 543 type = "range",
Zerotorescue@62 544 min = 0,
Zerotorescue@62 545 max = 10,
Zerotorescue@62 546 softMax = 100,
Zerotorescue@62 547 step = 0.05,
Zerotorescue@62 548 isPercent = true,
Zerotorescue@62 549 name = "Show in summary when below",
Zerotorescue@62 550 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 551 arg = "overrideSummaryThresholdShow",
Zerotorescue@62 552 },
Zerotorescue@62 553 },
Zerotorescue@62 554 },
Zerotorescue@62 555 refill = {
Zerotorescue@62 556 order = 20,
Zerotorescue@62 557 type = "group",
Zerotorescue@62 558 inline = true,
Zerotorescue@62 559 name = "Replenishing stock",
Zerotorescue@62 560 set = SetOption,
Zerotorescue@62 561 get = GetOption,
Zerotorescue@62 562 disabled = GetDisabled,
Zerotorescue@62 563 args = {
Zerotorescue@62 564 description = {
Zerotorescue@62 565 order = 0,
Zerotorescue@62 566 type = "description",
Zerotorescue@62 567 name = function(info)
Zerotorescue@62 568 local groupName = groupIdToName[info[2]];
Zerotorescue@62 569 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 570
Zerotorescue@62 571 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 572
Zerotorescue@62 573 if addon:GetOptionByKey(groupName, "priceThreshold") == 0 then
Zerotorescue@62 574 r = r .. "Queueing items at |cfffed000any|r auction value.";
Zerotorescue@62 575 else
Zerotorescue@62 576 r = r .. "Queueing items worth |cfffed000" .. addon:ReadableMoney(addon:GetOptionByKey(groupName, "priceThreshold")) .. "|r or more.";
Zerotorescue@62 577 end
Zerotorescue@62 578
Zerotorescue@62 579 return r;
Zerotorescue@62 580 end,
Zerotorescue@106 581 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@62 582 },
Zerotorescue@62 583 header = {
Zerotorescue@62 584 order = 5,
Zerotorescue@62 585 type = "header",
Zerotorescue@62 586 name = "",
Zerotorescue@106 587 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@62 588 },
Zerotorescue@62 589 overrideRestockTarget = {
Zerotorescue@62 590 order = 9,
Zerotorescue@62 591 type = "toggle",
Zerotorescue@62 592 name = "Override restock target",
Zerotorescue@62 593 desc = "Allows you to override the restock target setting for this group.",
Zerotorescue@62 594 arg = "restockTarget",
Zerotorescue@62 595 },
Zerotorescue@62 596 restockTarget = {
Zerotorescue@62 597 order = 10,
Zerotorescue@62 598 type = "range",
Zerotorescue@62 599 min = 0,
Zerotorescue@62 600 max = 100000,
Zerotorescue@62 601 softMax = 100,
Zerotorescue@62 602 step = 1,
Zerotorescue@62 603 name = "Restock target",
Zerotorescue@62 604 desc = "You can manually enter a value between 100 and 100.000 in the edit box if the provided range is insufficient.",
Zerotorescue@62 605 arg = "overrideRestockTarget",
Zerotorescue@62 606 },
Zerotorescue@62 607 overrideMinCraftingQueue = {
Zerotorescue@62 608 order = 19,
Zerotorescue@62 609 type = "toggle",
Zerotorescue@62 610 name = "Override min queue",
Zerotorescue@62 611 desc = "Allows you to override the minimum craftable items queue setting for this group.",
Zerotorescue@62 612 arg = "minCraftingQueue",
Zerotorescue@62 613 },
Zerotorescue@62 614 minCraftingQueue = {
Zerotorescue@62 615 order = 20,
Zerotorescue@62 616 type = "range",
Zerotorescue@62 617 min = 0,
Zerotorescue@62 618 max = 1,
Zerotorescue@62 619 step = 0.01,
Zerotorescue@62 620 isPercent = true,
Zerotorescue@154 621 name = "Don't queue when only missing...",
Zerotorescue@154 622 desc = "Don't add a craftable item to the queue when only missing 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 623 arg = "overrideMinCraftingQueue",
Zerotorescue@62 624 },
Zerotorescue@62 625 overrideBonusQueue = {
Zerotorescue@62 626 order = 29,
Zerotorescue@62 627 type = "toggle",
Zerotorescue@62 628 name = "Override bonus queue",
Zerotorescue@62 629 desc = "Allows you to override the bonus craftable items queue setting for this group.",
Zerotorescue@62 630 arg = "bonusQueue",
Zerotorescue@62 631 },
Zerotorescue@62 632 bonusQueue = {
Zerotorescue@62 633 order = 30,
Zerotorescue@62 634 type = "range",
Zerotorescue@62 635 min = 0,
Zerotorescue@62 636 max = 10, -- 1000%
Zerotorescue@62 637 step = 0.01, -- 1%
Zerotorescue@62 638 isPercent = true,
Zerotorescue@62 639 name = "Bonus queue",
Zerotorescue@62 640 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 641 arg = "overrideBonusQueue",
Zerotorescue@62 642 },
Zerotorescue@62 643 overridePriceThreshold = {
Zerotorescue@62 644 order = 39,
Zerotorescue@62 645 type = "toggle",
Zerotorescue@62 646 name = "Override price threshold",
Zerotorescue@62 647 desc = "Allows you to override the price threshold setting for this group.",
Zerotorescue@62 648 arg = "priceThreshold",
Zerotorescue@62 649 },
Zerotorescue@62 650 priceThreshold = {
Zerotorescue@62 651 order = 40,
Zerotorescue@62 652 type = "input",
Zerotorescue@62 653 name = "Price threshold",
Zerotorescue@62 654 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 655 validate = function(info, value) return addon:ValidateReadableMoney(info, value); end,
Zerotorescue@62 656 get = function(i) return addon:ReadableMoney(GetOption(i)); end,
Zerotorescue@62 657 set = function(i, v) SetOption(i, addon:ReadableMoneyToCopper(v)); end,
Zerotorescue@62 658 arg = "overridePriceThreshold",
Zerotorescue@62 659 },
Zerotorescue@62 660 overrideSummaryHidePriceThreshold = {
Zerotorescue@62 661 order = 49,
Zerotorescue@62 662 type = "toggle",
Zerotorescue@62 663 name = "Override summary showing",
Zerotorescue@62 664 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 665 arg = "summaryHidePriceThreshold",
Zerotorescue@62 666 },
Zerotorescue@62 667 summaryHidePriceThreshold = {
Zerotorescue@62 668 order = 50,
Zerotorescue@62 669 type = "toggle",
Zerotorescue@62 670 name = "Hide when below threshold",
Zerotorescue@62 671 desc = "Hide items from the summary when their value is below the set price threshold.",
Zerotorescue@62 672 arg = "overrideSummaryHidePriceThreshold",
Zerotorescue@62 673 },
Zerotorescue@62 674 overrideAlwaysGetAuctionValue = {
Zerotorescue@62 675 order = 59,
Zerotorescue@62 676 type = "toggle",
Zerotorescue@62 677 name = "Override auction value showing",
Zerotorescue@62 678 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 679 arg = "alwaysGetAuctionValue",
Zerotorescue@62 680 },
Zerotorescue@62 681 alwaysGetAuctionValue = {
Zerotorescue@62 682 order = 60,
Zerotorescue@62 683 type = "toggle",
Zerotorescue@62 684 name = "Always show auction value",
Zerotorescue@62 685 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 686 arg = "overrideAlwaysGetAuctionValue",
Zerotorescue@62 687 },
Zerotorescue@62 688 },
Zerotorescue@62 689 },
Zerotorescue@155 690 addons = {
Zerotorescue@155 691 order = 30,
Zerotorescue@155 692 type = "group",
Zerotorescue@155 693 inline = true,
Zerotorescue@155 694 name = "Prefered addons",
Zerotorescue@155 695 set = SetOption,
Zerotorescue@155 696 get = GetOption,
Zerotorescue@155 697 disabled = GetDisabled,
Zerotorescue@155 698 args = {
Zerotorescue@155 699 description = {
Zerotorescue@155 700 order = 0,
Zerotorescue@155 701 type = "description",
Zerotorescue@155 702 name = function(info)
Zerotorescue@155 703 local groupName = groupIdToName[info[2]];
Zerotorescue@155 704
Zerotorescue@155 705 local t = "";
Zerotorescue@155 706 if not addon.db.profile.defaults.hideHelp then
Zerotorescue@155 707 t = "Selecting your prefered addons is optional, the first working addon will be used if the selected addon doesn't exist. You only need to set this when you are running multiple addons of a kind and wish to specify which addons to use for what groups.\n\n";
Zerotorescue@155 708 end
Zerotorescue@155 709
Zerotorescue@155 710 local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
Zerotorescue@155 711 local preferedAddon = addon:GetOptionByKey(groupName, "itemCountAddon");
Zerotorescue@155 712
Zerotorescue@155 713 if currentAddon then
Zerotorescue@155 714 --GetCharacterCount
Zerotorescue@155 715 --addon.supportedAddons.itemCount[selectedExternalAddon]
Zerotorescue@155 716 t = t .. "Currently using |cfffed000" .. selectedAddonName .. "|r as your item count addon. This addon is " .. ((currentAddon.IsEnabled() and "|cff00ff00enabled|r") or "|cffff0000disabled|r") .. ".";
Zerotorescue@155 717
Zerotorescue@155 718 if currentAddon.GetTotalCount and currentAddon.GetCharacterCount then
Zerotorescue@155 719 t = t .. " This addon supports |cfffed000both total as local|r item counts.";
Zerotorescue@155 720 elseif currentAddon.GetTotalCount then
Zerotorescue@155 721 t = t .. " This addon supports |cfffed000only total|r item counts.";
Zerotorescue@155 722 elseif currentAddon.GetCharacterCount then
Zerotorescue@155 723 t = t .. " This addon supports |cfffed000only local|r item counts.";
Zerotorescue@155 724 end
Zerotorescue@155 725
Zerotorescue@155 726 if preferedAddon ~= selectedAddonName then
Zerotorescue@216 727 t = t .. "\n\n|cffff0000You have selected |cfffed000" .. preferedAddon .. "|r|cffff0000 as your item count addon, but this appears to be disabled and thus the best alternative was selected.|r";
Zerotorescue@155 728 end
Zerotorescue@155 729 end
Zerotorescue@155 730
Zerotorescue@155 731 return t;
Zerotorescue@155 732 end,
Zerotorescue@155 733 },
Zerotorescue@155 734 header = {
Zerotorescue@155 735 order = 5,
Zerotorescue@155 736 type = "header",
Zerotorescue@155 737 name = "",
Zerotorescue@155 738 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@155 739 },
Zerotorescue@155 740 overrideAuctionPricingAddon = {
Zerotorescue@155 741 order = 9,
Zerotorescue@155 742 type = "toggle",
Zerotorescue@155 743 name = "Override pricing addon",
Zerotorescue@155 744 desc = "Allows you to override the pricing addon setting for this group.",
Zerotorescue@155 745 arg = "auctionPricingAddon",
Zerotorescue@155 746 },
Zerotorescue@155 747 auctionPricingAddon = {
Zerotorescue@155 748 order = 10,
Zerotorescue@155 749 type = "select",
Zerotorescue@155 750 name = "Prefered pricing addon",
Zerotorescue@155 751 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@155 752 values = function()
Zerotorescue@155 753 local temp = {};
Zerotorescue@155 754 for name, value in pairs(addon.supportedAddons.auctionPricing) do
Zerotorescue@155 755 temp[name] = name;
Zerotorescue@155 756 end
Zerotorescue@155 757
Zerotorescue@155 758 return temp;
Zerotorescue@155 759 end,
Zerotorescue@155 760 set = function(info, value)
Zerotorescue@155 761 local groupName = groupIdToName[info[2]];
Zerotorescue@155 762 local optionName = info[#info];
Zerotorescue@155 763
Zerotorescue@155 764 addon.db.profile.groups[groupName][optionName] = value ~= "" and value;
Zerotorescue@155 765
Zerotorescue@155 766 if addon.supportedAddons.auctionPricing[value].OnSelect then
Zerotorescue@155 767 addon.supportedAddons.auctionPricing[value].OnSelect();
Zerotorescue@155 768 end
Zerotorescue@155 769 end,
Zerotorescue@155 770 arg = "overrideAuctionPricingAddon",
Zerotorescue@155 771 },
Zerotorescue@155 772 overrideItemCountAddon = {
Zerotorescue@155 773 order = 19,
Zerotorescue@155 774 type = "toggle",
Zerotorescue@155 775 name = "Override item count addon",
Zerotorescue@155 776 desc = "Allows you to override the item count addon setting for this group.",
Zerotorescue@155 777 arg = "itemCountAddon",
Zerotorescue@155 778 },
Zerotorescue@155 779 itemCountAddon = {
Zerotorescue@155 780 order = 20,
Zerotorescue@155 781 type = "select",
Zerotorescue@155 782 name = "Prefered item count addon",
Zerotorescue@216 783 desc = "Select the addon you prefer data for this group to be retrieved from. The best supported addon will be used if the selected addon can not be found.",
Zerotorescue@155 784 values = function()
Zerotorescue@155 785 local temp = {};
Zerotorescue@155 786 for name, value in pairs(addon.supportedAddons.itemCount) do
Zerotorescue@155 787 temp[name] = name;
Zerotorescue@155 788 end
Zerotorescue@155 789
Zerotorescue@155 790 return temp;
Zerotorescue@155 791 end,
Zerotorescue@155 792 set = function(info, value)
Zerotorescue@155 793 local groupName = groupIdToName[info[2]];
Zerotorescue@155 794 local optionName = info[#info];
Zerotorescue@155 795
Zerotorescue@155 796 addon.db.profile.groups[groupName][optionName] = value ~= "" and value;
Zerotorescue@155 797
Zerotorescue@155 798 if addon.supportedAddons.itemCount[value].OnSelect then
Zerotorescue@155 799 addon.supportedAddons.itemCount[value].OnSelect();
Zerotorescue@155 800 end
Zerotorescue@155 801 end,
Zerotorescue@155 802 arg = "overrideItemCountAddon",
Zerotorescue@155 803 },
Zerotorescue@155 804 overrideCraftingAddon = {
Zerotorescue@155 805 order = 29,
Zerotorescue@155 806 type = "toggle",
Zerotorescue@155 807 name = "Override crafting addon",
Zerotorescue@155 808 desc = "Allows you to override the crafting addon setting for this group.",
Zerotorescue@155 809 arg = "craftingAddon",
Zerotorescue@155 810 },
Zerotorescue@155 811 craftingAddon = {
Zerotorescue@155 812 order = 30,
Zerotorescue@155 813 type = "select",
Zerotorescue@155 814 name = "Prefered crafting addon",
Zerotorescue@155 815 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@155 816 values = function()
Zerotorescue@155 817 local temp = {};
Zerotorescue@155 818 for name, value in pairs(addon.supportedAddons.crafting) do
Zerotorescue@155 819 temp[name] = name;
Zerotorescue@155 820 end
Zerotorescue@155 821
Zerotorescue@155 822 return temp;
Zerotorescue@155 823 end,
Zerotorescue@155 824 set = function(info, value)
Zerotorescue@155 825 local groupName = groupIdToName[info[2]];
Zerotorescue@155 826 local optionName = info[#info];
Zerotorescue@155 827
Zerotorescue@155 828 addon.db.profile.groups[groupName][optionName] = value ~= "" and value;
Zerotorescue@155 829
Zerotorescue@155 830 if addon.supportedAddons.crafting[value].OnSelect then
Zerotorescue@155 831 addon.supportedAddons.crafting[value].OnSelect();
Zerotorescue@155 832 end
Zerotorescue@155 833 end,
Zerotorescue@155 834 arg = "overrideCraftingAddon",
Zerotorescue@155 835 },
Zerotorescue@155 836 },
Zerotorescue@155 837 },
Zerotorescue@62 838 },
Zerotorescue@62 839 },
Zerotorescue@62 840 group = {
Zerotorescue@62 841 order = 20,
Zerotorescue@62 842 type = "group",
Zerotorescue@62 843 name = "Management",
Zerotorescue@62 844 desc = "Rename, delete, duplicate or export this group.",
Zerotorescue@62 845 args = {
Zerotorescue@62 846 actions = {
Zerotorescue@62 847 order = 10,
Zerotorescue@62 848 type = "group",
Zerotorescue@62 849 name = "Actions",
Zerotorescue@62 850 inline = true,
Zerotorescue@62 851 args = {
Zerotorescue@62 852 rename = {
Zerotorescue@62 853 order = 10,
Zerotorescue@62 854 type = "input",
Zerotorescue@62 855 name = "Rename group - New name",
Zerotorescue@62 856 desc = "Change the name of this group to something else. You can also use item links here as you wish.",
Zerotorescue@62 857 validate = ValidateGroupName,
Zerotorescue@62 858 set = function(info, value)
Zerotorescue@62 859 local oldGroupName = groupIdToName[info[2]];
Zerotorescue@62 860
Zerotorescue@62 861 addon.db.profile.groups[value] = CopyTable(addon.db.profile.groups[oldGroupName]);
Zerotorescue@62 862 addon.db.profile.groups[oldGroupName] = nil;
Zerotorescue@62 863
Zerotorescue@62 864 groupIdToName[info[2]] = value;
Zerotorescue@62 865 groupIdToName[value] = true;
Zerotorescue@62 866 groupIdToName[oldGroupName] = nil;
Zerotorescue@62 867
Zerotorescue@62 868 mod:FillGroupOptions();
Zerotorescue@62 869 end,
Zerotorescue@62 870 get = function(info)
Zerotorescue@62 871 return groupIdToName[info[2]];
Zerotorescue@62 872 end,
Zerotorescue@62 873 },
Zerotorescue@62 874 duplicate = {
Zerotorescue@62 875 order = 20,
Zerotorescue@62 876 type = "input",
Zerotorescue@62 877 name = "Duplicate group - New name",
Zerotorescue@62 878 desc = "Duplicate this group. You can also use item links here as you wish.\n\nAll item data will be erased.",
Zerotorescue@62 879 validate = ValidateGroupName,
Zerotorescue@62 880 set = function(info, value)
Zerotorescue@62 881 local oldGroupName = groupIdToName[info[2]];
Zerotorescue@62 882
Zerotorescue@62 883 addon.db.profile.groups[value] = CopyTable(addon.db.profile.groups[oldGroupName]);
Zerotorescue@62 884
Zerotorescue@62 885 -- Reset item data (duplicate items me no want)
Zerotorescue@62 886 addon.db.profile.groups[value].items = nil;
Zerotorescue@62 887
Zerotorescue@62 888 mod:FillGroupOptions();
Zerotorescue@62 889 end,
Zerotorescue@62 890 get = false,
Zerotorescue@62 891 },
Zerotorescue@62 892 delete = {
Zerotorescue@62 893 order = 30,
Zerotorescue@62 894 type = "execute",
Zerotorescue@62 895 name = "Delete group",
Zerotorescue@62 896 desc = "Delete the currently selected group.",
Zerotorescue@62 897 confirm = true,
Zerotorescue@62 898 confirmText = "Are you sure you wish to |cffff0000DELETE|r this group? This action is not reversable!",
Zerotorescue@62 899 func = function(info)
Zerotorescue@62 900 local groupName = groupIdToName[info[2]];
Zerotorescue@62 901
Zerotorescue@62 902 addon.db.profile.groups[groupName] = nil;
Zerotorescue@62 903
Zerotorescue@62 904 mod:FillGroupOptions();
Zerotorescue@62 905 end,
Zerotorescue@62 906 },
Zerotorescue@62 907 },
Zerotorescue@62 908 },
Zerotorescue@62 909 export = {
Zerotorescue@62 910 order = 40,
Zerotorescue@62 911 type = "group",
Zerotorescue@62 912 name = "Export",
Zerotorescue@62 913 inline = true,
Zerotorescue@62 914 args = {
Zerotorescue@62 915 input = {
Zerotorescue@62 916 order = 10,
Zerotorescue@62 917 type = "input",
Zerotorescue@62 918 multiline = true,
Zerotorescue@62 919 name = "Group data",
Zerotorescue@62 920 width = "full",
Zerotorescue@62 921 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 922 set = false,
Zerotorescue@62 923 get = function(info)
Zerotorescue@62 924 local groupName = groupIdToName[info[2]];
Zerotorescue@62 925
Zerotorescue@152 926 return mod:ExportGroup(groupName);
Zerotorescue@62 927 end,
Zerotorescue@62 928 },
Zerotorescue@62 929 },
Zerotorescue@62 930 },
Zerotorescue@62 931 },
Zerotorescue@62 932 },
Zerotorescue@62 933 add = {
Zerotorescue@62 934 order = 30,
Zerotorescue@62 935 type = "group",
Zerotorescue@62 936 name = "Add items",
Zerotorescue@62 937 desc = "Add new items to this group.",
Zerotorescue@62 938 hidden = function(info) return groupIsVirtual[info[2]]; end,
Zerotorescue@62 939 args = {
Zerotorescue@62 940 singleAdd = {
Zerotorescue@62 941 order = 10,
Zerotorescue@62 942 type = "group",
Zerotorescue@62 943 inline = true,
Zerotorescue@62 944 name = "Add items",
Zerotorescue@62 945 args = {
Zerotorescue@62 946 help = {
Zerotorescue@62 947 order = 10,
Zerotorescue@62 948 type = "description",
Zerotorescue@62 949 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@106 950 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@62 951 },
Zerotorescue@62 952 itemLink = {
Zerotorescue@62 953 order = 20,
Zerotorescue@62 954 type = "input",
Zerotorescue@62 955 name = "Single item add (item-link or item-id)",
Zerotorescue@62 956 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 957 validate = function(info, value)
Zerotorescue@62 958 -- If the value is empty we'll allow passing to clear the carret
Zerotorescue@62 959 if value == "" then return true; end
Zerotorescue@62 960
Zerotorescue@62 961 local groupName = groupIdToName[info[2]];
Zerotorescue@62 962
Zerotorescue@76 963 local itemId = (addon:GetItemId(string.trim(value)) or tonumber(string.trim(value)));
Zerotorescue@76 964
Zerotorescue@76 965 local itemData = addon.ItemData:New(itemId);
Zerotorescue@62 966
Zerotorescue@62 967 if not itemId then
Zerotorescue@76 968 return "This is not a valid item link or id.";
Zerotorescue@76 969 elseif itemData:InGroup() then
Zerotorescue@76 970 return ("This item is already in the group |cfffed000%s|r."):format(itemData:InGroup());
Zerotorescue@62 971 end
Zerotorescue@62 972
Zerotorescue@62 973 return true;
Zerotorescue@62 974 end,
Zerotorescue@62 975 set = function(info, value)
Zerotorescue@62 976 if value and value ~= "" then
Zerotorescue@62 977 local groupName = groupIdToName[info[2]];
Zerotorescue@62 978
Zerotorescue@76 979 local itemId = (addon:GetItemId(string.trim(value)) or tonumber(string.trim(value)));
Zerotorescue@62 980
Zerotorescue@76 981 local itemData = addon.ItemData:New(itemId);
Zerotorescue@76 982
Zerotorescue@76 983 if itemData:AddToGroup(groupName) then
Zerotorescue@98 984 addon:Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green);
Zerotorescue@76 985
Zerotorescue@76 986 if AceConfigRegistry then
Zerotorescue@76 987 -- Now rebuild the list
Zerotorescue@172 988 AceConfigRegistry:NotifyChange("Inventorium");
Zerotorescue@76 989 end
Zerotorescue@76 990 else
Zerotorescue@98 991 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 992 end
Zerotorescue@62 993 end
Zerotorescue@62 994 end,
Zerotorescue@62 995 get = false,
Zerotorescue@62 996 },
Zerotorescue@62 997 importItemData = {
Zerotorescue@62 998 order = 30,
Zerotorescue@62 999 type = "input",
Zerotorescue@62 1000 name = "Import item data",
Zerotorescue@62 1001 desc = "Import item data from an exported item data-string. Any items already grouped will be skipped.",
Zerotorescue@62 1002 set = function(info, value)
Zerotorescue@62 1003 local groupName = groupIdToName[info[2]];
Zerotorescue@62 1004
Zerotorescue@62 1005 local allItemIds = { string.split(";", value or "") };
Zerotorescue@62 1006
Zerotorescue@62 1007 for _, value in pairs(allItemIds) do
Zerotorescue@62 1008 local itemId = tonumber(value);
Zerotorescue@62 1009
Zerotorescue@76 1010 if itemId then
Zerotorescue@76 1011 local itemData = addon.ItemData:New(itemId);
Zerotorescue@76 1012
Zerotorescue@76 1013 if itemData:InGroup() then
Zerotorescue@98 1014 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@98 1015 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 1016 elseif itemData:AddToGroup(groupName) then
Zerotorescue@98 1017 addon:Print(("Added %s to the group |cfffed000%s|r."):format(itemData.link or unknownItemName:format(itemId), groupName), addon.Colors.Green);
Zerotorescue@76 1018 end
Zerotorescue@62 1019 else
Zerotorescue@98 1020 addon:Print(("\"%s\" is not a number."):format(value), addon.Colors.Red);
Zerotorescue@62 1021 end
Zerotorescue@62 1022 end
Zerotorescue@76 1023
Zerotorescue@76 1024 if AceConfigRegistry then
Zerotorescue@76 1025 -- Now rebuild the list
Zerotorescue@172 1026 AceConfigRegistry:NotifyChange("Inventorium");
Zerotorescue@76 1027 end
Zerotorescue@62 1028 end,
Zerotorescue@62 1029 get = false,
Zerotorescue@62 1030 },
Zerotorescue@62 1031 importPremadeData = {
Zerotorescue@62 1032 order = 40,
Zerotorescue@62 1033 type = "select",
Zerotorescue@106 1034 width = "double",
Zerotorescue@62 1035 name = "Import premade data",
Zerotorescue@62 1036 desc = "Import item data from a premade item-group. Any items already grouped will be skipped.",
Zerotorescue@62 1037 values = function()
Zerotorescue@62 1038 local temp = {};
Zerotorescue@62 1039 for key, group in pairs(addon.defaultGroups) do
Zerotorescue@62 1040 temp[key] = key;
Zerotorescue@62 1041 end
Zerotorescue@62 1042
Zerotorescue@62 1043 return temp;
Zerotorescue@62 1044 end,
Zerotorescue@62 1045 set = function(info, value)
Zerotorescue@62 1046 local groupName = groupIdToName[info[2]];
Zerotorescue@62 1047
Zerotorescue@161 1048 local premadeItemGroup = addon.defaultGroups[value];
Zerotorescue@62 1049
Zerotorescue@161 1050 if premadeItemGroup.isParent and premadeItemGroup.childs then
Zerotorescue@161 1051 for _, premadeItemGroupName in pairs(premadeItemGroup.childs) do
Zerotorescue@161 1052 ImportPremadeItemsGroup(groupName, premadeItemGroupName);
Zerotorescue@62 1053 end
Zerotorescue@161 1054 else
Zerotorescue@161 1055 ImportPremadeItemsGroup(groupName, value);
Zerotorescue@62 1056 end
Zerotorescue@76 1057
Zerotorescue@76 1058 if AceConfigRegistry then
Zerotorescue@76 1059 -- Now rebuild the list
Zerotorescue@172 1060 AceConfigRegistry:NotifyChange("Inventorium");
Zerotorescue@76 1061 end
Zerotorescue@62 1062 end,
Zerotorescue@62 1063 get = false,
Zerotorescue@62 1064 },
Zerotorescue@62 1065 },
Zerotorescue@62 1066 },
Zerotorescue@62 1067 massAdd = {
Zerotorescue@62 1068 order = 20,
Zerotorescue@62 1069 type = "group",
Zerotorescue@62 1070 inline = true,
Zerotorescue@62 1071 name = "Mass add",
Zerotorescue@62 1072 args = {
Zerotorescue@62 1073 help = {
Zerotorescue@62 1074 order = 10,
Zerotorescue@62 1075 type = "description",
Zerotorescue@62 1076 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@106 1077 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@62 1078 },
Zerotorescue@62 1079 massAdd = {
Zerotorescue@62 1080 order = 20,
Zerotorescue@62 1081 type = "input",
Zerotorescue@62 1082 name = "Add all items matching...",
Zerotorescue@62 1083 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 1084 set = function(info, value)
Zerotorescue@62 1085 local groupName = groupIdToName[info[2]];
Zerotorescue@62 1086
Zerotorescue@62 1087 if not value then return; end
Zerotorescue@62 1088
Zerotorescue@62 1089 value = value:lower();
Zerotorescue@62 1090
Zerotorescue@62 1091 local ref = options.args.groups.args[info[2]].args.add.args.list.args;
Zerotorescue@62 1092
Zerotorescue@62 1093 for itemId, test in pairs(ref) do
Zerotorescue@62 1094 if test then
Zerotorescue@76 1095 local itemData = addon.ItemData:New(itemId);
Zerotorescue@62 1096
Zerotorescue@76 1097 if itemData.name:lower():find(value) then
Zerotorescue@76 1098 if itemData:AddToGroup(groupName) then
Zerotorescue@98 1099 addon:Print(("Added %s to the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Green);
Zerotorescue@76 1100 else
Zerotorescue@98 1101 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 1102 end
Zerotorescue@62 1103 end
Zerotorescue@62 1104 end
Zerotorescue@62 1105 end
Zerotorescue@76 1106
Zerotorescue@76 1107 if AceConfigRegistry then
Zerotorescue@76 1108 -- Now rebuild the list
Zerotorescue@172 1109 AceConfigRegistry:NotifyChange("Inventorium");
Zerotorescue@76 1110 end
Zerotorescue@62 1111 end,
Zerotorescue@62 1112 get = false,
Zerotorescue@62 1113 },
Zerotorescue@62 1114 minItemLevel = {
Zerotorescue@62 1115 order = 40,
Zerotorescue@62 1116 type = "select",
Zerotorescue@62 1117 values = function()
Zerotorescue@62 1118 local temp = {};
Zerotorescue@62 1119
Zerotorescue@62 1120 temp[0] = "Include everything";
Zerotorescue@62 1121
Zerotorescue@62 1122 local itemLevelTemplate = "Itemlevel >= %d";
Zerotorescue@62 1123
Zerotorescue@62 1124 for i = 1, 49 do
Zerotorescue@62 1125 temp[( i * 10 )] = itemLevelTemplate:format(( i * 10 ));
Zerotorescue@62 1126 end
Zerotorescue@62 1127
Zerotorescue@62 1128 temp[500] = "Include nothing";
Zerotorescue@62 1129
Zerotorescue@62 1130 return temp;
Zerotorescue@62 1131 end,
Zerotorescue@62 1132 name = "Include tradeskill items",
Zerotorescue@62 1133 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 1134 set = function(i, v) includeTradeSkillItems = v; end,
Zerotorescue@62 1135 get = function() return includeTradeSkillItems; end,
Zerotorescue@62 1136 disabled = function()
Zerotorescue@62 1137 if GetTradeSkillLine() == "UNKNOWN" then
Zerotorescue@62 1138 includeTradeSkillItems = 500;
Zerotorescue@62 1139 return true; -- disabled
Zerotorescue@62 1140 else
Zerotorescue@62 1141 return false;
Zerotorescue@62 1142 end
Zerotorescue@62 1143 end,
Zerotorescue@62 1144 },
Zerotorescue@62 1145 },
Zerotorescue@62 1146 },
Zerotorescue@62 1147 list = {
Zerotorescue@62 1148 order = 30,
Zerotorescue@62 1149 type = "group",
Zerotorescue@62 1150 inline = true,
Zerotorescue@62 1151 name = "Item list",
Zerotorescue@62 1152 hidden = UpdateAddItemList,
Zerotorescue@62 1153 args = {
Zerotorescue@62 1154
Zerotorescue@62 1155 },
Zerotorescue@62 1156 },
Zerotorescue@62 1157 },
Zerotorescue@62 1158 },
Zerotorescue@62 1159 remove = {
Zerotorescue@62 1160 order = 40,
Zerotorescue@62 1161 type = "group",
Zerotorescue@62 1162 name = "Current items",
Zerotorescue@62 1163 desc = "View, export or remove items from this group.",
Zerotorescue@62 1164 hidden = function(info) return groupIsVirtual[info[2]]; end,
Zerotorescue@62 1165 args = {
Zerotorescue@62 1166 help = {
Zerotorescue@62 1167 order = 10,
Zerotorescue@62 1168 type = "group",
Zerotorescue@62 1169 inline = true,
Zerotorescue@106 1170 name = "Remove items",
Zerotorescue@62 1171 hidden = false,
Zerotorescue@62 1172 args = {
Zerotorescue@62 1173 help = {
Zerotorescue@62 1174 order = 10,
Zerotorescue@62 1175 type = "description",
Zerotorescue@62 1176 name = "Click the items you wish to remove from this group.",
Zerotorescue@106 1177 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@62 1178 },
Zerotorescue@62 1179 massRemove = {
Zerotorescue@62 1180 order = 20,
Zerotorescue@62 1181 type = "input",
Zerotorescue@62 1182 name = "Remove all items matching...",
Zerotorescue@62 1183 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 1184 set = function(info, value)
Zerotorescue@62 1185 local groupName = groupIdToName[info[2]];
Zerotorescue@62 1186
Zerotorescue@62 1187 if not value then return; end
Zerotorescue@62 1188
Zerotorescue@62 1189 value = value:lower();
Zerotorescue@62 1190
Zerotorescue@62 1191 local ref = options.args.groups.args[info[2]].args.remove.args.list.args;
Zerotorescue@62 1192
Zerotorescue@62 1193 for itemId, test in pairs(ref) do
Zerotorescue@62 1194 if test then
Zerotorescue@76 1195 local itemData = addon.ItemData:New(itemId);
Zerotorescue@62 1196
Zerotorescue@76 1197 if itemData.name:lower():find(value) then
Zerotorescue@76 1198 itemData:RemoveFromGroup(groupName);
Zerotorescue@76 1199
Zerotorescue@98 1200 addon:Print(("Removed %s from the selected group."):format( (itemData.link or unknownItemName:format(itemId)) ), addon.Colors.Red);
Zerotorescue@62 1201 end
Zerotorescue@62 1202 end
Zerotorescue@62 1203 end
Zerotorescue@62 1204
Zerotorescue@76 1205 if AceConfigRegistry then
Zerotorescue@76 1206 -- Now rebuild the list
Zerotorescue@172 1207 AceConfigRegistry:NotifyChange("Inventorium");
Zerotorescue@76 1208 end
Zerotorescue@62 1209 end,
Zerotorescue@62 1210 get = false,
Zerotorescue@62 1211 },
Zerotorescue@62 1212 premadeGroups = {
Zerotorescue@62 1213 order = 30,
Zerotorescue@62 1214 type = "select",
Zerotorescue@106 1215 width = "double",
Zerotorescue@62 1216 name = "Imported premade groups",
Zerotorescue@62 1217 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 1218 values = function(info)
Zerotorescue@62 1219 local groupName = groupIdToName[info[2]];
Zerotorescue@62 1220
Zerotorescue@62 1221 local temp = {};
Zerotorescue@76 1222 temp[""] = "";
Zerotorescue@62 1223 if addon.db.profile.groups[groupName].premadeGroups then
Zerotorescue@62 1224 for name, version in pairs(addon.db.profile.groups[groupName].premadeGroups) do
Zerotorescue@62 1225 temp[name] = name;
Zerotorescue@62 1226 end
Zerotorescue@62 1227 end
Zerotorescue@62 1228
Zerotorescue@62 1229 return temp;
Zerotorescue@62 1230 end,
Zerotorescue@62 1231 set = function(info, value)
Zerotorescue@76 1232 if value and value ~= "" then
Zerotorescue@76 1233 -- Remove premade group from this group
Zerotorescue@76 1234 local groupName = groupIdToName[info[2]];
Zerotorescue@76 1235
Zerotorescue@76 1236 addon.db.profile.groups[groupName].premadeGroups[value] = nil;
Zerotorescue@76 1237
Zerotorescue@98 1238 addon:Print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value));
Zerotorescue@76 1239 end
Zerotorescue@62 1240 end,
Zerotorescue@62 1241 get = false,
Zerotorescue@62 1242 disabled = function(info)
Zerotorescue@62 1243 local groupName = groupIdToName[info[2]];
Zerotorescue@62 1244
Zerotorescue@62 1245 return (not addon.db.profile.groups[groupName].premadeGroups);
Zerotorescue@62 1246 end,
Zerotorescue@62 1247 },
Zerotorescue@62 1248 },
Zerotorescue@62 1249 },
Zerotorescue@62 1250 list = {
Zerotorescue@62 1251 order = 20,
Zerotorescue@62 1252 type = "group",
Zerotorescue@62 1253 inline = true,
Zerotorescue@62 1254 name = "Item list",
Zerotorescue@62 1255 hidden = UpdateRemoveItemList,
Zerotorescue@62 1256 args = {
Zerotorescue@62 1257
Zerotorescue@62 1258 },
Zerotorescue@62 1259 },
Zerotorescue@62 1260 export = {
Zerotorescue@62 1261 order = 30,
Zerotorescue@62 1262 type = "group",
Zerotorescue@62 1263 name = "Export",
Zerotorescue@62 1264 inline = true,
Zerotorescue@62 1265 args = {
Zerotorescue@62 1266 input = {
Zerotorescue@62 1267 order = 10,
Zerotorescue@62 1268 type = "input",
Zerotorescue@62 1269 name = "Item data",
Zerotorescue@62 1270 width = "full",
Zerotorescue@62 1271 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 1272 set = false,
Zerotorescue@62 1273 get = function(info)
Zerotorescue@62 1274 local groupName = groupIdToName[info[2]];
Zerotorescue@62 1275
Zerotorescue@62 1276 local combinedItemIds;
Zerotorescue@62 1277 -- Parse items in group and show these
Zerotorescue@62 1278 for itemId, _ in pairs(addon.db.profile.groups[groupName].items) do
Zerotorescue@62 1279 if not combinedItemIds then
Zerotorescue@62 1280 combinedItemIds = tostring(itemId);
Zerotorescue@62 1281 else
Zerotorescue@62 1282 combinedItemIds = combinedItemIds .. (";%d"):format(itemId);
Zerotorescue@62 1283 end
Zerotorescue@62 1284 end
Zerotorescue@62 1285
Zerotorescue@62 1286 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 1287 end,
Zerotorescue@62 1288 },
Zerotorescue@62 1289 },
Zerotorescue@62 1290 },
Zerotorescue@62 1291 },
Zerotorescue@62 1292 },
Zerotorescue@62 1293 },
Zerotorescue@62 1294 };
Zerotorescue@62 1295
Zerotorescue@62 1296
Zerotorescue@62 1297
Zerotorescue@62 1298
Zerotorescue@62 1299
Zerotorescue@62 1300
Zerotorescue@62 1301
Zerotorescue@62 1302
Zerotorescue@62 1303
Zerotorescue@62 1304 -- Object functions
Zerotorescue@62 1305
Zerotorescue@62 1306 function mod:OnEnable()
Zerotorescue@62 1307 -- Register our config slash command
Zerotorescue@62 1308 -- /im config
Zerotorescue@205 1309 addon:RegisterSlash(function()
Zerotorescue@205 1310 if mod:IsFrameOpen() then
Zerotorescue@205 1311 mod:CloseFrame();
Zerotorescue@205 1312 else
Zerotorescue@205 1313 mod:Show();
Zerotorescue@62 1314 end
Zerotorescue@62 1315 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 1316
Zerotorescue@172 1317 self:Load(false);
Zerotorescue@172 1318
Zerotorescue@62 1319 -- Whenever the profile is changed, update the groups | args: (object for the functionName, eventName, functionName)
Zerotorescue@62 1320 addon.db.RegisterCallback(self, "OnProfileChanged", "RefreshConfig");
Zerotorescue@62 1321 addon.db.RegisterCallback(self, "OnProfileCopied", "RefreshConfig");
Zerotorescue@62 1322 addon.db.RegisterCallback(self, "OnProfileReset", "RefreshConfig");
Zerotorescue@62 1323
Zerotorescue@62 1324 -- Register our custom widgets
Zerotorescue@62 1325 local Widgets = addon:GetModule("Widgets");
Zerotorescue@62 1326 Widgets:ItemLinkButton();
Zerotorescue@62 1327 Widgets:ConfigItemLinkButton();
Zerotorescue@62 1328 end
Zerotorescue@62 1329
Zerotorescue@205 1330 function mod:Show()
Zerotorescue@205 1331 -- We don't want any other windows open at this time.
Zerotorescue@205 1332 for name, module in addon:IterateModules() do
Zerotorescue@205 1333 if module.CloseFrame then
Zerotorescue@205 1334 module:CloseFrame();
Zerotorescue@205 1335 end
Zerotorescue@205 1336 end
Zerotorescue@205 1337
Zerotorescue@205 1338 self:Load(true);
Zerotorescue@205 1339
Zerotorescue@205 1340 AceConfigDialog:Open("Inventorium");
Zerotorescue@205 1341 end
Zerotorescue@205 1342
Zerotorescue@205 1343 function mod:IsFrameOpen()
Zerotorescue@205 1344 return (AceConfigDialog.OpenFrames["Inventorium"] ~= nil);
Zerotorescue@205 1345 end
Zerotorescue@205 1346
Zerotorescue@205 1347 function mod:CloseFrame()
Zerotorescue@205 1348 LibStub("AceConfigDialog-3.0"):Close("Inventorium");
Zerotorescue@205 1349 end
Zerotorescue@205 1350
Zerotorescue@152 1351 function mod:ExportGroup(groupName)
Zerotorescue@152 1352 -- We want to include the group name, so we copy the table then set another value
Zerotorescue@152 1353 local temp = CopyTable(addon.db.profile.groups[groupName]);
Zerotorescue@152 1354 temp.name = groupName;
Zerotorescue@152 1355 temp.trackAtCharacters = nil;
Zerotorescue@152 1356 temp.overrideTrackAtCharacters = nil;
Zerotorescue@176 1357 temp.dontAlertAtCharacters = nil;
Zerotorescue@176 1358 temp.overrideDontAlertAtCharacters = nil;
Zerotorescue@152 1359
Zerotorescue@152 1360 if not AceSerializer then
Zerotorescue@152 1361 AceSerializer = LibStub("AceSerializer-3.0");
Zerotorescue@152 1362 end
Zerotorescue@152 1363
Zerotorescue@152 1364 return AceSerializer:Serialize(temp);
Zerotorescue@152 1365 end
Zerotorescue@152 1366
Zerotorescue@62 1367 function mod:RefreshConfig()
Zerotorescue@65 1368 self:PremadeGroupsCheck();
Zerotorescue@65 1369
Zerotorescue@62 1370 self:FillGroupOptions();
Zerotorescue@62 1371 end
Zerotorescue@62 1372
Zerotorescue@172 1373 function mod:Load(premadeGroupsCheck)
Zerotorescue@172 1374 if premadeGroupsCheck then
Zerotorescue@172 1375 self:PremadeGroupsCheck();
Zerotorescue@172 1376 end
Zerotorescue@172 1377
Zerotorescue@62 1378 if not AceConfigDialog and not AceConfigRegistry then
Zerotorescue@62 1379 self:FillOptions();
Zerotorescue@62 1380
Zerotorescue@62 1381 -- Build options dialog
Zerotorescue@62 1382 AceConfigDialog = LibStub("AceConfigDialog-3.0");
Zerotorescue@62 1383 AceConfigRegistry = LibStub("AceConfigRegistry-3.0");
Zerotorescue@62 1384 -- Register options table
Zerotorescue@172 1385 LibStub("AceConfig-3.0"):RegisterOptionsTable("Inventorium", options);
Zerotorescue@62 1386 -- Set a nice default size (so that 4 normal sized elements fit next to eachother)
Zerotorescue@172 1387 AceConfigDialog:SetDefaultSize("Inventorium", 975, 600);
Zerotorescue@62 1388
Zerotorescue@62 1389 -- In case the addon is loaded from another condition, always call the remove interface options
Zerotorescue@62 1390 if AddonLoader and AddonLoader.RemoveInterfaceOptions then
Zerotorescue@62 1391 AddonLoader:RemoveInterfaceOptions("Inventorium");
Zerotorescue@62 1392 end
Zerotorescue@62 1393
Zerotorescue@62 1394 -- Add to the blizzard addons options thing
Zerotorescue@172 1395 AceConfigDialog:AddToBlizOptions("Inventorium", "Inventorium");
Zerotorescue@62 1396 end
Zerotorescue@62 1397 end
Zerotorescue@62 1398
Zerotorescue@62 1399 function mod:FillOptions()
Zerotorescue@62 1400 options = {
Zerotorescue@62 1401 type = "group",
Zerotorescue@62 1402 name = "Inventorium Config",
Zerotorescue@62 1403 childGroups = "tree",
Zerotorescue@62 1404 args = {
Zerotorescue@62 1405 },
Zerotorescue@62 1406 };
Zerotorescue@62 1407
Zerotorescue@62 1408 -- General
Zerotorescue@62 1409 self:FillGeneralOptions();
Zerotorescue@62 1410
Zerotorescue@62 1411 -- Help
Zerotorescue@62 1412 self:FillHelpOptions();
Zerotorescue@62 1413
Zerotorescue@62 1414 -- Profile
Zerotorescue@62 1415 options.args.profiles = LibStub("AceDBOptions-3.0"):GetOptionsTable(addon.db, true);
Zerotorescue@62 1416 options.args.profiles.order = 200;
Zerotorescue@62 1417
Zerotorescue@106 1418 -- Extra
Zerotorescue@106 1419 self:FillExtraOptions();
Zerotorescue@106 1420
Zerotorescue@62 1421 -- Groups
Zerotorescue@62 1422 self:MakeGroupOptions();
Zerotorescue@62 1423
Zerotorescue@62 1424 -- Groups-contents
Zerotorescue@62 1425 self:FillGroupOptions();
Zerotorescue@62 1426 end
Zerotorescue@62 1427
Zerotorescue@62 1428 function mod:FillGeneralOptions()
Zerotorescue@62 1429 options.args.general = {
Zerotorescue@62 1430 order = 100,
Zerotorescue@62 1431 type = "group",
Zerotorescue@62 1432 name = "General",
Zerotorescue@62 1433 desc = "Change general Inventorium settings.",
Zerotorescue@62 1434 args = {
Zerotorescue@62 1435 general = {
Zerotorescue@62 1436 order = 1,
Zerotorescue@62 1437 type = "group",
Zerotorescue@62 1438 inline = true,
Zerotorescue@62 1439 name = "General",
Zerotorescue@62 1440 args = {
Zerotorescue@62 1441 description = {
Zerotorescue@62 1442 order = 0,
Zerotorescue@62 1443 type = "description",
Zerotorescue@62 1444 name = function()
Zerotorescue@106 1445 local t = "";
Zerotorescue@106 1446 if not addon.db.profile.defaults.hideHelp then
Zerotorescue@155 1447 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.";
Zerotorescue@155 1448 end
Zerotorescue@155 1449
Zerotorescue@155 1450 return t;
Zerotorescue@155 1451 end,
Zerotorescue@155 1452 },
Zerotorescue@155 1453 header = {
Zerotorescue@155 1454 order = 5,
Zerotorescue@155 1455 type = "header",
Zerotorescue@155 1456 name = "",
Zerotorescue@155 1457 },
Zerotorescue@155 1458 trackAtCharacters = {
Zerotorescue@155 1459 order = 10,
Zerotorescue@155 1460 type = "multiselect",
Zerotorescue@176 1461 name = "Track at",
Zerotorescue@176 1462 desc = "Select at which characters groups should be tracked, appear in the summary or generate alerts.",
Zerotorescue@155 1463 values = function()
Zerotorescue@155 1464 local temp = {};
Zerotorescue@155 1465 for charName in pairs(addon.db.factionrealm.characters) do
Zerotorescue@155 1466 temp[charName] = charName;
Zerotorescue@155 1467 end
Zerotorescue@155 1468
Zerotorescue@155 1469 return temp;
Zerotorescue@155 1470 end,
Zerotorescue@155 1471 get = function(i, v)
Zerotorescue@155 1472 return addon.db.profile.defaults.trackAtCharacters[v];
Zerotorescue@155 1473 end,
Zerotorescue@155 1474 set = function(i, v, e)
Zerotorescue@155 1475 addon.db.profile.defaults.trackAtCharacters[v] = e or nil;
Zerotorescue@155 1476 end,
Zerotorescue@155 1477 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@155 1478 },
Zerotorescue@176 1479 dontAlertAtCharacters = {
Zerotorescue@176 1480 order = 15,
Zerotorescue@176 1481 type = "multiselect",
Zerotorescue@176 1482 name = "Do |cffff0000not|r alert at:",
Zerotorescue@176 1483 desc = "Select at which characters items in groups should |cffff0000not|r generate alerts when they are below the required stock.",
Zerotorescue@176 1484 values = function()
Zerotorescue@176 1485 local temp = {};
Zerotorescue@176 1486 for charName in pairs(addon.db.factionrealm.characters) do
Zerotorescue@176 1487 temp[charName] = charName;
Zerotorescue@176 1488 end
Zerotorescue@176 1489
Zerotorescue@176 1490 return temp;
Zerotorescue@176 1491 end,
Zerotorescue@176 1492 get = function(i, v)
Zerotorescue@176 1493 return addon.db.profile.defaults.dontAlertAtCharacters[v];
Zerotorescue@176 1494 end,
Zerotorescue@176 1495 set = function(i, v, e)
Zerotorescue@176 1496 addon.db.profile.defaults.dontAlertAtCharacters[v] = e or nil;
Zerotorescue@176 1497 end,
Zerotorescue@176 1498 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@176 1499 },
Zerotorescue@176 1500 --[[stockLevelAlertScanRepeatInterval = {
Zerotorescue@176 1501 order = 17,
Zerotorescue@176 1502 type = "multiselect",
Zerotorescue@176 1503 name = "Stock scan repeat interval",
Zerotorescue@176 1504 desc = "Select when or how often your stock levels should be checked and show alerts.",
Zerotorescue@176 1505 values = {
Zerotorescue@176 1506 ["00Login"] = "At login",
Zerotorescue@176 1507 ["01Repeat5"] = "Every 5 minutes",
Zerotorescue@176 1508 ["02Repeat10"] = "Every 10 minutes",
Zerotorescue@176 1509 ["03Repeat15"] = "Every 15 minutes",
Zerotorescue@176 1510 ["04Repeat30"] = "Every 30 minutes",
Zerotorescue@176 1511 ["05Repeat60"] = "Every 1 hour",
Zerotorescue@176 1512 ["06Repeat120"] = "Every 2 hours",
Zerotorescue@176 1513 },
Zerotorescue@176 1514 get = function(i, v) return addon.db.profile.defaults.scanRepeatInterval and addon.db.profile.defaults.scanRepeatInterval[v]; end,
Zerotorescue@176 1515 set = function(i, v, e) addon.db.profile.defaults.scanRepeatInterval[v] = e; end, -- can't be nil or the defaults will be used
Zerotorescue@176 1516 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@176 1517 },]]
Zerotorescue@155 1518 localItemData = {
Zerotorescue@155 1519 order = 20,
Zerotorescue@155 1520 type = "multiselect",
Zerotorescue@155 1521 name = "Include in local item data",
Zerotorescue@155 1522 desc = "Select which data should be included in the local item data.",
Zerotorescue@155 1523 values = {
Zerotorescue@155 1524 ["Bag"] = "Bag",
Zerotorescue@155 1525 ["Bank"] = "Bank",
Zerotorescue@155 1526 ["Auction House"] = "Auction House",
Zerotorescue@155 1527 ["Mailbox"] = "Mailbox",
Zerotorescue@155 1528 },
Zerotorescue@155 1529 get = function(i, v) return addon.db.profile.defaults.localItemData and addon.db.profile.defaults.localItemData[v]; end,
Zerotorescue@155 1530 set = function(i, v, e) addon.db.profile.defaults.localItemData[v] = e; end, -- can't be nil or the defaults will be used
Zerotorescue@155 1531 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@155 1532 },
Zerotorescue@155 1533 },
Zerotorescue@155 1534 },
Zerotorescue@155 1535 minimumStock = {
Zerotorescue@155 1536 order = 10,
Zerotorescue@155 1537 type = "group",
Zerotorescue@155 1538 inline = true,
Zerotorescue@155 1539 name = "Minimum stock",
Zerotorescue@155 1540 args = {
Zerotorescue@155 1541 description = {
Zerotorescue@155 1542 order = 0,
Zerotorescue@155 1543 type = "description",
Zerotorescue@155 1544 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@155 1545 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@155 1546 },
Zerotorescue@155 1547 header = {
Zerotorescue@155 1548 order = 5,
Zerotorescue@155 1549 type = "header",
Zerotorescue@155 1550 name = "",
Zerotorescue@155 1551 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@155 1552 },
Zerotorescue@176 1553
Zerotorescue@155 1554 minLocalStock = {
Zerotorescue@155 1555 order = 10,
Zerotorescue@155 1556 type = "range",
Zerotorescue@155 1557 min = 0,
Zerotorescue@155 1558 max = 100000,
Zerotorescue@155 1559 softMax = 100,
Zerotorescue@155 1560 step = 1,
Zerotorescue@155 1561 name = "Minimum local stock",
Zerotorescue@155 1562 desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
Zerotorescue@155 1563 get = function() return addon.db.profile.defaults.minLocalStock; end,
Zerotorescue@155 1564 set = function(i, v) addon.db.profile.defaults.minLocalStock = v; end,
Zerotorescue@155 1565 },
Zerotorescue@155 1566 alertBelowLocalMinimum = {
Zerotorescue@155 1567 order = 11,
Zerotorescue@155 1568 type = "toggle",
Zerotorescue@181 1569 name = "Alert when below local minimum",
Zerotorescue@155 1570 desc = "Show an alert when this item gets below this threshold.",
Zerotorescue@155 1571 get = function() return addon.db.profile.defaults.alertBelowLocalMinimum; end,
Zerotorescue@155 1572 set = function(i, v) addon.db.profile.defaults.alertBelowLocalMinimum = v; end,
Zerotorescue@155 1573 },
Zerotorescue@155 1574 autoRefill = {
Zerotorescue@155 1575 order = 12,
Zerotorescue@155 1576 type = "toggle",
Zerotorescue@155 1577 name = "Auto refill from storage",
Zerotorescue@155 1578 desc = "Automatically refill items from your storage (bank/mailbox - unless this is included in the local count - or the guild bank) when below the minimum local stock.",
Zerotorescue@155 1579 get = function() return addon.db.profile.defaults.autoRefill; end,
Zerotorescue@155 1580 set = function(i, v) addon.db.profile.defaults.autoRefill = v; end,
Zerotorescue@155 1581 },
Zerotorescue@184 1582 spacer = {
Zerotorescue@184 1583 order = 19,
Zerotorescue@184 1584 type = "description",
Zerotorescue@184 1585 name = "",
Zerotorescue@184 1586 },
Zerotorescue@176 1587
Zerotorescue@155 1588 minGlobalStock = {
Zerotorescue@155 1589 order = 20,
Zerotorescue@155 1590 type = "range",
Zerotorescue@155 1591 min = 0,
Zerotorescue@155 1592 max = 100000,
Zerotorescue@155 1593 softMax = 100,
Zerotorescue@155 1594 step = 1,
Zerotorescue@155 1595 name = "Minimum global stock",
Zerotorescue@155 1596 desc = "You can manually enter a value between 100 and 100.000 in the text box below if the provided range is insufficient.",
Zerotorescue@155 1597 get = function() return addon.db.profile.defaults.minGlobalStock; end,
Zerotorescue@155 1598 set = function(i, v) addon.db.profile.defaults.minGlobalStock = v; end,
Zerotorescue@155 1599 },
Zerotorescue@155 1600 alertBelowGlobalMinimum = {
Zerotorescue@155 1601 order = 21,
Zerotorescue@155 1602 type = "toggle",
Zerotorescue@181 1603 name = "Alert when below global minimum",
Zerotorescue@155 1604 desc = "Show an alert when this item gets below this threshold.",
Zerotorescue@155 1605 get = function() return addon.db.profile.defaults.alertBelowGlobalMinimum; end,
Zerotorescue@155 1606 set = function(i, v) addon.db.profile.defaults.alertBelowGlobalMinimum = v; end,
Zerotorescue@155 1607 },
Zerotorescue@176 1608
Zerotorescue@155 1609 summaryThresholdShow = {
Zerotorescue@155 1610 order = 30,
Zerotorescue@155 1611 type = "range",
Zerotorescue@155 1612 min = 0,
Zerotorescue@155 1613 max = 100,
Zerotorescue@155 1614 softMax = 100,
Zerotorescue@155 1615 step = 0.05,
Zerotorescue@155 1616 isPercent = true,
Zerotorescue@155 1617 name = "Show in summary when below",
Zerotorescue@155 1618 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.",
Zerotorescue@155 1619 get = function() return addon.db.profile.defaults.summaryThresholdShow; end,
Zerotorescue@155 1620 set = function(i, v) addon.db.profile.defaults.summaryThresholdShow = v; end,
Zerotorescue@155 1621 },
Zerotorescue@155 1622 },
Zerotorescue@155 1623 },
Zerotorescue@155 1624 refill = {
Zerotorescue@155 1625 order = 20,
Zerotorescue@155 1626 type = "group",
Zerotorescue@155 1627 inline = true,
Zerotorescue@155 1628 name = "Replenishing stock",
Zerotorescue@155 1629 args = {
Zerotorescue@155 1630 description = {
Zerotorescue@155 1631 order = 0,
Zerotorescue@155 1632 type = "description",
Zerotorescue@155 1633 name = function()
Zerotorescue@155 1634 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@155 1635
Zerotorescue@155 1636 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@155 1637
Zerotorescue@155 1638 return r;
Zerotorescue@155 1639 end,
Zerotorescue@155 1640 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@155 1641 },
Zerotorescue@155 1642 header = {
Zerotorescue@155 1643 order = 5,
Zerotorescue@155 1644 type = "header",
Zerotorescue@155 1645 name = "",
Zerotorescue@155 1646 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@155 1647 },
Zerotorescue@155 1648 restockTarget = {
Zerotorescue@155 1649 order = 10,
Zerotorescue@155 1650 type = "range",
Zerotorescue@155 1651 min = 0,
Zerotorescue@155 1652 max = 100000,
Zerotorescue@155 1653 softMax = 100,
Zerotorescue@155 1654 step = 1,
Zerotorescue@155 1655 name = "Restock target",
Zerotorescue@155 1656 desc = "You can manually enter a value between 100 and 100.000 in the edit box if the provided range is insufficient.",
Zerotorescue@155 1657 get = function() return addon.db.profile.defaults.restockTarget; end,
Zerotorescue@155 1658 set = function(i, v) addon.db.profile.defaults.restockTarget = v; end,
Zerotorescue@155 1659 },
Zerotorescue@155 1660 minCraftingQueue = {
Zerotorescue@155 1661 order = 20,
Zerotorescue@155 1662 type = "range",
Zerotorescue@155 1663 min = 0,
Zerotorescue@155 1664 max = 1,
Zerotorescue@155 1665 step = 0.01, -- 1%
Zerotorescue@155 1666 isPercent = true,
Zerotorescue@155 1667 name = "Don't queue if I only miss",
Zerotorescue@155 1668 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@155 1669 get = function() return addon.db.profile.defaults.minCraftingQueue; end,
Zerotorescue@155 1670 set = function(i, v) addon.db.profile.defaults.minCraftingQueue = v; end,
Zerotorescue@155 1671 },
Zerotorescue@155 1672 bonusQueue = {
Zerotorescue@155 1673 order = 30,
Zerotorescue@155 1674 type = "range",
Zerotorescue@155 1675 min = 0,
Zerotorescue@155 1676 max = 10, -- 1000%
Zerotorescue@155 1677 step = 0.01, -- 1%
Zerotorescue@155 1678 isPercent = true,
Zerotorescue@155 1679 name = "Bonus queue",
Zerotorescue@155 1680 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@155 1681 get = function() return addon.db.profile.defaults.bonusQueue; end,
Zerotorescue@155 1682 set = function(i, v) addon.db.profile.defaults.bonusQueue = v; end,
Zerotorescue@155 1683 },
Zerotorescue@155 1684 priceThreshold = {
Zerotorescue@155 1685 order = 40,
Zerotorescue@155 1686 type = "input",
Zerotorescue@155 1687 name = "Price threshold",
Zerotorescue@155 1688 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@155 1689 validate = function(info, value) return addon:ValidateReadableMoney(info, value); end,
Zerotorescue@155 1690 get = function() return addon:ReadableMoney(addon.db.profile.defaults.priceThreshold); end,
Zerotorescue@155 1691 set = function(i, v) addon.db.profile.defaults.priceThreshold = addon:ReadableMoneyToCopper(v); end,
Zerotorescue@155 1692 },
Zerotorescue@155 1693 summaryHidePriceThreshold = {
Zerotorescue@155 1694 order = 50,
Zerotorescue@155 1695 type = "toggle",
Zerotorescue@155 1696 name = "Hide when below threshold",
Zerotorescue@155 1697 desc = "Hide items from the summary when their value is below the set price threshold.",
Zerotorescue@155 1698 get = function() return addon.db.profile.defaults.summaryHidePriceThreshold; end,
Zerotorescue@155 1699 set = function(i, v) addon.db.profile.defaults.summaryHidePriceThreshold = v; end,
Zerotorescue@155 1700 },
Zerotorescue@155 1701 alwaysGetAuctionValue = {
Zerotorescue@155 1702 order = 60,
Zerotorescue@155 1703 type = "toggle",
Zerotorescue@155 1704 name = "Always show auction value",
Zerotorescue@155 1705 desc = "Always cache and show the auction value of items, even if the price threshold is set to 0|cffeda55fc|r.",
Zerotorescue@155 1706 get = function() return addon.db.profile.defaults.alwaysGetAuctionValue; end,
Zerotorescue@155 1707 set = function(i, v) addon.db.profile.defaults.alwaysGetAuctionValue = v; end,
Zerotorescue@155 1708 },
Zerotorescue@155 1709 },
Zerotorescue@155 1710 },
Zerotorescue@155 1711 addon = {
Zerotorescue@155 1712 order = 30,
Zerotorescue@155 1713 type = "group",
Zerotorescue@155 1714 inline = true,
Zerotorescue@155 1715 name = "Prefered addons",
Zerotorescue@155 1716 args = {
Zerotorescue@155 1717 description = {
Zerotorescue@155 1718 order = 0,
Zerotorescue@155 1719 type = "description",
Zerotorescue@155 1720 name = function()
Zerotorescue@155 1721 local t = "";
Zerotorescue@155 1722 if not addon.db.profile.defaults.hideHelp then
Zerotorescue@155 1723 t = "Selecting your prefered addons is optional, the first working addon will be used if the selected addon doesn't exist. You only need to set this when you are running multiple addons of a kind and wish to specify which addons to use for what groups.\n\n";
Zerotorescue@106 1724 end
Zerotorescue@62 1725
Zerotorescue@62 1726 local currentAddon, selectedAddonName = addon:GetItemCountAddon();
Zerotorescue@62 1727 local preferedAddon = addon.db.profile.defaults.itemCountAddon;
Zerotorescue@62 1728
Zerotorescue@62 1729 if currentAddon then
Zerotorescue@62 1730 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 1731
Zerotorescue@62 1732 if currentAddon.GetTotalCount and currentAddon.GetCharacterCount then
Zerotorescue@62 1733 t = t .. " This addon supports |cfffed000both total as local|r item counts.";
Zerotorescue@62 1734 elseif currentAddon.GetTotalCount then
Zerotorescue@62 1735 t = t .. " This addon supports |cfffed000only total|r item counts.";
Zerotorescue@62 1736 elseif currentAddon.GetCharacterCount then
Zerotorescue@62 1737 t = t .. " This addon supports |cfffed000only local|r item counts.";
Zerotorescue@62 1738 end
Zerotorescue@62 1739
Zerotorescue@62 1740 if preferedAddon ~= selectedAddonName then
Zerotorescue@216 1741 t = t .. "\n\n|cffff0000You have selected |cfffed000" .. preferedAddon .. "|r|cffff0000 as your item count addon, but this appears to be disabled and thus the best alternative was selected.|r";
Zerotorescue@62 1742 end
Zerotorescue@62 1743 end
Zerotorescue@62 1744
Zerotorescue@62 1745 return t;
Zerotorescue@62 1746 end,
Zerotorescue@62 1747 },
Zerotorescue@62 1748 header = {
Zerotorescue@62 1749 order = 5,
Zerotorescue@62 1750 type = "header",
Zerotorescue@62 1751 name = "",
Zerotorescue@62 1752 },
Zerotorescue@62 1753 auctionPricingAddon = {
Zerotorescue@62 1754 order = 10,
Zerotorescue@62 1755 type = "select",
Zerotorescue@62 1756 name = "Prefered pricing addon",
Zerotorescue@62 1757 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 1758 values = function()
Zerotorescue@62 1759 local temp = {};
Zerotorescue@62 1760 for name, value in pairs(addon.supportedAddons.auctionPricing) do
Zerotorescue@62 1761 temp[name] = name;
Zerotorescue@62 1762 end
Zerotorescue@62 1763
Zerotorescue@62 1764 return temp;
Zerotorescue@62 1765 end,
Zerotorescue@62 1766 get = function() return addon.db.profile.defaults.auctionPricingAddon; end,
Zerotorescue@62 1767 set = function(i, v)
Zerotorescue@62 1768 addon.db.profile.defaults.auctionPricingAddon = v;
Zerotorescue@62 1769
Zerotorescue@62 1770 if addon.supportedAddons.auctionPricing[v].OnSelect then
Zerotorescue@62 1771 addon.supportedAddons.auctionPricing[v].OnSelect();
Zerotorescue@62 1772 end
Zerotorescue@62 1773 end,
Zerotorescue@62 1774 },
Zerotorescue@62 1775 itemCountAddon = {
Zerotorescue@62 1776 order = 20,
Zerotorescue@62 1777 type = "select",
Zerotorescue@62 1778 name = "Prefered item count addon",
Zerotorescue@216 1779 desc = "Select the addon you prefer data to be retrieved from. The best supported addon will be used if the selected addon can not be found.",
Zerotorescue@62 1780 values = function()
Zerotorescue@62 1781 local temp = {};
Zerotorescue@62 1782 for name, value in pairs(addon.supportedAddons.itemCount) do
Zerotorescue@62 1783 temp[name] = name;
Zerotorescue@62 1784 end
Zerotorescue@62 1785
Zerotorescue@62 1786 return temp;
Zerotorescue@62 1787 end,
Zerotorescue@62 1788 get = function() return addon.db.profile.defaults.itemCountAddon; end,
Zerotorescue@62 1789 set = function(i, v)
Zerotorescue@62 1790 addon.db.profile.defaults.itemCountAddon = v;
Zerotorescue@62 1791
Zerotorescue@62 1792 if addon.supportedAddons.itemCount[v].OnSelect then
Zerotorescue@62 1793 addon.supportedAddons.itemCount[v].OnSelect();
Zerotorescue@62 1794 end
Zerotorescue@62 1795 end,
Zerotorescue@62 1796 },
Zerotorescue@62 1797 craftingAddon = {
Zerotorescue@62 1798 order = 30,
Zerotorescue@62 1799 type = "select",
Zerotorescue@62 1800 name = "Prefered crafting addon",
Zerotorescue@62 1801 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 1802 values = function()
Zerotorescue@62 1803 local temp = {};
Zerotorescue@62 1804 for name, value in pairs(addon.supportedAddons.crafting) do
Zerotorescue@62 1805 temp[name] = name;
Zerotorescue@62 1806 end
Zerotorescue@62 1807
Zerotorescue@62 1808 return temp;
Zerotorescue@62 1809 end,
Zerotorescue@62 1810 get = function() return addon.db.profile.defaults.craftingAddon; end,
Zerotorescue@62 1811 set = function(i, v)
Zerotorescue@62 1812 addon.db.profile.defaults.craftingAddon = v;
Zerotorescue@62 1813
Zerotorescue@62 1814 if addon.supportedAddons.crafting[v].OnSelect then
Zerotorescue@62 1815 addon.supportedAddons.crafting[v].OnSelect();
Zerotorescue@62 1816 end
Zerotorescue@62 1817 end,
Zerotorescue@62 1818 },
Zerotorescue@157 1819 guildSelection = {
Zerotorescue@157 1820 order = 40,
Zerotorescue@157 1821 type = "multiselect",
Zerotorescue@157 1822 name = "Include guild bank data",
Zerotorescue@157 1823 desc = "Select which guild data should be included in the item counts.",
Zerotorescue@157 1824 values = function()
Zerotorescue@157 1825 local temp = {};
Zerotorescue@157 1826
Zerotorescue@157 1827 local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
Zerotorescue@157 1828
Zerotorescue@176 1829 if currentAddon and currentAddon.GetGuildNames then
Zerotorescue@157 1830 local guilds = currentAddon.GetGuildNames();
Zerotorescue@157 1831
Zerotorescue@157 1832 if guilds and type(guilds) == "table" then
Zerotorescue@157 1833 for guildName, state in pairs(guilds) do
Zerotorescue@157 1834 temp[guildName] = guildName;
Zerotorescue@157 1835
Zerotorescue@157 1836 if addon.db.profile.defaults.itemCountGuildsExcluded[guildName] then
Zerotorescue@157 1837 currentAddon.SetGuildState(guildName, false);
Zerotorescue@157 1838 else
Zerotorescue@157 1839 currentAddon.SetGuildState(guildName, true);
Zerotorescue@157 1840 end
Zerotorescue@157 1841 end
Zerotorescue@157 1842 end
Zerotorescue@157 1843 end
Zerotorescue@157 1844
Zerotorescue@157 1845 return temp;
Zerotorescue@157 1846 end,
Zerotorescue@157 1847 get = function(i, v)
Zerotorescue@157 1848 local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
Zerotorescue@157 1849
Zerotorescue@176 1850 return currentAddon and currentAddon.GetGuildNames and currentAddon.GetGuildNames()[v];
Zerotorescue@157 1851 end,
Zerotorescue@157 1852 set = function(i, v, e)
Zerotorescue@157 1853 local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
Zerotorescue@157 1854
Zerotorescue@157 1855 if e then
Zerotorescue@157 1856 -- Guild is enabled, so not excluded
Zerotorescue@157 1857 addon.db.profile.defaults.itemCountGuildsExcluded[v] = nil;
Zerotorescue@157 1858 else
Zerotorescue@157 1859 addon.db.profile.defaults.itemCountGuildsExcluded[v] = true; -- this is excluded, excluded is indicated by true
Zerotorescue@157 1860 end
Zerotorescue@157 1861
Zerotorescue@176 1862 if currentAddon and currentAddon.SetGuildState then
Zerotorescue@157 1863 currentAddon.SetGuildState(v, e);
Zerotorescue@157 1864 end
Zerotorescue@157 1865 end, -- can't be nil or the defaults will be used
Zerotorescue@157 1866 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@157 1867 },
Zerotorescue@62 1868 },
Zerotorescue@62 1869 },
Zerotorescue@106 1870 },
Zerotorescue@106 1871 };
Zerotorescue@106 1872 end
Zerotorescue@106 1873
Zerotorescue@106 1874 function mod:FillExtraOptions()
Zerotorescue@189 1875 local selectedExportGroups, enableBackupGeneration;
Zerotorescue@106 1876 options.args.extra = {
Zerotorescue@106 1877 order = 300,
Zerotorescue@106 1878 type = "group",
Zerotorescue@106 1879 name = "Extra",
Zerotorescue@106 1880 desc = "Change additional (but completely optional) settings.",
Zerotorescue@106 1881 args = {
Zerotorescue@106 1882 misc = {
Zerotorescue@106 1883 order = 10,
Zerotorescue@62 1884 type = "group",
Zerotorescue@62 1885 inline = true,
Zerotorescue@106 1886 name = "Miscellaneous",
Zerotorescue@62 1887 args = {
Zerotorescue@210 1888 minimapIcon = {
Zerotorescue@210 1889 order = 0,
Zerotorescue@210 1890 type = "toggle",
Zerotorescue@210 1891 width = "full",
Zerotorescue@210 1892 name = "Display the minimap icon",
Zerotorescue@210 1893 desc = "Display the minimap icon for Inventorium allowing functionality to be used without typing slash commands.",
Zerotorescue@210 1894 get = function() return addon.db.profile.defaults.minimapIcon; end,
Zerotorescue@210 1895 set = function(i, v)
Zerotorescue@210 1896 addon.db.profile.defaults.minimapIcon = v;
Zerotorescue@210 1897
Zerotorescue@210 1898 if v then
Zerotorescue@210 1899 addon:GetModule("MinimapIcon"):ShowIcon();
Zerotorescue@210 1900 else
Zerotorescue@210 1901 addon:GetModule("MinimapIcon"):HideIcon();
Zerotorescue@210 1902 end
Zerotorescue@210 1903 end,
Zerotorescue@210 1904 },
Zerotorescue@106 1905 hideHelp = {
Zerotorescue@106 1906 order = 10,
Zerotorescue@106 1907 type = "toggle",
Zerotorescue@106 1908 width = "full",
Zerotorescue@106 1909 name = "Hide any help tooltips, descriptions and the help config category",
Zerotorescue@106 1910 desc = "Hide any optional help tooltips, descriptions and the help config category.\n\nPlease note some tooltips may not disappear until next login.",
Zerotorescue@106 1911 get = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@106 1912 set = function(i, v) addon.db.profile.defaults.hideHelp = v; end,
Zerotorescue@62 1913 },
Zerotorescue@106 1914 autoRefillSkipConfirm = {
Zerotorescue@62 1915 order = 20,
Zerotorescue@106 1916 type = "toggle",
Zerotorescue@106 1917 width = "full",
Zerotorescue@131 1918 name = "Skip the confirmation window for storage refilling",
Zerotorescue@131 1919 desc = "Automatically start moving items from the storage (bank, guild bank or mailbox) without showing the confirmation window.",
Zerotorescue@106 1920 get = function() return addon.db.profile.defaults.autoRefillSkipConfirm; end,
Zerotorescue@106 1921 set = function(i, v) addon.db.profile.defaults.autoRefillSkipConfirm = v; end,
Zerotorescue@76 1922 },
Zerotorescue@176 1923 stockAlertScanInterval = {
Zerotorescue@176 1924 order = 25,
Zerotorescue@176 1925 type = "select",
Zerotorescue@176 1926 width = "double",
Zerotorescue@176 1927 name = "Stock scan speed",
Zerotorescue@176 1928 desc = "Select the speed at which items should be scanned for stock alerts. Faster requires more resources and may drastically reduce your frame rate during a scan.",
Zerotorescue@176 1929 values = {
Zerotorescue@184 1930 ["0"] = "(Near) instant", -- scans in steps of 100
Zerotorescue@184 1931 ["0.01"] = "Very fast", -- scans in steps of 2
Zerotorescue@176 1932 ["0.05"] = "Fast",
Zerotorescue@176 1933 ["0.1"] = "Default",
Zerotorescue@176 1934 ["0.2"] = "Medium",
Zerotorescue@176 1935 ["0.3"] = "Slow",
Zerotorescue@176 1936 ["0.5"] = "Very slow",
Zerotorescue@176 1937 },
Zerotorescue@176 1938 get = function() return addon.db.profile.defaults.scanInterval; end,
Zerotorescue@176 1939 set = function(i, v) addon.db.profile.defaults.scanInterval = v; end,
Zerotorescue@176 1940 },
Zerotorescue@176 1941 spacer = {
Zerotorescue@176 1942 order = 26,
Zerotorescue@176 1943 type = "description",
Zerotorescue@176 1944 name = "",
Zerotorescue@176 1945 },
Zerotorescue@76 1946 removeCharacter = {
Zerotorescue@106 1947 order = 30,
Zerotorescue@76 1948 type = "select",
Zerotorescue@106 1949 width = "double",
Zerotorescue@106 1950 name = "Remove a character from Inventorium's memory",
Zerotorescue@76 1951 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 1952 values = function()
Zerotorescue@76 1953 local temp = {};
Zerotorescue@76 1954
Zerotorescue@76 1955 temp[""] = "";
Zerotorescue@76 1956
Zerotorescue@76 1957 local playerName = UnitName("player");
Zerotorescue@76 1958 for charName in pairs(addon.db.factionrealm.characters) do
Zerotorescue@76 1959 if playerName ~= charName then
Zerotorescue@76 1960 temp[charName] = charName;
Zerotorescue@76 1961 end
Zerotorescue@76 1962 end
Zerotorescue@76 1963
Zerotorescue@76 1964 return temp;
Zerotorescue@76 1965 end,
Zerotorescue@76 1966 set = function(i, value)
Zerotorescue@76 1967 if value and value ~= "" then
Zerotorescue@76 1968 addon.db.factionrealm.characters[value] = nil;
Zerotorescue@76 1969 addon.db.profile.defaults.trackAtCharacters[value] = nil;
Zerotorescue@176 1970 addon.db.profile.defaults.dontAlertAtCharacters[value] = nil;
Zerotorescue@76 1971 for name, values in pairs(addon.db.profile.groups) do
Zerotorescue@76 1972 if values.trackAtCharacters then
Zerotorescue@76 1973 values.trackAtCharacters[name] = nil;
Zerotorescue@76 1974 end
Zerotorescue@176 1975
Zerotorescue@176 1976 if values.dontAlertAtCharacters then
Zerotorescue@176 1977 values.dontAlertAtCharacters[name] = nil;
Zerotorescue@176 1978 end
Zerotorescue@76 1979 end
Zerotorescue@76 1980 end
Zerotorescue@76 1981 end,
Zerotorescue@76 1982 },
Zerotorescue@76 1983 },
Zerotorescue@76 1984 },
Zerotorescue@106 1985 colorCodes = {
Zerotorescue@106 1986 order = 30,
Zerotorescue@106 1987 type = "group",
Zerotorescue@106 1988 inline = true,
Zerotorescue@106 1989 name = "Color codes",
Zerotorescue@106 1990 args = {
Zerotorescue@106 1991 description = {
Zerotorescue@106 1992 order = 0,
Zerotorescue@106 1993 type = "description",
Zerotorescue@106 1994 name = "Change the color code thresholds based on the current stock remaining of the required minimum stock.",
Zerotorescue@106 1995 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@106 1996 },
Zerotorescue@106 1997 header = {
Zerotorescue@106 1998 order = 5,
Zerotorescue@106 1999 type = "header",
Zerotorescue@106 2000 name = "",
Zerotorescue@106 2001 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@106 2002 },
Zerotorescue@106 2003 green = {
Zerotorescue@106 2004 order = 10,
Zerotorescue@106 2005 type = "range",
Zerotorescue@106 2006 min = 0,
Zerotorescue@106 2007 max = 1,
Zerotorescue@106 2008 step = 0.01,
Zerotorescue@106 2009 isPercent = true,
Zerotorescue@106 2010 name = "|cff00ff00Green|r",
Zerotorescue@106 2011 desc = "Show quantity in green when at least this much of the minimum stock is available.",
Zerotorescue@106 2012 get = function() return addon.db.profile.defaults.colors.green; end,
Zerotorescue@106 2013 set = function(i, v) addon.db.profile.defaults.colors.green = v; end,
Zerotorescue@106 2014 },
Zerotorescue@106 2015 yellow = {
Zerotorescue@106 2016 order = 20,
Zerotorescue@106 2017 type = "range",
Zerotorescue@106 2018 min = 0,
Zerotorescue@106 2019 max = 1,
Zerotorescue@106 2020 step = 0.01,
Zerotorescue@106 2021 isPercent = true,
Zerotorescue@106 2022 name = "|cffffff00Yellow|r",
Zerotorescue@106 2023 desc = "Show quantity in yellow when at least this much of the minimum stock is available.",
Zerotorescue@106 2024 get = function() return addon.db.profile.defaults.colors.yellow; end,
Zerotorescue@106 2025 set = function(i, v) addon.db.profile.defaults.colors.yellow = v; end,
Zerotorescue@106 2026 },
Zerotorescue@106 2027 orange = {
Zerotorescue@106 2028 order = 30,
Zerotorescue@106 2029 type = "range",
Zerotorescue@106 2030 min = 0,
Zerotorescue@106 2031 max = 1,
Zerotorescue@106 2032 step = 0.01,
Zerotorescue@106 2033 isPercent = true,
Zerotorescue@106 2034 name = "|cffff9933Orange|r",
Zerotorescue@106 2035 desc = "Show quantity in orange when at least this much of the minimum stock is available.",
Zerotorescue@106 2036 get = function() return addon.db.profile.defaults.colors.orange; end,
Zerotorescue@106 2037 set = function(i, v) addon.db.profile.defaults.colors.orange = v; end,
Zerotorescue@106 2038 },
Zerotorescue@106 2039 red = {
Zerotorescue@106 2040 order = 40,
Zerotorescue@106 2041 type = "range",
Zerotorescue@106 2042 min = 0,
Zerotorescue@106 2043 max = 1,
Zerotorescue@106 2044 step = 0.01,
Zerotorescue@106 2045 isPercent = true,
Zerotorescue@106 2046 name = "|cffff0000Red|r",
Zerotorescue@106 2047 desc = "Show quantity in red when at least this much of the minimum stock is available.",
Zerotorescue@106 2048 get = function() return addon.db.profile.defaults.colors.red; end,
Zerotorescue@106 2049 set = function(i, v) addon.db.profile.defaults.colors.red = v; end,
Zerotorescue@106 2050 },
Zerotorescue@106 2051 },
Zerotorescue@106 2052 },
Zerotorescue@189 2053 export = {
Zerotorescue@189 2054 order = 80,
Zerotorescue@189 2055 type = "group",
Zerotorescue@189 2056 inline = true,
Zerotorescue@189 2057 name = "Export groups",
Zerotorescue@189 2058 args = {
Zerotorescue@189 2059 description = {
Zerotorescue@189 2060 order = 0,
Zerotorescue@189 2061 type = "description",
Zerotorescue@189 2062 name = "Select the groups you wish to export below. Each group will have any account specific data removed and can safely and freely be shared with other users. All exported groups can be imported at once at the bottom of the \"Groups\" category of the config.",
Zerotorescue@189 2063 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@189 2064 },
Zerotorescue@189 2065 header = {
Zerotorescue@189 2066 order = 5,
Zerotorescue@189 2067 type = "header",
Zerotorescue@189 2068 name = "",
Zerotorescue@189 2069 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@189 2070 },
Zerotorescue@189 2071 localItemData = {
Zerotorescue@189 2072 order = 9,
Zerotorescue@189 2073 type = "multiselect",
Zerotorescue@189 2074 name = "Select groups",
Zerotorescue@189 2075 desc = "Select which groups should be included in the export.",
Zerotorescue@189 2076 values = function()
Zerotorescue@189 2077 local temp = {};
Zerotorescue@189 2078
Zerotorescue@189 2079 if addon.db.profile.groups then
Zerotorescue@189 2080 temp["*InverseAll"] = "Inverse";
Zerotorescue@189 2081
Zerotorescue@189 2082 for groupName, _ in pairs(addon.db.profile.groups) do
Zerotorescue@189 2083 temp[groupName] = groupName;
Zerotorescue@189 2084 end
Zerotorescue@189 2085 end
Zerotorescue@189 2086
Zerotorescue@189 2087 return temp;
Zerotorescue@189 2088 end,
Zerotorescue@189 2089 get = function(info, value)
Zerotorescue@189 2090 --local groupName = groupIdToName[info[2]];
Zerotorescue@189 2091 --local optionName = info[#info];
Zerotorescue@189 2092
Zerotorescue@189 2093 return selectedExportGroups and selectedExportGroups[value];
Zerotorescue@189 2094 end,
Zerotorescue@189 2095 set = function(info, name, value)
Zerotorescue@189 2096 --local groupName = groupIdToName[info[2]];
Zerotorescue@189 2097 --local optionName = info[#info];
Zerotorescue@189 2098
Zerotorescue@189 2099 if not selectedExportGroups then
Zerotorescue@189 2100 selectedExportGroups = {};
Zerotorescue@189 2101 end
Zerotorescue@189 2102
Zerotorescue@189 2103 if name == "*InverseAll" then
Zerotorescue@189 2104 for groupName, _ in pairs(addon.db.profile.groups) do
Zerotorescue@189 2105 if selectedExportGroups and selectedExportGroups[groupName] then
Zerotorescue@189 2106 selectedExportGroups[groupName] = nil;
Zerotorescue@189 2107 else
Zerotorescue@189 2108 selectedExportGroups[groupName] = true;
Zerotorescue@189 2109 end
Zerotorescue@189 2110 end
Zerotorescue@189 2111 else
Zerotorescue@189 2112 if selectedExportGroups and selectedExportGroups[name] then
Zerotorescue@189 2113 selectedExportGroups[name] = nil;
Zerotorescue@189 2114 else
Zerotorescue@189 2115 selectedExportGroups[name] = true;
Zerotorescue@189 2116 end
Zerotorescue@189 2117 end
Zerotorescue@189 2118 end,
Zerotorescue@189 2119 },
Zerotorescue@189 2120 input = {
Zerotorescue@189 2121 order = 10,
Zerotorescue@189 2122 type = "input",
Zerotorescue@189 2123 multiline = true,
Zerotorescue@189 2124 width = "full",
Zerotorescue@189 2125 name = "Exported data",
Zerotorescue@189 2126 desc = "Exported group data for the currently selected group(s). Press CTRL-A to select all and CTRL-C to copy the text.",
Zerotorescue@189 2127 set = false,
Zerotorescue@189 2128 get = function()
Zerotorescue@189 2129 local result = "";
Zerotorescue@189 2130 if selectedExportGroups then
Zerotorescue@189 2131 for groupName, v in pairs(selectedExportGroups) do
Zerotorescue@189 2132 if v then
Zerotorescue@189 2133 result = result .. mod:ExportGroup(groupName) .. "\n";
Zerotorescue@189 2134 end
Zerotorescue@189 2135 end
Zerotorescue@189 2136 end
Zerotorescue@189 2137
Zerotorescue@189 2138 return result;
Zerotorescue@189 2139 end,
Zerotorescue@189 2140 },
Zerotorescue@189 2141 },
Zerotorescue@189 2142 },
Zerotorescue@189 2143 backup = {
Zerotorescue@189 2144 order = 100,
Zerotorescue@189 2145 type = "group",
Zerotorescue@189 2146 inline = true,
Zerotorescue@189 2147 name = "Generate a full backup",
Zerotorescue@189 2148 args = {
Zerotorescue@189 2149 description = {
Zerotorescue@189 2150 order = 0,
Zerotorescue@189 2151 type = "description",
Zerotorescue@189 2152 name = "With this you can generate a full backup of all your Inventorium settings. You can store this in a text file on your computer so you can import it at a later time if anything breaks to prevent losing a time consuming setup. You can also use it to share with other users but keep in mind this will include account specific data which you might not want in the wrong hands.",
Zerotorescue@189 2153 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@189 2154 },
Zerotorescue@189 2155 header = {
Zerotorescue@189 2156 order = 5,
Zerotorescue@189 2157 type = "header",
Zerotorescue@189 2158 name = "",
Zerotorescue@189 2159 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@189 2160 },
Zerotorescue@189 2161 generate = {
Zerotorescue@189 2162 order = 9,
Zerotorescue@189 2163 type = "toggle",
Zerotorescue@189 2164 width = "full",
Zerotorescue@189 2165 name = "Generate a full backup (might take a second)",
Zerotorescue@189 2166 desc = "Generate a full backup. This process might take 1 to 2 seconds.",
Zerotorescue@189 2167 set = function(_, v)
Zerotorescue@189 2168 enableBackupGeneration = v;
Zerotorescue@189 2169 end,
Zerotorescue@189 2170 get = function()
Zerotorescue@189 2171 return enableBackupGeneration;
Zerotorescue@189 2172 end,
Zerotorescue@189 2173 },
Zerotorescue@189 2174 input = {
Zerotorescue@189 2175 order = 10,
Zerotorescue@189 2176 type = "input",
Zerotorescue@189 2177 multiline = true,
Zerotorescue@189 2178 width = "full",
Zerotorescue@189 2179 name = "Exported data",
Zerotorescue@189 2180 desc = "Exported backup data. Press CTRL-A to select all and CTRL-C to copy the text.\n\nPlease note this includes character data.",
Zerotorescue@189 2181 set = false,
Zerotorescue@189 2182 get = function()
Zerotorescue@189 2183 if not enableBackupGeneration then
Zerotorescue@189 2184 return;
Zerotorescue@189 2185 end
Zerotorescue@189 2186
Zerotorescue@189 2187 -- We want to include the group name, so we copy the table then set another value
Zerotorescue@189 2188 local temp = {
Zerotorescue@189 2189 ["type"] = "backup",
Zerotorescue@189 2190 ["global"] = addon.db.global or {},
Zerotorescue@189 2191 ["profiles"] = addon.db.profiles or {},
Zerotorescue@189 2192 ["factionrealm"] = addon.db.factionrealm or {},
Zerotorescue@189 2193 };
Zerotorescue@189 2194
Zerotorescue@189 2195 if not AceSerializer then
Zerotorescue@189 2196 AceSerializer = LibStub("AceSerializer-3.0");
Zerotorescue@189 2197 end
Zerotorescue@189 2198
Zerotorescue@189 2199 return AceSerializer:Serialize(temp);
Zerotorescue@189 2200 end,
Zerotorescue@189 2201 },
Zerotorescue@189 2202 },
Zerotorescue@189 2203 },
Zerotorescue@189 2204 importBackup = {
Zerotorescue@189 2205 order = 101,
Zerotorescue@189 2206 type = "group",
Zerotorescue@189 2207 inline = true,
Zerotorescue@189 2208 name = "Import a full backup",
Zerotorescue@189 2209 args = {
Zerotorescue@189 2210 description = {
Zerotorescue@189 2211 order = 0,
Zerotorescue@189 2212 type = "description",
Zerotorescue@189 2213 name = "With this you can import a full backup of all your Inventorium settings. |cffff0000Warning! Importing a backup will TRASH all your current settings and profiles. You are advised to store your own backup prior to importing one.|r",
Zerotorescue@189 2214 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@189 2215 },
Zerotorescue@189 2216 header = {
Zerotorescue@189 2217 order = 5,
Zerotorescue@189 2218 type = "header",
Zerotorescue@189 2219 name = "",
Zerotorescue@189 2220 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@189 2221 },
Zerotorescue@189 2222 input = {
Zerotorescue@189 2223 order = 10,
Zerotorescue@189 2224 type = "input",
Zerotorescue@189 2225 multiline = true,
Zerotorescue@189 2226 width = "full",
Zerotorescue@189 2227 name = "Paste the backup data here",
Zerotorescue@189 2228 desc = "Exported backup data. To copy the backup data, press CTRL-A to select all and CTRL-C to copy it. Then click this textblock and hit CTRL-V to paste it.",
Zerotorescue@189 2229 set = function(_, v)
Zerotorescue@189 2230 if v and string.trim(v) ~= "" then
Zerotorescue@189 2231 if not AceSerializer then
Zerotorescue@189 2232 AceSerializer = LibStub("AceSerializer-3.0");
Zerotorescue@189 2233 end
Zerotorescue@189 2234
Zerotorescue@189 2235 local result, temp = AceSerializer:Deserialize(v);
Zerotorescue@189 2236
Zerotorescue@189 2237 if result and temp and type(temp) == "table" and temp.type and temp.type == "backup" then
Zerotorescue@189 2238 addon.db:ResetDB("TEMPPROFILENAME" .. GetTime());
Zerotorescue@189 2239
Zerotorescue@189 2240 local tempProfileName = addon.db:GetCurrentProfile();
Zerotorescue@189 2241
Zerotorescue@189 2242 if temp.global then
Zerotorescue@189 2243 print("Importing |cfffed000global|r data...");
Zerotorescue@189 2244
Zerotorescue@189 2245 -- Update by reference, rather than changing the reference
Zerotorescue@189 2246 for k, v in pairs(temp.global) do
Zerotorescue@189 2247 addon.db.global[k] = v;
Zerotorescue@189 2248 end
Zerotorescue@189 2249 end
Zerotorescue@189 2250
Zerotorescue@189 2251 if temp.profiles then
Zerotorescue@189 2252 print("Importing |cfffed000profiles|r data...");
Zerotorescue@189 2253
Zerotorescue@189 2254 -- Update by reference, rather than changing the reference
Zerotorescue@189 2255 for profileName, profile in pairs(temp.profiles) do
Zerotorescue@189 2256 print("Importing profile |cfffed000" .. profileName .. "|r...");
Zerotorescue@189 2257
Zerotorescue@189 2258 addon.db.profiles[profileName] = profile;
Zerotorescue@189 2259
Zerotorescue@189 2260 -- If the current profile is the temp profile, select the first profile in the backup
Zerotorescue@189 2261 if addon.db:GetCurrentProfile() == tempProfileName or profileName == "Default" then
Zerotorescue@189 2262 addon.db:SetProfile(profileName);
Zerotorescue@189 2263 end
Zerotorescue@189 2264
Zerotorescue@189 2265 -- If our backup contains a profile with the same name as the temp profile, then don't delete the temp profile
Zerotorescue@189 2266 if profileName == tempProfileName then
Zerotorescue@189 2267 tempProfileName = nil;
Zerotorescue@189 2268 end
Zerotorescue@189 2269 end
Zerotorescue@189 2270 end
Zerotorescue@189 2271
Zerotorescue@189 2272 -- Delete the temp profile
Zerotorescue@189 2273 if tempProfileName then
Zerotorescue@189 2274 addon.db:DeleteProfile(tempProfileName);
Zerotorescue@189 2275 end
Zerotorescue@189 2276
Zerotorescue@189 2277 if temp.factionrealm then
Zerotorescue@189 2278 print("Importing |cfffed000character|r data...");
Zerotorescue@189 2279
Zerotorescue@189 2280 -- Update by reference, rather than changing the reference
Zerotorescue@189 2281 for k, v in pairs(temp.factionrealm) do
Zerotorescue@189 2282 addon.db.factionrealm[k] = v;
Zerotorescue@189 2283 end
Zerotorescue@189 2284 end
Zerotorescue@189 2285
Zerotorescue@189 2286 mod:FillGroupOptions();
Zerotorescue@189 2287
Zerotorescue@189 2288 addon:Print("Import finished.", addon.Colors.Green);
Zerotorescue@189 2289 else
Zerotorescue@189 2290 addon:Print("The data provided is not supported.", addon.Colors.Red);
Zerotorescue@189 2291 end
Zerotorescue@189 2292 else
Zerotorescue@189 2293 addon:Print("The data provided is not supported.", addon.Colors.Red);
Zerotorescue@189 2294 end
Zerotorescue@189 2295 end,
Zerotorescue@189 2296 get = false,
Zerotorescue@189 2297 confirm = function() return "Are you sure you wish to override all your current settings with this data?"; end,
Zerotorescue@189 2298 },
Zerotorescue@189 2299 },
Zerotorescue@189 2300 },
Zerotorescue@62 2301 },
Zerotorescue@62 2302 };
Zerotorescue@62 2303 end
Zerotorescue@62 2304
Zerotorescue@62 2305 function mod:FillHelpOptions()
Zerotorescue@62 2306 options.args.help = {
Zerotorescue@62 2307 order = 150,
Zerotorescue@62 2308 type = "group",
Zerotorescue@106 2309 hidden = function() return addon.db.profile.defaults.hideHelp; end,
Zerotorescue@62 2310 childGroups = "tab",
Zerotorescue@62 2311 name = "Help",
Zerotorescue@62 2312 desc = "Useful information for if you're unfamiliar with a part of the addon.",
Zerotorescue@62 2313 args = {
Zerotorescue@62 2314 general = {
Zerotorescue@62 2315 order = 1,
Zerotorescue@62 2316 type = "group",
Zerotorescue@62 2317 name = "General",
Zerotorescue@62 2318 args = {
Zerotorescue@62 2319 description = {
Zerotorescue@62 2320 order = 0,
Zerotorescue@62 2321 type = "description",
Zerotorescue@214 2322 name = "You can find a |cfffed000User Manual|r inside your addon folder or online at Google Docs (see the addon download page for a link). If you are new to this addon it may be a wealth of information.\n\n" ..
Zerotorescue@214 2323 "Dropdown boxes that allow you to select more than 1 option should be closed using the \"|cfffed000Close|r\" option at the bottom before switching groups or closing the config. If this dropdown is still opened while switching groups or closing the config, it may cause an error and break the config requiring you to do /reloadui to continue working with the config.\n\n" ..
Zerotorescue@214 2324 "Please request things you want and report anything that's clunky, weird, vague or otherwise buggy at |cfffed000the Inventorium ticket tracker|r. You can find this by going to the addon page.\n\n" ..
Zerotorescue@214 2325 "You might notice the summary window currently gets a little slow when refreshed once you get over 200ish items in the list. This is a known issue and the summary window will be rewritten to resolve this somewhere in a future patch.",
Zerotorescue@62 2326 },
Zerotorescue@62 2327 },
Zerotorescue@62 2328 },
Zerotorescue@62 2329 FAQ = {
Zerotorescue@62 2330 order = 3,
Zerotorescue@62 2331 type = "group",
Zerotorescue@62 2332 name = "FAQ",
Zerotorescue@62 2333 args = {
Zerotorescue@62 2334 description = {
Zerotorescue@62 2335 order = 0,
Zerotorescue@62 2336 type = "description",
Zerotorescue@214 2337 name = "|cfffed000My groups don't appear in the summary window.|r\n" ..
Zerotorescue@214 2338 "Please 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@214 2339
Zerotorescue@214 2340 "|cfffed000The auction value column always shows a \"-\".|r\n" ..
Zerotorescue@214 2341 "The 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@214 2342
Zerotorescue@214 2343 "|cfffed000Some items appear in the \"unqueueable\" frame while I can find them in the profession.|r\n" ..
Zerotorescue@214 2344 "Old items from before Cataclysm (such as any old gems) may have been renamed and their crafting skill removed. This might have resulted in certain items having the same name as others but with different ids, for example for Smooth King's Amber (search that at Wowhead for more info). Remove both items with the same name and add the one in your profession window again and this should no longer occur.\n\n" ..
Zerotorescue@214 2345
Zerotorescue@214 2346 "|cfffed000What use do profiles have?|r\n" ..
Zerotorescue@214 2347 "Because 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@214 2348
Zerotorescue@214 2349 "|cfffed000Can you provide me with an example scenario for virtual groups?|r\n" ..
Zerotorescue@214 2350 "The simplest (and possibly most popular) setup to imagine for using virtual groups are glyphs. There are over 300 glyphs available distributed over 10 classes (or 8 inks). 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\n" ..
Zerotorescue@214 2351 "To 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\n" ..
Zerotorescue@214 2352 "Now, 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 2353 "",
Zerotorescue@62 2354 },
Zerotorescue@62 2355 },
Zerotorescue@62 2356 },
Zerotorescue@62 2357 },
Zerotorescue@62 2358 };
Zerotorescue@62 2359 end
Zerotorescue@62 2360
Zerotorescue@62 2361 function mod:MakeGroupOptions()
Zerotorescue@62 2362 options.args.groups = {
Zerotorescue@62 2363 order = 1100,
Zerotorescue@62 2364 type = "group",
Zerotorescue@62 2365 name = "Groups",
Zerotorescue@62 2366 desc = "Change a group.",
Zerotorescue@62 2367 args = {
Zerotorescue@62 2368 create = {
Zerotorescue@62 2369 order = 10,
Zerotorescue@62 2370 type = "group",
Zerotorescue@62 2371 inline = true,
Zerotorescue@62 2372 name = "Create a brand new group",
Zerotorescue@62 2373 args = {
Zerotorescue@62 2374 name = {
Zerotorescue@62 2375 order = 10,
Zerotorescue@62 2376 type = "input",
Zerotorescue@62 2377 name = "Group name",
Zerotorescue@62 2378 desc = "The name of the group. You can also use item links as you wish.",
Zerotorescue@62 2379 validate = ValidateGroupName,
Zerotorescue@62 2380 set = function(_, value)
Zerotorescue@62 2381 addon.db.profile.groups[value] = {};
Zerotorescue@62 2382 if currentGroupType == "Virtual" then
Zerotorescue@62 2383 addon.db.profile.groups[value].isVirtual = true;
Zerotorescue@62 2384 end
Zerotorescue@62 2385
Zerotorescue@62 2386 mod:FillGroupOptions();
Zerotorescue@62 2387 end,
Zerotorescue@62 2388 get = false,
Zerotorescue@62 2389 width = "double",
Zerotorescue@62 2390 },
Zerotorescue@62 2391 type = {
Zerotorescue@62 2392 order = 20,
Zerotorescue@62 2393 type = "select",
Zerotorescue@62 2394 name = "Type (advanced)",
Zerotorescue@62 2395 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 2396 values = {
Zerotorescue@62 2397 ["Normal"] = "Normal",
Zerotorescue@62 2398 ["Virtual"] = "Virtual",
Zerotorescue@62 2399 },
Zerotorescue@62 2400 set = function(_, value) currentGroupType = value; end,
Zerotorescue@62 2401 get = function() return currentGroupType; end,
Zerotorescue@62 2402 },
Zerotorescue@62 2403 },
Zerotorescue@62 2404 },
Zerotorescue@62 2405 import = {
Zerotorescue@62 2406 order = 20,
Zerotorescue@62 2407 type = "group",
Zerotorescue@62 2408 inline = true,
Zerotorescue@62 2409 name = "Import a group",
Zerotorescue@62 2410 args = {
Zerotorescue@62 2411 input = {
Zerotorescue@62 2412 order = 10,
Zerotorescue@62 2413 type = "input",
Zerotorescue@62 2414 multiline = true,
Zerotorescue@62 2415 name = "Group data",
Zerotorescue@62 2416 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 2417 set = function(info, value)
Zerotorescue@62 2418 local data = { string.split("\n", value or "") };
Zerotorescue@62 2419
Zerotorescue@62 2420 for _, current in pairs(data) do
Zerotorescue@152 2421 if current and string.trim(current) ~= "" then
Zerotorescue@152 2422 if not AceSerializer then
Zerotorescue@152 2423 AceSerializer = LibStub("AceSerializer-3.0");
Zerotorescue@152 2424 end
Zerotorescue@62 2425
Zerotorescue@152 2426 local result, temp = AceSerializer:Deserialize(current);
Zerotorescue@152 2427
Zerotorescue@152 2428 if not temp.name then
Zerotorescue@152 2429 addon:Print("The provided data is not supported.", addon.Colors.Red);
Zerotorescue@152 2430 elseif ValidateGroupName(nil, temp.name) ~= true then
Zerotorescue@152 2431 addon:Print(("Aborting: A group named \"%s\" already exists."):format(temp.name), addon.Colors.Red);
Zerotorescue@152 2432 else
Zerotorescue@152 2433 local name = temp.name;
Zerotorescue@152 2434 temp.name = nil;
Zerotorescue@152 2435 addon:Print(("Importing %s..."):format(name));
Zerotorescue@152 2436
Zerotorescue@152 2437 if temp.items then
Zerotorescue@152 2438 -- Remove items that are already in another group
Zerotorescue@152 2439 for value, count in pairs(temp.items) do
Zerotorescue@152 2440 local itemId = tonumber(value);
Zerotorescue@152 2441
Zerotorescue@152 2442 local itemData = addon.ItemData:New(itemId);
Zerotorescue@152 2443
Zerotorescue@152 2444 if not itemId then
Zerotorescue@152 2445 addon:Print(("\"%s\" is not a number."):format(value), addon.Colors.Red);
Zerotorescue@152 2446 temp.items[value] = nil;
Zerotorescue@152 2447 elseif itemData:InGroup() then
Zerotorescue@152 2448 addon:Print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ), addon.Colors.Red);
Zerotorescue@152 2449 temp.items[value] = nil;
Zerotorescue@152 2450 else
Zerotorescue@152 2451 -- Ensure the keys are numeric
Zerotorescue@152 2452 temp.items[value] = nil;
Zerotorescue@152 2453 temp.items[itemId] = tonumber(count) or 0;
Zerotorescue@152 2454 end
Zerotorescue@62 2455 end
Zerotorescue@62 2456 end
Zerotorescue@152 2457
Zerotorescue@152 2458 -- 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@152 2459 temp.trackAtCharacters = nil;
Zerotorescue@152 2460 temp.overrideTrackAtCharacters = nil;
Zerotorescue@176 2461 temp.dontAlertAtCharacters = nil;
Zerotorescue@176 2462 temp.overrideDontAlertAtCharacters = nil;
Zerotorescue@152 2463
Zerotorescue@152 2464 addon.db.profile.groups[name] = temp;
Zerotorescue@62 2465 end
Zerotorescue@62 2466 end
Zerotorescue@62 2467 end
Zerotorescue@62 2468
Zerotorescue@62 2469 self:FillGroupOptions();
Zerotorescue@62 2470 end,
Zerotorescue@62 2471 get = false,
Zerotorescue@62 2472 width = "full",
Zerotorescue@62 2473 },
Zerotorescue@62 2474 },
Zerotorescue@62 2475 },
Zerotorescue@62 2476 },
Zerotorescue@62 2477 };
Zerotorescue@62 2478 end
Zerotorescue@62 2479
Zerotorescue@62 2480 function mod:FillGroupOptions()
Zerotorescue@62 2481 for id, name in pairs(groupIdToName) do
Zerotorescue@62 2482 if type(name) == "string" and not addon.db.profile.groups[name] then
Zerotorescue@62 2483 options.args.groups.args[id] = nil;
Zerotorescue@62 2484 groupIdToName[id] = nil;
Zerotorescue@62 2485 groupIdToName[name] = nil;
Zerotorescue@62 2486 groupIsVirtual[id] = nil;
Zerotorescue@62 2487 end
Zerotorescue@62 2488 end
Zerotorescue@62 2489
Zerotorescue@62 2490 for name, values in pairs(addon.db.profile.groups) do
Zerotorescue@62 2491 if not groupIdToName[name] then
Zerotorescue@62 2492 options.args.groups.args[tostring(count)] = defaultGroup;
Zerotorescue@62 2493
Zerotorescue@62 2494 groupIdToName[tostring(count)] = name;
Zerotorescue@62 2495 groupIdToName[name] = true;
Zerotorescue@62 2496 if values.isVirtual then
Zerotorescue@62 2497 groupIsVirtual[tostring(count)] = true;
Zerotorescue@62 2498 end
Zerotorescue@62 2499
Zerotorescue@62 2500 count = ( count + 1 );
Zerotorescue@62 2501 end
Zerotorescue@62 2502 end
Zerotorescue@62 2503 end
Zerotorescue@65 2504
Zerotorescue@65 2505
Zerotorescue@65 2506
Zerotorescue@65 2507
Zerotorescue@65 2508
Zerotorescue@65 2509
Zerotorescue@65 2510 -- Verify premade groups
Zerotorescue@65 2511
Zerotorescue@65 2512 function mod:PremadeGroupsCheck(updateGroupName, updateKey, accept)
Zerotorescue@65 2513 -- Compare the current premade groups with those used, notify about changes
Zerotorescue@65 2514 if addon.defaultGroups then
Zerotorescue@65 2515 for premadeGroupName, groupInfo in pairs(addon.defaultGroups) do
Zerotorescue@65 2516 -- Go through all default groups
Zerotorescue@65 2517
Zerotorescue@65 2518 for groupName, values in pairs(addon.db.profile.groups) do
Zerotorescue@65 2519 -- Go through all groups to find those with this premade group
Zerotorescue@65 2520
Zerotorescue@65 2521 if values.premadeGroups and values.premadeGroups[premadeGroupName] and values.premadeGroups[premadeGroupName] < groupInfo.version then
Zerotorescue@65 2522 -- Outdated group
Zerotorescue@65 2523
Zerotorescue@65 2524 if updateGroupName and updateKey then
Zerotorescue@65 2525 -- This function was called after pressing yes or no in a confirm box
Zerotorescue@65 2526
Zerotorescue@65 2527 if accept then
Zerotorescue@65 2528 -- Yes was clicked
Zerotorescue@65 2529
Zerotorescue@65 2530 for itemId, version in pairs(groupInfo.items) do
Zerotorescue@65 2531 -- Go through all items in this premade group
Zerotorescue@65 2532
Zerotorescue@76 2533 local itemData = addon.ItemData:New(itemId);
Zerotorescue@76 2534
Zerotorescue@65 2535 if version > values.premadeGroups[premadeGroupName] then
Zerotorescue@65 2536 -- This item was added in a more recent version than this group: Add item
Zerotorescue@65 2537
Zerotorescue@76 2538 if itemData:InGroup() then
Zerotorescue@98 2539 addon:Print(("Skipping %s as it is already in the group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
Zerotorescue@76 2540 elseif itemData:AddToGroup(groupName) then
Zerotorescue@98 2541 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 2542 end
Zerotorescue@65 2543 elseif ( version * -1 ) > values.premadeGroups[premadeGroupName] then
Zerotorescue@76 2544 if itemData:InGroup() == groupName then
Zerotorescue@76 2545 itemData:RemoveFromGroup(groupName);
Zerotorescue@76 2546
Zerotorescue@98 2547 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 2548 else
Zerotorescue@98 2549 addon: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 2550 end
Zerotorescue@65 2551 end
Zerotorescue@65 2552 end
Zerotorescue@65 2553
Zerotorescue@76 2554 if AceConfigRegistry then
Zerotorescue@76 2555 -- Now rebuild the list
Zerotorescue@172 2556 AceConfigRegistry:NotifyChange("Inventorium");
Zerotorescue@76 2557 end
Zerotorescue@76 2558
Zerotorescue@65 2559 -- Remember the new version
Zerotorescue@65 2560 values.premadeGroups[premadeGroupName] = groupInfo.version;
Zerotorescue@65 2561 else
Zerotorescue@65 2562 -- No was clicked
Zerotorescue@65 2563
Zerotorescue@65 2564 -- Let user know what was not added
Zerotorescue@65 2565 for itemId, version in pairs(groupInfo.items) do
Zerotorescue@65 2566 -- Go through all items in this premade group
Zerotorescue@65 2567
Zerotorescue@76 2568 local itemData = addon.ItemData:New(itemId);
Zerotorescue@76 2569
Zerotorescue@65 2570 if version > values.premadeGroups[premadeGroupName] then
Zerotorescue@65 2571 -- This item was added in a more recent version than this group: don't add (since we clicked no), but announce it
Zerotorescue@65 2572
Zerotorescue@98 2573 addon:Print(("Skipping %s found in the premade group |cfffed000%s|r."):format( (itemData.link or unknownItemName:format(itemId)), itemData:InGroup() ));
Zerotorescue@65 2574 end
Zerotorescue@65 2575 end
Zerotorescue@65 2576
Zerotorescue@65 2577 -- Remember the new version
Zerotorescue@65 2578 values.premadeGroups[premadeGroupName] = groupInfo.version;
Zerotorescue@65 2579 end
Zerotorescue@65 2580 else
Zerotorescue@65 2581 StaticPopupDialogs["InventoriumConfirmUpdatePremadeGroup"] = {
Zerotorescue@65 2582 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 2583 button1 = YES,
Zerotorescue@65 2584 button2 = NO,
Zerotorescue@65 2585 OnAccept = function()
Zerotorescue@131 2586 mod:PremadeGroupsCheck(groupName, premadeGroupName, true);
Zerotorescue@65 2587 end,
Zerotorescue@65 2588 OnCancel = function(_, _, reason)
Zerotorescue@65 2589 if reason == "clicked" then
Zerotorescue@131 2590 mod:PremadeGroupsCheck(groupName, premadeGroupName, false);
Zerotorescue@65 2591 end
Zerotorescue@65 2592 end,
Zerotorescue@65 2593 timeout = 0,
Zerotorescue@65 2594 whileDead = 1,
Zerotorescue@65 2595 hideOnEscape = 1,
Zerotorescue@65 2596 };
Zerotorescue@65 2597 StaticPopup_Show("InventoriumConfirmUpdatePremadeGroup", premadeGroupName, groupName);
Zerotorescue@65 2598
Zerotorescue@65 2599 return;
Zerotorescue@65 2600 end
Zerotorescue@65 2601 end
Zerotorescue@65 2602 end
Zerotorescue@65 2603 end
Zerotorescue@65 2604 end
Zerotorescue@65 2605 end