---------------------------------------------------------------------------------
--
-- 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: PratEventNames
Revision: $Revision: 25896 $
Author(s): Sylvanaar
Website: http://www.wowace.com/files/index.php?path=Prat/
Documentation: http://www.wowace.com/wiki/Prat/Integrated_Modules#EventNames
SVN: http://svn.wowace.com/wowace/trunk/Prat/
Description: Module for Prat that toggles showing hidden addon messages on and off (default=off).
Dependencies: Prat
]]

local L = AceLibrary("AceLocale-2.2"):new("PratEventNames")

L:RegisterTranslations("enUS", function() return {
    ["EventNames"] = true,
    ["Chat window event name options."] = true,
    ["show_name"] = "Show Events",
    ["show_desc"] = "Toggle showing event names on and off for each window.",
    ["show_perframename"] = "Chat%dEventNamesShow",
    ["show_perframedesc"] = "Toggles showing event names on and off for chat window %d.",
} end)

L:RegisterTranslations("frFR", function() return {
    ["EventNames"] = "Noms des \195\169venements",
    ["Chat window event name options."] = "Options d'affichage des \195\169v\195\168nements des fen\195\170tres.",
    ["show_name"] = "Afficher les \195\169v\195\168nements",
    ["show_desc"] = "Activer/d\195\169sactiver l'affichage des noms d'\195\169v\195\168nements pour chaque fen\195\170tre.",
    ["show_perframename"] = "Affichage des \195\169v\195\168nements de la fen\195\170tre %d",
    ["show_perframedesc"] = "Active/d\195\169sactive l'affichage des \195\169v\195\168nements de la fen\195\170tre %d.",
} end)

-- L:RegisterTranslations("zhCN", function() return {
--     ["EventNames"] = "事件名称",
--     ["EventNames options."] = "事件名称设置",
--     ["Toggle"] = "切换",
--     ["Toggle the module on and off."] = "切换此模块打开与关闭",
--     ["Show"] = "显示",
--     ["Toggle showing event names for each window."] = "切换是否在每个窗口显示事件名称",
--     ["Chat%dEventNamesShow"] = "显示窗口%d事件名称",
--     ["Toggles showing event names on and off for chat window %d."] = "切换是否在聊天窗口%d显示事件名称."
-- } end)

L:RegisterTranslations("koKR", function() return {
    ["EventNames"] = "이벤트명",
    ["Chat window event name options."] = "대화창 이벤트명 설정입니다.",
    ["show_name"] = "이벤트명 표시",
    ["show_desc"] = "각각의 대화창에 이벤트명을 표시합니다.",
    ["show_perframename"] = "대화%d이벤트명표시",
    ["show_perframedesc"] = "대화창 %d에 이벤트명을 표시합니다."
} end)

-- L:RegisterTranslations("zhTW", function() return {
--     ["EventNames"] = "事件名稱",
--     ["EventNames options."] = "事件名稱選項。",
--     ["Toggle"] = "切換",
--     ["Toggle the module on and off."] = "切換打開或關閉此模組。",
--     ["Show"] = "顯示",
--     ["Toggle showing event names for each window."] = "切換是否在每個視窗顯示事件名稱。",
--     ["Chat%dEventNamesShow"] = "顯示視窗%d事件名稱",
--     ["Toggles showing event names on and off for chat window %d."] = "切換是否在聊天視窗%d顯示事件名稱。"
-- } end)

L:RegisterTranslations("esES", function() return {
    ["EventNames"] = "Nombres de Evento",
    ["Chat window event name options."] = "Opciones de nombres de evento",
    ["show_name"] = "Mostrar Eventos",
    ["show_desc"] = "Determina si se muestran los nombres de evento para cada ventana",
    ["show_perframename"] = "Mostrar Nombres de Evento en el Chat %d",
    ["show_perframedesc"] = "Determina si se muestran los nombres de evento en la ventana %d"
} end)

L:RegisterTranslations("deDE", function() return {
	["EventNames"] = "Event Namen",
	["Chat window event name options."] = "Chatfenster Event Namen Optionen.",
	["show_name"] = "Zeige Name",
	["show_desc"] = "Aktiviert das Anzeigen von Event Namen in jedem Fenster.",
	["show_perframename"] = "Chat %d Event Namen Anzeigen",
	["show_perframedesc"] = "Schaltet das Anzeigen von Event Namen an und aus f\195\188r Chat Fenster %d."
} end)

Prat_EventNames = Prat:NewModule(Prat:RequestModuleName("PratEventNames"))

Prat_EventNames.revision = tonumber(string.sub("$Revision: 25896 $", 12, -3))

--Prat_EventNames.consoleCmd = "eventnames"

Prat_EventNames.defaultDB = {
    on = true,
    show = {false, false, false, false, false, false, false},
}

Prat_EventNames.moduleOptions = {}
Prat_EventNames.toggleOptions = { show={} }

-- Set this to true to use Prat Event Support
Prat_EventNames.supportsPratEvents = true

local cat = Prat.Categories
Prat_EventNames.Categories = { cat.DEV, cat.IMFO }


function Prat_EventNames:GetModuleOptions()
    self.moduleOptions = {
        name = L["EventNames"],
        desc = L["Chat window event name options."],
        type = "group",
        args = {
        }
    }
   	return self.moduleOptions
end


function Prat_EventNames:OnModuleEnable()
	self:RegisterEvent("Prat_PreAddMessage")
end

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

function CLR:EventBrackets(text) return self:Colorize("ffffff", text) end
function CLR:EventName(text, c)  return self:Colorize(c, text) end

--
-- Prat Event Implementation
--

function Prat_EventNames:Prat_PreAddMessage(message, frame, t, r, g, b)
	if self.db.profile.show[frame:GetID()] then
		local c = ("%02x%02x%02x"):format((r or 1.0)*192*0.7+63, (g or 1.0)*192*0.7+63, (b or 1.0)*192*0.7+63)
		self:Debug(tostring(event))
		message.POST =  "  "..CLR:EventBrackets("(")..CLR:EventName(tostring(event), c)..CLR:EventBrackets(")")
	end
end