Mercurial > wow > inventory
diff Core.lua @ 36:58fb38f0b447
The list of possible commands when you write /im without any arguement will now include commands inserted by modules with their own descriptions.
Clicking a command in this list will now execute it.
The slash command handler function is now a global so you can invoke these through other methods.
Added an optional event function to registering auction pricing addons, when defined this will be executed when the pricing addon gets selected.
Removed the unused ?Override local item data? option.
Added ?AuctionProfitMaster? and ?ZeroAuctions? pricing support. The pricing info displayed in the summary window will be used for this.
Trying to queue without any items in the summary should no longer give an error.
author | Zerotorescue |
---|---|
date | Sat, 20 Nov 2010 17:24:16 +0100 |
parents | 31e5da6a2b16 |
children | abc824800387 |
line wrap: on
line diff
--- a/Core.lua Wed Nov 03 19:38:53 2010 +0100 +++ b/Core.lua Sat Nov 20 17:24:16 2010 +0100 @@ -69,10 +69,44 @@ -- Register our own slash commands SLASH_INVENTORIUM1 = "/inventorium"; SLASH_INVENTORIUM2 = "/im"; - SlashCmdList["INVENTORIUM"] = function(msg) - self:CommandHandler(msg); - end + SlashCmdList["INVENTORIUM"] = InventoriumCommandHandler; + -- Config command handling + self:RegisterSlash(function(this) + -- We don't want any other windows open at this time. + for name, module in this:IterateModules() do + if module.CloseFrame then + module:CloseFrame(); + end + end + + this:Show(); + 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."); + + -- Debug command handling + self:RegisterSlash(function(this) + this.debugChannel = false; + for i = 1, NUM_CHAT_WINDOWS do + local name = GetChatWindowInfo(i); + + if name:upper() == "DEBUG" then + this.debugChannel = _G["ChatFrame" .. i]; + + print("A debug channel already exists, used the old one. (" .. i .. ")"); + return; + end + end + + if not this.debugChannel then + -- Create a new debug channel + local chatFrame = FCF_OpenNewWindow('Debug'); + ChatFrame_RemoveAllMessageGroups(chatFrame); + this.debugChannel = chatFrame; + + print("New debug channel created."); + end + end, { "d", "debug" }); + -- INTERFACE OPTIONS -- Attempt to remove the interface options added by AddonLoader (if enabled) @@ -196,12 +230,6 @@ end -local slashArgs = {}; -function addon:RegisterSlash(func, ...) - for _, arg in pairs({ ... }) do - slashArgs[arg] = func; - end -end function addon:MakeItemLinkButtonWidget() --[[ @@ -228,8 +256,8 @@ -- when the widget is re-used from the widget pool widget.originalOnAcquire = widget.OnAcquire; widget.OnAcquire = function(self, ...) - - + + -- We overwrite the setcallback because we don't want anything else -- to overwrite our OnEnter, OnLeave and OnClick events -- which would be done by the AceConfigDialog after a widget gets re-used @@ -252,6 +280,7 @@ end + -- Set our own events, since we disabled the normal event-names, we'll call them our custom versions self:SetCallback("CustomOnEnter", function(this) local itemId = this:GetUserData("itemId"); @@ -356,44 +385,27 @@ AceGUI:RegisterWidgetType(widgetType, GetItemLinkButton, widgetVersion); end -function addon:CommandHandler(message) +local slashArgs = {}; +local slashError = "Wrong arguement, the following arguements are available:"; + +function addon:RegisterSlash(func, args, description) + for _, arg in pairs(args) do + slashArgs[arg] = func; + end + + if description then + slashError = slashError .. "\n" .. description; + end +end + +function InventoriumCommandHandler(message) local cmd, arg = string.split(" ", (message or ""), 2); cmd = string.lower(cmd); - if cmd == "c" or cmd == "config" or cmd == "conf" or cmd == "option" or cmd == "options" or cmd == "opt" or cmd == "setting" or cmd == "settings" then - -- We don't want any other windows open at this time. - for name, module in self:IterateModules() do - if module.CloseFrame then - module:CloseFrame(); - end - end - - self:Show(); - elseif cmd == "d" or cmd == "debug" then - self.debugChannel = false; - for i = 1, NUM_CHAT_WINDOWS do - local name = GetChatWindowInfo(i); - - if name:upper() == "DEBUG" then - self.debugChannel = _G["ChatFrame" .. i]; - - print("A debug channel already exists, used the old one. (" .. i .. ")"); - return; - end - end - - if not self.debugChannel then - -- Create a new debug channel - local chatFrame = FCF_OpenNewWindow('Debug'); - ChatFrame_RemoveAllMessageGroups(chatFrame); - self.debugChannel = chatFrame; - - print("New debug channel created."); - end - elseif slashArgs[cmd] then - slashArgs[cmd](); + if slashArgs[cmd] then + slashArgs[cmd](addon, arg); else - print("Wrong command, available: /inventorium config (or /im c) and /inventorium summary (or /im s)"); + print(slashError); end end @@ -574,7 +586,13 @@ return temp; end, get = function() return self.db.global.defaults.auctionPricingAddon; end, - set = function(i, v) self.db.global.defaults.auctionPricingAddon = v; end, + set = function(i, v) + self.db.global.defaults.auctionPricingAddon = v; + + if self.supportedAddons.auctionPricing[v].OnSelect then + self.supportedAddons.auctionPricing[v].OnSelect(); + end + end, }, itemCountAddon = { order = 20, @@ -608,7 +626,7 @@ get = function() return self.db.global.defaults.craftingAddon; end, set = function(i, v) self.db.global.defaults.craftingAddon = v; end, }, - localItemData = { + --[[localItemData = { order = 40, type = "multiselect", name = "Include in local item data", @@ -622,7 +640,7 @@ get = function(i, v) return self.db.global.defaults.localItemData and self.db.global.defaults.localItemData[v]; end, set = function(i, v, e) self.db.global.defaults.localItemData[v] = e or nil; end, --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. - }, + },]] }, }, minimumStock = { @@ -1208,6 +1226,16 @@ return temp; end, + set = function(info, value) + local groupName = groupIdToName[info[2]]; + local optionName = info[#info]; + + addon.db.global.groups[groupName][optionName] = value ~= "" and value; + + if addon.supportedAddons.auctionPricing[value].OnSelect then + addon.supportedAddons.auctionPricing[value].OnSelect(); + end + end, arg = "overrideAuctionPricingAddon", }, overrideItemCountAddon = { @@ -1254,7 +1282,7 @@ end, arg = "overrideCraftingAddon", }, - overrideLocalItemData = { + --[[overrideLocalItemData = { order = 39, type = "toggle", name = "Override local item data", @@ -1275,7 +1303,7 @@ get = GetMultiOption, --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. arg = "overrideLocalItemData", - }, + },]] virtualGroup = { order = 50, type = "select", @@ -2162,10 +2190,11 @@ -- Public -function IMRegisterPricingAddon(name, get, enabled) +function IMRegisterPricingAddon(name, get, enabled, onSelect) addon.supportedAddons.auctionPricing[name] = { GetValue = get, IsEnabled = enabled, + OnSelect = onSelect, }; end