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