---------------------------------------------------------------------------------
--
-- Prat - A framework for World of Warcraft chat mods
--
-- Copyright (C) 2006-2007  Prat Development Team
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License
-- as published by the Free Software Foundation; either version 2
-- of the License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to:
--
-- Free Software Foundation, Inc., 
-- 51 Franklin Street, Fifth Floor, 
-- Boston, MA  02110-1301, USA.
--
--
-------------------------------------------------------------------------------



--[[
Name: PratAddonMsgs
Revision: $Revision: 30740 $
Author(s): Sylvanaar (sylvanaar@mindspring.com)
Website: http://www.wowace.com/files/index.php?path=Prat/
Documentation: http://www.wowace.com/wiki/Prat/Integrated_Modules#AddonMsgs
Subversion: http://svn.wowace.com/wowace/trunk/Prat/
Discussions: http://groups.google.com/group/wow-prat
Issues and feature requests: http://code.google.com/p/prat/issues/list
Description: Module for Prat that toggles showing hidden addon messages on and off (default=off).
Dependencies: Prat
]]

-- set prat module name
local PRAT_MODULE = Prat:RequestModuleName("PratAddonMsgs")

-- define localized strings
local L = AceLibrary("AceLocale-2.2"):new(PRAT_MODULE)

L:RegisterTranslations("enUS", function() return {
    ["AddonMsgs"] = true,
    ["Addon message options."] = true,
    ["show_name"] = "Show Addon Messages",
    ["show_desc"] = "Toggle showing hidden addon messages on and off for each window.",
    ["show_perframename"] = "Chat%dAddonMsgsShow",
    ["show_perframedesc"] = "Toggle showing hidden addon messages on and off for chat window %d.",
} end)

L:RegisterTranslations("deDE", function() return {
    ["AddonMsgs"] = "Addon Nachrichten",
    ["Addon message options."] = "Chatfenster Addon Nachrichten Optionen.",
    ["show_name"] = "Zeige Addon Nachrichten",
    ["show_desc"] = "Schaltet das Anzeigen von verborgenen Addon Nachrichten an und aus f\195\188r jedes Fenster.",
    ["show_perframename"] = "Chat %d Addon Nachricht Anzeigen",
    ["show_perframedesc"] = "Schaltet das Anzeigen von verborgenen Addon Nachrichten ein und aus  f\195\188r Chat Fenster %d.",
} end)

L:RegisterTranslations("frFR", function() return {
    ["AddonMsgs"] = "Messages des Addons",
    ["Addon message options."] = "Options des messages d'addon.",
    ["show_name"] = "Afficher les messages des addons",
    ["show_desc"] = "Active/d\195\169sactive les messages des addons pour chaque fen\195\170tre.",
    ["show_perframename"] = "Chat %d : Afficher les messages des addons",
    ["show_perframedesc"] = "Active/d\195\169sactive les messages des addons dans la fen\195\170tre %d.",
} end)

L:RegisterTranslations("esES", function() return {
    ["AddonMsgs"] = "Mensajes de Accesorio",
    ["Addon message options."] = "Opciones de Mensajes de Accesorio",
    ["show_name"] = "Mostrar",
    ["show_desc"] = "Determina si se muestran los mensajes ocultos de accesorio para cada ventana.",
    ["show_perframename"] = "Mostrar Mensajes en Chat %d",
    ["show_perframedesc"] = "Determina si se muestran los mensajes de accesorio para la ventana de chat %d."
} end)

L:RegisterTranslations("koKR", function() return {
    ["AddonMsgs"] = "애드온메세지",
    ["Addon message options."] = "애드온 메세지 설정입니다.",
    ["show_name"] = "애드온 메세지 표시",
    ["show_desc"] = "각각의 대화창에 숨겨진 애드온 메세지를 표시합니다.",
    ["show_perframename"] = "대화창%d애드온메세지표시",
    ["show_perframedesc"] = "대화창%d에 숨겨진 애드온 메세지를 표시합니다.",
} end)

L:RegisterTranslations("zhTW", function() return {
    ["AddonMsgs"] = "插件訊息",
    ["Addon message options."] = "插件訊息選項",
    ["show_name"] = "顯示插件訊息",
    ["show_desc"] = "切換是否在每個視窗顯示插件訊息。",
    ["show_perframename"] = "在視窗%d顯示插件訊息",
    ["show_perframedesc"] = "選擇是否在聊天視窗%d顯示隱藏的插件訊息。"
} end)

-- L:RegisterTranslations("zhCN", function() return {
--     ["AddonMsgs"] = "插件信息",
--     ["Addon message options."] = "插件信息设置",
--     ["show_name"] = "显示",
--     ["show_desc"] = "选择是否在每个窗口显示插件信息",
--     ["show_perframename"] = "在窗口%d显示插件信息",
--     ["show_perframedesc"] = "选择是否在聊天窗口%d显示隐藏的插件信息."
-- } end)

-- get prat module categories
local cat = Prat.Categories

-- create prat module
Prat_AddonMsgs = Prat:NewModule(PRAT_MODULE)
Prat_AddonMsgs.revision = tonumber(string.sub("$Revision: 30740 $", 12, -3))

-- define key module values
Prat_AddonMsgs.moduleName = L["AddonMsgs"]
Prat_AddonMsgs.moduleDesc = L["Addon message options."]
Prat_AddonMsgs.consoleName = "addonmsgs"
Prat_AddonMsgs.guiName = L["AddonMsgs"]
Prat_AddonMsgs.Categories = { cat.DEV, cat.INFO }

-- define the default db values
Prat_AddonMsgs.defaultDB = {
    on = false,
    show = {false, false, false, false, false, false, false},
}

-- build the options menu using prat templates
Prat_AddonMsgs.toggleOptions = { show={} }

--[[------------------------------------------------
    Module Event Functions
------------------------------------------------]]--

-- things to do when the module is enabled
function Prat_AddonMsgs:OnModuleEnable()
    -- register events
    self:RegisterEvent("CHAT_MSG_ADDON")
end

-- things to do when the module is disabled
function Prat_AddonMsgs:OnModuleDisable()
    -- unregister events
    self:UnregisterAllEvents()
end

--[[------------------------------------------------
    Core Functions
------------------------------------------------]]--

-- add a splash of color to text
function CLR:arg1(text) return self:Colorize("ffff40", text) end
function CLR:arg2(text) return self:Colorize("a0a0a0", text) end
function CLR:arg3(text) return self:Colorize("40ff40", text) end
function CLR:arg4(text) return self:Colorize("4040ff", text) end

-- show hidden addon channel messages
function Prat_AddonMsgs:CHAT_MSG_ADDON()
    for i=1,NUM_CHAT_WINDOWS do
        if self.db.profile.show[i] then
            getglobal("ChatFrame"..i):AddMessage("["..CLR:arg1(arg1).."]["..CLR:arg2(arg2).."]["..CLR:arg3(arg3).."]["..CLR:arg4(arg4).."]")
        end
    end
end