forked from StrafesNET/map-tool
tweaks
This commit is contained in:
parent
8bd0765290
commit
e833d4c032
24
src/main.rs
24
src/main.rs
@ -1086,24 +1086,21 @@ fn get_some_texture(material:vmt_parser::material::Material)->AResult<VMTContent
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_vmt<F:Fn(String)->AResult<Option<Vec<u8>>>>(find_stuff:&F,search_name:String)->AResult<Option<vmt_parser::material::Material>>{
|
fn get_vmt<F:Fn(String)->AResult<Option<Vec<u8>>>>(find_stuff:&F,search_name:String)->AResult<vmt_parser::material::Material>{
|
||||||
println!("looking for {}",search_name);
|
println!("looking for {}",search_name);
|
||||||
if let Some(stuff)=find_stuff(search_name)?{
|
if let Some(stuff)=find_stuff(search_name)?{
|
||||||
//decode vmt and then write
|
//decode vmt and then write
|
||||||
let stuff=String::from_utf8(stuff)?;
|
let stuff=String::from_utf8(stuff)?;
|
||||||
let material=vmt_parser::from_str(stuff.as_str())?;
|
let material=vmt_parser::from_str(stuff.as_str())?;
|
||||||
println!("vmt material={:?}",material);
|
println!("vmt material={:?}",material);
|
||||||
return Ok(Some(material));
|
return Ok(material);
|
||||||
}
|
}
|
||||||
Ok(None)
|
Err(anyhow::Error::msg("vmt not found"))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn recursive_vmt_loader<F:Fn(String)->AResult<Option<Vec<u8>>>>(find_stuff:&F,material:vmt_parser::material::Material)->AResult<Option<Vec<u8>>>{
|
fn recursive_vmt_loader<F:Fn(String)->AResult<Option<Vec<u8>>>>(find_stuff:&F,material:vmt_parser::material::Material)->AResult<Option<Vec<u8>>>{
|
||||||
match get_some_texture(material)?{
|
match get_some_texture(material)?{
|
||||||
VMTContent::VMT(s)=>match get_vmt(find_stuff,s)?{
|
VMTContent::VMT(s)=>recursive_vmt_loader(find_stuff,get_vmt(find_stuff,s)?),
|
||||||
Some(mat)=>recursive_vmt_loader(find_stuff,mat),
|
|
||||||
None=>Ok(None),
|
|
||||||
},
|
|
||||||
VMTContent::VTF(s)=>find_stuff(s),
|
VMTContent::VTF(s)=>find_stuff(s),
|
||||||
VMTContent::Patch(mat)=>recursive_vmt_loader(find_stuff,
|
VMTContent::Patch(mat)=>recursive_vmt_loader(find_stuff,
|
||||||
mat.resolve(|search_name|
|
mat.resolve(|search_name|
|
||||||
@ -1113,8 +1110,8 @@ fn recursive_vmt_loader<F:Fn(String)->AResult<Option<Vec<u8>>>>(find_stuff:&F,ma
|
|||||||
}
|
}
|
||||||
)?
|
)?
|
||||||
),
|
),
|
||||||
VMTContent::Unsupported=>Ok(None),
|
VMTContent::Unsupported=>Err(anyhow::Error::msg("Unsupported vmt")),
|
||||||
VMTContent::Unresolved=>Ok(None),
|
VMTContent::Unresolved=>Err(anyhow::Error::msg("Unresolved vmt")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1219,16 +1216,13 @@ fn extract_textures(paths:Vec<std::path::PathBuf>,vpk_path:std::path::PathBuf)->
|
|||||||
texture_file_name.pop();
|
texture_file_name.pop();
|
||||||
texture_file_name.push(stem);
|
texture_file_name.push(stem);
|
||||||
//somehow search for both files
|
//somehow search for both files
|
||||||
let mut texture_file_name2=texture_file_name.clone();
|
let mut texture_file_name_vmt=texture_file_name.clone();
|
||||||
texture_file_name.set_extension("vtf");
|
texture_file_name.set_extension("vtf");
|
||||||
texture_file_name2.set_extension("vmt");
|
texture_file_name_vmt.set_extension("vmt");
|
||||||
if let Some(stuff)=find_stuff(texture_file_name.to_string_lossy().to_string())?{
|
if let Some(stuff)=find_stuff(texture_file_name.to_string_lossy().to_string())?{
|
||||||
return Ok(Some(stuff))
|
return Ok(Some(stuff))
|
||||||
}
|
}
|
||||||
if let Some(mat)=get_vmt(&find_stuff,texture_file_name2.to_string_lossy().to_string())?{
|
recursive_vmt_loader(&find_stuff,get_vmt(&find_stuff,texture_file_name_vmt.to_string_lossy().to_string())?)
|
||||||
return recursive_vmt_loader(&find_stuff,mat);
|
|
||||||
}
|
|
||||||
Ok(None)
|
|
||||||
};
|
};
|
||||||
if let Some(stuff)=loader(texture_name.to_string_lossy().to_string())?{
|
if let Some(stuff)=loader(texture_name.to_string_lossy().to_string())?{
|
||||||
found_texture=true;
|
found_texture=true;
|
||||||
|
Loading…
Reference in New Issue
Block a user