void Costume::load(string dirPath) { Log::write(LOG_INFO, "Costume\n"); Log::indent(); XMLFile xmlFile; xmlFile.open(dirPath + XML_FILE_NAME); XMLNode *rootNode = xmlFile.getRootNode(); _name = rootNode->getChild("name")->getStringContent(); Log::write(LOG_INFO, "name: %s\n", _name.c_str()); _mirror = rootNode->getChild("mirror")->getBooleanContent(); Log::write(LOG_INFO, "mirror: %d\n", _mirror); int i = 0; XMLNode *child; while ((child = rootNode->getChild("anim", i++)) != NULL) { Anim *anim = new Anim(); anim->load(child); _anims.push_back(anim); } i = 0; while ((child = rootNode->getChild("frame", i++)) != NULL) { Frame *frame = new Frame(); frame->load(child, dirPath); _frames.push_back(frame); } _paletteData = new PaletteData(); _paletteData->load(dirPath); Log::unIndent(); }
void Object::load(string dirPath) { Log::write(LOG_INFO, "Object\n"); Log::indent(); XMLFile xmlFile; xmlFile.open(dirPath + XML_FILE_NAME); XMLNode *rootNode = xmlFile.getRootNode(); _name = rootNode->getChild("name")->getStringContent(); Log::write(LOG_INFO, "name: %s\n", _name.c_str()); _displayName = rootNode->getChild("displayName")->getStringContent(); Log::write(LOG_INFO, "displayName: %s\n", _displayName.c_str()); _hotspotX = rootNode->getChild("hotspotX")->getIntegerContent(); Log::write(LOG_INFO, "hotspotX: %u\n", _hotspotX); _hotspotY = rootNode->getChild("hotspotY")->getIntegerContent(); Log::write(LOG_INFO, "hotspotY: %u\n", _hotspotY); _x = rootNode->getChild("x")->getIntegerContent(); Log::write(LOG_INFO, "x: %u\n", _x); _y = rootNode->getChild("y")->getIntegerContent(); Log::write(LOG_INFO, "y: %u\n", _y); _width = rootNode->getChild("width")->getIntegerContent(); Log::write(LOG_INFO, "width: %u\n", _width); _height = rootNode->getChild("height")->getIntegerContent(); Log::write(LOG_INFO, "height: %u\n", _height); string actorDir = rootNode->getChild("actorDir")->getStringContent(); if (actorDir == "west") _actorDir = ACTOR_DIR_WEST; else if (actorDir == "east") _actorDir = ACTOR_DIR_EAST; else if (actorDir == "south") _actorDir = ACTOR_DIR_SOUTH; else if (actorDir == "north") _actorDir = ACTOR_DIR_NORTH; else Log::write(LOG_ERROR, "Unable to convert actorDir \"%s\" !\n", actorDir.c_str()); Log::write(LOG_INFO, "actorDir: %s (%u)\n", actorDir.c_str(), _actorDir); int i = 0; XMLNode *child; while ((child = rootNode->getChild("image", i++)) != NULL) { Image *image = new Image(); image->load(dirPath + child->getStringContent() + "/"); _images.push_back(image); } if (!_images.empty()) { _paletteData = new PaletteData(); _paletteData->load(dirPath); } // Change hotspots from absolute to relative positions _hotspotX -= _x; _hotspotY -= _y; Log::unIndent(); }