------------------------------------
-- dugu 2009-12-22

if (GetLocale() == "zhCN") then
	QUEST_TITLE						= "任务增强";
	QUESTHUBBER_ENABLE					= "显示可接任务";
	QUEST_INFO_ENABLE					= "开启任务指引";
	QUEST_INFO_ENABLE_DESC				= "规划任务路径并用箭头给以指引";
	QUEST_INFO_OPTION					= "打开设置";
	QUEST_INFO_AUTOUPDATE				= "自动更新任务标记";
	QUEST_INFO_MINIMAP_ICONS			= "显示小地图任务标记";
	QUEST_INFO_QUESTHELPER				= "使用大脚任务方式";
	FASTQUEST_TOGGLE_DESC				= "开启多玩任务增强";
	FASTQUEST_AUTONOTIFY_TITLE			= "自动向队友通报任务进展";
	FASTQUEST_NOTIFYDETAIL_TITLE			= "详尽通报任务进度";
	FASTQUEST_DOUBLEWIDTH_TITLE			= "双倍任务窗口宽度";	
	FASTQUEST_QUESTFORMAT_TITLE			= "显示任务等级和类型";
	FASTQUEST_COLOR_TITLE				= "在追踪窗口显示任务颜色";
	FASTQUEST_LOCK_TITLE				= "锁定任务追踪窗口";
	FASTQUEST_AUTOADD_TITLE				= "自动增加追踪任务";
	FASTQUEST_AUTOCOMPLETE_TITLE		= "自动完成任务";
	FASTQUEST_SORT_TYPE_TITLE			= "优先按照距离排序";
	FASTQUEST_AUTOCOLLAPSE_TITLE			= "副本中自动收起任务追踪";
	FASTQUEST_AUTO_CHOICE_TITLE			= "自动选择任务推荐(最贵)物品";
	QUEST_HELPER_ONLY_WATCH			= "只显示追踪的任务";
	DUOWAN_TURN_IN_TITLE				= "自动交接任务";
	DUOWAN_TURN_IN_DESC				= "与NPC交谈时自动交接任务";
	
	QUEST_TOMTOM = "启用导航助手";
	QUEST_TOMTOM_CLOSEST = "自动任务目标路径点";
	QUEST_TOMTOM_BLOCK = "坐标模块";
	QUEST_TOMTOM_TIP = "启用箭头指引";
	
	QUEST_DuowanQuestEnable = "启用任务增强"
	QUEST_DuowanQuestOpenCfg = "打开设置"
	DuowanWorldQuestTracker = "世界任务追踪"
elseif (GetLocale() == "zhTW") then
	QUEST_TITLE						= "任務增強";
	QUESTHUBBER_ENABLE					= "顯示可接任務";
	QUEST_INFO_ENABLE					= "開啟任務指引";
	QUEST_INFO_ENABLE_DESC				= "規劃任務路徑並用箭頭給以指引";
	QUEST_INFO_OPTION					= "打開配置";
	QUEST_INFO_AUTOUPDATE				= "自動更新任務標記";
	QUEST_INFO_MINIMAP_ICONS			= "顯示小地圖任務標記";
	QUEST_INFO_QUESTHELPER				= "使用大腳任務方式";
	FASTQUEST_TOGGLE_DESC				= "開啟增強任務日誌";	
	FASTQUEST_AUTONOTIFY_TITLE			= "自動向隊友通報任務進展";
	FASTQUEST_NOTIFYDETAIL_TITLE			= "詳盡通報任務進度";
	FASTQUEST_DOUBLEWIDTH_TITLE			= "雙倍任務窗口寬度";	
	FASTQUEST_QUESTFORMAT_TITLE			= "顯示任務等級和類型";
	FASTQUEST_COLOR_TITLE				= "在追蹤視窗顯示任務顏色";
	FASTQUEST_LOCK_TITLE				= "鎖定任務追蹤窗口";
	FASTQUEST_AUTOADD_TITLE				= "自動增加追蹤任務";
	FASTQUEST_AUTOCOMPLETE_TITLE		= "自動完成任務";
	FASTQUEST_SORT_TYPE_TITLE			= "優先按照距離排序";
	FASTQUEST_AUTOCOLLAPSE_TITLE			= "副本中自動收起任務追蹤";
	FASTQUEST_AUTO_CHOICE_TITLE			= "自動選擇任務推薦(最貴)物品";
	QUEST_HELPER_ONLY_WATCH			= "只顯示追蹤的任務";
	DUOWAN_TURN_IN_TITLE				= "自動交接任務";
	DUOWAN_TURN_IN_DESC				= "與NPC交談時自動交接任務";
	
	QUEST_TOMTOM = "啓用導航助手";
	QUEST_TOMTOM_CLOSEST = "自動任務目標路徑點";
	QUEST_TOMTOM_BLOCK = "從標模塊";
	QUEST_TOMTOM_TIP = "啓用箭頭指引";
	QUEST_DuowanQuestEnable = "啓用任務增強"
	QUEST_DuowanQuestOpenCfg = "打開設置"
	DuowanWorldQuestTracker = "世界任务追踪"
