annotate Core.lua @ 36:58fb38f0b447

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