Generate assets file
This commit is contained in:
2
applyemip.sh
Normal file
2
applyemip.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
AssetBundleExtractor.exe applyemip output/onikakushi-win.emip output
|
||||||
|
exit $?
|
||||||
119
src/main.rs
119
src/main.rs
@@ -2,97 +2,130 @@ use std::env;
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::process;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
let chapter = &args[1];
|
let chapter = &args[1];
|
||||||
let platform = &args[2];
|
let platform = &args[2];
|
||||||
|
|
||||||
let arc_type = if chapter == "onikakushi" || chapter == "watanagashi" || chapter == "tatarigoroshi" || chapter == "himatsubushi" { "question_arcs" } else { "answer_arcs" };
|
let mut chapters = HashMap::new();
|
||||||
|
chapters.insert("onikakushi".to_string(), 1);
|
||||||
|
chapters.insert("watanagashi".to_string(), 2);
|
||||||
|
chapters.insert("tatarigoroshi".to_string(), 3);
|
||||||
|
chapters.insert("himatsubushi".to_string(), 4);
|
||||||
|
chapters.insert("meakashi".to_string(), 5);
|
||||||
|
chapters.insert("tsumihoroboshi".to_string(), 6);
|
||||||
|
|
||||||
|
if !chapters.contains_key(chapter) {
|
||||||
|
println!("Unknown chapter");
|
||||||
|
process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
let arc_number = chapters.get(chapter).unwrap();
|
||||||
|
let arc_type = if arc_number <= &4 { "question_arcs" } else { "answer_arcs" };
|
||||||
let assets = format!("assets/vanilla/{}/{}/sharedassets0.assets", chapter, platform);
|
let assets = format!("assets/vanilla/{}/{}/sharedassets0.assets", chapter, platform);
|
||||||
let directory = "output/assets";
|
let directory_assets = "output/assets";
|
||||||
let emip = format!("output/{}-{}.emip", &chapter, &platform);
|
let directory_data = format!("output/HigurashiEp{:02}_Data", arc_number);
|
||||||
|
let emip = format!("{}/{}-{}.emip", &directory_data, &chapter, &platform);
|
||||||
|
|
||||||
if Path::new(&emip).exists() {
|
if Path::new(&emip).exists() {
|
||||||
fs::remove_file(&emip).expect("Failed to remove file");
|
fs::remove_file(&emip).expect("Failed to remove file");
|
||||||
}
|
}
|
||||||
if Path::new(&directory).exists() {
|
if Path::new(&directory_assets).exists() {
|
||||||
fs::remove_dir_all("output/assets").expect("Failed to remove directory");
|
fs::remove_dir_all(&directory_assets).expect("Failed to remove directory");
|
||||||
}
|
}
|
||||||
fs::create_dir_all("output/assets").expect("Failed to recreate directory");
|
fs::create_dir_all(&directory_assets).expect("Failed to recreate directory");
|
||||||
|
if Path::new(&directory_data).exists() {
|
||||||
|
fs::remove_dir_all(&directory_data).expect("Failed to remove directory");
|
||||||
|
}
|
||||||
|
fs::create_dir_all(&directory_data).expect("Failed to recreate directory");
|
||||||
|
|
||||||
// 1. texts
|
// 1. texts
|
||||||
let output = Command::new("python")
|
let status = Command::new("python")
|
||||||
.env("PYTHONIOENCODING", "utf-8")
|
.env("PYTHONIOENCODING", "utf-8")
|
||||||
.arg("scripts/UnityTextModifier.py")
|
.arg("scripts/UnityTextModifier.py")
|
||||||
.arg(&assets)
|
.arg(&assets)
|
||||||
.arg("assets/text-edits.json")
|
.arg("assets/text-edits.json")
|
||||||
.arg(&directory)
|
.arg(&directory_assets)
|
||||||
.output()
|
.status()
|
||||||
.expect("failed to execute UnityTextModifier.py");
|
.expect("failed to execute UnityTextModifier.py");
|
||||||
|
|
||||||
if output.status.success() {
|
assert!(status.success());
|
||||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
|
||||||
} else {
|
|
||||||
println!("{}", String::from_utf8_lossy(&output.stderr));
|
|
||||||
}
|
|
||||||
|
|
||||||
// 2. images
|
// 2. images
|
||||||
copy_files("assets/images/shared", &directory);
|
copy_images("assets/images/shared", &directory_assets);
|
||||||
copy_files(format!("assets/images/{}", &arc_type).as_ref(), &directory);
|
copy_images(format!("assets/images/{}", &arc_type).as_ref(), &directory_assets);
|
||||||
copy_files(format!("assets/images/specific/{}", &chapter).as_ref(), &directory);
|
copy_images(format!("assets/images/specific/{}", &chapter).as_ref(), &directory_assets);
|
||||||
fs::rename("output/assets/configbg_Texture2D.png", "output/assets/47configbg_Texture2D.png").expect("Unable to rename");
|
fs::rename("output/assets/configbg_Texture2D.png", "output/assets/47configbg_Texture2D.png").expect("Unable to rename");
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
// 3. fonts
|
// 3. fonts
|
||||||
let output = Command::new("python")
|
let status = Command::new("python")
|
||||||
.env("PYTHONIOENCODING", "utf-8")
|
.env("PYTHONIOENCODING", "utf-8")
|
||||||
.arg("scripts/TMPAssetConverter.py")
|
.arg("scripts/TMPAssetConverter.py")
|
||||||
.arg("assets/fonts/msgothic_0 SDF Atlas_Texture2D.dat")
|
.arg("assets/fonts/msgothic_0 SDF Atlas_Texture2D.dat")
|
||||||
.arg("assets/fonts/msgothic_0 SDF_TextMeshProFont.dat")
|
.arg("assets/fonts/msgothic_0 SDF_TextMeshProFont.dat")
|
||||||
.arg(format!("assets/vanilla/{}/msgothic_0.dat", &chapter))
|
.arg(format!("assets/vanilla/{}/msgothic_0.dat", &chapter))
|
||||||
.arg(&directory)
|
.arg(&directory_assets)
|
||||||
.output()
|
.status()
|
||||||
.expect("failed to execute TMPAssetConverter.py");
|
.expect("failed to execute TMPAssetConverter.py");
|
||||||
|
|
||||||
if output.status.success() {
|
assert!(status.success());
|
||||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
|
||||||
} else {
|
|
||||||
println!("{}", String::from_utf8_lossy(&output.stderr));
|
|
||||||
}
|
|
||||||
|
|
||||||
let output = Command::new("python")
|
let status = Command::new("python")
|
||||||
.env("PYTHONIOENCODING", "utf-8")
|
.env("PYTHONIOENCODING", "utf-8")
|
||||||
.arg("scripts/TMPAssetConverter.py")
|
.arg("scripts/TMPAssetConverter.py")
|
||||||
.arg("assets/fonts/msgothic_2 SDF Atlas_Texture2D.dat")
|
.arg("assets/fonts/msgothic_2 SDF Atlas_Texture2D.dat")
|
||||||
.arg("assets/fonts/msgothic_2 SDF_TextMeshProFont.dat")
|
.arg("assets/fonts/msgothic_2 SDF_TextMeshProFont.dat")
|
||||||
.arg(format!("assets/vanilla/{}/msgothic_2.dat", &chapter))
|
.arg(format!("assets/vanilla/{}/msgothic_2.dat", &chapter))
|
||||||
.arg(&directory)
|
.arg(&directory_assets)
|
||||||
.output()
|
.status()
|
||||||
.expect("failed to execute TMPAssetConverter.py");
|
.expect("failed to execute TMPAssetConverter.py");
|
||||||
|
|
||||||
if output.status.success() {
|
assert!(status.success());
|
||||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
|
||||||
} else {
|
|
||||||
println!("{}", String::from_utf8_lossy(&output.stderr));
|
|
||||||
}
|
|
||||||
|
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
// 4. emip
|
// 4. copy assets
|
||||||
let output = Command::new("python")
|
copy_files(format!("assets/vanilla/{}/{}", chapter, platform).as_ref(), &directory_data);
|
||||||
|
|
||||||
|
println!();
|
||||||
|
|
||||||
|
// 5. generate emip
|
||||||
|
let status = Command::new("python")
|
||||||
.env("PYTHONIOENCODING", "utf-8")
|
.env("PYTHONIOENCODING", "utf-8")
|
||||||
.arg("scripts/EMIPGenerator.py")
|
.arg("scripts/EMIPGenerator.py")
|
||||||
.arg(&assets)
|
.arg(format!("{}/sharedassets0.assets", &directory_data))
|
||||||
.arg(&directory)
|
.arg(&directory_assets)
|
||||||
.arg(&emip)
|
.arg(&emip)
|
||||||
.output()
|
.status()
|
||||||
.expect("failed to execute EMIPGenerator.py");
|
.expect("failed to execute EMIPGenerator.py");
|
||||||
|
|
||||||
if output.status.success() {
|
assert!(status.success());
|
||||||
println!("{}", String::from_utf8_lossy(&output.stdout));
|
|
||||||
} else {
|
println!();
|
||||||
println!("{}", String::from_utf8_lossy(&output.stderr));
|
|
||||||
|
// 6. apply emip
|
||||||
|
let status = Command::new("AssetBundleExtractor.exe")
|
||||||
|
.arg("applyemip")
|
||||||
|
.arg(&emip)
|
||||||
|
.arg("output")
|
||||||
|
.status()
|
||||||
|
.expect("failed to execute AssetBundleExtractor.exe");
|
||||||
|
|
||||||
|
println!("{}", status.to_string());
|
||||||
|
|
||||||
|
fs::remove_file(format!("{}/sharedassets0.assets.bak0000", &directory_data)).expect("Failed to remove file");
|
||||||
|
fs::remove_file(&emip).expect("Failed to remove file");
|
||||||
|
}
|
||||||
|
|
||||||
|
fn copy_images(from: &str, to: &str) {
|
||||||
|
println!("Copying files from {}", from);
|
||||||
|
for entry in fs::read_dir(from).expect("Can't read directory") {
|
||||||
|
let path = entry.unwrap().path();
|
||||||
|
fs::copy(&path, format!("{}/{}_Texture2D.png", to, path.file_stem().unwrap().to_str().unwrap())).expect("Unable to copy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,6 +133,6 @@ fn copy_files(from: &str, to: &str) {
|
|||||||
println!("Copying files from {}", from);
|
println!("Copying files from {}", from);
|
||||||
for entry in fs::read_dir(from).expect("Can't read directory") {
|
for entry in fs::read_dir(from).expect("Can't read directory") {
|
||||||
let path = entry.unwrap().path();
|
let path = entry.unwrap().path();
|
||||||
fs::copy(&path, format!("{}/{}_Texture2D.png", to, path.file_stem().unwrap().to_str().unwrap())).expect("Unable to copy");
|
fs::copy(&path, format!("{}/{}", to, path.file_name().unwrap().to_str().unwrap())).expect("Unable to copy");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user