diff Modules/Options.lua @ 55:234896be4087

Adding an option to direct ItemAuditor output to a different chat frame
author Asa Ayers <Asa.Ayers@Gmail.com>
date Thu, 22 Jul 2010 23:17:57 -0700
parents 003de902ae64
children 8afc1ac9bf58
line wrap: on
line diff
--- 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',
+				},
 			},
 		},