示例#1
0
bool iface_write_settings_singleplayer(iface_type *iface,char *err_str)
{
	int							n;
	char						path[1024];
	bool						ok;
	iface_sp_option_type		*sp_option;
	
		// start new file
		
	xml_new_file();

		// singleplayer

	xml_add_tagstart("Singleplayer");
	xml_add_tagend(FALSE);

		// settings
		
	xml_add_tagstart("Settings");
	xml_add_attribute_boolean("skill",iface->singleplayer.skill);
	xml_add_attribute_boolean("map_pick",iface->singleplayer.map_pick);
	xml_add_attribute_int("map_pick_ss_reveal_id",iface->singleplayer.map_pick_ss_reveal_id);
	xml_add_tagend(TRUE);

		// options

	xml_add_tagstart("Options");
	xml_add_tagend(FALSE);

	sp_option=iface->singleplayer.option_list.options;

	for (n=0;n!=iface->singleplayer.option_list.noption;n++) {
		xml_add_tagstart("Option");
		xml_add_attribute_text("name",sp_option->name);
		xml_add_attribute_text("description",sp_option->descript);
		xml_add_attribute_int("ss_reveal_id",sp_option->ss_reveal_id);
		xml_add_tagend(TRUE);

		sp_option++;
	}

	xml_add_tagclose("Options");

	xml_add_tagclose("Singleplayer");

        // write the xml
		
	file_paths_data(&file_path_setup,path,"Settings","Singleplayer","xml");
		
	ok=xml_save_file(path,err_str);
    xml_close_file();
	
	return(ok);
}
示例#2
0
void bitmap_texture_write_xml(texture_type *texture,int frame_count,bool write_scale)
{
	int						k;
	
		// settings
		
	xml_add_attribute_boolean("animate",texture->animate.on);
	xml_add_attribute_boolean("additive",texture->additive);
	xml_add_attribute_boolean("pixelated",texture->pixelated);
	xml_add_attribute_boolean("compress",texture->compress);
	xml_add_attribute_boolean("flip_normal",texture->flip_normal);

	xml_add_attribute_float("shine_factor",texture->shine_factor);
	xml_add_attribute_list("rl_alpha_type",(char*)rtl_alpha_list_str,texture->rl_alpha_type);
	xml_add_attribute_float("rl_refract_factor",texture->rl_refract_factor);
	
	xml_add_attribute_int("glow_rate",texture->glow.rate);
	xml_add_attribute_float("glow_min",texture->glow.min);
	xml_add_attribute_float("glow_max",texture->glow.max);
	
	xml_add_attribute_text("shader",texture->shader_name);
	xml_add_attribute_text("material_name",texture->material_name);
	
	xml_add_tagend(FALSE);

		// scale
		
	if (write_scale) {
		xml_add_tagstart("Scale");
		xml_add_attribute_float("x",texture->scale.uv_size.x);
		xml_add_attribute_float("y",texture->scale.uv_size.y);
		xml_add_attribute_float("x_off",texture->scale.uv_offset.x);
		xml_add_attribute_float("y_off",texture->scale.uv_offset.y);
		xml_add_tagend(TRUE);
	}
	
		// images
		
	xml_add_tagstart("Images");
	xml_add_tagend(FALSE);
		
	for (k=0;k!=frame_count;k++) {
		xml_add_tagstart("Image");
		if (texture->animate.wait[k]!=0) xml_add_attribute_int("wait",texture->animate.wait[k]);
		if (texture->frames[k].name[0]!=0x0) xml_add_attribute_text("bitmap",texture->frames[k].name);
		xml_add_tagend(TRUE);
	}
	
	xml_add_tagclose("Images");
}
示例#3
0
bool write_mesh_xml(model_type *model)
{
    char					path[1024];
    bool					ok;

    // start

    xml_new_file();

    xml_add_tagstart("Model");
    xml_add_attribute_int("version",2);
    xml_add_tagend(FALSE);

    // encode

    encode_mesh_v2_xml(model);

    // save model

    xml_add_tagclose("Model");

    sprintf(path,"%s/mesh.xml",model->load_base_path);
    ok=xml_save_file(path);

    xml_close_file();

    return(ok);
}
示例#4
0
void encode_mesh_v2_xml(model_type *model)
{
	int						i,n,k,j,frame_count;
	char					tag_name[32];
	model_hit_box_type		*hit_box;
	model_mesh_type			*mesh;
    model_vertex_type		*vertex;
	model_material_type		*material;
    model_bone_type			*bone;
    model_trig_type			*trig;
    texture_type			*texture;
    
        // model info
    
    xml_add_tagstart("Creator");
    xml_add_attribute_text("name","dim3 Animator");
    xml_add_attribute_text("version","1.0");
    xml_add_tagend(TRUE);
	
        // options
    
    xml_add_tagstart("Options");
	xml_add_attribute_list("deform",(char*)deform_mode_str,model->deform_mode);
    xml_add_tagend(TRUE);
 	
        // center
	
    xml_add_tagstart("Center");
    xml_add_attribute_3_coord_int("offset",model->center.x,model->center.y,model->center.z);
    xml_add_tagend(TRUE);
    
        // boxes
    
    xml_add_tagstart("View_Box");
    xml_add_attribute_3_coord_int("size",model->view_box.size.x,model->view_box.size.y,model->view_box.size.z);
    xml_add_attribute_3_coord_int("offset",model->view_box.offset.x,model->view_box.offset.y,model->view_box.offset.z);
    xml_add_tagend(TRUE);
	
		// light
	
    xml_add_tagstart("Light");

	for (k=0;k!=max_model_light;k++) {
		if (k==0) {
			strcpy(tag_name,"light_bone");
		}
		else {
			sprintf(tag_name,"light_bone_%d",k);
		}
		xml_add_attribute_model_tag(tag_name,model->tags.light_bone_tag[k]);
	}

	for (k=0;k!=max_model_halo;k++) {
		if (k==0) {
			strcpy(tag_name,"halo_bone");
		}
		else {
			sprintf(tag_name,"halo_bone_%d",k);
		}
 		xml_add_attribute_model_tag(tag_name,model->tags.halo_bone_tag[k]);
	}

 	xml_add_attribute_model_tag("name_bone",model->tags.name_bone_tag);

	xml_add_tagend(TRUE);
	
		// hit boxes
		
    xml_add_tagstart("Hit_Boxes");
    xml_add_tagend(FALSE);
    
    hit_box=model->hit_boxes;
    
    for (i=0;i!=model->nhit_box;i++) {
		xml_add_tagstart("Hit_Box");
		xml_add_attribute_text("name",hit_box->name);
		xml_add_attribute_3_coord_int("size",hit_box->box.size.x,hit_box->box.size.y,hit_box->box.size.z);
		xml_add_attribute_3_coord_int("offset",hit_box->box.offset.x,hit_box->box.offset.y,hit_box->box.offset.z);
		xml_add_tagend(TRUE);
		
		hit_box++;
	}
	
    xml_add_tagclose("Hit_Boxes");
    
        // bones
        
    xml_add_tagstart("Bones");
    xml_add_tagend(FALSE);
    
    bone=model->bones;
    
    for (i=0;i!=model->nbone;i++) {
    
        xml_add_tagstart("Bone");
        
        xml_add_attribute_model_tag("tag",bone->tag);
		xml_add_attribute_text("name",bone->name);
		
        xml_add_attribute_3_coord_int("c3",bone->pnt.x,bone->pnt.y,bone->pnt.z);
		
        if (bone->parent_idx!=-1) xml_add_attribute_model_tag("parent",model->bones[bone->parent_idx].tag);
        
        xml_add_tagend(TRUE);
    
        bone++;
    }

    xml_add_tagclose("Bones");
	
        // meshes
        
    xml_add_tagstart("Meshes");
    xml_add_tagend(FALSE);
	
	for (j=0;j!=model->nmesh;j++) {
	
		mesh=&model->meshes[j];
	
		xml_add_tagstart("Mesh");
		xml_add_attribute_text("name",mesh->name);
		xml_add_attribute_boolean("no_lighting",mesh->no_lighting);
		xml_add_attribute_boolean("additive",mesh->blend_add);
		xml_add_attribute_boolean("tintable",mesh->tintable);
		xml_add_tagend(FALSE);
	   
			// vertexes
			
		xml_add_tagstart("Vertexes");
		xml_add_tagend(FALSE);
		
		vertex=mesh->vertexes;
		
		for (i=0;i!=mesh->nvertex;i++) {
		
			xml_add_tagstart("v");
			
			xml_add_attribute_3_coord_int("c3",vertex->pnt.x,vertex->pnt.y,vertex->pnt.z);
			xml_add_attribute_3_coord_float("n3",vertex->normal.x,vertex->normal.y,vertex->normal.z);

			if (vertex->major_bone_idx!=-1) {
				xml_add_attribute_model_tag("major",model->bones[vertex->major_bone_idx].tag);
			}
			if (vertex->minor_bone_idx!=-1) {
				xml_add_attribute_model_tag("minor",model->bones[vertex->minor_bone_idx].tag);
				xml_add_attribute_float("factor",vertex->bone_factor);
			}
			
			xml_add_tagend(TRUE);
		
			vertex++;
		}
						
		xml_add_tagclose("Vertexes");
		
			// materials
			
		xml_add_tagstart("Materials");
		xml_add_tagend(FALSE);
		
		texture=model->textures;
		material=mesh->materials;
		
		for (n=0;n!=max_model_texture;n++) {
		
			if (texture->frames[0].name[0]==0x0) {
				texture++;
				material++;
				continue;
			}
			
			xml_add_tagstart("Material");
			xml_add_tagend(FALSE);

				// triangles
				
			xml_add_tagstart("Triangles");
			xml_add_tagend(FALSE);
		
			trig=&mesh->trigs[material->trig_start];
		
			for (i=0;i!=material->trig_count;i++) {
		
				for (k=0;k!=3;k++) {
					xml_add_tagstart("v");
					
					xml_add_attribute_int("id",trig->v[k]);
					xml_add_attribute_2_coord_float("uv",trig->gx[k],trig->gy[k]);
					
					xml_add_tagend(TRUE);
				}
				
				trig++;
			}
			
			xml_add_tagclose("Triangles");
			xml_add_tagclose("Material");
			
			texture++;
			material++;
		}
		
		xml_add_tagclose("Materials");
		
		xml_add_tagclose("Mesh");
	}
	
	xml_add_tagclose("Meshes");
   
         // fills
         
    xml_add_tagstart("Fills");
    xml_add_tagend(FALSE);
    
    texture=model->textures;
    
    for (n=0;n!=max_model_texture;n++) {
    
        if (texture->frames[0].name[0]==0x0) {
            texture++;
            continue;
        }

		frame_count=model_count_texture_frames(model,n);
        
        xml_add_tagstart("Fill");
		bitmap_texture_write_xml(texture,frame_count,FALSE);
        xml_add_tagclose("Fill");
        
		texture++;
    }
    
    xml_add_tagclose("Fills");
}
示例#5
0
bool iface_write_settings_halo(iface_type *iface,char *err_str)
{
	int					n;
	char				path[1024];
	bool				ok;
	iface_halo_type		*halo;
	
		// start new file
		
	xml_new_file();

	xml_add_tagstart("Halos");
	xml_add_tagend(FALSE);

	halo=iface->halo_list.halos;

	for (n=0;n!=iface->halo_list.nhalo;n++) {

		xml_add_tagstart("Halo");
		xml_add_attribute_text("name",halo->name);
		xml_add_tagend(FALSE);

		xml_add_tagstart("Image");
		xml_add_attribute_text("file",halo->bitmap_name);
		xml_add_tagend(TRUE);

		xml_add_tagstart("Distance");
		xml_add_attribute_int("min",halo->min_dist);
		xml_add_attribute_int("max",halo->max_dist);
		xml_add_tagend(TRUE);

		xml_add_tagstart("Size");
		xml_add_attribute_int("min",halo->min_size);
		xml_add_attribute_int("max",halo->max_size);
		xml_add_tagend(TRUE);

		xml_add_tagstart("Alpha");
		xml_add_attribute_float("min",halo->min_alpha);
		xml_add_attribute_float("max",halo->max_alpha);
		xml_add_tagend(TRUE);

		xml_add_tagstart("Option");
		xml_add_attribute_boolean("no_clip_object",halo->no_clip_object);
		xml_add_attribute_boolean("no_clip_self",halo->no_clip_self);
		xml_add_tagend(TRUE);

		xml_add_tagclose("Halo");

		halo++;
	}

	xml_add_tagclose("Halos");

        // write the xml
		
	file_paths_data(&file_path_setup,path,"Settings","Halos","xml");
		
	ok=xml_save_file(path,err_str);
    xml_close_file();
	
	return(ok);
}
示例#6
0
文件: base_xml.c 项目: rzel/dim3
void xml_key_write_int(char *name,int value)
{
    xml_add_tagstart(name);
    xml_add_attribute_int("value",value);
    xml_add_tagend(TRUE);
}
示例#7
0
bool iface_write_settings_ring(iface_type *iface,char *err_str)
{
	int					n;
	char				path[1024];
	bool				ok;
	iface_ring_type		*ring;
	
		// start new file
		
	xml_new_file();

	xml_add_tagstart("Rings");
	xml_add_tagend(FALSE);

	ring=iface->ring_list.rings;

	for (n=0;n!=iface->ring_list.nring;n++) {

		xml_add_tagstart("Ring");
		xml_add_attribute_text("name",ring->name);
		xml_add_tagend(FALSE);
		
  		xml_add_tagstart("Settings");
		xml_add_attribute_int("time",ring->life_msec);
		xml_add_attribute_boolean("additive",ring->blend_add);
		xml_add_tagend(TRUE);
		
        xml_add_tagstart("Image");
		xml_add_attribute_text("file",ring->bitmap_name);
		xml_add_attribute_int("count",ring->animate.image_count);
		xml_add_attribute_int("time",ring->animate.msec);
		xml_add_attribute_boolean("loop",ring->animate.loop);
		xml_add_attribute_boolean("loop_back",ring->animate.loop_back);
		xml_add_tagend(TRUE);
		
        xml_add_tagstart("Outer");
		xml_add_attribute_int("start",ring->start_outer_size);
		xml_add_attribute_int("end",ring->end_outer_size);
		xml_add_tagend(TRUE);

        xml_add_tagstart("Inner");
		xml_add_attribute_int("start",ring->start_inner_size);
		xml_add_attribute_int("end",ring->end_inner_size);
		xml_add_tagend(TRUE);

        xml_add_tagstart("Rotate");
		xml_add_attribute_float("x",ring->ang.x);
		xml_add_attribute_float("y",ring->ang.y);
		xml_add_attribute_float("z",ring->ang.z);
		xml_add_attribute_float("x_add",ring->rot.x);
		xml_add_attribute_float("y_add",ring->rot.y);
		xml_add_attribute_float("z_add",ring->rot.z);
		xml_add_attribute_float("x_accel",ring->rot_accel.x);
		xml_add_attribute_float("y_accel",ring->rot_accel.y);
		xml_add_attribute_float("z_accel",ring->rot_accel.z);
		xml_add_tagend(TRUE);

        xml_add_tagstart("Move");
		xml_add_attribute_float("x",ring->vct.x);
		xml_add_attribute_float("y",ring->vct.y);
		xml_add_attribute_float("z",ring->vct.z);
		xml_add_tagend(TRUE);

        xml_add_tagstart("Color");
		xml_add_attribute_color("start",&ring->start_color);
		xml_add_attribute_color("end",&ring->end_color);
		xml_add_tagend(TRUE);

        xml_add_tagstart("Alpha");
        xml_add_attribute_float("start",ring->start_alpha);
        xml_add_attribute_float("end",ring->end_alpha);
		xml_add_tagend(TRUE);
	
		xml_add_tagclose("Ring");

		ring++;
	}

	xml_add_tagclose("Rings");

        // write the xml
		
	file_paths_data(&file_path_setup,path,"Settings","Rings","xml");
		
	ok=xml_save_file(path,err_str);
    xml_close_file();
	
	return(ok);
}