annotate Core.lua @ 46:87d68ccf0a8f

The premade group update processor should now properly add items when they were added to a premade group. Items can now be indicated as removed in premade groups by setting the version number to a negative value of the latest version. Removed Enchanted Spellthread from the Cataclysm enchants premade group.
author Zerotorescue
date Sun, 12 Dec 2010 17:18:19 +0100
parents abc824800387
children 9607b3251655
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@13 652 set = function(i, v) self.db.global.defaults.itemCountAddon = v; end,
Zerotorescue@13 653 },
Zerotorescue@13 654 craftingAddon = {
Zerotorescue@23 655 order = 30,
Zerotorescue@13 656 type = "select",
Zerotorescue@13 657 name = "Prefered crafting addon",
Zerotorescue@13 658 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 659 values = function()
Zerotorescue@13 660 local temp = {};
Zerotorescue@13 661 for name, value in pairs(self.supportedAddons.crafting) do
Zerotorescue@13 662 temp[name] = name;
Zerotorescue@13 663 end
Zerotorescue@13 664
Zerotorescue@13 665 return temp;
Zerotorescue@13 666 end,
Zerotorescue@13 667 get = function() return self.db.global.defaults.craftingAddon; end,
Zerotorescue@13 668 set = function(i, v) self.db.global.defaults.craftingAddon = v; end,
Zerotorescue@0 669 },
Zerotorescue@36 670 --[[localItemData = {
Zerotorescue@23 671 order = 40,
Zerotorescue@23 672 type = "multiselect",
Zerotorescue@31 673 name = "Include in local item data",
Zerotorescue@23 674 desc = "Select which data should be included in the local item data.",
Zerotorescue@23 675 values = {
Zerotorescue@23 676 ["Bag"] = "Bag",
Zerotorescue@23 677 ["Bank"] = "Bank",
Zerotorescue@23 678 ["Auction House"] = "Auction House",
Zerotorescue@23 679 ["Mailbox"] = "Mailbox",
Zerotorescue@23 680 },
Zerotorescue@23 681 get = function(i, v) return self.db.global.defaults.localItemData and self.db.global.defaults.localItemData[v]; end,
Zerotorescue@23 682 set = function(i, v, e) self.db.global.defaults.localItemData[v] = e or nil; end,
Zerotorescue@23 683 --dialogControl = "Dropdown", -- this is not standard, normal multiselect control gives us a list of all chars with toggle-boxes. UGLY! We want a multiselect-box instead.
Zerotorescue@36 684 },]]
Zerotorescue@0 685 },
Zerotorescue@0 686 },
Zerotorescue@0 687 minimumStock = {
Zerotorescue@0 688 order = 10,
Zerotorescue@0 689 type = "group",
Zerotorescue@0 690 inline = true,
Zerotorescue@0 691 name = "Minimum stock",
Zerotorescue@0 692 args = {
Zerotorescue@0 693 description = {
Zerotorescue@0 694 order = 0,
Zerotorescue@0 695 type = "description",
Zerotorescue@0 696 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 697 },
Zerotorescue@0 698 header = {
Zerotorescue@0 699 order = 5,
Zerotorescue@0 700 type = "header",
Zerotorescue@0 701 name = "",
Zerotorescue@0 702 },
Zerotorescue@0 703 minimumStock = {
Zerotorescue@0 704 order = 10,
Zerotorescue@0 705 type = "range",
Zerotorescue@0 706 min = 0,
Zerotorescue@0 707 max = 100000,
Zerotorescue@17 708 softMax = 100,
Zerotorescue@0 709 step = 1,
Zerotorescue@0 710 name = "Minimum stock",
Zerotorescue@17 711 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 712 get = function() return self.db.global.defaults.minimumStock; end,
Zerotorescue@0 713 set = function(i, v) self.db.global.defaults.minimumStock = v; end,
Zerotorescue@0 714 },
Zerotorescue@0 715 summaryThresholdShow = {
Zerotorescue@0 716 order = 20,
Zerotorescue@0 717 type = "range",
Zerotorescue@0 718 min = 0,
Zerotorescue@0 719 max = 100,
Zerotorescue@0 720 softMax = 10,
Zerotorescue@0 721 step = 0.05,
Zerotorescue@0 722 isPercent = true,
Zerotorescue@0 723 name = "Show in summary when below",
Zerotorescue@0 724 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 725 get = function() return self.db.global.defaults.summaryThresholdShow; end,
Zerotorescue@0 726 set = function(i, v) self.db.global.defaults.summaryThresholdShow = v; end,
Zerotorescue@0 727 },
Zerotorescue@0 728 alertBelowMinimum = {
Zerotorescue@0 729 order = 30,
Zerotorescue@0 730 type = "toggle",
Zerotorescue@30 731 name = "NYI | Alert when below minimum",
Zerotorescue@0 732 desc = "Show an alert when this item gets below this threshold.",
Zerotorescue@0 733 get = function() return self.db.global.defaults.alertBelowMinimum; end,
Zerotorescue@0 734 set = function(i, v) self.db.global.defaults.alertBelowMinimum = v; end,
Zerotorescue@0 735 },
Zerotorescue@0 736 trackAtCharacters = {
Zerotorescue@0 737 order = 40,
Zerotorescue@0 738 type = "multiselect",
Zerotorescue@0 739 name = "Track at",
Zerotorescue@0 740 desc = "Select at which characters this should appear in the summary and generate alerts.",
Zerotorescue@0 741 values = function()
Zerotorescue@0 742 local temp = {};
Zerotorescue@0 743 for charName in pairs(self.db.factionrealm.characters) do
Zerotorescue@0 744 temp[charName] = charName;
Zerotorescue@0 745 end
Zerotorescue@0 746
Zerotorescue@0 747 return temp;
Zerotorescue@0 748 end,
Zerotorescue@1 749 get = function(i, v) return self.db.global.defaults.trackAtCharacters[v]; end,
Zerotorescue@23 750 set = function(i, v, e) self.db.global.defaults.trackAtCharacters[v] = e or nil; end,
Zerotorescue@13 751 --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 752 },
Zerotorescue@0 753 },
Zerotorescue@0 754 },
Zerotorescue@0 755 refill = {
Zerotorescue@0 756 order = 20,
Zerotorescue@0 757 type = "group",
Zerotorescue@0 758 inline = true,
Zerotorescue@0 759 name = "Replenishing stock",
Zerotorescue@0 760 args = {
Zerotorescue@0 761 description = {
Zerotorescue@0 762 order = 0,
Zerotorescue@0 763 type = "description",
Zerotorescue@0 764 name = function()
Zerotorescue@0 765 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 766
Zerotorescue@0 767 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 768
Zerotorescue@0 769 return r;
Zerotorescue@0 770 end,
Zerotorescue@0 771 },
Zerotorescue@0 772 header = {
Zerotorescue@0 773 order = 5,
Zerotorescue@0 774 type = "header",
Zerotorescue@0 775 name = "",
Zerotorescue@0 776 },
Zerotorescue@0 777 restockTarget = {
Zerotorescue@0 778 order = 10,
Zerotorescue@0 779 type = "range",
Zerotorescue@0 780 min = 0,
Zerotorescue@0 781 max = 100000,
Zerotorescue@30 782 softMax = 100,
Zerotorescue@0 783 step = 1,
Zerotorescue@0 784 name = "Restock target",
Zerotorescue@30 785 desc = "You can manually enter a value between 100 and 100.000 in the edit box if the provided range is insufficient.",
Zerotorescue@0 786 get = function() return self.db.global.defaults.restockTarget; end,
Zerotorescue@0 787 set = function(i, v) self.db.global.defaults.restockTarget = v; end,
Zerotorescue@0 788 },
Zerotorescue@0 789 minCraftingQueue = {
Zerotorescue@0 790 order = 20,
Zerotorescue@0 791 type = "range",
Zerotorescue@0 792 min = 0,
Zerotorescue@0 793 max = 1,
Zerotorescue@0 794 step = 0.01, -- 1%
Zerotorescue@0 795 isPercent = true,
Zerotorescue@0 796 name = "Don't queue if I only miss",
Zerotorescue@0 797 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 798 get = function() return self.db.global.defaults.minCraftingQueue; end,
Zerotorescue@0 799 set = function(i, v) self.db.global.defaults.minCraftingQueue = v; end,
Zerotorescue@0 800 },
Zerotorescue@0 801 bonusQueue = {
Zerotorescue@0 802 order = 30,
Zerotorescue@0 803 type = "range",
Zerotorescue@0 804 min = 0,
Zerotorescue@0 805 max = 10, -- 1000%
Zerotorescue@0 806 step = 0.01, -- 1%
Zerotorescue@0 807 isPercent = true,
Zerotorescue@0 808 name = "Bonus queue",
Zerotorescue@1 809 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 810 get = function() return self.db.global.defaults.bonusQueue; end,
Zerotorescue@0 811 set = function(i, v) self.db.global.defaults.bonusQueue = v; end,
Zerotorescue@0 812 },
Zerotorescue@0 813 priceThreshold = {
Zerotorescue@0 814 order = 40,
Zerotorescue@0 815 type = "input",
Zerotorescue@0 816 name = "Price threshold",
Zerotorescue@1 817 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 818 validate = function(info, value) return self:ValidateReadableMoney(info, value); end,
Zerotorescue@1 819 get = function() return self:ReadableMoney(self.db.global.defaults.priceThreshold); end,
Zerotorescue@1 820 set = function(i, v) self.db.global.defaults.priceThreshold = self:ReadableMoneyToCopper(v); end,
Zerotorescue@0 821 },
Zerotorescue@13 822 summaryHidePriceThreshold = {
Zerotorescue@0 823 order = 50,
Zerotorescue@0 824 type = "toggle",
Zerotorescue@1 825 name = "Hide when below threshold",
Zerotorescue@0 826 desc = "Hide items from the summary when their value is below the set price threshold.",
Zerotorescue@13 827 get = function() return self.db.global.defaults.summaryHidePriceThreshold; end,
Zerotorescue@13 828 set = function(i, v) self.db.global.defaults.summaryHidePriceThreshold = v; end,
Zerotorescue@0 829 },
Zerotorescue@23 830 alwaysGetAuctionValue = {
Zerotorescue@23 831 order = 60,
Zerotorescue@23 832 type = "toggle",
Zerotorescue@23 833 name = "Always show auction value",
Zerotorescue@31 834 desc = "Always cache and show the auction value of items, even if the price threshold is set to 0|cffeda55fc|r.",
Zerotorescue@23 835 get = function() return self.db.global.defaults.alwaysGetAuctionValue; end,
Zerotorescue@23 836 set = function(i, v) self.db.global.defaults.alwaysGetAuctionValue = v; end,
Zerotorescue@23 837 },
Zerotorescue@0 838 },
Zerotorescue@0 839 },
Zerotorescue@0 840 colorCodes = {
Zerotorescue@0 841 order = 30,
Zerotorescue@0 842 type = "group",
Zerotorescue@0 843 inline = true,
Zerotorescue@0 844 name = "Color codes",
Zerotorescue@0 845 args = {
Zerotorescue@0 846 description = {
Zerotorescue@0 847 order = 0,
Zerotorescue@0 848 type = "description",
Zerotorescue@0 849 name = "Change the color code thresholds based on the current stock remaining of the required minimum stock.",
Zerotorescue@0 850 },
Zerotorescue@0 851 header = {
Zerotorescue@0 852 order = 5,
Zerotorescue@0 853 type = "header",
Zerotorescue@0 854 name = "",
Zerotorescue@0 855 },
Zerotorescue@0 856 green = {
Zerotorescue@0 857 order = 10,
Zerotorescue@0 858 type = "range",
Zerotorescue@0 859 min = 0,
Zerotorescue@0 860 max = 1,
Zerotorescue@0 861 step = 0.01,
Zerotorescue@0 862 isPercent = true,
Zerotorescue@0 863 name = "|cff00ff00Green|r",
Zerotorescue@0 864 desc = "Show quantity in green when at least this much of the minimum stock is available.",
Zerotorescue@0 865 get = function() return self.db.global.defaults.colors.green; end,
Zerotorescue@0 866 set = function(i, v) self.db.global.defaults.colors.green = v; end,
Zerotorescue@0 867 },
Zerotorescue@0 868 yellow = {
Zerotorescue@0 869 order = 20,
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 = "|cffffff00Yellow|r",
Zerotorescue@0 876 desc = "Show quantity in yellow when at least this much of the minimum stock is available.",
Zerotorescue@0 877 get = function() return self.db.global.defaults.colors.yellow; end,
Zerotorescue@0 878 set = function(i, v) self.db.global.defaults.colors.yellow = v; end,
Zerotorescue@0 879 },
Zerotorescue@0 880 orange = {
Zerotorescue@0 881 order = 30,
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 = "|cffff9933Orange|r",
Zerotorescue@0 888 desc = "Show quantity in orange when at least this much of the minimum stock is available.",
Zerotorescue@0 889 get = function() return self.db.global.defaults.colors.orange; end,
Zerotorescue@0 890 set = function(i, v) self.db.global.defaults.colors.orange = v; end,
Zerotorescue@0 891 },
Zerotorescue@0 892 red = {
Zerotorescue@0 893 order = 40,
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 = "|cffff0000Red|r",
Zerotorescue@0 900 desc = "Show quantity in red when at least this much of the minimum stock is available.",
Zerotorescue@0 901 get = function() return self.db.global.defaults.colors.red; end,
Zerotorescue@0 902 set = function(i, v) self.db.global.defaults.colors.red = v; end,
Zerotorescue@0 903 },
Zerotorescue@0 904 },
Zerotorescue@0 905 },
Zerotorescue@0 906 },
Zerotorescue@0 907 };
Zerotorescue@0 908 end
Zerotorescue@0 909
Zerotorescue@0 910 local count = 0;
Zerotorescue@0 911 local temp = {};
Zerotorescue@0 912
Zerotorescue@1 913 local function SetOption(info, value, multiSelectEnabled)
Zerotorescue@0 914 local groupName = groupIdToName[info[2]];
Zerotorescue@0 915 local optionName = info[#info];
Zerotorescue@0 916
Zerotorescue@23 917 -- Special treatment for override toggle boxes
Zerotorescue@31 918 if optionName:find("override") then
Zerotorescue@23 919 if not value and info.arg then
Zerotorescue@23 920 -- If this override was disabled and a saved variable name was provided, set it to nil rather than false
Zerotorescue@23 921
Zerotorescue@23 922 value = nil;
Zerotorescue@23 923
Zerotorescue@23 924 -- If this is an override toggler then also set the related field to nil
Zerotorescue@23 925 addon.db.global.groups[groupName][info.arg] = nil;
Zerotorescue@23 926 elseif value and info.arg then
Zerotorescue@23 927 -- 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 928
Zerotorescue@23 929 addon.db.global.groups[groupName][info.arg] = addon:GetOptionByKey(groupName, info.arg);
Zerotorescue@23 930 end
Zerotorescue@0 931 end
Zerotorescue@0 932
Zerotorescue@1 933 if multiSelectEnabled ~= nil then
Zerotorescue@1 934 -- 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 935 if not addon.db.global.groups[groupName][optionName] then
Zerotorescue@1 936 addon.db.global.groups[groupName][optionName] = {};
Zerotorescue@1 937 end
Zerotorescue@1 938
Zerotorescue@1 939 addon.db.global.groups[groupName][optionName][value] = multiSelectEnabled or nil;
Zerotorescue@1 940 else
Zerotorescue@1 941 addon.db.global.groups[groupName][optionName] = value;
Zerotorescue@1 942 end
Zerotorescue@0 943 end
Zerotorescue@0 944
Zerotorescue@1 945 function addon:GetOptionByKey(groupName, optionName, noDefault)
Zerotorescue@23 946 if groupName and self.db.global.groups[groupName] and self.db.global.groups[groupName][optionName] ~= nil then
Zerotorescue@31 947 -- If this option exists within the settings of this group
Zerotorescue@31 948
Zerotorescue@23 949 return self.db.global.groups[groupName][optionName];
Zerotorescue@31 950 elseif groupName and self.db.global.groups[groupName] and self.db.global.groups[groupName].virtualGroup ~= "" and not noDefault then
Zerotorescue@31 951 -- If a virtual group was selected
Zerotorescue@31 952
Zerotorescue@31 953 return self:GetOptionByKey(self.db.global.groups[groupName].virtualGroup, optionName, noDefault);
Zerotorescue@23 954 elseif self.db.global.defaults[optionName] and not noDefault then
Zerotorescue@23 955 return self.db.global.defaults[optionName];
Zerotorescue@0 956 else
Zerotorescue@0 957 return nil;
Zerotorescue@0 958 end
Zerotorescue@0 959 end
Zerotorescue@0 960
Zerotorescue@0 961 local function GetOption(info)
Zerotorescue@0 962 local groupName = groupIdToName[info[2]];
Zerotorescue@0 963 local optionName = info[#info];
Zerotorescue@0 964
Zerotorescue@31 965 local noDefault;
Zerotorescue@31 966
Zerotorescue@31 967 if optionName:find("override") then
Zerotorescue@31 968 noDefault = true;
Zerotorescue@31 969 end
Zerotorescue@31 970
Zerotorescue@31 971 return addon:GetOptionByKey(groupName, optionName, noDefault);
Zerotorescue@1 972 end
Zerotorescue@1 973
Zerotorescue@1 974 local function GetMultiOption(info, value)
Zerotorescue@1 975 local groupName = groupIdToName[info[2]];
Zerotorescue@1 976 local optionName = info[#info];
Zerotorescue@1 977
Zerotorescue@1 978 if addon.db.global.groups[groupName][optionName] ~= nil then
Zerotorescue@1 979 return addon.db.global.groups[groupName][optionName][value];
Zerotorescue@1 980 elseif addon.db.global.defaults[optionName] then
Zerotorescue@1 981 return addon.db.global.defaults[optionName][value];
Zerotorescue@1 982 else
Zerotorescue@1 983 return nil;
Zerotorescue@1 984 end
Zerotorescue@0 985 end
Zerotorescue@0 986
Zerotorescue@0 987 local function GetDisabled(info)
Zerotorescue@31 988 local groupName = groupIdToName[info[2]];
Zerotorescue@31 989 local optionName = info[#info];
Zerotorescue@31 990
Zerotorescue@35 991 if optionName:find("override") or not info.arg then
Zerotorescue@0 992 return false;
Zerotorescue@0 993 end
Zerotorescue@0 994
Zerotorescue@1 995 return (addon:GetOptionByKey(groupName, info.arg, true) == nil);
Zerotorescue@0 996 end
Zerotorescue@0 997
Zerotorescue@0 998 local function ValidateGroupName(_, value)
Zerotorescue@0 999 value = string.lower(string.trim(value or ""));
Zerotorescue@0 1000
Zerotorescue@0 1001 for name, _ in pairs(addon.db.global.groups) do
Zerotorescue@0 1002 if string.lower(name) == value then
Zerotorescue@0 1003 return ("A group named \"%s\" already exists."):format(name);
Zerotorescue@0 1004 end
Zerotorescue@0 1005 end
Zerotorescue@0 1006
Zerotorescue@0 1007 return true;
Zerotorescue@0 1008 end
Zerotorescue@0 1009
Zerotorescue@0 1010 local tblAddItemTemplate = {
Zerotorescue@0 1011 order = 0,
Zerotorescue@0 1012 type = "input",
Zerotorescue@0 1013 name = function(info)
Zerotorescue@0 1014 local itemName, _, itemRarity = GetItemInfo(info[#info]);
Zerotorescue@0 1015 return tostring( 7 - (itemRarity or 0) ) .. (itemName or "");
Zerotorescue@0 1016 end,
Zerotorescue@0 1017 get = function(info)
Zerotorescue@0 1018 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 1019 end,
Zerotorescue@1 1020 set = function(groupId, itemId)
Zerotorescue@0 1021 -- This is NOT a real "set", we pass the widget reference to this function which contains similar, but not the same, info.
Zerotorescue@0 1022
Zerotorescue@1 1023 if itemId then
Zerotorescue@1 1024 local groupName = groupIdToName[groupId];
Zerotorescue@0 1025
Zerotorescue@1 1026 if not AddToGroup(groupName, itemId) then
Zerotorescue@1 1027 print("|cffff0000Couldn't add the item with itemId (" .. itemId .. ") because it is already in a group.|r");
Zerotorescue@0 1028 end
Zerotorescue@0 1029 end
Zerotorescue@0 1030 end,
Zerotorescue@0 1031 width = "double",
Zerotorescue@1 1032 dialogControl = "ConfigItemLinkButton",
Zerotorescue@0 1033 };
Zerotorescue@0 1034
Zerotorescue@0 1035 local tblRemoveItemTemplate = {
Zerotorescue@0 1036 order = 0,
Zerotorescue@0 1037 type = "input",
Zerotorescue@0 1038 name = function(info)
Zerotorescue@0 1039 local itemName, _, itemRarity = GetItemInfo(info[#info]);
Zerotorescue@0 1040 return tostring( 7 - (itemRarity or 0) ) .. (itemName or "");
Zerotorescue@0 1041 end,
Zerotorescue@0 1042 get = function(info)
Zerotorescue@0 1043 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 1044 end,
Zerotorescue@1 1045 set = function(groupId, itemId)
Zerotorescue@0 1046 -- This is NOT a real "set", we pass the widget reference to this function which contains similar, but not the same, info.
Zerotorescue@0 1047
Zerotorescue@1 1048 if itemId then
Zerotorescue@1 1049 local groupName = groupIdToName[groupId];
Zerotorescue@0 1050
Zerotorescue@46 1051 RemoveFromGroup(groupName, itemId);
Zerotorescue@46 1052
Zerotorescue@46 1053 -- Now rebuild the list
Zerotorescue@46 1054 AceConfigRegistry:NotifyChange("InventoriumOptions");
Zerotorescue@0 1055 end
Zerotorescue@0 1056 end,
Zerotorescue@0 1057 width = "double",
Zerotorescue@1 1058 dialogControl = "ConfigItemLinkButton",
Zerotorescue@0 1059 };
Zerotorescue@0 1060
Zerotorescue@0 1061 local function UpdateAddItemList(info)
Zerotorescue@0 1062 local groupName = groupIdToName[info[2]];
Zerotorescue@0 1063
Zerotorescue@0 1064 if not addon.db.global.groups[groupName].items then
Zerotorescue@0 1065 addon.db.global.groups[groupName].items = {};
Zerotorescue@0 1066 end
Zerotorescue@0 1067
Zerotorescue@0 1068 -- Merge all items from all groups together
Zerotorescue@0 1069 local items = {};
Zerotorescue@0 1070 for groupName, values in pairs(addon.db.global.groups) do
Zerotorescue@0 1071 if values.items then
Zerotorescue@0 1072 for itemId, _ in pairs(values.items) do
Zerotorescue@0 1073 items[itemId] = true;
Zerotorescue@0 1074 end
Zerotorescue@0 1075 end
Zerotorescue@0 1076 end
Zerotorescue@0 1077
Zerotorescue@0 1078 local ref = options.args.groups.args[info[2]].args.add.args.list.args;
Zerotorescue@0 1079
Zerotorescue@13 1080 -- Remaking the list, so out with the old, in with the new
Zerotorescue@13 1081 table.wipe(ref);
Zerotorescue@13 1082
Zerotorescue@0 1083 -- Parse bags and show these
Zerotorescue@0 1084 for bagID = 4, 0, -1 do
Zerotorescue@0 1085 for slot = 1, GetContainerNumSlots(bagID) do
Zerotorescue@0 1086 local itemId = addon:GetItemId(GetContainerItemLink(bagID, slot));
Zerotorescue@0 1087
Zerotorescue@0 1088 if itemId then
Zerotorescue@0 1089 if not items[itemId] then
Zerotorescue@0 1090 -- If this item isn't used in any group yet
Zerotorescue@0 1091 ref[itemId] = tblAddItemTemplate;
Zerotorescue@0 1092 else
Zerotorescue@0 1093 -- It's already used in a group, don't show it
Zerotorescue@0 1094 ref[itemId] = nil;
Zerotorescue@0 1095 end
Zerotorescue@0 1096 end
Zerotorescue@0 1097 end
Zerotorescue@0 1098 end
Zerotorescue@13 1099
Zerotorescue@13 1100 if includeTradeSkillItems ~= 500 then
Zerotorescue@13 1101 -- Include tradeskill items
Zerotorescue@13 1102
Zerotorescue@13 1103 -- Go through all trade skills for the profession
Zerotorescue@13 1104 for i = 1, GetNumTradeSkills() do
Zerotorescue@13 1105 -- Try to retrieve the itemlink, this will be nil if current item is a group instead
Zerotorescue@13 1106 local itemLink = GetTradeSkillItemLink(i);
Zerotorescue@13 1107
Zerotorescue@13 1108 if itemLink then
Zerotorescue@13 1109 local itemId = addon:GetItemId(itemLink);
Zerotorescue@13 1110 if not itemId then
Zerotorescue@13 1111 -- If this isn't an item, it can only be an enchant instead
Zerotorescue@13 1112 itemId = tonumber(itemLink:match("|Henchant:([-0-9]+)|h"));
Zerotorescue@13 1113
Zerotorescue@17 1114 itemId = addon.scrollIds[itemId]; -- change enchantIds into scrollIds
Zerotorescue@13 1115 end
Zerotorescue@13 1116
Zerotorescue@17 1117 if itemId then
Zerotorescue@17 1118 local itemLevel = select(4, GetItemInfo(itemId)) or 0;
Zerotorescue@17 1119
Zerotorescue@17 1120 if includeTradeSkillItems == 0 or itemLevel >= includeTradeSkillItems then
Zerotorescue@17 1121 if not items[itemId] then
Zerotorescue@17 1122 -- If this item isn't used in any group yet
Zerotorescue@17 1123 ref[itemId] = tblAddItemTemplate;
Zerotorescue@17 1124 else
Zerotorescue@17 1125 -- It's already used in a group, don't show it
Zerotorescue@17 1126 ref[itemId] = nil;
Zerotorescue@17 1127 end
Zerotorescue@13 1128 end
Zerotorescue@17 1129 else
Zerotorescue@17 1130 addon:Debug("|cffff0000ERROR|r: Couldn't find proper item id for " .. itemLink);
Zerotorescue@13 1131 end
Zerotorescue@13 1132 end
Zerotorescue@13 1133 end
Zerotorescue@13 1134 end
Zerotorescue@0 1135 end
Zerotorescue@0 1136
Zerotorescue@0 1137 local function UpdateRemoveItemList(info)
Zerotorescue@0 1138 local groupName = groupIdToName[info[2]];
Zerotorescue@0 1139
Zerotorescue@0 1140 if not addon.db.global.groups[groupName].items then
Zerotorescue@0 1141 addon.db.global.groups[groupName].items = {};
Zerotorescue@0 1142 end
Zerotorescue@0 1143
Zerotorescue@0 1144 local ref = options.args.groups.args[info[2]].args.remove.args.list.args;
Zerotorescue@0 1145
Zerotorescue@0 1146 -- Unset all
Zerotorescue@0 1147 for itemId, _ in pairs(ref) do
Zerotorescue@0 1148 ref[itemId] = nil;
Zerotorescue@0 1149 end
Zerotorescue@0 1150
Zerotorescue@0 1151 -- Parse items in group and show these
Zerotorescue@0 1152 for itemId, _ in pairs(addon.db.global.groups[groupName].items) do
Zerotorescue@0 1153 ref[itemId] = tblRemoveItemTemplate;
Zerotorescue@0 1154 end
Zerotorescue@0 1155 end
Zerotorescue@0 1156
Zerotorescue@0 1157 function addon:GetItemId(itemLink)
Zerotorescue@13 1158 itemLink = itemLink and itemLink:match("|Hitem:([-0-9]+):"); -- if itemLink is nil, it won't execute the second part
Zerotorescue@0 1159 itemLink = itemLink and tonumber(itemLink);
Zerotorescue@0 1160
Zerotorescue@0 1161 return itemLink;
Zerotorescue@0 1162 end
Zerotorescue@0 1163
Zerotorescue@0 1164 -- Default group
Zerotorescue@0 1165 local defaultGroup = {
Zerotorescue@0 1166 order = 0,
Zerotorescue@0 1167 type = "group",
Zerotorescue@0 1168 childGroups = "tab",
Zerotorescue@0 1169 name = function(info)
Zerotorescue@30 1170 local groupId = info[#info];
Zerotorescue@30 1171 if groupIsVirtual[groupId] then
Zerotorescue@30 1172 return ("%s |cfffed000Virtual|r"):format(groupIdToName[groupId]);
Zerotorescue@30 1173 else
Zerotorescue@30 1174 return groupIdToName[groupId];
Zerotorescue@30 1175 end
Zerotorescue@30 1176 end,
Zerotorescue@30 1177 desc = function(info)
Zerotorescue@30 1178 local groupId = info[#info];
Zerotorescue@30 1179 if groupIsVirtual[groupId] then
Zerotorescue@30 1180 return "This is a virtual group, you can use it to override the defaults for other groups.";
Zerotorescue@30 1181 end
Zerotorescue@0 1182 end,
Zerotorescue@0 1183 args = {
Zerotorescue@0 1184 general = {
Zerotorescue@0 1185 order = 10,
Zerotorescue@0 1186 type = "group",
Zerotorescue@23 1187 name = "General",
Zerotorescue@23 1188 desc = "Change the general settings for just this group.",
Zerotorescue@0 1189 args = {
Zerotorescue@23 1190 general = {
Zerotorescue@23 1191 order = 0,
Zerotorescue@23 1192 type = "group",
Zerotorescue@23 1193 inline = true,
Zerotorescue@23 1194 name = "General",
Zerotorescue@23 1195 set = SetOption,
Zerotorescue@23 1196 get = GetOption,
Zerotorescue@23 1197 disabled = GetDisabled,
Zerotorescue@23 1198 args = {
Zerotorescue@23 1199 description = {
Zerotorescue@23 1200 order = 0,
Zerotorescue@23 1201 type = "description",
Zerotorescue@35 1202 name = function(info)
Zerotorescue@35 1203 local groupName = groupIdToName[info[2]];
Zerotorescue@35 1204
Zerotorescue@35 1205 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 1206
Zerotorescue@35 1207 local currentAddon, selectedAddonName = addon:GetItemCountAddon(groupName);
Zerotorescue@35 1208
Zerotorescue@35 1209 if currentAddon then
Zerotorescue@35 1210 --GetCharacterCount
Zerotorescue@35 1211 --self.supportedAddons.itemCount[selectedExternalAddon]
Zerotorescue@35 1212 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 1213
Zerotorescue@35 1214 if currentAddon.GetTotalCount and currentAddon.GetCharacterCount then
Zerotorescue@35 1215 t = t .. " This addon supports |cfffed000both total as local|r item counts.";
Zerotorescue@35 1216 elseif currentAddon.GetTotalCount then
Zerotorescue@35 1217 t = t .. " This addon supports |cfffed000only total|r item counts.";
Zerotorescue@35 1218 elseif currentAddon.GetCharacterCount then
Zerotorescue@35 1219 t = t .. " This addon supports |cfffed000only local|r item counts.";
Zerotorescue@35 1220 end
Zerotorescue@35 1221 end
Zerotorescue@35 1222
Zerotorescue@35 1223 return t;
Zerotorescue@35 1224 end,
Zerotorescue@23 1225 },
Zerotorescue@23 1226 header = {
Zerotorescue@23 1227 order = 5,
Zerotorescue@23 1228 type = "header",
Zerotorescue@23 1229 name = "",
Zerotorescue@23 1230 },
Zerotorescue@23 1231 overrideAuctionPricingAddon = {
Zerotorescue@23 1232 order = 9,
Zerotorescue@23 1233 type = "toggle",
Zerotorescue@23 1234 name = "Override pricing addon",
Zerotorescue@23 1235 desc = "Allows you to override the pricing addon setting for this group.",
Zerotorescue@23 1236 arg = "auctionPricingAddon",
Zerotorescue@23 1237 },
Zerotorescue@23 1238 auctionPricingAddon = {
Zerotorescue@23 1239 order = 10,
Zerotorescue@23 1240 type = "select",
Zerotorescue@23 1241 name = "Prefered pricing addon",
Zerotorescue@23 1242 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 1243 values = function()
Zerotorescue@23 1244 local temp = {};
Zerotorescue@23 1245 for name, value in pairs(addon.supportedAddons.auctionPricing) do
Zerotorescue@23 1246 temp[name] = name;
Zerotorescue@23 1247 end
Zerotorescue@23 1248
Zerotorescue@23 1249 return temp;
Zerotorescue@23 1250 end,
Zerotorescue@36 1251 set = function(info, value)
Zerotorescue@36 1252 local groupName = groupIdToName[info[2]];
Zerotorescue@36 1253 local optionName = info[#info];
Zerotorescue@36 1254
Zerotorescue@36 1255 addon.db.global.groups[groupName][optionName] = value ~= "" and value;
Zerotorescue@36 1256
Zerotorescue@36 1257 if addon.supportedAddons.auctionPricing[value].OnSelect then
Zerotorescue@36 1258 addon.supportedAddons.auctionPricing[value].OnSelect();
Zerotorescue@36 1259 end
Zerotorescue@36 1260 end,
Zerotorescue@23 1261 arg = "overrideAuctionPricingAddon",
Zerotorescue@23 1262 },
Zerotorescue@23 1263 overrideItemCountAddon = {
Zerotorescue@23 1264 order = 19,
Zerotorescue@23 1265 type = "toggle",
Zerotorescue@23 1266 name = "Override item count addon",
Zerotorescue@23 1267 desc = "Allows you to override the item count addon setting for this group.",
Zerotorescue@23 1268 arg = "itemCountAddon",
Zerotorescue@23 1269 },
Zerotorescue@23 1270 itemCountAddon = {
Zerotorescue@23 1271 order = 20,
Zerotorescue@23 1272 type = "select",
Zerotorescue@23 1273 name = "Prefered item count addon",
Zerotorescue@23 1274 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 1275 values = function()
Zerotorescue@23 1276 local temp = {};
Zerotorescue@23 1277 for name, value in pairs(addon.supportedAddons.itemCount) do
Zerotorescue@23 1278 temp[name] = name;
Zerotorescue@23 1279 end
Zerotorescue@23 1280
Zerotorescue@23 1281 return temp;
Zerotorescue@23 1282 end,
Zerotorescue@23 1283 arg = "overrideItemCountAddon",
Zerotorescue@23 1284 },
Zerotorescue@23 1285 overrideCraftingAddon = {
Zerotorescue@23 1286 order = 29,
Zerotorescue@23 1287 type = "toggle",
Zerotorescue@23 1288 name = "Override crafting addon",
Zerotorescue@23 1289 desc = "Allows you to override the crafting addon setting for this group.",
Zerotorescue@23 1290 arg = "craftingAddon",
Zerotorescue@23 1291 },
Zerotorescue@23 1292 craftingAddon = {
Zerotorescue@23 1293 order = 30,
Zerotorescue@23 1294 type = "select",
Zerotorescue@23 1295 name = "Prefered crafting addon",
Zerotorescue@23 1296 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 1297 values = function()
Zerotorescue@23 1298 local temp = {};
Zerotorescue@23 1299 for name, value in pairs(addon.supportedAddons.crafting) do
Zerotorescue@23 1300 temp[name] = name;
Zerotorescue@23 1301 end
Zerotorescue@23 1302
Zerotorescue@23 1303 return temp;
Zerotorescue@23 1304 end,
Zerotorescue@23 1305 arg = "overrideCraftingAddon",
Zerotorescue@23 1306 },
Zerotorescue@36 1307 --[[overrideLocalItemData = {
Zerotorescue@31 1308 order = 39,
Zerotorescue@31 1309 type = "toggle",
Zerotorescue@31 1310 name = "Override local item data",
Zerotorescue@31 1311 desc = "Allows you to override the local item data setting for this group.",
Zerotorescue@31 1312 arg = "localItemData",
Zerotorescue@31 1313 },
Zerotorescue@31 1314 localItemData = {
Zerotorescue@31 1315 order = 40,
Zerotorescue@31 1316 type = "multiselect",
Zerotorescue@31 1317 name = "Include in local item data",
Zerotorescue@31 1318 desc = "Select which data should be included in the local item data.",
Zerotorescue@31 1319 values = {
Zerotorescue@31 1320 ["Bag"] = "Bag",
Zerotorescue@31 1321 ["Bank"] = "Bank",
Zerotorescue@31 1322 ["Auction House"] = "Auction House",
Zerotorescue@31 1323 ["Mailbox"] = "Mailbox",
Zerotorescue@31 1324 },
Zerotorescue@31 1325 get = GetMultiOption,
Zerotorescue@31 1326 --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 1327 arg = "overrideLocalItemData",
Zerotorescue@36 1328 },]]
Zerotorescue@30 1329 virtualGroup = {
Zerotorescue@31 1330 order = 50,
Zerotorescue@30 1331 type = "select",
Zerotorescue@30 1332 name = "Use virtual group settings",
Zerotorescue@30 1333 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 1334 values = function(info)
Zerotorescue@31 1335 local groupName = groupIdToName[info[2]];
Zerotorescue@31 1336
Zerotorescue@30 1337 local temp = {};
Zerotorescue@30 1338
Zerotorescue@30 1339 temp[""] = "";
Zerotorescue@31 1340 for name, values in pairs(addon.db.global.groups) do
Zerotorescue@31 1341 if values.isVirtual and name ~= groupName then
Zerotorescue@31 1342 temp[name] = name;
Zerotorescue@31 1343 end
Zerotorescue@31 1344 end
Zerotorescue@30 1345
Zerotorescue@30 1346 return temp;
Zerotorescue@30 1347 end,
Zerotorescue@31 1348 set = function(info, value)
Zerotorescue@31 1349 local groupName = groupIdToName[info[2]];
Zerotorescue@31 1350 local optionName = info[#info];
Zerotorescue@31 1351
Zerotorescue@31 1352 addon.db.global.groups[groupName][optionName] = value ~= "" and value;
Zerotorescue@31 1353 end,
Zerotorescue@35 1354 disabled = false,
Zerotorescue@30 1355 },
Zerotorescue@23 1356 },
Zerotorescue@23 1357 },
Zerotorescue@0 1358 minimumStock = {
Zerotorescue@0 1359 order = 10,
Zerotorescue@0 1360 type = "group",
Zerotorescue@0 1361 inline = true,
Zerotorescue@0 1362 name = "Minimum stock",
Zerotorescue@0 1363 set = SetOption,
Zerotorescue@0 1364 get = GetOption,
Zerotorescue@0 1365 disabled = GetDisabled,
Zerotorescue@0 1366 args = {
Zerotorescue@0 1367 description = {
Zerotorescue@0 1368 order = 0,
Zerotorescue@0 1369 type = "description",
Zerotorescue@31 1370 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 1371 },
Zerotorescue@0 1372 header = {
Zerotorescue@0 1373 order = 5,
Zerotorescue@0 1374 type = "header",
Zerotorescue@0 1375 name = "",
Zerotorescue@0 1376 },
Zerotorescue@0 1377 overrideMinimumStock = {
Zerotorescue@0 1378 order = 9,
Zerotorescue@0 1379 type = "toggle",
Zerotorescue@0 1380 name = "Override min stock",
Zerotorescue@0 1381 desc = "Allows you to override the minimum stock setting for this group.",
Zerotorescue@0 1382 arg = "minimumStock",
Zerotorescue@0 1383 },
Zerotorescue@0 1384 minimumStock = {
Zerotorescue@0 1385 order = 10,
Zerotorescue@0 1386 type = "range",
Zerotorescue@0 1387 min = 0,
Zerotorescue@0 1388 max = 100000,
Zerotorescue@17 1389 softMax = 100,
Zerotorescue@0 1390 step = 1,
Zerotorescue@0 1391 name = "Minimum stock",
Zerotorescue@17 1392 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 1393 arg = "overrideMinimumStock",
Zerotorescue@0 1394 },
Zerotorescue@0 1395 overrideSummaryThresholdShow = {
Zerotorescue@0 1396 order = 19,
Zerotorescue@0 1397 type = "toggle",
Zerotorescue@0 1398 name = "Override summary showing",
Zerotorescue@0 1399 desc = "Allows you to override when this group should appear in the summary.",
Zerotorescue@0 1400 arg = "summaryThresholdShow",
Zerotorescue@0 1401 },
Zerotorescue@0 1402 summaryThresholdShow = {
Zerotorescue@0 1403 order = 20,
Zerotorescue@0 1404 type = "range",
Zerotorescue@0 1405 min = 0,
Zerotorescue@0 1406 max = 100,
Zerotorescue@0 1407 softMax = 10,
Zerotorescue@0 1408 step = 0.05,
Zerotorescue@0 1409 isPercent = true,
Zerotorescue@0 1410 name = "Show in summary when below",
Zerotorescue@0 1411 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 1412 arg = "overrideSummaryThresholdShow",
Zerotorescue@0 1413 },
Zerotorescue@0 1414 overrideAlertBelowMinimum = {
Zerotorescue@0 1415 order = 29,
Zerotorescue@0 1416 type = "toggle",
Zerotorescue@0 1417 name = "Override minimum alert",
Zerotorescue@0 1418 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 1419 arg = "alertBelowMinimum",
Zerotorescue@0 1420 },
Zerotorescue@0 1421 alertBelowMinimum = {
Zerotorescue@0 1422 order = 30,
Zerotorescue@0 1423 type = "toggle",
Zerotorescue@30 1424 name = "NYI | Alert when below minimum",
Zerotorescue@0 1425 desc = "Show an alert when an item in this group gets below the minimum stock threshold.",
Zerotorescue@0 1426 arg = "overrideAlertBelowMinimum",
Zerotorescue@0 1427 },
Zerotorescue@1 1428 overrideTrackAtCharacters = {
Zerotorescue@1 1429 order = 39,
Zerotorescue@1 1430 type = "toggle",
Zerotorescue@1 1431 name = "Override track at",
Zerotorescue@1 1432 desc = "Allows you to override at which characters items in this group should appear in the summary and generate alerts.",
Zerotorescue@1 1433 arg = "trackAtCharacters",
Zerotorescue@1 1434 },
Zerotorescue@1 1435 trackAtCharacters = {
Zerotorescue@1 1436 order = 40,
Zerotorescue@1 1437 type = "multiselect",
Zerotorescue@1 1438 name = "Track at",
Zerotorescue@1 1439 desc = "Select at which characters this should appear in the summary and generate alerts.",
Zerotorescue@1 1440 values = function()
Zerotorescue@1 1441 local temp = {};
Zerotorescue@1 1442 for charName in pairs(addon.db.factionrealm.characters) do
Zerotorescue@1 1443 temp[charName] = charName;
Zerotorescue@1 1444 end
Zerotorescue@1 1445
Zerotorescue@1 1446 return temp;
Zerotorescue@1 1447 end,
Zerotorescue@1 1448 get = GetMultiOption,
Zerotorescue@13 1449 --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 1450 arg = "overrideTrackAtCharacters",
Zerotorescue@1 1451 },
Zerotorescue@0 1452 },
Zerotorescue@0 1453 },
Zerotorescue@0 1454 refill = {
Zerotorescue@0 1455 order = 20,
Zerotorescue@0 1456 type = "group",
Zerotorescue@0 1457 inline = true,
Zerotorescue@0 1458 name = "Replenishing stock",
Zerotorescue@0 1459 set = SetOption,
Zerotorescue@0 1460 get = GetOption,
Zerotorescue@0 1461 disabled = GetDisabled,
Zerotorescue@0 1462 args = {
Zerotorescue@0 1463 description = {
Zerotorescue@0 1464 order = 0,
Zerotorescue@0 1465 type = "description",
Zerotorescue@0 1466 name = function(info)
Zerotorescue@0 1467 local groupName = groupIdToName[info[2]];
Zerotorescue@0 1468 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 1469
Zerotorescue@31 1470 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 1471
Zerotorescue@31 1472 if addon:GetOptionByKey(groupName, "priceThreshold") == 0 then
Zerotorescue@31 1473 r = r .. "Queueing items at |cfffed000any|r auction value.";
Zerotorescue@31 1474 else
Zerotorescue@31 1475 r = r .. "Queueing items worth |cfffed000" .. addon:ReadableMoney(addon:GetOptionByKey(groupName, "priceThreshold")) .. "|r or more.";
Zerotorescue@31 1476 end
Zerotorescue@0 1477
Zerotorescue@0 1478 return r;
Zerotorescue@0 1479 end,
Zerotorescue@0 1480 },
Zerotorescue@0 1481 header = {
Zerotorescue@0 1482 order = 5,
Zerotorescue@0 1483 type = "header",
Zerotorescue@0 1484 name = "",
Zerotorescue@0 1485 },
Zerotorescue@0 1486 overrideRestockTarget = {
Zerotorescue@0 1487 order = 9,
Zerotorescue@0 1488 type = "toggle",
Zerotorescue@0 1489 name = "Override restock target",
Zerotorescue@0 1490 desc = "Allows you to override the restock target setting for this group.",
Zerotorescue@0 1491 arg = "restockTarget",
Zerotorescue@0 1492 },
Zerotorescue@0 1493 restockTarget = {
Zerotorescue@0 1494 order = 10,
Zerotorescue@0 1495 type = "range",
Zerotorescue@0 1496 min = 0,
Zerotorescue@0 1497 max = 100000,
Zerotorescue@30 1498 softMax = 100,
Zerotorescue@0 1499 step = 1,
Zerotorescue@0 1500 name = "Restock target",
Zerotorescue@30 1501 desc = "You can manually enter a value between 100 and 100.000 in the edit box if the provided range is insufficient.",
Zerotorescue@0 1502 arg = "overrideRestockTarget",
Zerotorescue@0 1503 },
Zerotorescue@0 1504 overrideMinCraftingQueue = {
Zerotorescue@0 1505 order = 19,
Zerotorescue@0 1506 type = "toggle",
Zerotorescue@0 1507 name = "Override min queue",
Zerotorescue@0 1508 desc = "Allows you to override the minimum craftable items queue setting for this group.",
Zerotorescue@0 1509 arg = "minCraftingQueue",
Zerotorescue@0 1510 },
Zerotorescue@0 1511 minCraftingQueue = {
Zerotorescue@0 1512 order = 20,
Zerotorescue@0 1513 type = "range",
Zerotorescue@0 1514 min = 0,
Zerotorescue@0 1515 max = 1,
Zerotorescue@0 1516 step = 0.01,
Zerotorescue@0 1517 isPercent = true,
Zerotorescue@0 1518 name = "Don't queue if I only miss",
Zerotorescue@0 1519 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 1520 arg = "overrideMinCraftingQueue",
Zerotorescue@0 1521 },
Zerotorescue@1 1522 overrideBonusQueue = {
Zerotorescue@1 1523 order = 29,
Zerotorescue@1 1524 type = "toggle",
Zerotorescue@1 1525 name = "Override bonus queue",
Zerotorescue@1 1526 desc = "Allows you to override the bonus craftable items queue setting for this group.",
Zerotorescue@1 1527 arg = "bonusQueue",
Zerotorescue@1 1528 },
Zerotorescue@1 1529 bonusQueue = {
Zerotorescue@1 1530 order = 30,
Zerotorescue@1 1531 type = "range",
Zerotorescue@1 1532 min = 0,
Zerotorescue@1 1533 max = 10, -- 1000%
Zerotorescue@1 1534 step = 0.01, -- 1%
Zerotorescue@1 1535 isPercent = true,
Zerotorescue@1 1536 name = "Bonus queue",
Zerotorescue@1 1537 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 1538 arg = "overrideBonusQueue",
Zerotorescue@1 1539 },
Zerotorescue@1 1540 overridePriceThreshold = {
Zerotorescue@1 1541 order = 39,
Zerotorescue@1 1542 type = "toggle",
Zerotorescue@1 1543 name = "Override price threshold",
Zerotorescue@1 1544 desc = "Allows you to override the price threshold setting for this group.",
Zerotorescue@1 1545 arg = "priceThreshold",
Zerotorescue@1 1546 },
Zerotorescue@1 1547 priceThreshold = {
Zerotorescue@1 1548 order = 40,
Zerotorescue@1 1549 type = "input",
Zerotorescue@1 1550 name = "Price threshold",
Zerotorescue@1 1551 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 1552 validate = function(info, value) return addon:ValidateReadableMoney(info, value); end,
Zerotorescue@1 1553 get = function(i) return addon:ReadableMoney(GetOption(i)); end,
Zerotorescue@1 1554 set = function(i, v) SetOption(i, addon:ReadableMoneyToCopper(v)); end,
Zerotorescue@1 1555 arg = "overridePriceThreshold",
Zerotorescue@1 1556 },
Zerotorescue@13 1557 overrideSummaryHidePriceThreshold = {
Zerotorescue@1 1558 order = 49,
Zerotorescue@1 1559 type = "toggle",
Zerotorescue@1 1560 name = "Override summary showing",
Zerotorescue@1 1561 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 1562 arg = "summaryHidePriceThreshold",
Zerotorescue@1 1563 },
Zerotorescue@13 1564 summaryHidePriceThreshold = {
Zerotorescue@1 1565 order = 50,
Zerotorescue@1 1566 type = "toggle",
Zerotorescue@1 1567 name = "Hide when below threshold",
Zerotorescue@1 1568 desc = "Hide items from the summary when their value is below the set price threshold.",
Zerotorescue@13 1569 arg = "overrideSummaryHidePriceThreshold",
Zerotorescue@1 1570 },
Zerotorescue@23 1571 overrideAlwaysGetAuctionValue = {
Zerotorescue@23 1572 order = 59,
Zerotorescue@23 1573 type = "toggle",
Zerotorescue@23 1574 name = "Override auction value showing",
Zerotorescue@31 1575 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 1576 arg = "alwaysGetAuctionValue",
Zerotorescue@23 1577 },
Zerotorescue@23 1578 alwaysGetAuctionValue = {
Zerotorescue@23 1579 order = 60,
Zerotorescue@23 1580 type = "toggle",
Zerotorescue@23 1581 name = "Always show auction value",
Zerotorescue@31 1582 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 1583 arg = "overrideAlwaysGetAuctionValue",
Zerotorescue@23 1584 },
Zerotorescue@0 1585 },
Zerotorescue@0 1586 },
Zerotorescue@0 1587 },
Zerotorescue@0 1588 },
Zerotorescue@0 1589 group = {
Zerotorescue@0 1590 order = 20,
Zerotorescue@0 1591 type = "group",
Zerotorescue@23 1592 name = "Management",
Zerotorescue@23 1593 desc = "Rename, delete, duplicate or export this group.",
Zerotorescue@0 1594 args = {
Zerotorescue@10 1595 actions = {
Zerotorescue@0 1596 order = 10,
Zerotorescue@0 1597 type = "group",
Zerotorescue@10 1598 name = "Actions",
Zerotorescue@0 1599 inline = true,
Zerotorescue@0 1600 args = {
Zerotorescue@0 1601 rename = {
Zerotorescue@0 1602 order = 10,
Zerotorescue@0 1603 type = "input",
Zerotorescue@10 1604 name = "Rename group - New name",
Zerotorescue@0 1605 desc = "Change the name of this group to something else. You can also use item links here as you wish.",
Zerotorescue@0 1606 validate = ValidateGroupName,
Zerotorescue@0 1607 set = function(info, value)
Zerotorescue@0 1608 local oldGroupName = groupIdToName[info[2]];
Zerotorescue@0 1609
Zerotorescue@0 1610 addon.db.global.groups[value] = CopyTable(addon.db.global.groups[oldGroupName]);
Zerotorescue@0 1611 addon.db.global.groups[oldGroupName] = nil;
Zerotorescue@0 1612
Zerotorescue@0 1613 groupIdToName[info[2]] = value;
Zerotorescue@0 1614 groupIdToName[value] = true;
Zerotorescue@0 1615 groupIdToName[oldGroupName] = nil;
Zerotorescue@0 1616
Zerotorescue@0 1617 addon:FillGroupOptions();
Zerotorescue@0 1618 end,
Zerotorescue@0 1619 get = function(info)
Zerotorescue@0 1620 return groupIdToName[info[2]];
Zerotorescue@0 1621 end,
Zerotorescue@0 1622 },
Zerotorescue@10 1623 duplicate = {
Zerotorescue@10 1624 order = 20,
Zerotorescue@10 1625 type = "input",
Zerotorescue@10 1626 name = "Duplicate group - New name",
Zerotorescue@10 1627 desc = "Duplicate this group. You can also use item links here as you wish.\n\nAll item data will be erased.",
Zerotorescue@10 1628 validate = ValidateGroupName,
Zerotorescue@10 1629 set = function(info, value)
Zerotorescue@10 1630 local oldGroupName = groupIdToName[info[2]];
Zerotorescue@10 1631
Zerotorescue@10 1632 addon.db.global.groups[value] = CopyTable(addon.db.global.groups[oldGroupName]);
Zerotorescue@10 1633
Zerotorescue@10 1634 -- Reset item data (duplicate items me no want)
Zerotorescue@10 1635 addon.db.global.groups[value].items = nil;
Zerotorescue@10 1636
Zerotorescue@10 1637 addon:FillGroupOptions();
Zerotorescue@10 1638 end,
Zerotorescue@10 1639 get = false,
Zerotorescue@10 1640 },
Zerotorescue@0 1641 delete = {
Zerotorescue@10 1642 order = 30,
Zerotorescue@0 1643 type = "execute",
Zerotorescue@0 1644 name = "Delete group",
Zerotorescue@0 1645 desc = "Delete the currently selected group.",
Zerotorescue@0 1646 confirm = true,
Zerotorescue@0 1647 confirmText = "Are you sure you wish to |cffff0000DELETE|r this group? This action is not reversable!",
Zerotorescue@0 1648 func = function(info)
Zerotorescue@0 1649 local groupName = groupIdToName[info[2]];
Zerotorescue@0 1650
Zerotorescue@0 1651 addon.db.global.groups[groupName] = nil;
Zerotorescue@0 1652
Zerotorescue@0 1653 addon:FillGroupOptions();
Zerotorescue@0 1654 end,
Zerotorescue@0 1655 },
Zerotorescue@0 1656 },
Zerotorescue@0 1657 },
Zerotorescue@0 1658 export = {
Zerotorescue@10 1659 order = 40,
Zerotorescue@0 1660 type = "group",
Zerotorescue@0 1661 name = "Export",
Zerotorescue@0 1662 inline = true,
Zerotorescue@0 1663 args = {
Zerotorescue@0 1664 input = {
Zerotorescue@0 1665 order = 10,
Zerotorescue@0 1666 type = "input",
Zerotorescue@0 1667 multiline = true,
Zerotorescue@0 1668 name = "Group data",
Zerotorescue@0 1669 width = "full",
Zerotorescue@0 1670 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 1671 set = false,
Zerotorescue@0 1672 get = function(info)
Zerotorescue@0 1673 local groupName = groupIdToName[info[2]];
Zerotorescue@0 1674
Zerotorescue@0 1675 -- We want to include the group name, so we copy the table then set another value
Zerotorescue@0 1676 local temp = CopyTable(addon.db.global.groups[groupName]);
Zerotorescue@0 1677 temp.name = groupName;
Zerotorescue@9 1678 temp.trackAtCharacters = nil;
Zerotorescue@9 1679 temp.overrideTrackAtCharacters = nil;
Zerotorescue@0 1680
Zerotorescue@0 1681 if not AceSerializer then
Zerotorescue@0 1682 AceSerializer = LibStub("AceSerializer-3.0");
Zerotorescue@0 1683 end
Zerotorescue@0 1684
Zerotorescue@0 1685 return AceSerializer:Serialize(temp);
Zerotorescue@0 1686 end,
Zerotorescue@0 1687 },
Zerotorescue@0 1688 },
Zerotorescue@0 1689 },
Zerotorescue@0 1690 },
Zerotorescue@0 1691 },
Zerotorescue@0 1692 add = {
Zerotorescue@0 1693 order = 30,
Zerotorescue@0 1694 type = "group",
Zerotorescue@0 1695 name = "Add items",
Zerotorescue@23 1696 desc = "Add new items to this group.",
Zerotorescue@31 1697 hidden = function(info) return groupIsVirtual[info[2]]; end,
Zerotorescue@0 1698 args = {
Zerotorescue@0 1699 singleAdd = {
Zerotorescue@0 1700 order = 10,
Zerotorescue@0 1701 type = "group",
Zerotorescue@0 1702 inline = true,
Zerotorescue@0 1703 name = "Add items",
Zerotorescue@0 1704 args = {
Zerotorescue@0 1705 help = {
Zerotorescue@0 1706 order = 10,
Zerotorescue@0 1707 type = "description",
Zerotorescue@0 1708 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 1709 },
Zerotorescue@0 1710 itemLink = {
Zerotorescue@0 1711 order = 20,
Zerotorescue@0 1712 type = "input",
Zerotorescue@0 1713 name = "Single item add (item-link or item-id)",
Zerotorescue@0 1714 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 1715 validate = function(info, value)
Zerotorescue@0 1716 -- If the value is empty we'll allow passing to clear the carret
Zerotorescue@0 1717 if value == "" then return true; end
Zerotorescue@0 1718
Zerotorescue@0 1719 local groupName = groupIdToName[info[2]];
Zerotorescue@0 1720
Zerotorescue@0 1721 local itemId = addon:GetItemId(string.trim(value or "")) or tonumber(string.trim(value or ""));
Zerotorescue@0 1722
Zerotorescue@0 1723 if not itemId then
Zerotorescue@0 1724 return "This is not a valid item link.";
Zerotorescue@0 1725 elseif InGroup(itemId) then
Zerotorescue@0 1726 return ("This item is already in the group \"%s\"."):format(InGroup(itemId));
Zerotorescue@0 1727 end
Zerotorescue@0 1728
Zerotorescue@0 1729 return true;
Zerotorescue@0 1730 end,
Zerotorescue@0 1731 set = function(info, value)
Zerotorescue@0 1732 if value and value ~= "" then
Zerotorescue@0 1733 local groupName = groupIdToName[info[2]];
Zerotorescue@0 1734
Zerotorescue@0 1735 local itemId = addon:GetItemId(string.trim(value or "")) or tonumber(string.trim(value or ""));
Zerotorescue@0 1736
Zerotorescue@0 1737 AddToGroup(groupName, itemId);
Zerotorescue@0 1738
Zerotorescue@0 1739 print(("Added %s"):format(select(2, GetItemInfo(itemId)) or ("Unknown (#%d)"):format(itemId)));
Zerotorescue@0 1740 end
Zerotorescue@0 1741 end,
Zerotorescue@0 1742 get = false,
Zerotorescue@0 1743 },
Zerotorescue@17 1744 importItemData = {
Zerotorescue@17 1745 order = 30,
Zerotorescue@0 1746 type = "input",
Zerotorescue@0 1747 name = "Import item data",
Zerotorescue@0 1748 desc = "Import item data from an exported item data-string. Any items already grouped will be skipped.",
Zerotorescue@0 1749 set = function(info, value)
Zerotorescue@0 1750 local groupName = groupIdToName[info[2]];
Zerotorescue@0 1751
Zerotorescue@0 1752 local allItemIds = { string.split(";", value or "") };
Zerotorescue@0 1753
Zerotorescue@0 1754 for _, value in pairs(allItemIds) do
Zerotorescue@0 1755 local itemId = tonumber(value);
Zerotorescue@0 1756
Zerotorescue@0 1757 if not itemId then
Zerotorescue@0 1758 print(("\"%s\" is not a number."):format(value));
Zerotorescue@0 1759 elseif InGroup(itemId) then
Zerotorescue@0 1760 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 1761 else
Zerotorescue@0 1762 AddToGroup(groupName, itemId);
Zerotorescue@0 1763 end
Zerotorescue@0 1764 end
Zerotorescue@0 1765 end,
Zerotorescue@0 1766 get = false,
Zerotorescue@0 1767 },
Zerotorescue@17 1768 importPremadeData = {
Zerotorescue@17 1769 order = 40,
Zerotorescue@17 1770 type = "select",
Zerotorescue@17 1771 name = "Import premade data",
Zerotorescue@17 1772 desc = "Import item data from a premade item-group. Any items already grouped will be skipped.",
Zerotorescue@17 1773 values = function()
Zerotorescue@17 1774 local temp = {};
Zerotorescue@17 1775 for key, group in pairs(addon.defaultGroups) do
Zerotorescue@17 1776 temp[key] = key;
Zerotorescue@17 1777 end
Zerotorescue@17 1778
Zerotorescue@17 1779 return temp;
Zerotorescue@17 1780 end,
Zerotorescue@17 1781 set = function(info, value)
Zerotorescue@17 1782 local groupName = groupIdToName[info[2]];
Zerotorescue@17 1783
Zerotorescue@17 1784 print(("Importing items from the premade group \"|cfffed000%s|r\"."):format(value));
Zerotorescue@17 1785
Zerotorescue@17 1786 -- Remember we imported this group and it's version so if it is ever changed, people can be notified
Zerotorescue@17 1787 if not addon.db.global.groups[groupName].premadeGroups then
Zerotorescue@17 1788 addon.db.global.groups[groupName].premadeGroups = {};
Zerotorescue@17 1789 end
Zerotorescue@17 1790 addon.db.global.groups[groupName].premadeGroups[value] = addon.defaultGroups[value].version;
Zerotorescue@17 1791
Zerotorescue@46 1792 for itemId, version in pairs(addon.defaultGroups[value].items) do
Zerotorescue@46 1793 if version > 0 then
Zerotorescue@46 1794 itemId = itemId and tonumber(itemId);
Zerotorescue@46 1795
Zerotorescue@46 1796 if not itemId then
Zerotorescue@46 1797 print(("\"|cfffed000%s|r\" is not a number."):format(value));
Zerotorescue@46 1798 elseif InGroup(itemId) then
Zerotorescue@46 1799 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 1800 else
Zerotorescue@46 1801 AddToGroup(groupName, itemId);
Zerotorescue@46 1802 print(("|cff00ff00Added|r |cfffed000%s|r (#%d) to the group |cfffed000%s|r."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId, groupName));
Zerotorescue@46 1803 end
Zerotorescue@17 1804 end
Zerotorescue@17 1805 end
Zerotorescue@17 1806 end,
Zerotorescue@17 1807 get = false,
Zerotorescue@17 1808 },
Zerotorescue@0 1809 },
Zerotorescue@0 1810 },
Zerotorescue@0 1811 massAdd = {
Zerotorescue@0 1812 order = 20,
Zerotorescue@0 1813 type = "group",
Zerotorescue@0 1814 inline = true,
Zerotorescue@0 1815 name = "Mass add",
Zerotorescue@0 1816 args = {
Zerotorescue@0 1817 help = {
Zerotorescue@0 1818 order = 10,
Zerotorescue@0 1819 type = "description",
Zerotorescue@0 1820 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 1821 },
Zerotorescue@0 1822 massAdd = {
Zerotorescue@0 1823 order = 20,
Zerotorescue@0 1824 type = "input",
Zerotorescue@0 1825 name = "Add all items matching...",
Zerotorescue@0 1826 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 1827 set = function(info, value)
Zerotorescue@17 1828 local groupName = groupIdToName[info[2]];
Zerotorescue@17 1829
Zerotorescue@13 1830 if not value then return; end
Zerotorescue@13 1831
Zerotorescue@13 1832 value = value:lower();
Zerotorescue@13 1833
Zerotorescue@13 1834 local ref = options.args.groups.args[info[2]].args.add.args.list.args;
Zerotorescue@13 1835
Zerotorescue@13 1836 for itemId, test in pairs(ref) do
Zerotorescue@13 1837 if test then
Zerotorescue@13 1838 local itemName = GetItemInfo(itemId);
Zerotorescue@13 1839
Zerotorescue@13 1840 if itemName:lower():find(value) then
Zerotorescue@13 1841 if not AddToGroup(groupName, itemId) then
Zerotorescue@13 1842 print("|cffff0000Couldn't add the item with itemId (" .. itemId .. ") because it is already in a group.|r");
Zerotorescue@13 1843 end
Zerotorescue@13 1844 end
Zerotorescue@13 1845 end
Zerotorescue@13 1846 end
Zerotorescue@13 1847 end,
Zerotorescue@0 1848 get = false,
Zerotorescue@0 1849 },
Zerotorescue@13 1850 minItemLevel = {
Zerotorescue@13 1851 order = 40,
Zerotorescue@13 1852 type = "select",
Zerotorescue@13 1853 values = function()
Zerotorescue@13 1854 local temp = {};
Zerotorescue@13 1855
Zerotorescue@13 1856 temp[0] = "Include everything";
Zerotorescue@13 1857
Zerotorescue@13 1858 local itemLevelTemplate = "Itemlevel >= %d";
Zerotorescue@13 1859
Zerotorescue@13 1860 for i = 1, 49 do
Zerotorescue@13 1861 temp[( i * 10 )] = itemLevelTemplate:format(( i * 10 ));
Zerotorescue@13 1862 end
Zerotorescue@13 1863
Zerotorescue@13 1864 temp[500] = "Include nothing";
Zerotorescue@13 1865
Zerotorescue@13 1866 return temp;
Zerotorescue@13 1867 end,
Zerotorescue@13 1868 name = "Include tradeskill items",
Zerotorescue@13 1869 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 1870 set = function(i, v) includeTradeSkillItems = v; end,
Zerotorescue@13 1871 get = function() return includeTradeSkillItems; end,
Zerotorescue@13 1872 disabled = function()
Zerotorescue@13 1873 if GetTradeSkillLine() == "UNKNOWN" then
Zerotorescue@13 1874 includeTradeSkillItems = 500;
Zerotorescue@13 1875 return true; -- disabled
Zerotorescue@13 1876 else
Zerotorescue@13 1877 return false;
Zerotorescue@13 1878 end
Zerotorescue@13 1879 end,
Zerotorescue@13 1880 },
Zerotorescue@0 1881 },
Zerotorescue@0 1882 },
Zerotorescue@0 1883 list = {
Zerotorescue@0 1884 order = 30,
Zerotorescue@0 1885 type = "group",
Zerotorescue@0 1886 inline = true,
Zerotorescue@0 1887 name = "Item list",
Zerotorescue@0 1888 hidden = UpdateAddItemList,
Zerotorescue@0 1889 args = {
Zerotorescue@0 1890
Zerotorescue@0 1891 },
Zerotorescue@0 1892 },
Zerotorescue@0 1893 },
Zerotorescue@0 1894 },
Zerotorescue@0 1895 remove = {
Zerotorescue@0 1896 order = 40,
Zerotorescue@0 1897 type = "group",
Zerotorescue@0 1898 name = "Current items",
Zerotorescue@23 1899 desc = "View, export or remove items from this group.",
Zerotorescue@31 1900 hidden = function(info) return groupIsVirtual[info[2]]; end,
Zerotorescue@0 1901 args = {
Zerotorescue@0 1902 help = {
Zerotorescue@0 1903 order = 10,
Zerotorescue@0 1904 type = "group",
Zerotorescue@0 1905 inline = true,
Zerotorescue@0 1906 name = "Help",
Zerotorescue@0 1907 hidden = false,
Zerotorescue@0 1908 args = {
Zerotorescue@0 1909 help = {
Zerotorescue@0 1910 order = 10,
Zerotorescue@0 1911 type = "description",
Zerotorescue@0 1912 name = "Click the items you wish to remove from this group.",
Zerotorescue@0 1913 },
Zerotorescue@17 1914 massRemove = {
Zerotorescue@17 1915 order = 20,
Zerotorescue@17 1916 type = "input",
Zerotorescue@17 1917 name = "Remove all items matching...",
Zerotorescue@17 1918 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 1919 set = function(info, value)
Zerotorescue@17 1920 local groupName = groupIdToName[info[2]];
Zerotorescue@17 1921
Zerotorescue@17 1922 if not value then return; end
Zerotorescue@17 1923
Zerotorescue@17 1924 value = value:lower();
Zerotorescue@17 1925
Zerotorescue@17 1926 local ref = options.args.groups.args[info[2]].args.remove.args.list.args;
Zerotorescue@17 1927
Zerotorescue@17 1928 for itemId, test in pairs(ref) do
Zerotorescue@17 1929 if test then
Zerotorescue@17 1930 local itemName = GetItemInfo(itemId);
Zerotorescue@17 1931
Zerotorescue@17 1932 if itemName:lower():find(value) then
Zerotorescue@46 1933 RemoveFromGroup(groupName, itemId);
Zerotorescue@46 1934 print(("|cffff0000Removed|r %s (#%d)."):format(select(2, GetItemInfo(itemId)) or "Unknown", itemId));
Zerotorescue@17 1935 end
Zerotorescue@17 1936 end
Zerotorescue@17 1937 end
Zerotorescue@46 1938
Zerotorescue@46 1939 -- Now rebuild the list
Zerotorescue@46 1940 AceConfigRegistry:NotifyChange("InventoriumOptions");
Zerotorescue@17 1941 end,
Zerotorescue@17 1942 get = false,
Zerotorescue@17 1943 },
Zerotorescue@17 1944 premadeGroups = {
Zerotorescue@17 1945 order = 30,
Zerotorescue@17 1946 type = "select",
Zerotorescue@17 1947 name = "Imported premade groups",
Zerotorescue@23 1948 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 1949 values = function(info)
Zerotorescue@17 1950 local groupName = groupIdToName[info[2]];
Zerotorescue@17 1951
Zerotorescue@17 1952 local temp = {};
Zerotorescue@17 1953 if addon.db.global.groups[groupName].premadeGroups then
Zerotorescue@17 1954 for name, version in pairs(addon.db.global.groups[groupName].premadeGroups) do
Zerotorescue@17 1955 temp[name] = name;
Zerotorescue@17 1956 end
Zerotorescue@17 1957 end
Zerotorescue@17 1958
Zerotorescue@17 1959 return temp;
Zerotorescue@17 1960 end,
Zerotorescue@17 1961 set = function(info, value)
Zerotorescue@17 1962 -- Remove premade group from this group
Zerotorescue@17 1963 local groupName = groupIdToName[info[2]];
Zerotorescue@17 1964
Zerotorescue@17 1965 addon.db.global.groups[groupName].premadeGroups[value] = nil;
Zerotorescue@17 1966
Zerotorescue@17 1967 print(("No longer notifying you about changes made to the premade group named \"|cfffed000%s|r\"."):format(value));
Zerotorescue@17 1968 end,
Zerotorescue@17 1969 get = false,
Zerotorescue@17 1970 disabled = function(info)
Zerotorescue@17 1971 local groupName = groupIdToName[info[2]];
Zerotorescue@17 1972
Zerotorescue@17 1973 return (not addon.db.global.groups[groupName].premadeGroups);
Zerotorescue@17 1974 end,
Zerotorescue@17 1975 },
Zerotorescue@0 1976 },
Zerotorescue@0 1977 },
Zerotorescue@0 1978 list = {
Zerotorescue@0 1979 order = 20,
Zerotorescue@0 1980 type = "group",
Zerotorescue@0 1981 inline = true,
Zerotorescue@0 1982 name = "Item list",
Zerotorescue@0 1983 hidden = UpdateRemoveItemList,
Zerotorescue@0 1984 args = {
Zerotorescue@0 1985
Zerotorescue@0 1986 },
Zerotorescue@0 1987 },
Zerotorescue@0 1988 export = {
Zerotorescue@0 1989 order = 30,
Zerotorescue@0 1990 type = "group",
Zerotorescue@0 1991 name = "Export",
Zerotorescue@0 1992 inline = true,
Zerotorescue@0 1993 args = {
Zerotorescue@0 1994 input = {
Zerotorescue@0 1995 order = 10,
Zerotorescue@0 1996 type = "input",
Zerotorescue@0 1997 name = "Item data",
Zerotorescue@0 1998 width = "full",
Zerotorescue@0 1999 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 2000 set = false,
Zerotorescue@0 2001 get = function(info)
Zerotorescue@0 2002 local groupName = groupIdToName[info[2]];
Zerotorescue@0 2003
Zerotorescue@0 2004 local combinedItemIds;
Zerotorescue@0 2005 -- Parse items in group and show these
Zerotorescue@0 2006 for itemId, _ in pairs(addon.db.global.groups[groupName].items) do
Zerotorescue@0 2007 if not combinedItemIds then
Zerotorescue@0 2008 combinedItemIds = tostring(itemId);
Zerotorescue@0 2009 else
Zerotorescue@0 2010 combinedItemIds = combinedItemIds .. (";%d"):format(itemId);
Zerotorescue@0 2011 end
Zerotorescue@0 2012 end
Zerotorescue@0 2013
Zerotorescue@0 2014 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 2015 end,
Zerotorescue@0 2016 },
Zerotorescue@0 2017 },
Zerotorescue@0 2018 },
Zerotorescue@0 2019 },
Zerotorescue@0 2020 },
Zerotorescue@0 2021 },
Zerotorescue@0 2022 };
Zerotorescue@0 2023
Zerotorescue@30 2024 local currentGroupType = "Normal";
Zerotorescue@0 2025 function addon:MakeGroupOptions()
Zerotorescue@0 2026 options.args.groups = {
Zerotorescue@0 2027 order = 1100,
Zerotorescue@0 2028 type = "group",
Zerotorescue@0 2029 name = "Groups",
Zerotorescue@0 2030 desc = "Change a group.",
Zerotorescue@0 2031 args = {
Zerotorescue@0 2032 create = {
Zerotorescue@0 2033 order = 10,
Zerotorescue@0 2034 type = "group",
Zerotorescue@0 2035 inline = true,
Zerotorescue@0 2036 name = "Create a brand new group",
Zerotorescue@0 2037 args = {
Zerotorescue@0 2038 name = {
Zerotorescue@0 2039 order = 10,
Zerotorescue@0 2040 type = "input",
Zerotorescue@0 2041 name = "Group name",
Zerotorescue@0 2042 desc = "The name of the group. You can also use item links as you wish.",
Zerotorescue@0 2043 validate = ValidateGroupName,
Zerotorescue@0 2044 set = function(_, value)
Zerotorescue@0 2045 self.db.global.groups[value] = {};
Zerotorescue@30 2046 if currentGroupType == "Virtual" then
Zerotorescue@30 2047 self.db.global.groups[value].isVirtual = true;
Zerotorescue@30 2048 end
Zerotorescue@30 2049
Zerotorescue@0 2050 addon:FillGroupOptions();
Zerotorescue@0 2051 end,
Zerotorescue@0 2052 get = false,
Zerotorescue@0 2053 width = "double",
Zerotorescue@0 2054 },
Zerotorescue@30 2055 type = {
Zerotorescue@30 2056 order = 20,
Zerotorescue@30 2057 type = "select",
Zerotorescue@30 2058 name = "Type (advanced)",
Zerotorescue@30 2059 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 2060 values = {
Zerotorescue@30 2061 ["Normal"] = "Normal",
Zerotorescue@30 2062 ["Virtual"] = "Virtual",
Zerotorescue@30 2063 },
Zerotorescue@30 2064 set = function(_, value) currentGroupType = value; end,
Zerotorescue@30 2065 get = function() return currentGroupType; end,
Zerotorescue@30 2066 },
Zerotorescue@0 2067 },
Zerotorescue@0 2068 },
Zerotorescue@0 2069 import = {
Zerotorescue@0 2070 order = 20,
Zerotorescue@0 2071 type = "group",
Zerotorescue@0 2072 inline = true,
Zerotorescue@0 2073 name = "Import a group",
Zerotorescue@0 2074 args = {
Zerotorescue@0 2075 input = {
Zerotorescue@0 2076 order = 10,
Zerotorescue@0 2077 type = "input",
Zerotorescue@0 2078 multiline = true,
Zerotorescue@0 2079 name = "Group data",
Zerotorescue@0 2080 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 2081 set = function(info, value)
Zerotorescue@9 2082 local data = { string.split("\n", value or "") };
Zerotorescue@0 2083
Zerotorescue@9 2084 for _, current in pairs(data) do
Zerotorescue@0 2085 if not AceSerializer then
Zerotorescue@0 2086 AceSerializer = LibStub("AceSerializer-3.0");
Zerotorescue@0 2087 end
Zerotorescue@0 2088
Zerotorescue@0 2089 local result, temp = AceSerializer:Deserialize(current);
Zerotorescue@0 2090
Zerotorescue@0 2091 if not temp.name then
Zerotorescue@0 2092 print("|cffff0000The provided data is not supported.|r");
Zerotorescue@10 2093 elseif ValidateGroupName(nil, temp.name) ~= true then
Zerotorescue@10 2094 print(("|cffff0000Aborting: A group named \"%s\" already exists.|r"):format(temp.name));
Zerotorescue@0 2095 else
Zerotorescue@10 2096 local name = temp.name;
Zerotorescue@0 2097 temp.name = nil;
Zerotorescue@9 2098 print(("Importing %s..."):format(name));
Zerotorescue@10 2099
Zerotorescue@10 2100 -- Remove items that are already in another group
Zerotorescue@10 2101 for value, _ in pairs(temp.items) do
Zerotorescue@17 2102 local itemId = tonumber(value);
Zerotorescue@10 2103
Zerotorescue@10 2104 if not itemId then
Zerotorescue@10 2105 print(("\"%s\" is not a number."):format(value));
Zerotorescue@10 2106 temp.items[value] = nil;
Zerotorescue@10 2107 elseif InGroup(itemId) then
Zerotorescue@10 2108 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 2109 temp.items[value] = nil;
Zerotorescue@10 2110 else
Zerotorescue@10 2111 -- Ensure the keys are numeric
Zerotorescue@10 2112 temp.items[value] = nil;
Zerotorescue@10 2113 temp.items[itemId] = true;
Zerotorescue@10 2114 end
Zerotorescue@10 2115 end
Zerotorescue@10 2116
Zerotorescue@23 2117 -- 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 2118 temp.trackAtCharacters = nil;
Zerotorescue@10 2119 temp.overrideTrackAtCharacters = nil;
Zerotorescue@10 2120
Zerotorescue@10 2121 self.db.global.groups[name] = temp;
Zerotorescue@0 2122 end
Zerotorescue@0 2123 end
Zerotorescue@10 2124
Zerotorescue@10 2125 self:FillGroupOptions();
Zerotorescue@0 2126 end,
Zerotorescue@0 2127 get = false,
Zerotorescue@0 2128 width = "full",
Zerotorescue@0 2129 },
Zerotorescue@0 2130 },
Zerotorescue@0 2131 },
Zerotorescue@0 2132 },
Zerotorescue@0 2133 };
Zerotorescue@0 2134 end
Zerotorescue@0 2135
Zerotorescue@0 2136 function addon:FillGroupOptions()
Zerotorescue@0 2137 for id, name in pairs(groupIdToName) do
Zerotorescue@0 2138 if type(name) == "string" and not self.db.global.groups[name] then
Zerotorescue@0 2139 options.args.groups.args[id] = nil;
Zerotorescue@0 2140 groupIdToName[id] = nil;
Zerotorescue@0 2141 groupIdToName[name] = nil;
Zerotorescue@30 2142 groupIsVirtual[id] = nil;
Zerotorescue@0 2143 end
Zerotorescue@0 2144 end
Zerotorescue@0 2145
Zerotorescue@0 2146 for name, values in pairs(self.db.global.groups) do
Zerotorescue@0 2147 if not groupIdToName[name] then
Zerotorescue@23 2148 options.args.groups.args[tostring(count)] = defaultGroup;
Zerotorescue@0 2149
Zerotorescue@0 2150 groupIdToName[tostring(count)] = name;
Zerotorescue@0 2151 groupIdToName[name] = true;
Zerotorescue@30 2152 if values.isVirtual then
Zerotorescue@30 2153 groupIsVirtual[tostring(count)] = true;
Zerotorescue@30 2154 end
Zerotorescue@0 2155
Zerotorescue@0 2156 count = ( count + 1 );
Zerotorescue@0 2157 end
Zerotorescue@0 2158 end
Zerotorescue@0 2159 end
Zerotorescue@0 2160
Zerotorescue@13 2161
Zerotorescue@13 2162
Zerotorescue@13 2163 -- General functions used addon-wide
Zerotorescue@13 2164
Zerotorescue@35 2165 function addon:GetItemCountAddon(group)
Zerotorescue@35 2166 local selectedExternalAddon = self:GetOptionByKey(group, "itemCountAddon");
Zerotorescue@35 2167
Zerotorescue@35 2168 if self.supportedAddons.itemCount[selectedExternalAddon] and self.supportedAddons.itemCount[selectedExternalAddon].IsEnabled() then
Zerotorescue@35 2169 -- Try to use the default item count addon
Zerotorescue@35 2170
Zerotorescue@35 2171 return self.supportedAddons.itemCount[selectedExternalAddon], selectedExternalAddon;
Zerotorescue@35 2172 else
Zerotorescue@35 2173 -- Default not available, get the first one then
Zerotorescue@35 2174
Zerotorescue@35 2175 for name, value in pairs(self.supportedAddons.itemCount) do
Zerotorescue@35 2176 if value.IsEnabled() then
Zerotorescue@35 2177 return value, name;
Zerotorescue@35 2178 end
Zerotorescue@35 2179 end
Zerotorescue@35 2180 end
Zerotorescue@35 2181
Zerotorescue@35 2182 return;
Zerotorescue@35 2183 end
Zerotorescue@35 2184
Zerotorescue@23 2185 function addon:GetItemCount(itemId, group)
Zerotorescue@13 2186 itemId = tonumber(itemId);
Zerotorescue@13 2187
Zerotorescue@13 2188 if not itemId then return; end
Zerotorescue@13 2189
Zerotorescue@35 2190 local itemCountAddon = self:GetItemCountAddon(group);
Zerotorescue@23 2191
Zerotorescue@35 2192 return (itemCountAddon and itemCountAddon.GetTotalCount(itemId)) or -1;
Zerotorescue@0 2193 end
Zerotorescue@0 2194
Zerotorescue@23 2195 function addon:GetAuctionValue(itemLink, group)
Zerotorescue@23 2196 if not itemLink then return -5; end
Zerotorescue@13 2197
Zerotorescue@23 2198 local selectedExternalAddon = self:GetOptionByKey(group, "auctionPricingAddon");
Zerotorescue@23 2199
Zerotorescue@23 2200 if self.supportedAddons.auctionPricing[selectedExternalAddon] and self.supportedAddons.auctionPricing[selectedExternalAddon].IsEnabled() then
Zerotorescue@13 2201 -- Try to use the default auction pricing addon
Zerotorescue@1 2202
Zerotorescue@23 2203 return self.supportedAddons.auctionPricing[selectedExternalAddon].GetValue(itemLink);
Zerotorescue@13 2204 else
Zerotorescue@13 2205 -- Default not available, get the first one then
Zerotorescue@1 2206
Zerotorescue@13 2207 for name, value in pairs(self.supportedAddons.auctionPricing) do
Zerotorescue@13 2208 if value.IsEnabled() then
Zerotorescue@13 2209 return value.GetValue(itemLink);
Zerotorescue@13 2210 end
Zerotorescue@1 2211 end
Zerotorescue@1 2212 end
Zerotorescue@7 2213
Zerotorescue@7 2214 return -2;
Zerotorescue@1 2215 end
Zerotorescue@1 2216
Zerotorescue@0 2217
Zerotorescue@0 2218
Zerotorescue@13 2219 -- Public
Zerotorescue@13 2220
Zerotorescue@36 2221 function IMRegisterPricingAddon(name, get, enabled, onSelect)
Zerotorescue@13 2222 addon.supportedAddons.auctionPricing[name] = {
Zerotorescue@13 2223 GetValue = get,
Zerotorescue@13 2224 IsEnabled = enabled,
Zerotorescue@36 2225 OnSelect = onSelect,
Zerotorescue@13 2226 };
Zerotorescue@13 2227 end
Zerotorescue@13 2228
Zerotorescue@17 2229 function IMRegisterItemCountAddon(name, getTotal, getCharacter, enabled)
Zerotorescue@13 2230 addon.supportedAddons.itemCount[name] = {
Zerotorescue@17 2231 GetTotalCount = getTotal,
Zerotorescue@17 2232 GetCharacterCount = getCharacter,
Zerotorescue@13 2233 IsEnabled = enabled,
Zerotorescue@13 2234 };
Zerotorescue@13 2235 end
Zerotorescue@13 2236
Zerotorescue@13 2237 function IMRegisterCraftingAddon(name, queue, enabled)
Zerotorescue@13 2238 addon.supportedAddons.crafting[name] = {
Zerotorescue@13 2239 Queue = queue,
Zerotorescue@13 2240 IsEnabled = enabled,
Zerotorescue@13 2241 };
Zerotorescue@13 2242 end
Zerotorescue@13 2243
Zerotorescue@13 2244
Zerotorescue@13 2245
Zerotorescue@13 2246 -- Debug
Zerotorescue@0 2247
Zerotorescue@0 2248 function addon:Debug(t)
Zerotorescue@0 2249 if not self.debugChannel and self.debugChannel ~= false then
Zerotorescue@0 2250 -- 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 2251 self.debugChannel = false;
Zerotorescue@0 2252
Zerotorescue@0 2253 for i = 1, NUM_CHAT_WINDOWS do
Zerotorescue@0 2254 local name = GetChatWindowInfo(i);
Zerotorescue@0 2255
Zerotorescue@0 2256 if name:upper() == "DEBUG" then
Zerotorescue@0 2257 self.debugChannel = _G["ChatFrame" .. i];
Zerotorescue@0 2258 end
Zerotorescue@0 2259 end
Zerotorescue@0 2260 end
Zerotorescue@0 2261
Zerotorescue@0 2262 if self.debugChannel then
Zerotorescue@0 2263 self.debugChannel:AddMessage(t);
Zerotorescue@0 2264 end
Zerotorescue@0 2265 end