final final
This commit is contained in:
parent
71dcde8a3f
commit
96e8d9aeea
@ -22,14 +22,14 @@ pub struct SourceToSNFSubcommand {
|
||||
#[arg(required=true)]
|
||||
input_files:Vec<PathBuf>,
|
||||
#[arg(long)]
|
||||
vpk_dir_files:Vec<PathBuf>,
|
||||
vpks:Vec<PathBuf>,
|
||||
}
|
||||
#[derive(Args)]
|
||||
pub struct ExtractTexturesSubcommand{
|
||||
#[arg(required=true)]
|
||||
bsp_files:Vec<PathBuf>,
|
||||
#[arg(long)]
|
||||
vpk_dir_files:Vec<PathBuf>,
|
||||
vpks:Vec<PathBuf>,
|
||||
}
|
||||
#[derive(Args)]
|
||||
pub struct VPKContentsSubcommand {
|
||||
@ -45,8 +45,8 @@ pub struct BSPContentsSubcommand {
|
||||
impl Commands{
|
||||
pub async fn run(self)->AResult<()>{
|
||||
match self{
|
||||
Commands::SourceToSNF(subcommand)=>source_to_snf(subcommand.input_files,subcommand.output_folder,subcommand.vpk_dir_files).await,
|
||||
Commands::ExtractTextures(subcommand)=>extract_textures(subcommand.bsp_files,subcommand.vpk_dir_files).await,
|
||||
Commands::SourceToSNF(subcommand)=>source_to_snf(subcommand.input_files,subcommand.output_folder,subcommand.vpks).await,
|
||||
Commands::ExtractTextures(subcommand)=>extract_textures(subcommand.bsp_files,subcommand.vpks).await,
|
||||
Commands::VPKContents(subcommand)=>vpk_contents(subcommand.input_file),
|
||||
Commands::BSPContents(subcommand)=>bsp_contents(subcommand.input_file),
|
||||
}
|
||||
@ -232,8 +232,12 @@ async fn gimme_them_textures(path:PathBuf,vpk_list:&[vpk::VPK],send_texture:toki
|
||||
}
|
||||
|
||||
for texture_path in texture_deferred_loader.indices(){
|
||||
if let Some(texture)=load_texture(finder,texture_path.as_ref())?{
|
||||
send_texture.send((texture.into_owned(),texture_path.as_ref().to_owned())).await.unwrap();
|
||||
match load_texture(finder,texture_path.as_ref()){
|
||||
Ok(Some(texture))=>send_texture.send(
|
||||
(texture.into_owned(),texture_path.as_ref().to_owned())
|
||||
).await.unwrap(),
|
||||
Ok(None)=>(),
|
||||
Err(e)=>println!("Load error: {e}"),
|
||||
}
|
||||
}
|
||||
|
||||
@ -315,7 +319,10 @@ async fn extract_textures(paths:Vec<PathBuf>,vpk_paths:Vec<PathBuf>)->AResult<()
|
||||
tokio::spawn(async move{
|
||||
let result=gimme_them_textures(path,vpk_list,send).await;
|
||||
drop(permit);
|
||||
result.unwrap();
|
||||
match result{
|
||||
Ok(())=>(),
|
||||
Err(e)=>println!("Decode error: {e:?}"),
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
@ -324,10 +331,14 @@ async fn extract_textures(paths:Vec<PathBuf>,vpk_paths:Vec<PathBuf>)->AResult<()
|
||||
static SEM:tokio::sync::Semaphore=tokio::sync::Semaphore::const_new(0);
|
||||
SEM.add_permits(thread_limit);
|
||||
while let (Ok(permit),Some((data,dest)))=(SEM.acquire().await,recv_texture.recv().await){
|
||||
// TODO: dedup dest?
|
||||
tokio::spawn(async move{
|
||||
let result=convert_texture(data,dest).await;
|
||||
drop(permit);
|
||||
result.unwrap();
|
||||
match result{
|
||||
Ok(())=>(),
|
||||
Err(e)=>println!("Convert error: {e:?}"),
|
||||
}
|
||||
});
|
||||
}
|
||||
extract_thread.await?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user