annotate Core.lua @ 50:9607b3251655

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