From c168e91dd428da7b520081b1f082996439643a4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A1chym=20Tou=C5=A1ek?= Date: Fri, 7 Sep 2018 19:01:20 +0200 Subject: [PATCH] Finish emip compilation --- src/main.rs | 52 +++++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 45 insertions(+), 7 deletions(-) diff --git a/src/main.rs b/src/main.rs index c32e45b..b113e78 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,11 @@ fn main() { let arc_type = if chapter == "onikakushi" || chapter == "watanagashi" || chapter == "tatarigoroshi" || chapter == "himatsubushi" { "question_arcs" } else { "answer_arcs" }; let assets = format!("assets/vanilla/{}/{}/sharedassets0.assets", chapter, platform); let directory = "output/assets"; + let emip = format!("output/{}-{}.emip", &chapter, &platform); + if Path::new(&emip).exists() { + fs::remove_file(&emip).expect("Failed to remove file"); + } if Path::new(&directory).exists() { fs::remove_dir_all("output/assets").expect("Failed to remove directory"); } @@ -21,9 +25,9 @@ fn main() { let output = Command::new("python") .env("PYTHONIOENCODING", "utf-8") .arg("../ui-editing-scripts/UnityTextModifier.py") - .arg(format!("{}", &assets)) - .arg(format!("assets/text-edits.json")) - .arg(format!("{}", &directory)) + .arg(&assets) + .arg("assets/text-edits.json") + .arg(&directory) .output() .expect("failed to execute UnityTextModifier.py"); @@ -34,12 +38,46 @@ fn main() { } // 2. images - copy_files("assets/images/shared", directory); - copy_files(format!("assets/images/{}", &arc_type).as_ref(), directory); - copy_files(format!("assets/images/specific/{}", &chapter).as_ref(), directory); + copy_files("assets/images/shared", &directory); + copy_files(format!("assets/images/{}", &arc_type).as_ref(), &directory); + copy_files(format!("assets/images/specific/{}", &chapter).as_ref(), &directory); fs::rename("output/assets/configbg_Texture2D.png", "output/assets/47configbg_Texture2D.png").expect("Unable to rename"); + println!(); // 3. fonts + let output = Command::new("python") + .env("PYTHONIOENCODING", "utf-8") + .arg("../ui-editing-scripts/TMPAssetConverter.py") + .arg("assets/fonts/msgothic_0 SDF Atlas_Texture2D.dat") + .arg("assets/fonts/msgothic_0 SDF_TextMeshProFont.dat") + .arg(format!("assets/vanilla/{}/msgothic_0.dat", &chapter)) + .arg(&directory) + .output() + .expect("failed to execute TMPAssetConverter.py"); + + if output.status.success() { + println!("{}", String::from_utf8_lossy(&output.stdout)); + } else { + println!("{}", String::from_utf8_lossy(&output.stderr)); + } + + println!(); + + // 4. emip + let output = Command::new("python") + .env("PYTHONIOENCODING", "utf-8") + .arg("../ui-editing-scripts/EMIPGenerator.py") + .arg(&assets) + .arg(&directory) + .arg(&emip) + .output() + .expect("failed to execute EMIPGenerator.py"); + + if output.status.success() { + println!("{}", String::from_utf8_lossy(&output.stdout)); + } else { + println!("{}", String::from_utf8_lossy(&output.stderr)); + } } fn copy_files(from: &str, to: &str) { @@ -48,4 +86,4 @@ fn copy_files(from: &str, to: &str) { let path = entry.unwrap().path(); fs::copy(&path, format!("{}/{}_Texture2D.png", to, path.file_stem().unwrap().to_str().unwrap())).expect("Unable to copy"); } -} \ No newline at end of file +}