annotate Core.lua @ 35:31e5da6a2b16

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