-- file:		UI_MM_MP_CREATE.SCRIPT
--


class "mp_options" (CUIWindow)

function mp_options:__init() super()
end

function mp_options:__finalize()
end

function mp_options:InitControls(x, y, xml, handler)

	self:SetAutoDelete	(true)
	xml:InitWindow			("tab_options:main", 0, self)

--	self.bk = xml:InitFrame("frame", self)
	xml:InitFrame("tab_options:frame_1", self)
	xml:InitFrame("tab_options:frame_2", self)
	xml:InitFrame("tab_options:frame_3", self)

--	xml:InitFrameLine("tab_options:vert_separator",		self)
--	xml:InitFrameLine("tab_options:vert_separator_2",	self)
	xml:InitFrameLine("tab_options:cap_network_connection",	self)
	xml:InitFrameLine("tab_options:cap_respawn_options",	self)
	xml:InitFrameLine("tab_options:cap_server_list",		self)
	xml:InitFrameLine("tab_options:cap_weather_options",	self)
	xml:InitFrameLine("tab_options:cap_spectator_options",	self)
	xml:InitFrameLine("tab_options:cap_demosave_options",	self)
	xml:InitStatic("tab_options:cap_damage_block",		self)
	xml:InitStatic("tab_options:cap_artreturn_time",	self)

	xml:InitStatic("tab_options:cap_friendly_fire",		self)
	xml:InitStatic("tab_options:cap_frag_limit",		self)
	xml:InitStatic("tab_options:cap_time_limit",		self)
	xml:InitStatic("tab_options:cap_artefact_stay",		self)
	xml:InitStatic("tab_options:cap_artefact_num",		self)
	xml:InitStatic("tab_options:cap_anomaly_time",		self)
	xml:InitStatic("tab_options:cap_warm_up_time",		self)
	xml:InitStatic("tab_options:cap_artefact_delay",	self)
	xml:InitStatic("tab_options:cap_starting_weather",	self)
	xml:InitStatic("tab_options:cap_rate_of_change",	self)
	xml:InitStatic("tab_options:cap_max_ping",			self)

--	xml:InitStatic("tab_options:public_server_t", self)
	
	handler.check_public_server			= xml:InitCheck("tab_options:check_public_server", 			self)
	handler.check_spectator				= xml:InitCheck("tab_options:check_spectator",				self)
	handler.check_allow_voting			= xml:InitCheck("tab_options:check_allow_voting",			self)
	handler.spin_max_ping				= xml:InitSpinNum("tab_options:spin_max_ping",				self)


	handler.check_damage_block			= xml:InitCheck("tab_options:check_damage_block",			self)
	handler.check_auto_team_balance		= xml:InitCheck("tab_options:check_auto_team_balance",		self)
	handler.check_auto_team_swap		= xml:InitCheck("tab_options:check_auto_team_swap",			self)
	handler.check_friendly_indicators	= xml:InitCheck("tab_options:check_friendly_indicators",	self)
	handler.check_friendly_names		= xml:InitCheck("tab_options:check_friendly_names",			self)
	handler.check_no_anmalies			= xml:InitCheck("tab_options:check_no_anmalies",			self)

	handler.check_spec_teamonly			= xml:InitCheck("tab_options:check_spec_teamonly",			self)
	handler.check_spec_freefly			= xml:InitCheck("tab_options:check_spec_freefly",			self)
	handler.check_spec_firsteye			= xml:InitCheck("tab_options:check_spec_firsteye",			self)
	handler.check_spec_lookat			= xml:InitCheck("tab_options:check_spec_lookat",			self)
	handler.check_spec_freelook			= xml:InitCheck("tab_options:check_spec_freelook",			self)

	handler.check_demosave				= xml:InitCheck("tab_options:check_demosave",				self)
	handler:Register					(handler.check_demosave, "check_demosave")

	handler.tab_respawn					= xml:InitTab("tab_options:radio_tab_respawn_options",		self)
	-- spin boxes
	handler.spin_friendly_fire			= xml:InitSpinFlt("tab_options:spin_friendly_fire",			self)
	handler.spin_artefacts_num			= xml:InitSpinNum("tab_options:spin_artefacts_num",			self)
	handler.spin_spectator				= xml:InitSpinNum("tab_options:spin_spectator",				self)
	handler.spin_force_respawn			= xml:InitSpinNum("tab_options:spin_force_respawn", 		self)
	handler.spin_reinforcement 			= xml:InitSpinNum("tab_options:spin_reinforcement", 		self)

	handler.spin_damage_block			= xml:InitSpinNum("tab_options:spin_damage_block",			self)
	handler.spin_artreturn_time			= xml:InitSpinNum("tab_options:spin_artreturn_time",		self)
	handler.check_activated_return		= xml:InitCheck("tab_options:check_activated_return",		self)
	handler.spin_frag_limit				= xml:InitSpinNum("tab_options:spin_frag_limit",			self)
	handler.spin_time_limit				= xml:InitSpinNum("tab_options:spin_time_limit",			self)
	handler.spin_artefact_stay			= xml:InitSpinNum("tab_options:spin_artefact_stay",			self)
	handler.spin_artefact_delay			= xml:InitSpinNum("tab_options:spin_artefact_delay",		self)
	handler.spin_anomaly_time			= xml:InitSpinNum("tab_options:spin_anomaly_time",			self)
	handler.spin_warm_up_time			= xml:InitSpinNum("tab_options:spin_warm_up_time",			self)

	handler.check_pda_hunt				= xml:InitCheck("tab_options:check_pda_hunt",				self)

	handler.spin_rate_of_change			= xml:InitSpinFlt("tab_options:spin_rate_of_change",		self)

	handler.spin_weather				= xml:InitComboBox("tab_options:spin_weather",				self)

	handler.check_spectator:SetDependControl(handler.spin_spectator)

