annotate Core.lua @ 57:03c0610e9c1e

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