annotate Core.lua @ 17:8f5c02113c5c

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