--	handler.check_public_server:SetDependControl(handler.check_verify_cdkey)

--[[if (self.online) then
--		handler.check_public_server:SetCheck(true)
	else
--		handler.check_public_server:SetCheck(false)
	end]]
	

end

function mp_options:SetGameMode(mode, handler)
	handler.spin_friendly_fire:Enable(true)
	handler.check_auto_team_balance:Enable(true)
	handler.check_auto_team_swap:Enable(true)
	handler.spin_artefacts_num:Enable(true)
	handler.spin_artefact_delay:Enable(true)
	handler.spin_artefact_stay:Enable(true)
	handler.check_friendly_indicators:Enable(true)
	handler.check_friendly_names:Enable(true)
	handler.spin_reinforcement:Enable(true)
	handler.spin_frag_limit:Enable(true)
	handler.check_spec_teamonly:Enable(true)

	handler.spin_artreturn_time:Enable(true);
	handler.check_activated_return:Enable(true)


	local btn_reinforcement		= handler.tab_respawn:GetButtonById("reinforcement")
	local btn_artefactcapture	= handler.tab_respawn:GetButtonById("artefactcapture")
	btn_reinforcement:Enable	(true)
	btn_artefactcapture:Enable	(true)
	

	if GAME_TYPE.GAME_UNKNOWN ~= 0 then
		if GAME_TYPE.eGameIDDeathmatch == mode then
			handler.spin_friendly_fire:Enable(false)
			handler.check_auto_team_balance:Enable(false)
			handler.check_auto_team_swap:Enable(false)
			handler.spin_artefacts_num:Enable(false)
			handler.spin_artefact_delay:Enable(false)
			handler.spin_artefact_stay:Enable(false)
			handler.check_friendly_indicators:Enable(false)
			handler.check_friendly_names:Enable(false)
			handler.check_spec_teamonly:Enable(false)
			handler.spin_reinforcement:Enable(false)
			-- tab
			handler.tab_respawn:SetActiveTab("forcerespawn")
			btn_reinforcement:Enable(false)
			btn_artefactcapture:Enable(false)
			handler.spin_artreturn_time:Enable(false);
			handler.check_activated_return:Enable(false)
		elseif GAME_TYPE.eGameIDTeamDeathmatch == mode then
			handler.spin_artefacts_num:Enable(false)
			handler.spin_artefact_delay:Enable(false)
			handler.spin_artefact_stay:Enable(false)
			-- tab
			handler.tab_respawn:SetActiveTab("forcerespawn")
			btn_reinforcement:Enable(false)
			btn_artefactcapture:Enable(false)
			handler.spin_artreturn_time:Enable(false);
			handler.check_activated_return:Enable(false)
		elseif GAME_TYPE.eGameIDArtefactHunt == mode then
			handler.spin_frag_limit:Enable(false)
			handler.spin_artreturn_time:Enable(false);
			handler.check_activated_return:Enable(false)
		elseif GAME_TYPE.eGameIDCaptureTheArtefact == mode then
			handler.spin_artefact_delay:Enable(false)
			handler.spin_artefact_stay:Enable(false)
			handler.spin_frag_limit:Enable(false)
		end
	elseif GAME_TYPE.GAME_UNKNOWN == 0 then
		handler.spin_artreturn_time:Enable(false);
		handler.check_activated_return:Enable(false)
		if GAME_TYPE.GAME_DEATHMATCH == mode then
			handler.spin_friendly_fire:Enable(false)
			handler.check_auto_team_balance:Enable(false)
			handler.check_auto_team_swap:Enable(false)
			handler.spin_artefacts_num:Enable(false)
			handler.spin_artefact_delay:Enable(false)
			handler.spin_artefact_stay:Enable(false)
			handler.check_friendly_indicators:Enable(false)
			handler.check_friendly_names:Enable(false)
			handler.check_spec_teamonly:Enable(false)
			handler.spin_reinforcement:Enable(false)
			-- tab
			handler.tab_respawn:SetActiveTab("forcerespawn")
			btn_reinforcement:Enable(false)
			btn_artefactcapture:Enable(false)
		elseif GAME_TYPE.GAME_TEAMDEATHMATCH == mode then
			handler.spin_artefacts_num:Enable(false)
			handler.spin_artefact_delay:Enable(false)
			handler.spin_artefact_stay:Enable(false)
			-- tab
			handler.tab_respawn:SetActiveTab("forcerespawn")
			btn_reinforcement:Enable(false)
			btn_artefactcapture:Enable(false)
		elseif GAME_TYPE.GAME_ARTEFACTHUNT == mode then
			handler.spin_frag_limit:Enable(false)
		end
	end
end


