Deduplicate unxwb code
This commit is contained in:
parent
7dbb8c1e62
commit
8afe245e05
31
src/main.rs
31
src/main.rs
|
@ -102,23 +102,22 @@ fn main() -> Result<()> {
|
||||||
let wave_bank = WaveBank::parse(&xwb_data)?;
|
let wave_bank = WaveBank::parse(&xwb_data)?;
|
||||||
info!("Opened wave bank “{}” from {:?}", wave_bank.name, opts.file);
|
info!("Opened wave bank “{}” from {:?}", wave_bank.name, opts.file);
|
||||||
|
|
||||||
match opts.single_entry {
|
let entries = match opts.single_entry {
|
||||||
Some(name) => {
|
Some(name) => match wave_bank.sounds.get(&name) {
|
||||||
let sound = match wave_bank.sounds.get(&name) {
|
Some(_) => vec![name],
|
||||||
Some(sound) => sound,
|
None => return error(format!("Entry {} not found in wave bank", name)),
|
||||||
None => return error(format!("Entry {} not found in wave bank", name)),
|
},
|
||||||
};
|
None => wave_bank.sounds.keys().cloned().collect(),
|
||||||
fs::write(format!("{}.wav", name), &sound.to_wav()?)?;
|
};
|
||||||
}
|
|
||||||
None => {
|
for (name, sound) in wave_bank.sounds {
|
||||||
for (name, sound) in wave_bank.sounds {
|
if entries.contains(&name) {
|
||||||
if opts.list_entries {
|
if opts.list_entries {
|
||||||
println!("{}", name);
|
println!("{}", name);
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
info!("Extracting {}", name);
|
|
||||||
fs::write(format!("{}.wav", name), &sound.to_wav()?)?;
|
|
||||||
}
|
}
|
||||||
|
info!("Extracting {}", name);
|
||||||
|
fs::write(format!("{}.wav", name), &sound.to_wav()?)?;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Reference in a new issue