--[[
-- $Id: cosmos.lua 1641 2005-05-29 01:32:45Z sparkz $
-- Cosmos-integration for MobHealth2
-- By Sparkz	
--]]


-- Variables
MobHealth_Cosmos_Registered = 0;
MobHealth_Enabled						= 1;

-- registers the mod with Cosmos
function MobHealth_Register_Cosmos()
	if ( ( Cosmos_UpdateValue ) and ( Cosmos_RegisterConfiguration ) and ( MobHealth_Cosmos_Registered == 0 ) ) then
		Cosmos_RegisterConfiguration(
			"COS_MOBHEALTH",
			"SECTION",
			TEXT(MOBHEALTH_CONFIG_HEADER),
			TEXT(MOBHEALTH_CONFIG_HEADER_INFO)
		);
		Cosmos_RegisterConfiguration(
			"COS_MOBHEALTH_HEADER",
			"SEPARATOR",
			TEXT(MOBHEALTH_CONFIG_HEADER),
			TEXT(MOBHEALTH_CONFIG_HEADER_INFO)
		);
		Cosmos_RegisterConfiguration(
			"COS_MOBHEALTH_ENABLED",
			"CHECKBOX",
			TEXT(MOBHEALTH_ENABLED),
			TEXT(MOBHEALTH_ENABLED_INFO),
			function (checked)
				MobHealth_Enabled = checked;
				local field = getglobal("MobHealthText");
				field:SetText("");
			end,
			MobHealth_Enabled
		);
		Cosmos_RegisterConfiguration(
			"COS_MOBHEALTH_POSITION",
			"SLIDER",
			TEXT(MOBHEALTH_POSITION_SLIDER_DESC),
			TEXT(MOBHEALTH_POSITION_SLIDER_INFO),
			function (checked, value) MobHealth_SetPos(value, false); end,
			1,
			22,
			0,
			55,
			MOBHEALTH_POSITION_SLIDER,
			1,
			1,
			"",
			1
		);
		Cosmos_RegisterConfiguration(
			"COS_MOBHEALTH_STABLEMAX",
			"CHECKBOX",
			TEXT(MOBHEALTH_STABLEMAX),
			TEXT(MOBHEALTH_STABLEMAX_INFO),
			function (checked) MobHealth_StableMax_Set(checked); end,
			0
		);
		Cosmos_RegisterConfiguration(
			"COS_MOBHEALTH_RESET_ALL",
			"BUTTON",
			TEXT(MOBHEALTH_RESET_ALL),
			TEXT(MOBHEALTH_RESET_ALL_INFO),
			MobHealth_Reset,
			0,
			0,
			0,
			0,
			TEXT(MOBHEALTH_RESET_ALL_BUTTON)
		);
		Cosmos_RegisterConfiguration(
			"COS_MOBHEALTH_RESET_TARGET",
			"BUTTON",
			TEXT(MOBHEALTH_RESET_TARGET),
			TEXT(MOBHEALTH_RESET_TARGET_INFO),
			MobHealth_ClearTargetData,
			0,
			0,
			0,
			0,
			TEXT(MOBHEALTH_RESET_TARGET_BUTTON)
		);
		MobHealth_Cosmos_Registered = 1;
	end
end

function MobHealth_StableMax_Set(checked)
	--DEFAULT_CHAT_FRAME:AddMessage(COLOR_WHITE..checked);
	if (checked == 1) then
		MobHealthConfig["unstablemax"] = true;
	else
		MobHealthConfig["unstablemax"] = nil;
	end
end
