Beispiel #1
0
void MainScene::setup() {
	setSceneName("main");

	json.setFile("resources/main/scenes/main");

	layerhandler.add("background");
	layerhandler.add("buttons");
	layerhandler.add("console");

	getSceneButtons();
}
Beispiel #2
0
void TupScene::fromXml(const QString &xml)
{
    QDomDocument document;

    if (! document.setContent(xml))
        return;

    QDomElement root = document.documentElement();

    setSceneName(root.attribute("name", sceneName()));

    QDomNode n = root.firstChild();

    while (!n.isNull()) {
           QDomElement e = n.toElement();

           if (!e.isNull()) {
               if (e.tagName() == "layer") {
                   int pos = k->layers.count();
                   TupLayer *layer = createLayer(e.attribute("name"), pos, true);

                   if (layer) {
                       QString newDoc;
                       {
                         QTextStream ts(&newDoc);
                         ts << n;
                       }

                       layer->fromXml(newDoc);
                   }
               } else if (e.tagName() == "background") {

                          QString newDoc;
                          {
                            QTextStream ts(&newDoc);
                            ts << n;
                          }

                          k->background->fromXml(newDoc); 

               } else if (e.tagName() == "soundlayer") {
                          int pos = k->soundLayers.count();
                          TupSoundLayer *layer = createSoundLayer(pos, true);

                          if (layer) {
                              QString newDoc;
                               {
                                 QTextStream ts(&newDoc);
                                 ts << n;
                               }

                              layer->fromXml(newDoc);
                          }
               } else if (e.tagName() == "storyboard") {
                          QString newDoc;
                          {
                            QTextStream ts(&newDoc);
                            ts << n;
                          }
                          k->storyboard->fromXml(newDoc);
               }
           }

           n = n.nextSibling();

    } // end while
}