Exemplo n.º 1
0
int main()
{
	IrrXMLReader* xml = createIrrXMLReader("config.xml");

	// strings for storing the data we want to get out of the file
	std::string modelFile;
	std::string messageText;
	std::string caption;

	// parse the file until end reached
	while(xml && xml->read())
	{
		switch(xml->getNodeType())
		{
		case EXN_TEXT:
			// in this xml file, the only text which occurs is the messageText
			messageText = xml->getNodeData();
			break;
		case EXN_ELEMENT:
			{
				if (!strcmp("startUpModel", xml->getNodeName()))
					modelFile = xml->getAttributeValue("file");
				else
				if (!strcmp("messageText", xml->getNodeName()))
					caption = xml->getAttributeValue("caption");
			}
			break;
		}
	}

	// delete the xml parser after usage
	delete xml;
	return 0;
}
Exemplo n.º 2
0
int LoadStringsFromXML(const char* filename, PSC_Application2 *App){
	IrrXMLReader* xml = createIrrXMLReader(filename);
	int i=-1;
	while(xml && xml->read()){
 		switch(xml->getNodeType())
		{
			case EXN_ELEMENT:
			{
				if (!strcmp("elements", xml->getNodeName())){
					App->n_elem  = xml->getAttributeValueAsInt("n");

					App->name      = new string[App->n_elem+1];
					App->version   = new string[App->n_elem+1];
					App->link      = new string[App->n_elem+1];
					App->pkg_file  = new string[App->n_elem+1];
					App->img_file  = new string[App->n_elem+1];
					App->type_file = new int[App->n_elem+1];
				}
				if (!strcmp("app", xml->getNodeName()))
					i++;
				if (!strcmp("NameApp", xml->getNodeName()))
					App->name[i]    = xml->getAttributeValue("name");
				if (!strcmp("Version", xml->getNodeName()))
					App->version[i] = xml->getAttributeValue("v");
				if (!strcmp("Link", xml->getNodeName()))
					App->link[i]    = xml->getAttributeValue("link");
				if (!strcmp("Pkg", xml->getNodeName()))
					App->pkg_file[i]    = xml->getAttributeValue("file");
				if (!strcmp("Image", xml->getNodeName()))
					App->img_file[i]    = xml->getAttributeValue("img");
				if (!strcmp("Type", xml->getNodeName()))
					App->type_file[i]   = xml->getAttributeValueAsInt("type");

				break;
			}
		}
		if(i == App->n_elem)
			break;

	}
	if(i > App->n_elem)
		App->n_elem = i;

	App->name[App->n_elem] =      "";
	App->version[App->n_elem] =   "";
	App->link[App->n_elem] =      "";
	App->pkg_file[App->n_elem] =  "";
	App->img_file[App->n_elem] =  "";
	App->type_file[App->n_elem] = -1;
	delete xml;
	return 1;
}
Exemplo n.º 3
0
int LoadMainStringsFromXML(const char* filename, string *str){
	IrrXMLReader* xml = createIrrXMLReader(filename);
	int i=0;  //should be 5 categories.
	while(xml && xml->read() && i< 5)
	{
 		switch(xml->getNodeType())
		{
			case EXN_ELEMENT:
			{
				if (!strcmp("file", xml->getNodeName())){
					str[i] = xml->getAttributeValue("id");
					i++;
				}
			}
				break;
			case EXN_NONE:
				break;
			case EXN_ELEMENT_END:
				break;
			case EXN_TEXT:
				break;
			case EXN_COMMENT:
				break;
			case EXN_CDATA:
				break;
			case EXN_UNKNOWN:
				break;
		}
	}
	delete xml;
	return 1;
}
Exemplo n.º 4
0
Arquivo: nave.cpp Projeto: lymber/tdm
//---------------------------------------------------------------------
void Nave::LeAtributos(const char *arquivo)
{
   IrrXMLReader* xml = createIrrXMLReader(arquivo);
   
   while(xml && xml->read())
   {
      switch(xml->getNodeType())
      {     
         case EXN_ELEMENT:  
            if (!strcmp("atributos", xml->getNodeName()))
            {
               Objeto::LeModelo(xml->getAttributeValue("arquivo"));
               velocidadeMaxima = xml->getAttributeValueAsFloat("velocidadeMaxima");
            }
            else if (!strcmp("tiro", xml->getNodeName()))
            {
               if (!strcmp("laser", xml->getAttributeValue("qualBasico"))) tipoTiroBasico = TIPO_LASER;
               else if (!strcmp("missil", xml->getAttributeValue("qualBasico"))) tipoTiroBasico = TIPO_MISSIL;
               if (!strcmp("multiplo", xml->getAttributeValue("qualBasico"))) tipoTiroBasico = TIPO_MULTIPLO;
            }
            else if (!strcmp("recargaLaser", xml->getNodeName()))
            {
               tempoDeRecargaTotal[TIPO_LASER] = xml->getAttributeValueAsInt("tempo");
            }  
            else if (!strcmp("recargaMissil", xml->getNodeName()))
            {
               tempoDeRecargaTotal[TIPO_MISSIL] = xml->getAttributeValueAsInt("tempo");
            }
            else if (!strcmp("recargaMultiplo", xml->getNodeName()))
            {
               tempoDeRecargaTotal[TIPO_MULTIPLO] = xml->getAttributeValueAsInt("tempo");
            }
            break;   
      }
   }   
}
Exemplo n.º 5
0
void ConfigurationData::loadFile(std::string fp){
	IrrXMLReader* xml = createIrrXMLReader(fp.c_str());
	std::string pack_id;

	while (xml && xml->read()){
		switch (xml->getNodeType()){
		case EXN_ELEMENT:
			if (!strcmp(xml->getNodeName(), "Window")){
				this->SCREEN_SIZE.x = xml->getAttributeValueAsInt("SIZE_X");
				this->SCREEN_SIZE.y = xml->getAttributeValueAsInt("SIZE_Y");
				this->WINDOW_TITLE = xml->getAttributeValue("TITLE");
			}

			if (!strcmp(xml->getNodeName(), "Paddle")){
				this->PADDLE_SPEED = xml->getAttributeValueAsFloat("SPEED");
				this->PADDLE_SPEED_CAP = xml->getAttributeValueAsFloat("SPEED_CAP");
				this->PADDLE_VELOCITY_DECAY = xml->getAttributeValueAsFloat("VELOCITY_DECAY");
			}

			if (!strcmp(xml->getNodeName(), "Ball")){
				this->BALL_INITIAL_VELOCITY.x = xml->getAttributeValueAsFloat("INITIAL_VELOCITY_X");
				this->BALL_INITIAL_VELOCITY.y = xml->getAttributeValueAsFloat("INITIAL_VELOCITY_Y");
				this->BALL_VELOCITY_INCREASE = xml->getAttributeValueAsFloat("VELOCITY_INCREASE");
			}

			if (!strcmp(xml->getNodeName(), "Skinpacks")){
				pack_id = xml->getAttributeValue("pack_id");
			}
			if (!strcmp(xml->getNodeName(), "Pack")){
				if (xml->getAttributeValue("pack_id") == pack_id){
					this->background_tex_path = xml->getAttributeValue("BG_TEX_PATH");
					this->paddle_tex_path = xml->getAttributeValue("PADDLE_TEX_PATH");
					this->ball_tex_path = xml->getAttributeValue("BALL_TEX_PATH");
				}
			}

			break;
		}
	}

	delete xml;
}
Exemplo n.º 6
0
        bool bCharger(std::string _cCheminFichier = "")
        {
            bool bRetour = false;
            if(_cCheminFichier != "")
            {
                cCheminFichier = _cCheminFichier;
            }
            
            if(cCheminFichier != "")
            {
                if (bCharge == true)
                {
                    vNettoyer();
                }
                
                xml = createIrrXMLReader(cCheminFichier.c_str());
                
                while(xml && xml->read())
                {
                        switch(xml->getNodeType())
                        {
                            case EXN_TEXT:
                                /*if(strcmp("messageText", xml->getNodeName()))
                                {
                                    messageText = xml->getNodeData();
                                }*/
                                break;
                            case EXN_ELEMENT:
                                {
                                        if (!strcmp("antialiazing", xml->getNodeName()))
                                                antialiazing = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("fullscreen", xml->getNodeName()))
                                                fullscreen = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("musicAndFX", xml->getNodeName()))
                                                musicAndFX = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("realTimeShadows", xml->getNodeName()))
                                                realTimeShadows = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("verticalSynch", xml->getNodeName()))
                                                verticalSynch = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("oldHWBlending", xml->getNodeName()))
                                                oldHWBlending = (!strcmp(xml->getAttributeValue("value"),"ON")?true:false);
                                        else
                                        if (!strcmp("driver", xml->getNodeName()))
                                                driver = (E_DRIVER_TYPE)atoi(xml->getAttributeValue("value"));
                                        else
                                        if (!strcmp("windowSize", xml->getNodeName()))
                                        {
                                                width = atoi(xml->getAttributeValue("width"));
                                                height = atoi(xml->getAttributeValue("height"));
                                        }
                                }
                                break;
                        }
                }

                // delete the xml parser after usage
                delete xml;
                xml = NULL;
                bCharge = true;
            }
            
            return bRetour;
        }
