# HG changeset patch # User Asa Ayers # Date 1279865877 25200 # Node ID 234896be40878f64f31a72d3aad763ee8675a010 # Parent 52f691a2a3a405a256b73d0f0aef1f4978bd8479 Adding an option to direct ItemAuditor output to a different chat frame diff -r 52f691a2a3a4 -r 234896be4087 CHANGELOG.txt --- a/CHANGELOG.txt Wed Jul 21 22:40:21 2010 -0700 +++ b/CHANGELOG.txt Thu Jul 22 23:17:57 2010 -0700 @@ -1,3 +1,7 @@ +2010-07-22 Asa Ayers + +- I Added an option to direct ItemAuditor output to a different chat frame. + 2010-07-21 Asa Ayers - Fixed a bug where if you attached money and items to a piece of mail it would count all of the money as postage. diff -r 52f691a2a3a4 -r 234896be4087 Core.lua --- a/Core.lua Wed Jul 21 22:40:21 2010 -0700 +++ b/Core.lua Thu Jul 22 23:17:57 2010 -0700 @@ -18,6 +18,7 @@ use_quick_auctions = false, crafting_threshold = 1, auction_threshold = 0.15, + output_chat_frame = nil, }, profile = { messages = { @@ -109,8 +110,7 @@ local printPrefix = "|cFFA3CEFFItemAuditor|r: " function addon:Print(message, ...) message = format(message, ...) - DEFAULT_CHAT_FRAME:AddMessage( printPrefix .. tostring(message)) - self:Log(message) + self:GetSelectedChatWindow():AddMessage( printPrefix .. tostring(message)) end function addon:GetCurrentInventory() diff -r 52f691a2a3a4 -r 234896be4087 Modules/Options.lua --- a/Modules/Options.lua Wed Jul 21 22:40:21 2010 -0700 +++ b/Modules/Options.lua Thu Jul 22 23:17:57 2010 -0700 @@ -12,6 +12,52 @@ -- craftingThresholdsDisplay[key] = value end +local windowIndex = nil +function addon:GetChatWindowList() + local windows = {} + for i=1, NUM_CHAT_WINDOWS do + local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i) + if (name ~= "") and (docked or shown) then + windows[i] = name + end + end + return windows +end + +function addon:GetChatWindowIndex() + local cf = self.db.char.output_chat_frame + if not windowIndex then + for i=1, NUM_CHAT_WINDOWS do + local name, _, _, _, _, _, shown, locked, docked = GetChatWindowInfo(i) + if name ~= "" and cf ~= nil and cf == name then + self:SetChatWindow(nil, i) + end + end + end + return windowIndex +end + + +local selectedWindow = nil + +function addon:SetChatWindow(info, index) + windowIndex = index + local name = GetChatWindowInfo(windowIndex) + + self.db.char.output_chat_frame = name + selectedWindow = nil +end + +function addon:GetSelectedChatWindow() + if not selectedWindow then + selectedWindow = _G["ChatFrame"..self:GetChatWindowIndex()] + end + if (selectedWindow) then + return selectedWindow + end + return DEFAULT_CHAT_FRAME +end + local options = { handler = addon, name = "ItemAuditor", @@ -57,6 +103,14 @@ disabled = 'IsQADisabled', order = 1, }, + output = { + type = "select", + name = "Output", + desc = "", + values = 'GetChatWindowList', + get = 'GetChatWindowIndex', + set = 'SetChatWindow', + }, }, },