annotate Core.lua @ 61:d903b0a151d3

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