Example #1
0
int scanfont(char * font_dir, char ** files)
{
    int count = 0;
    struct dirent * entry;
    char path[MAXPATHLEN];
    DIR * dir;

    dir = opendir(font_dir);
    if ( dir == NULL ) {  return count;  }
//    if ( dir == NULL ) {  perror("opendir");  printf(" %s\n", font_dir);  }  // Add to error logging when that's ready
    chdir(font_dir);
    while(entry = readdir(dir))
    {
        if ( entry->d_type == DT_DIR && ! relative_dir(entry) )
        {
            getcwd(path, MAXPATHLEN);
            count += scanfont(entry->d_name, files);
            chdir(path);
        }
        if ( entry->d_type == DT_REG || entry->d_type == DT_LNK )
        {
            getcwd(path, MAXPATHLEN);
            strcat(path, "/");  strcat(path, entry->d_name);  // inelegant, but works
            if ( addfont(path, NULL) == 0 )  count++;
        }
    }
    return count;
}
void file_system::open_bin_output(FILE *file)
{
    std::string temp_filename = root_dir() + relative_dir();
//
    file = fopen(temp_filename.std::string::c_str(), "w");
//
    switch(file not_eq NULL)
    {
        case true: stream_ready = true; break;
    }
}
void file_system::open_txt_input(std::fstream &file)
{
    std::string temp_filename = root_dir() + relative_dir();
//
    file.std::fstream::open(temp_filename.std::string::c_str(), 
                            std::fstream::in);
//
    switch(file.std::fstream::is_open() and file.std::fstream::good())
    {
        case true: stream_ready = true; break;
    }
}
void file_system::open_bin_output(std::fstream &file)
{
    std::string temp_filename = root_dir() + relative_dir();
//
    file.std::fstream::open(temp_filename.std::string::c_str(), 
                            std::fstream::out | std::ios::binary | std::ios::app);
//
    switch(file.std::fstream::is_open() and file.std::fstream::good())
    {
        case true: stream_ready = true; break;
    }
}
Example #5
0
bool MasterEffect::Parse(TiXmlElement* xml)
{
	assert(xml);
	if (xml == 0)
		return false; // file could not be opened

	const char *str;

	xml = ObjectsLibrary::CheckLID(xml);

	str = xml->Attribute("type");

	if (str)
	{
		if (strcmp(str,"onshoot")==0)
			Type=IMasterEffect::MET_ONSHOOT;
		else
			if (strcmp(str,"onblow")==0)
				Type=IMasterEffect::MET_ONBLOW;
			else
				if (strcmp(str,"permanent")==0)
					Type=IMasterEffect::MET_PERMANENT;
	}
	
	int x=0, y=0, z=0, res, resx, resy, resz,val;
	resx = xml->QueryIntAttribute("x", &x);	
	resy = xml->QueryIntAttribute("y", &y);	
	resz = xml->QueryIntAttribute("z", &z);	

	if (TIXML_SUCCESS==resx && TIXML_SUCCESS==resy && TIXML_SUCCESS==resz) 
	{
		RelativePos = Ogre::Vector3((float)x,(float)y,(float)z);
	}

	float dirx, diry, dirz;
	resx = xml->QueryFloatAttribute("dirx", &dirx);	
	resy = xml->QueryFloatAttribute("diry", &diry);	
	resz = xml->QueryFloatAttribute("dirz", &dirz);	

	if (TIXML_SUCCESS==resx && TIXML_SUCCESS==resy && TIXML_SUCCESS==resz)
	{
		Ogre::Vector3 relative_dir(dirx,diry,dirz);
		RelOrientation = relative_dir.getRotationTo(Ogre::Vector3::UNIT_Z);
	}
	    	
	str = xml->Attribute("name");
	assert(str);
	if (Name)
		delete [] Name;
    Name = AAUtilities::StringCopy(str);

	res = xml->QueryIntAttribute("duration", &Duration);
	
	val=0;
	res = xml->QueryIntAttribute("run", &val);        
	RunOnCreate = val ? true : false;

    val=0;
    res = xml->QueryIntAttribute("loop", &val);        
    IsLoop = val ? true : false;
    
    TiXmlElement *xml_element = 0;
	xml_element = xml->FirstChildElement("subeffects");
	
	if (xml_element)
	{
        int val=0, res=0;
        		
		ISubEffect *effect;		
		xml_element = xml_element->FirstChildElement("subeffect");	
		
		while (xml_element)
		{				            
            str = xml_element->Attribute("class");
            assert(str);
            if (strcmp(str,"MeshSubEffect")==0)
            {
                effect = new MeshSubEffect();
            } else
                if (strcmp(str,"BillboardSubEffect")==0)
                {
                    effect = new BillboardSubEffect();
                }

            assert(effect);
                        
            if (effect) 
            {         
				effect->SetMaster(this);
                effect->Parse(xml_element);
                SubEffects.push_back(effect);
            }
			xml_element = xml_element->NextSiblingElement("subeffect");
		}         
	}

    xml_element = xml->FirstChildElement("sounds");

    if (xml_element)
    {
		SoundQueues.reset(new std::list<SSoundDescription>);
		TiXmlElement *xml_sound_element = 0;
		xml_sound_element = xml_element->FirstChildElement("sound");	
        while (xml_sound_element)
        {			
			SSoundDescription descr;
			val = 0;
            res = xml_sound_element->QueryIntAttribute("queue", &val);
			descr.QueueNumber = val;

			val = 1;
			res = xml_sound_element->QueryIntAttribute("priority", &val);
			descr.Priority = val;

			SoundQueues->push_back(descr);
            xml_sound_element = xml_sound_element->NextSiblingElement("sound");
        }

        List<char*>* res = AAUtilities::ParseStrings(xml_element, "sound", "file");
        if (res)
            SoundFiles.reset(res);
    }     
	
	return true;
}