annotate Core.lua @ 23:7d7aaa3fbe94

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