当前位置: 首页>>代码示例>>C++>>正文


C++ XMLFile::getRootNode方法代码示例

本文整理汇总了C++中XMLFile::getRootNode方法的典型用法代码示例。如果您正苦于以下问题:C++ XMLFile::getRootNode方法的具体用法?C++ XMLFile::getRootNode怎么用?C++ XMLFile::getRootNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XMLFile的用法示例。


在下文中一共展示了XMLFile::getRootNode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: load

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();
}
开发者ID:RumRogers,项目名称:scummgen,代码行数:37,代码来源:Costume.cpp

示例2: load

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();
}
开发者ID:RumRogers,项目名称:scummgen,代码行数:67,代码来源:Object.cpp


注:本文中的XMLFile::getRootNode方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。