
.namespace AreaHotspot

function OnEnable()

	if self.Important == false then
		self.Color.r = 255
		self.Color.g = 0
		self.Color.b = 72
		self.Color.a = 72
	else
		self.Color.r = 173
		self.Color.g = 255
		self.Color.b = 47
		self.Color.a = 72
		local ut = OPUnitFactory.CreateUnit("Sparkle")
		ut.Name = self.Name.."_hint"
		--g_sparkle_unit=ut
		ut.Parent = Search_HintLayer
		local center = self.GetCenter()
		OPLog.Log(self.Name.." "..center.x..","..center.y)
		ut.Position_X = center.x +180
		ut.Position_Y = center.y
		ut.Layer="LayerPopup"
		

	end
	--OPLog.Log("enable de "..self.Name)
end


function OnWbpMouseLUp()
	if self.CanClickOn() then
		--OPLog.Log("click sur "..self.Name)
		AssertPopup(self.OnActivate ~= nil , "erreur activate non défini sur"..self.Name)
		local res = self.OnActivate()
		
		
		if res == true then -- s'il y a eu un changement, on sauvegarde
			SaveManager.saveGame("Profil"..ProfilConfig.Get("CurrentProfil"))
		end
		
		return true
	end
end

function SetCursor()
	if self.CanClickOn() then
		if self.GetSpecificCursor ~= nil then
			local frame,dest = self.GetSpecificCursor()
			Cursor.ChangeCursor(frame,dest)
		else
			Cursor.ChangeCursor(CURSOR_AREA_HOTSPOT)
		end
		return true
	end	
	return false
end


function CanClickOn()
	
	local res = self.Flags_Visible == true
	res = res and (IsEqualVariables("CurrentGamePhase","SearchSite") or IsEqualVariables("CurrentGamePhase","Closeup") 
	or (IsEqualVariables("CurrentGamePhase","Tutorial") and NewTutorialManager.g_state == "waitforaction" ))
	
	if self.PrivateCanClickOn ~= nil then
		res = res and self.PrivateCanClickOn()
	end	
	
	return res
end


function OnDisable()

end

function Toto()
	OPLog.Log("toto sur la classe")
end
