void Costume::save(string dirPath) { Log::write(LOG_INFO, "Costume\n"); Log::indent(); if (!IO::createDirectory(dirPath)) Log::write(LOG_ERROR, "Could not create directory \"%s\" !\n", dirPath.c_str()); XMLFile xmlFile; XMLNode *rootNode = new XMLNode("costume"); xmlFile.setRootNode(rootNode); rootNode->addChild(new XMLNode("name", _name)); Log::write(LOG_INFO, "name: %s\n", _name.c_str()); rootNode->addChild(new XMLNode("mirror", _mirror)); Log::write(LOG_INFO, "mirror: %d\n", _mirror); for (int i = 0; i < _anims.size(); i++) { XMLNode *child = new XMLNode("anim"); rootNode->addChild(child); _anims[i]->save(child); } for (int i = 0; i < _frames.size(); i++) { XMLNode *child = new XMLNode("frame"); rootNode->addChild(child); _frames[i]->save(child, dirPath); } _paletteData->save(dirPath); if (!xmlFile.save(dirPath + XML_FILE_NAME)) Log::write(LOG_ERROR, "Couldn't save costume to the specified directory !\n"); Log::unIndent(); }
void Object::save(string dirPath) { Log::write(LOG_INFO, "Object\n"); Log::indent(); if (!IO::createDirectory(dirPath)) Log::write(LOG_ERROR, "Could not create directory \"%s\" !\n", dirPath.c_str()); XMLFile xmlFile; XMLNode *rootNode = new XMLNode("object"); xmlFile.setRootNode(rootNode); rootNode->addChild(new XMLNode("name", _name)); Log::write(LOG_INFO, "name: %s\n", _name.c_str()); rootNode->addChild(new XMLNode("displayName", _displayName)); Log::write(LOG_INFO, "displayName: %s\n", _displayName.c_str()); // Change hotspots from relative to absolute positions when saving them rootNode->addChild(new XMLNode("hotspotX", _hotspotX + _x)); Log::write(LOG_INFO, "hotspotX: %d\n", _hotspotX + _y); rootNode->addChild(new XMLNode("hotspotY", _hotspotY)); Log::write(LOG_INFO, "hotspotY: %d\n", _hotspotY); rootNode->addChild(new XMLNode("x", _x)); Log::write(LOG_INFO, "x: %u\n", _x); rootNode->addChild(new XMLNode("y", _y)); Log::write(LOG_INFO, "y: %u\n", _y); rootNode->addChild(new XMLNode("width", _width)); Log::write(LOG_INFO, "width: %u\n", _width); rootNode->addChild(new XMLNode("height", _height)); Log::write(LOG_INFO, "height: %u\n", _height); string actorDir; switch (_actorDir) { case ACTOR_DIR_WEST: actorDir = "west"; break; case ACTOR_DIR_EAST: actorDir = "east"; break; case ACTOR_DIR_SOUTH: actorDir = "south"; break; case ACTOR_DIR_NORTH: actorDir = "north"; break; } rootNode->addChild(new XMLNode("actorDir", actorDir)); Log::write(LOG_INFO, "actorDir: %s (%u)\n", actorDir.c_str(), _actorDir); for (int i = 0; i < _images.size(); i++) { _images[i]->save(dirPath + _images[i]->getName() + '/'); rootNode->addChild(new XMLNode("image", _images[i]->getName())); } if (!_images.empty()) _paletteData->save(dirPath); if (!xmlFile.save(dirPath + XML_FILE_NAME)) Log::write(LOG_ERROR, "Couldn't save object to the specified directory !\n"); Log::unIndent(); }