Exemplo n.º 7
0
bool CollisionMap::loadCollisionWorld(std::string cfgFile, CollisionLineSetFactory* factory) {
	unsigned collMapId, tileType;
	float yRotation = 0;
	std::string fileType, fileName;
	TransformationData trans;
	CollisionLineSet* collLineSet;
	IrrXMLReader * xml;

	if (!fileExists(cfgFile)) {
		printd(ERROR, "CollisionMap::loadCollisionWorld(): ERROR: could not find config-file %s\n",
				cfgFile.c_str());
		return false;
	} // if

	xml = createIrrXMLReader(cfgFile.c_str());

	printd(INFO, "CollisionMap::loadCollisionWorld(): loading from file: %s\n", cfgFile.c_str());
	while (xml && xml->read()) {
		switch (xml -> getNodeType()) {
		case EXN_ELEMENT:
			if (!strcmp("collisionMapConfig", xml->getNodeName())) {
			} // if
			else if (!strcmp("collisionMaps", xml->getNodeName())) {
			} // else if
			else if (!strcmp("collisionMap", xml->getNodeName())) {
				collMapId = xml->getAttributeValueAsInt("id");
			} // else if
			else if (!strcmp("trans", xml->getNodeName())) {
				yRotation = xml->getAttributeValueAsFloat("yRotation");
			} // else if
			else if (!strcmp("file", xml->getNodeName())) {
				fileType = xml->getAttributeValue("type");
			} // else if
			else if (!strcmp("fileName", xml->getNodeName())) {
				fileName = xml->getAttributeValue("name");
			} // else if
			else if (!strcmp("mapping", xml->getNodeName())) {
			} // else if
			else if (!strcmp("tile", xml->getNodeName())) {
				tileType = xml->getAttributeValueAsInt("type");
				collMapId = xml->getAttributeValueAsInt("collisionMapId");
				tileMap[tileType] = objectMap[collMapId];
			} // else if
			break;
		case EXN_ELEMENT_END:
			if (!strcmp("collisionMap", xml->getNodeName())) {
				// TODO: also allow other collision primitives, not only lineSets
				trans = identityTransformation();
				setQuatfAsAxisAngleDeg(trans.orientation, 0, 1, 0, yRotation);
				// TODO: add extra path for CollisionMaps
				collLineSet = loadCollisionLineSet(Configuration::getPath("Tiles") + fileName,
						trans, factory);
				if (collLineSet)
					objectMap[collMapId] = collLineSet;
			} // if
			break;
		default:
			break;
		} // switch
	} // while

	delete xml;
	return true;
} // loadCollisionWorld
Exemplo n.º 8
0
int main(int argc, char** argv)
{
	CCmdLineInfo cmdLine(argc, argv);
	IrrXMLReader* pXML = NULL;
	vector<string> arrStrings;

	print_title();
	if ( cmdLine.GetArgCount() < 2 )
	{
		print_usage();
		return 1;
	}

  string option;
	string src_file = cmdLine.GetArg(1);
	string target_file = cmdLine.GetArg(2);

  if ( src_file[0] == '-' )
  {
    option = src_file;
    src_file = cmdLine.GetArg(2);
    target_file = cmdLine.GetArg(3);

    if ( option == "-wide" )
    {
      g_ExportWideStrings= true;
      printf("[CONFIG] Exporting wide strings\n");
    }
  }

	pXML = createIrrXMLReader( src_file.c_str() );

	if ( pXML )
	{
		string elemName, string_id, string_val;

		while ( pXML->read() )
		{
			switch ( pXML->getNodeType() )
			{
			case	EXN_ELEMENT:
				elemName = pXML->getNodeName();
				if ( elemName == "String" )
				{
					string_id = pXML->getAttributeValue( "id" );
					arrStrings.push_back(string_id);
				}
				break;

			default:
				break;
			}
		}

		ofstream fs_target;

		fs_target.open( target_file.c_str() );
		if ( fs_target.is_open() )
		{
			write_h_header(fs_target, src_file);
			vector<string>::iterator it = arrStrings.begin();

			while ( it != arrStrings.end() )
			{
				write_h_stringdef(fs_target, *it);
				it++;
			}
		}
		fs_target.close();
	}

	printf("%ld string definitions written to %s\n", arrStrings.size(), target_file.c_str());

	return 0;
}
Exemplo n.º 9
0
int updateFinder(const char* TITLE_ID, int env_choose, PSN_Update* game){
	const char *env[3] = {"np","sp-int","prod-qa"};
	int size = strlen(TITLE_ID)*2+49+strlen(env[env_choose])*2;
	char *xml_url = (char*) malloc(size);

	snprintf(xml_url,size,"https://a0.ww.%s.dl.playstation.net/tpl/%s/%s/%s-ver.xml",env[env_choose],env[env_choose],TITLE_ID,TITLE_ID);
	download_game_update(xml_url,CACHE_PATH2"/game-update.xml", progress, NULL);
	free((void*)xml_url);
	
	size = get_size(CACHE_PATH2"/game-update.xml");
	if(size == 16 || size == 241 || size == 0){ //Update not found
		file_delete(CACHE_PATH2"/game-update.xml");
		return 0;
	}
	
	if(get_download_status()==DOWNLOAD_FAILED){
		file_delete(CACHE_PATH2"/game-update.xml");
		return 0;
	}
	
	
	IrrXMLReader* xml = createIrrXMLReader(CACHE_PATH2"/game-update.xml");
	int i=-1;
	PSN_Update game_tmp;
	game_tmp.version = new string  [10];
	game_tmp.link    = new string  [10];
	game_tmp.size    = new uint32_t[10];
	game_tmp.min_ver = new float   [10];
	game_tmp.pkgs	 = 0;
	while(xml && xml->read() && i<10){
		//printf("debug: %s\n", xml->getNodeData());
 		switch(xml->getNodeType())
		{
			case EXN_NONE:
				break;
			case EXN_ELEMENT:
			{
				if (!strcmp("package", xml->getNodeName())){
					++i;
					char tmp[10];
					game_tmp.version[i] = xml->getAttributeValue("version");
					game_tmp.size[i]    = xml->getAttributeValueAsInt("size");
					game_tmp.link[i]    = xml->getAttributeValue("url");
					game_tmp.min_ver[i] = xml->getAttributeValueAsFloat("ps3_system_ver");
					game_tmp.pkgs++;
					break;
				}else if (!strcmp("TITLE", xml->getNodeName())){
					xml->read();
					game_tmp.name = xml->getNodeData();
					break;
				}
			}
			case EXN_ELEMENT_END:
				break;
			case EXN_TEXT:
				break;
			case EXN_COMMENT:
				break;
			case EXN_CDATA:
				break;
			case EXN_UNKNOWN:
				break;
		}
	}
	delete xml;
	game->name    = game_tmp.name.c_str();
	game->version = new string  [game_tmp.pkgs];
	game->link    = new string  [game_tmp.pkgs];
	game->size    = new uint32_t[game_tmp.pkgs];
	game->min_ver = new float   [game_tmp.pkgs];
	game->pkgs    = game_tmp.pkgs;
	for(u8 j=0; j<game_tmp.pkgs; ++j){
		game->version[j] = game_tmp.version[j];
		game->link[j]    = game_tmp.link[j];
		game->size[j]    = game_tmp.size[j];
		game->min_ver[j] = game_tmp.min_ver[j];
	}
	
	delete [] game_tmp.version;
	delete [] game_tmp.link;
	delete [] game_tmp.size;
	
	file_delete(CACHE_PATH2"/game-update.xml");
	return 1;
}
Exemplo n.º 10
0
bool CParser::parseIrrXml(string xmlFile, string method){
	IrrXMLReader* xml = createIrrXMLReader(xmlFile.c_str());
	if(!xml){
		ELOG("CParser", "parseIrrXml", string("Plik XML nie istnieje: ") + xmlFile);
		return false;
	}
	int status = 0;
	Entity entity;
	ClearEntity(&entity);

	while(xml && xml->read()){
		switch(xml->getNodeType()){
		case EXN_ELEMENT:
			{
				string get = xml->getNodeName();
				if(get == "node"){
					string type = xml->getAttributeValue("type");
					if(type == "mesh"){
						if(status == 0){
							status = 1; //zaczynamy parsowanie modelu (dzieki temu omijamy zbedne poczatkowe znaczniki)
							//ELOGEX("DEBUG: WYKRYTO MESHA");
						}else{
							if(!CallLuaFunction(method, &entity)) {
								break;
							}else{
								//ELOGEX("DEBUG: WYKRYTO MESHA");
							}
						}
					}
				}else if(get == "vector3d" && status == 1){
					string name = xml->getAttributeValue("name");
					if(name == "Position"){
						string position = xml->getAttributeValue("value");
						entity.position = strToVec(position);
					}else if(name == "Rotation"){						
						string rotation = xml->getAttributeValue("value");
						entity.rotation = strToVec(rotation);
					}else if(name == "Scale"){
						string scale = xml->getAttributeValue("value");
						entity.scale = strToVec(scale);
					}
				}else if(get == "string" && status == 1){
					string name = xml->getAttributeValue("name");
					if(name == "Mesh"){
						string model = cutDir(xml->getAttributeValue("value"));
						entity.mesh = model;
					}else if(name == "Name"){
						string nazwa = xml->getAttributeValue("value");
						entity.name = nazwa;
					}
				}else if(get == "texture" && status == 1){
					string name = xml->getAttributeValue("name");
					if(name == "Texture1"){
						string filename = cutDir(xml->getAttributeValue("value"));
						entity.texture = filename;
					}
				}
			}
			break;
		}
	}
	CallLuaFunction(method, &entity);
	delete xml;
	return true;
}