コード例 #1
0
bool EditorWidgets::load(std::string _fileName)
{
	std::string _instance = "Editor";

	MyGUI::xml::xmlDocument doc;
	std::string file(MyGUI::helper::getResourcePath(_fileName, Ogre::ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME));
	if (file.empty())
	{
		if (false == doc.open(_fileName)) {
			LOGGING(LogSection, Error, _instance << " : '" << _fileName << "' not found");
			return false;
		}
	}
	else if (false == doc.open(file))
	{
		LOGGING(LogSection, Error, _instance << " : " << doc.getLastError());
		return false;
	}

	MyGUI::xml::xmlNodePtr root = doc.getRoot();
	if ( (null == root) || (root->getName() != "MyGUI") ) {
		LOGGING(LogSection, Error, _instance << " : '" << _fileName << "', tag 'MyGUI' not found");
		return false;
	}

	std::string type;
	if (root->findAttribute("type", type)) {
		if (type == "Layout")
		{
			// берем детей и крутимся
			MyGUI::xml::xmlNodeIterator widget = root->getNodeIterator();
			while (widget.nextNode("Widget")) parseWidget(widget, 0);
		}
		
	}
	return true;
}
コード例 #2
0
bool WorldManagerServer::loadMap(const Ogre::String& mapName)
{
	WorldManager::loadMap(mapName);
	//cleanup
	for (std::vector<dGeomID>::iterator igeom = mStaticGeometries.begin();
			igeom != mStaticGeometries.end(); igeom++) {
		dGeomDestroy(*igeom);
	}
		//creating new game and loading new map
	Ogre::DataStreamPtr stream = Ogre::ResourceGroupManager::getSingleton().openResource(mapName);
	MyGUI::xml::xmlDocument xml;
	if (!xml.open(stream))
		return false;
	MyGUI::xml::xmlNodePtr root_node = xml.getRoot();
	if (root_node->getName() != "map")
		return false;

	MyGUI::xml::xmlNodeIterator inode = root_node->getNodeIterator();
	while (inode.nextNode()) {
		if (inode->getName() == "geom") {
			Ogre::String type = inode->findAttribute("type");
			std::vector<Ogre::String> params = Ogre::StringUtil::split(inode->findAttribute("size"), " ");
			dGeomID geom;

			if (type == "box") {
				geom = dCreateBox(mStaticSpace,
						Ogre::StringConverter::parseReal(params[0]),
						Ogre::StringConverter::parseReal(params[1]),
						Ogre::StringConverter::parseReal(params[2])
					);
			} else if (type == "sphere") {
				geom = dCreateSphere(mStaticSpace,
						Ogre::StringConverter::parseReal(params[0])
					);
			} else if (type == "cylinder") {
				geom = dCreateCylinder(mStaticSpace,
						Ogre::StringConverter::parseReal(params[0]),
						Ogre::StringConverter::parseReal(params[1])
					);
			} else if (type == "capsule") {
				geom = dCreateCapsule(mStaticSpace,
						Ogre::StringConverter::parseReal(params[0]),
						Ogre::StringConverter::parseReal(params[1])
					);
			} else if (type == "plane") {
				geom = dCreatePlane(mStaticSpace,
						Ogre::StringConverter::parseReal(params[0]),
						Ogre::StringConverter::parseReal(params[1]),
						Ogre::StringConverter::parseReal(params[2]),
						Ogre::StringConverter::parseReal(params[3])
					);
			} else {
				return false;
			}

			mStaticGeometries.push_back(geom);
		} else {
			return false;
		}
	}

	return true;
}