Ejemplo n.º 1
0
void LayerBitmap::loadDomElement(QDomElement element, QString dataDirPath)
{
    if (!element.attribute("id").isNull()) id = element.attribute("id").toInt();
    name = element.attribute("name");
    visible = (element.attribute("visibility") == "1");
    type = element.attribute("type").toInt();

    QDomNode imageTag = element.firstChild();
    while (!imageTag.isNull())
    {
        QDomElement imageElement = imageTag.toElement();
        if (!imageElement.isNull())
        {
            if (imageElement.tagName() == "image")
            {
                QString path =  dataDirPath +"/" + imageElement.attribute("src"); // the file is supposed to be in the data directory
     //qDebug() << "LAY_BITMAP  dataDirPath=" << dataDirPath << "   ;path=" << path;  //added for debugging puproses
                QFileInfo fi(path);
                if (!fi.exists()) path = imageElement.attribute("src");
                int position = imageElement.attribute("frame").toInt();
                int x = imageElement.attribute("topLeftX").toInt();
                int y = imageElement.attribute("topLeftY").toInt();
                loadImageAtFrame( path, QPoint(x,y), position );
            }
            /*if (imageElement.tagName() == "image") {
            	int frame = imageElement.attribute("frame").toInt();
            	addImageAtFrame( frame );
            	getBitmapImageAtFrame( frame )->loadDomElement(imageElement, filePath);
            }*/
        }
        imageTag = imageTag.nextSibling();
    }
}
Ejemplo n.º 2
0
void LayerCamera::loadDomElement(QDomElement element, QString dataDirPath)
{
    Q_UNUSED(dataDirPath);

    mName = element.attribute("name");
    visible = true;

    int width = element.attribute( "width" ).toInt();
    int height = element.attribute( "height" ).toInt();
    viewRect = QRect( -width / 2, -height / 2, width, height );

    QDomNode imageTag = element.firstChild();
    while (!imageTag.isNull())
    {
        QDomElement imageElement = imageTag.toElement();
        if (!imageElement.isNull())
        {
            if (imageElement.tagName() == "camera")
            {
                int frame = imageElement.attribute("frame").toInt();

                qreal m11 = imageElement.attribute("m11").toDouble();
                qreal m12 = imageElement.attribute("m12").toDouble();
                qreal m21 = imageElement.attribute("m21").toDouble();
                qreal m22 = imageElement.attribute("m22").toDouble();
                qreal dx = imageElement.attribute("dx").toDouble();
                qreal dy = imageElement.attribute("dy").toDouble();

                loadImageAtFrame(frame, QMatrix(m11,m12,m21,m22,dx,dy) );
            }
        }
        imageTag = imageTag.nextSibling();
    }
}
Ejemplo n.º 3
0
void LayerCamera::loadDomElement(QDomElement element, QString filePath) {
	name = element.attribute("name");
	//visible = (element.attribute("visibility") == "1");
	visible = true;
	type = element.attribute("type").toInt();
	
	int width = element.attribute("width").toInt();
	int height = element.attribute("height").toInt();
	viewRect = QRect(-width/2,-height/2,width,height);
							
	QDomNode imageTag = element.firstChild();
	while(!imageTag.isNull()) {
		QDomElement imageElement = imageTag.toElement();
		if(!imageElement.isNull()) {
			if(imageElement.tagName() == "camera") {
				int frame = imageElement.attribute("frame").toInt();
	
				qreal m11 = imageElement.attribute("m11").toDouble();
				qreal m12 = imageElement.attribute("m12").toDouble();
				qreal m21 = imageElement.attribute("m21").toDouble();
				qreal m22 = imageElement.attribute("m22").toDouble();
				qreal dx = imageElement.attribute("dx").toDouble();
				qreal dy = imageElement.attribute("dy").toDouble();
				
				loadImageAtFrame(frame, QMatrix(m11,m12,m21,m22,dx,dy) );
			}
			/*if(imageElement.tagName() == "image") {
				int frame = imageElement.attribute("frame").toInt();
				addImageAtFrame( frame );
				getBitmapImageAtFrame( frame )->loadDomElement(imageElement, filePath);
			}*/
		}
		imageTag = imageTag.nextSibling();
	}
}
Ejemplo n.º 4
0
void LayerVector::loadDomElement(QDomElement element, QString dataDirPath)
{
    if (!element.attribute("id").isNull()) id = element.attribute("id").toInt();
    name = element.attribute("name");
    visible = (element.attribute("visibility") == "1");
    m_eType = static_cast<LAYER_TYPE>( element.attribute( "type" ).toInt( ) );

    QDomNode imageTag = element.firstChild();
    while (!imageTag.isNull())
    {
        QDomElement imageElement = imageTag.toElement();
        if (!imageElement.isNull())
        {
            if (imageElement.tagName() == "image")
            {
                if (!imageElement.attribute("src").isNull())
                {
                    QString path =  dataDirPath +"/" + imageElement.attribute("src"); // the file is supposed to be in the data irectory
                    //qDebug() << "LAY_VECTOR  dataDirPath=" << dataDirPath << "   ;path=" << path;  //added for debugging puproses
                    QFileInfo fi(path);
                    if (!fi.exists()) path = imageElement.attribute("src");
                    int position = imageElement.attribute("frame").toInt();
                    loadImageAtFrame( path, position );
                }
                else
                {
                    int frame = imageElement.attribute("frame").toInt();
                    addImageAtFrame( frame );
                    getVectorImageAtFrame( frame )->loadDomElement(imageElement);
                }
            }
        }
        imageTag = imageTag.nextSibling();
    }
}
Ejemplo n.º 5
0
void LayerVector::loadDomElement(QDomElement element, QString filePath) {
	if(!element.attribute("id").isNull()) id = element.attribute("id").toInt();
	name = element.attribute("name");
	visible = (element.attribute("visibility") == "1");
	type = element.attribute("type").toInt();

	QDomNode imageTag = element.firstChild();
	while(!imageTag.isNull()) {
		QDomElement imageElement = imageTag.toElement();
		if(!imageElement.isNull()) {
			if(imageElement.tagName() == "image") {
				if(!imageElement.attribute("src").isNull()) {
					QString path =  filePath +".data/" + imageElement.attribute("src"); // the file is supposed to be in the data irectory
					QFileInfo fi(path);
					if(!fi.exists()) path = imageElement.attribute("src");
					int position = imageElement.attribute("frame").toInt();
					loadImageAtFrame( path, position );
				} else {
					int frame = imageElement.attribute("frame").toInt();
					addImageAtFrame( frame );
					getVectorImageAtFrame( frame )->loadDomElement(imageElement);
				}
			}
		}
		imageTag = imageTag.nextSibling();
	}
}