else
	QUEST_TITLE						= "任务增强";
	QUESTHUBBER_ENABLE					= "显示可接任务";
	QUEST_INFO_ENABLE					= "开启任务查询";
	QUEST_INFO_OPTION					= "打开配置";
	QUEST_INFO_AUTOUPDATE				= "自动更新任务标记";
	QUEST_INFO_MINIMAP_ICONS			= "显示小地图任务标记";
	QUEST_INFO_QUESTHELPER				= "使用大脚任务方式";
	FASTQUEST_TOGGLE_DESC				= "开启增强任务日志";
	FASTQUEST_AUTONOTIFY_TITLE			= "自动向队友通报任务进展";
	FASTQUEST_NOTIFYDETAIL_TITLE			= "详尽通报任务进度";
	FASTQUEST_DOUBLEWIDTH_TITLE			= "双倍任务窗口宽度";	
	FASTQUEST_QUESTFORMAT_TITLE			= "显示任务等级和类型";
	FASTQUEST_COLOR_TITLE				= "在追踪窗口显示任务颜色";
	FASTQUEST_LOCK_TITLE				= "锁定任务追踪窗口";
	FASTQUEST_AUTOADD_TITLE				= "自动新增/移除任务";
	FASTQUEST_AUTOCOMPLETE_TITLE		= "自动完成任务";
	FASTQUEST_SORT_TYPE_TITLE			= "优先按照距离排序";
	FASTQUEST_AUTOCOLLAPSE_TITLE			= "副本中自动收起任务追踪";
	FASTQUEST_AUTO_CHOICE_TITLE			= "自动选择任务推荐(最贵)物品";
	QUEST_HELPER_ONLY_WATCH			= "只显示追踪的任务";
	DUOWAN_TURN_IN_TITLE				= "自动交接任务";
	DUOWAN_TURN_IN_DESC				= "与NPC交谈时自动交接任务";
	QUEST_TOMTOM = "启用导航助手";
	QUEST_TOMTOM_CLOSEST = "自动任务目标路径点";
	QUEST_TOMTOM_BLOCK = "坐标模块";	
	QUEST_TOMTOM_TIP = "启用箭头指引";
	QUEST_DuowanQuestEnable = "启用任务增强"
	QUEST_DuowanQuestOpenCfg = "打开设置"
	DuowanWorldQuestTracker = "世界任务追踪"
end

if dwIsConfigurableAddOn("QuestHelperLite") or dwIsConfigurableAddOn("QuestHubber") or dwIsConfigurableAddOn("DuowanQuest") or dwIsConfigurableAddOn("TurnIn") then
	dwRegisterMod(
		"QuestMod",
		QUEST_TITLE,
		"QUEST",
		"",
		"Interface\\ICONS\\INV_Misc_Book_08",
		nil
	);
end

