---------------------------------------------------------------------------------
--
-- 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: Prat_Presets
Revision: $Revision: 31363 $
-- !!
Your Name (sylvanaar@mindspring.com)
Author(s):  ( sylvanaar )
Website: http://files.wowace.com/Prat/
Documentation: http://www.wowace.com/wiki/Prat/Integrated_Modules#Presets
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: Preset Prat configurations to help get you started (default=off).
Dependencies: Prat
]]

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

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

L:RegisterTranslations("enUS", function() return {
	["Presets"] = true,
	["Preset Prat configurations to help get you started"] = true,
	["AllOff_name"] = "All Modules Off",
	["AllOff_desc"] = "Turn everything off so you can just turn on what you want.",
	["BasicTimeStamps_name"] = "Basic Time Stamps",
	["BasicTimeStamps_desc"] = "Enable very basic time stamps in a grey color.",
	["ChannelNameRemove_name"] = "Remove Chat Prefixes",
	["ChannelNameRemove_desc"] = "Removes Guild, Say, Party Prefixes",
	} end)

L:RegisterTranslations("deDE", function() return {
	["Presets"] = "Voreinstellungen",
	["Preset Prat configurations to help get you started"] = "Prat Konfigurations Voreinstellungen um dir zu helfen neu anzufangen mit Prat",
	["AllOff_name"] = "Alle Modules Aus",
	["AllOff_desc"] = "Schaltet alles aus so das du ausw\195\164hlen kannst was du brauchst.",
	} end)

L:RegisterTranslations("koKR", function() return {
	["Presets"] = "Presets",
	["Preset Prat configurations to help get you started"] = "Preset Prat configurations to help get you started",
	["AllOff_name"] = "모든 모듈 끄기",
	["AllOff_desc"] = "당신이 원하는 모듈만 켤 수 있도록 모든 모듈을 끕니다.",
	["BasicTimeStamps_name"] = "기본 타임 스탬프",
	["BasicTimeStamps_desc"] = "회색으로 표시되는 기본 타임스탬프를 사용합니다.",
	["ChannelNameRemove_name"] = "기본 채널명 제거",
	["ChannelNameRemove_desc"] = "길드,일반,파티 채널명 제거",
	} end)

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

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

-- define key module values
Prat_Presets.moduleName	    = L["Presets"] 	
Prat_Presets.consoleName	= string.lower(Prat_Presets.moduleName)
Prat_Presets.guiName		= Prat_Presets.moduleName

Prat_Presets.moduleHidden = true

-- categories the module is related to, eg "{ cat.TEXT, cat.INFO }"
-- list here: http://groups-beta.google.com/group/wow-prat/web/prat-categories
-- !!
Prat_Presets.Categories	= { cat.FORMATTING, cat.BEHAVIOUR }

-- init moduleOoptions (populated by the other various options tables below)
Prat_Presets.moduleOptions = {}

local function DUMP_MODULE(...) DBG:Dump("MODULE", ...) end
local function PresetOpt(t, n)
    t[string.lower(n)] = {    
        name=L[n.."_name"],
        desc = L[n.."_desc"],
        type="execute",
        func=n 
        }
end
                

-- default values for any settings that need them
Prat_Presets.defaultDB = {
	on	= false,
	}


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

function Prat_Presets:GetModuleOptions()
    self.moduleOptions = {
        type = "group",
        name = L["Presets"],
        desc = L["Preset Prat configurations to help get you started"],
        order = 349,
        hidden = false,
        args = {
        }
    }
    
    local t = self.moduleOptions.args
    
    PresetOpt(t, "AllOff")
    
    PresetOpt(t, "BasicTimeStamps")

    PresetOpt(t, "ChannelNameRemove")

  
    Prat.Options.args.optsep342 = {
            order = 348,
            type = 'header',
    }
 
  
    Prat.Options.args.presets = self.moduleOptions
    
    return self.moduleOptions 
end    

--[[------------------------------------------------
    Core Functions
------------------------------------------------]]--
function Prat_Presets:AllOff()
	for n,m in Prat:IterateModules() do
	    if not m.moduleHidden then 
    		m.db.profile.on = false
    		Prat:ToggleModuleActive(m, false)
    	end
	end
end

function Prat_Presets:BasicTimeStamps()
    local o = Prat_Timestamps.moduleOptions.args
    
    if not o.toggle.get() then 
       o.toggle.set(true)
    end
    
    if not o["separate"].get() then
        o["separate"].set(false)
    end
    
	o["setcolor"].set(0.6, 0.6, 0.6, 1.0)
	
	o["formatall"].set("[%X]")

end

function Prat_Presets:ChannelNameRemove()
    local o = Prat_ChannelNames.moduleOptions.args

    if not o.toggle.get() then 
        o.toggle.set(Prat_ChannelNames, true)
    end
    
    for chan, v in pairs(o) do
        if strsub(chan, 1, 7) ~= "channel" then
            if o[chan].type == "group" and type(o[chan].args.off.func) == "function" then 
                o[chan].args.off.func()
                o[chan].args.replace.set(true)
            end
        end
    end
end



--  Prat_ChannelNames.moduleOptions.args.battleground.args.off.func()