annotate Core.lua @ 40:abc824800387

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