if (dwIsConfigurableAddOn("QuestHelperLite")--[[ or dwIsConfigurableAddOn("QuestHelper")]]) then
	dwRegisterCheckButton(
		"QuestMod",
		QUEST_INFO_ENABLE,
		QUEST_INFO_ENABLE_DESC,
		"QuestHelperLiteEnable",
		0,
		function (arg)		
			if(arg==1)then			
				if (not dwIsAddOnLoaded("QuestHelperLite")) then
					dwLoadAddOn("QuestHelperLite");
				end
			else
				if (dwIsAddOnLoaded("QuestHelperLite")) then
					dwRequestReloadUI(nil);
				end
			end
		end
	);

	dwRegisterButton(
		"QuestMod",
		QUEST_INFO_OPTION, 
		function()			
			if (dwIsAddOnLoaded("QuestHelperLite")) then
				--HideUIPanel(DuowanConfigFrame);
				QuestHelperLite:OpenOptions();
			end
		end, 
		1
	);	
end


if (dwIsConfigurableAddOn("TurnIn")) then
	dwRegisterCheckButton(
		"QuestMod",
		DUOWAN_TURN_IN_TITLE,
		DUOWAN_TURN_IN_DESC,
		"EnableTurnIn",
		0,
		function (arg)
			if(arg==1)then
				if (not dwIsAddOnLoaded("TurnIn")) then
					dwLoadAddOn("TurnIn");
				end
				if (dwIsAddOnLoaded("TurnIn")) then
					dwTurnIn_Toggle(true);
				end
			else
				if (dwIsAddOnLoaded("TurnIn")) then
					dwTurnIn_Toggle(false);
				end				
			end
		end
	);

	if (dwIsConfigurableAddOn("DuowanQuest")) then
		dwRegisterCheckButton(
			"QuestMod",
			FASTQUEST_AUTOCOMPLETE_TITLE	,
			nil,
			"AutoComplete",
			0,
			function (arg)			
				if (arg == 1) then	
					if (dwIsAddOnLoaded("DuowanQuest")) then
						DuowanQuest:AutoComplete_Toggle(true);
					end
				else			
					if (dwIsAddOnLoaded("DuowanQuest")) then
						DuowanQuest:AutoComplete_Toggle(false);
					end
				end
			end
		);
	end
end

if dwIsConfigurableAddOn("Wholly") then
	local check = CreateFrame("CheckButton", "QuestHubberLoaderCheckButton", WorldMapDetailFrame, "InterfaceOptionsBaseCheckButtonTemplate");
	check:SetWidth(28);
	check:SetHeight(28);	
	check:SetPoint("TOPLEFT", WorldMapDetailFrame, "TOPLEFT", 5, -2);
	check:SetFrameLevel(check:GetFrameLevel()+2);
	local font, size = GameTooltipHeader:GetFont();
	check.text = check:CreateFontString();
	check.text:SetFont(font, 20, "OUTLINE");
	check.text:SetTextColor(1, 1, 1, 1);
	check.text:SetText(QUESTHUBBER_ENABLE);
	check.text:SetPoint("LEFT", check, "RIGHT");
	check:RegisterEvent("ADDON_LOADED");

	local function loadWholly()
		if (not dwIsAddOnLoaded("Grail")) then
			dwLoadAddOn("Grail");
		end
		if (not dwIsAddOnLoaded("Wholly")) then
			dwLoadAddOn("Wholly");
		end
	end

	check:SetScript("OnClick", function(self, button)
		if (self:GetChecked()) then
			loadWholly();
			WhollyDatabase.displaysMapPins = true;
			Wholly.pairedConfigurationButton:SetChecked(true);
			dwSetCVar("QuestMod", "QHubberEnableNew", 1);
		else
			WhollyDatabase.displaysMapPins = false;
			Wholly.pairedConfigurationButton:SetChecked(false);
			dwSetCVar("QuestMod", "QHubberEnableNew", 0);
		end
		Wholly:_UpdatePins();
	end);
	

	dwRegisterCheckButton(
		"QuestMod",
		QUESTHUBBER_ENABLE,
		DUOWAN_RELOAD_DESC,
		"QHubberEnableNew",
		0,
		function (arg)			
			if(arg==1)then
				loadWholly();
				if (dwIsAddOnLoaded("Wholly")) then
					WhollyDatabase.displaysMapPins = true;
					Wholly.pairedConfigurationButton:SetChecked(true);
					check:SetChecked(true);
					Wholly:_UpdatePins();
				end
			else
				if (dwIsAddOnLoaded("Wholly")) then
					WhollyDatabase.displaysMapPins = false;
					Wholly.pairedConfigurationButton:SetChecked(false);
					check:SetChecked(false);
					Wholly:_UpdatePins();
				end		
			end
		end
	);
end

if (dwIsConfigurableAddOn("TomTom")) then
	dwRegisterCheckButton(
		"QuestMod",
		QUEST_TOMTOM,
		QUEST_TOMTOM_TIP,
		"TomTomEnabled",
		0,
		function (arg)
			if(arg==1)then
				if (not dwIsAddOnLoaded("TomTom")) then
					dwLoadAddOn("TomTom");
					Duowan_TomTom_Toggle();
				end
			else
				if (dwIsAddOnLoaded("TomTom")) then
					dwRequestReloadUI(nil);
				end				
			end
		end
	);
	dwRegisterCheckButton(
		"QuestMod",
		QUEST_TOMTOM_CLOSEST,
		nil,
		"TomTomEnabledClosest",
		1,
		function (arg)
			if (dwIsAddOnLoaded("TomTom")) then
				Duowan_TomTom_Toggle_Closest(arg)
			end
		end,
		1
	);
	dwRegisterCheckButton(
		"QuestMod",
		QUEST_TOMTOM_BLOCK,
		nil,
		"TomTomEnabledBlock",
		1,
		function (arg)
			if (dwIsAddOnLoaded("TomTom")) then
				Duowan_TomTom_Toggle_Block(arg)
			end
		end,
		1
	);
end;

if (dwIsConfigurableAddOn("DuowanQuest")) then 
	dwRegisterCheckButton(
		"QuestMod",
		QUEST_DuowanQuestEnable,
		nil,
		"DuowanQuestEnable",
		1,
		function (arg)			
			if ( arg == 1 ) then
				if not dwIsAddOnLoaded("DuowanQuest") then
					dwLoadAddOn("DuowanQuest");
				end
			else
				if dwIsAddOnLoaded("DuowanQuest") then
					dwRequestReloadUI(nil);
				end
			end
		end
	);
	
	dwRegisterButton(
		"QuestMod",
		QUEST_DuowanQuestOpenCfg, 
		function()
			if (dwIsAddOnLoaded("DuowanQuest")) then
				InterfaceOptionsFrame_OpenToCategory(LibStub("AceAddon-3.0"):GetAddon("Quester").optFrame);
				InterfaceOptionsFrame_OpenToCategory(LibStub("AceAddon-3.0"):GetAddon("Quester").optFrame);
			end
		end, 
		1
	);
	dwRegisterCheckButton(
		"QuestMod",
		FASTQUEST_AUTOCOLLAPSE_TITLE	,
		nil,
		"AutoCollapse",
		1,
		function (arg)			
			if (arg == 1) then	
				if (dwIsAddOnLoaded("DuowanQuest")) then
				--	DuowanQuest:AutoCollapse_Toggle(true);
				end
			else			
				if (dwIsAddOnLoaded("DuowanQuest")) then
				--	DuowanQuest:AutoCollapse_Toggle(false);
				end
			end
		end,
		1
	);	
end

if (dwIsConfigurableAddOn("WorldQuestTracker")) then 
	dwRegisterCheckButton(
		"QuestMod",
		DuowanWorldQuestTracker,
		nil,
		"DuowanWorldQuestTrackertEnable",
		0,
		function (arg)			
			if ( arg == 1 ) then
				if not dwIsAddOnLoaded("WorldQuestTracker") then
					dwLoadAddOn("WorldQuestTracker");
				end
			else
				if dwIsAddOnLoaded("WorldQuestTracker") then
					dwRequestReloadUI(nil);
				end
			end
		end
	);
end

--[[
if (dwIsConfigurableAddOn("DuowanQuest")) then
	local Quester = LibStub("AceAddon-3.0"):GetAddon("Quester")

	dwRegisterCheckButton(
		"QuestMod",
		QUEST_trackerMovable,
		nil,
		"QuesttrackerMovable",
		1,
		function (arg)			
			if (arg == 1) then		
				if (dwIsAddOnLoaded("DuowanQuest")) then
					Quester.db.trackerMovable = true;
					Quester:ToggleTrackerMovable()
				end
			else
				if (dwIsAddOnLoaded("DuowanQuest")) then
					Quester.db.trackerMovable = true;
					Quester:ToggleTrackerMovable()
				end
			end
		end
	);
	
	dwRegisterCheckButton(
		"QuestMod",
		QUEST_questLevel,
		nil,
		"QuestquestLevel",
		1,
		function (arg)			
			if (arg == 1) then		
				if (dwIsAddOnLoaded("DuowanQuest")) then
					Quester.db.questLevels = true;
				end
			else
				if (dwIsAddOnLoaded("DuowanQuest")) then
					Quester.db.questLevels = false;			
				end
			end
		end,
		1
	);
	
	dwRegisterCheckButton(
		"QuestMod",
		QUEST_highlightReward,
		nil,
		"QuesthighlightReward",
		1,
		function (arg)			
			if (arg == 1) then				
				if (dwIsAddOnLoaded("DuowanQuest")) then
					Quester.db.highlightReward = true;
				end	
			else
				if (dwIsAddOnLoaded("DuowanQuest")) then
					Quester.db.highlightReward = false;		
				end
			end
		end
	);

	dwRegisterCheckButton(
		"QuestMod",
		FASTQUEST_AUTONOTIFY_TITLE,
		nil,
		"EnableAutoNotify",
		1,
		function (arg)
			if (arg == 1) then
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:AutoNotify_Toggle(true);
				end
			else
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:AutoNotify_Toggle(false);
				end
			end
		end,
		1
	);
	
	dwRegisterCheckButton(
		"QuestMod",
		FASTQUEST_NOTIFYDETAIL_TITLE,
		nil,
		"EnableNotifyDetail",
		1,
		function (arg)			
			if (arg == 1) then	
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:Detail_Toggle(true);
				end
			else
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:Detail_Toggle(false);	
				end
			end
		end,
		2
	);
	dwRegisterCheckButton(
		"QuestMod",
		FASTQUEST_QUESTFORMAT_TITLE,
		nil,
		"EnableQuestFormat",
		1,
		function (arg)			
			if (arg == 1) then
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:QuestLevel_Toggle(true);
				end
			else
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:QuestLevel_Toggle(false);
				end
			end
		end,
		1
	);
	dwRegisterCheckButton(
		"QuestMod",
		FASTQUEST_AUTOADD_TITLE,
		nil,
		"AutoAdd",
		1,
		function (arg)			
			if (arg == 1) then		
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:AutoAdd_Toggle(true);
				end
			else	
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:AutoAdd_Toggle(false);
				end
			end
		end,
		1
	);

	
	dwRegisterCheckButton(
		"QuestMod",
		FASTQUEST_AUTO_CHOICE_TITLE	,
		nil,
		"AutoChoice",
		1,
		function (arg)			
			if (arg == 1) then	
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:AutoChoice_Toggle(true);
				end
			else			
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:AutoChoice_Toggle(false);
				end
			end
		end,
		1
	);	
	
	dwRegisterCheckButton(
		"QuestMod",
		FASTQUEST_SORT_TYPE_TITLE	,
		nil,
		"SortType",
		1,
		function (arg)			
			if (arg == 1) then	
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:SortDistance_Toggle(true, "QuestMod");
				end
			else			
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:SortDistance_Toggle(false, "QuestMod");
				end
			end
		end,
		1
	);

	dwRegisterCheckButton(
		"QuestMod",
		FASTQUEST_AUTOCOLLAPSE_TITLE	,
		nil,
		"AutoCollapse",
		1,
		function (arg)			
			if (arg == 1) then	
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:AutoCollapse_Toggle(true);
				end
			else			
				if (dwIsAddOnLoaded("DuowanQuest")) then
					DuowanQuest:AutoCollapse_Toggle(false);
				end
			end
		end,
		1
	);
end]]