diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7c38e2e --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +/output +/target +**/*.rs.bk diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..976993a --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,4 @@ +[[package]] +name = "ui-compiler" +version = "0.1.0" + diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..c8a8e6c --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "ui-compiler" +version = "0.1.0" +authors = ["Jáchym Toušek "] + +[dependencies] diff --git a/README.md b/README.md index 859ea67..e613ec7 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,20 @@ -# UI editing scripts +UI Compiler +---- Scripts for easier editing of Unity assets for Higurashi. -Documentation can be found [here](https://github.com/07th-mod/higurashi-dev-guides/wiki/UI-editing-scripts). +To use this tool you will need to install both Python and Rust. Then simply run this: + +``` +cargo run +``` + +`` is simply `onikakushi`, `watanagashi` and so on. + +`` is `win` or `mac`. For tatarigoroshi platform can also be `win-mg` and `mac-mg`. + +Documentation for the underlying python scripts can be found [here](https://github.com/07th-mod/higurashi-dev-guides/wiki/UI-editing-scripts). + +The rust script will generate a new emip file in the output directory which you can apply to assets file using UABE as described in the docs for the python scripts. + +If you want to use this tool to compile assets for a different language, you can change the files in the assets directory to your needs. diff --git a/assets/fonts/msgothic_0 SDF Atlas_Texture2D.dat b/assets/fonts/msgothic_0 SDF Atlas_Texture2D.dat new file mode 100644 index 0000000..1d34187 Binary files /dev/null and b/assets/fonts/msgothic_0 SDF Atlas_Texture2D.dat differ diff --git a/assets/fonts/msgothic_0 SDF_TextMeshProFont.dat b/assets/fonts/msgothic_0 SDF_TextMeshProFont.dat new file mode 100644 index 0000000..2e2b245 Binary files /dev/null and b/assets/fonts/msgothic_0 SDF_TextMeshProFont.dat differ diff --git a/assets/images/answer_arcs/ChapterPreview.png b/assets/images/answer_arcs/ChapterPreview.png new file mode 100644 index 0000000..1d70ec0 Binary files /dev/null and b/assets/images/answer_arcs/ChapterPreview.png differ diff --git a/assets/images/answer_arcs/TitleHigurashi.png b/assets/images/answer_arcs/TitleHigurashi.png new file mode 100644 index 0000000..c83eef9 Binary files /dev/null and b/assets/images/answer_arcs/TitleHigurashi.png differ diff --git a/assets/images/question_arcs/ChapterPreview.png b/assets/images/question_arcs/ChapterPreview.png new file mode 100644 index 0000000..278e432 Binary files /dev/null and b/assets/images/question_arcs/ChapterPreview.png differ diff --git a/assets/images/question_arcs/TitleHigurashi.png b/assets/images/question_arcs/TitleHigurashi.png new file mode 100644 index 0000000..4270165 Binary files /dev/null and b/assets/images/question_arcs/TitleHigurashi.png differ diff --git a/assets/images/shared/Backlog.png b/assets/images/shared/Backlog.png new file mode 100644 index 0000000..4af56c2 Binary files /dev/null and b/assets/images/shared/Backlog.png differ diff --git a/assets/images/shared/ConfigHigurashi.png b/assets/images/shared/ConfigHigurashi.png new file mode 100644 index 0000000..289d925 Binary files /dev/null and b/assets/images/shared/ConfigHigurashi.png differ diff --git a/assets/images/shared/HigurashiMenu.png b/assets/images/shared/HigurashiMenu.png new file mode 100644 index 0000000..0b51a67 Binary files /dev/null and b/assets/images/shared/HigurashiMenu.png differ diff --git a/assets/images/shared/MainUI.png b/assets/images/shared/MainUI.png new file mode 100644 index 0000000..799fbd4 Binary files /dev/null and b/assets/images/shared/MainUI.png differ diff --git a/assets/images/shared/PromptHigurashi.png b/assets/images/shared/PromptHigurashi.png new file mode 100644 index 0000000..9073355 Binary files /dev/null and b/assets/images/shared/PromptHigurashi.png differ diff --git a/assets/images/shared/SGMenu990000.png b/assets/images/shared/SGMenu990000.png new file mode 100644 index 0000000..d1276ce Binary files /dev/null and b/assets/images/shared/SGMenu990000.png differ diff --git a/assets/images/shared/SGMenu990000_jp.png b/assets/images/shared/SGMenu990000_jp.png new file mode 100644 index 0000000..c80cb24 Binary files /dev/null and b/assets/images/shared/SGMenu990000_jp.png differ diff --git a/assets/images/shared/black.png b/assets/images/shared/black.png new file mode 100644 index 0000000..b0d8486 Binary files /dev/null and b/assets/images/shared/black.png differ diff --git a/assets/images/shared/configbg.png b/assets/images/shared/configbg.png new file mode 100644 index 0000000..d3c7753 Binary files /dev/null and b/assets/images/shared/configbg.png differ diff --git a/assets/images/shared/configbg_jp.png b/assets/images/shared/configbg_jp.png new file mode 100644 index 0000000..a20440e Binary files /dev/null and b/assets/images/shared/configbg_jp.png differ diff --git a/assets/images/shared/dialog_areyousure.png b/assets/images/shared/dialog_areyousure.png new file mode 100644 index 0000000..bd85f79 Binary files /dev/null and b/assets/images/shared/dialog_areyousure.png differ diff --git a/assets/images/shared/dialog_areyousure_jp.png b/assets/images/shared/dialog_areyousure_jp.png new file mode 100644 index 0000000..8205f69 Binary files /dev/null and b/assets/images/shared/dialog_areyousure_jp.png differ diff --git a/assets/images/shared/dialog_delete.png b/assets/images/shared/dialog_delete.png new file mode 100644 index 0000000..5ad03d6 Binary files /dev/null and b/assets/images/shared/dialog_delete.png differ diff --git a/assets/images/shared/dialog_delete_jp.png b/assets/images/shared/dialog_delete_jp.png new file mode 100644 index 0000000..ee12890 Binary files /dev/null and b/assets/images/shared/dialog_delete_jp.png differ diff --git a/assets/images/shared/dialog_edit.png b/assets/images/shared/dialog_edit.png new file mode 100644 index 0000000..32fed2d Binary files /dev/null and b/assets/images/shared/dialog_edit.png differ diff --git a/assets/images/shared/dialog_edit_jp.png b/assets/images/shared/dialog_edit_jp.png new file mode 100644 index 0000000..5d969ff Binary files /dev/null and b/assets/images/shared/dialog_edit_jp.png differ diff --git a/assets/images/shared/dialog_exit.png b/assets/images/shared/dialog_exit.png new file mode 100644 index 0000000..9926a85 Binary files /dev/null and b/assets/images/shared/dialog_exit.png differ diff --git a/assets/images/shared/dialog_exit_jp.png b/assets/images/shared/dialog_exit_jp.png new file mode 100644 index 0000000..191994e Binary files /dev/null and b/assets/images/shared/dialog_exit_jp.png differ diff --git a/assets/images/shared/dialog_language.png b/assets/images/shared/dialog_language.png new file mode 100644 index 0000000..829b7c7 Binary files /dev/null and b/assets/images/shared/dialog_language.png differ diff --git a/assets/images/shared/dialog_load.png b/assets/images/shared/dialog_load.png new file mode 100644 index 0000000..404d00a Binary files /dev/null and b/assets/images/shared/dialog_load.png differ diff --git a/assets/images/shared/dialog_load_jp.png b/assets/images/shared/dialog_load_jp.png new file mode 100644 index 0000000..e206ed5 Binary files /dev/null and b/assets/images/shared/dialog_load_jp.png differ diff --git a/assets/images/shared/dialog_save.png b/assets/images/shared/dialog_save.png new file mode 100644 index 0000000..caf6255 Binary files /dev/null and b/assets/images/shared/dialog_save.png differ diff --git a/assets/images/shared/dialog_save_jp.png b/assets/images/shared/dialog_save_jp.png new file mode 100644 index 0000000..4270084 Binary files /dev/null and b/assets/images/shared/dialog_save_jp.png differ diff --git a/assets/images/shared/log_bg_base_b.png b/assets/images/shared/log_bg_base_b.png new file mode 100644 index 0000000..b142a29 Binary files /dev/null and b/assets/images/shared/log_bg_base_b.png differ diff --git a/assets/images/shared/s_jump_back.png b/assets/images/shared/s_jump_back.png new file mode 100644 index 0000000..35ecb2c Binary files /dev/null and b/assets/images/shared/s_jump_back.png differ diff --git a/assets/images/shared/saveloadbg.png b/assets/images/shared/saveloadbg.png new file mode 100644 index 0000000..06c40dd Binary files /dev/null and b/assets/images/shared/saveloadbg.png differ diff --git a/assets/images/shared/saveloadhigurashi.png b/assets/images/shared/saveloadhigurashi.png new file mode 100644 index 0000000..ded6e9b Binary files /dev/null and b/assets/images/shared/saveloadhigurashi.png differ diff --git a/assets/images/shared/tipsback.png b/assets/images/shared/tipsback.png new file mode 100644 index 0000000..7557c45 Binary files /dev/null and b/assets/images/shared/tipsback.png differ diff --git a/assets/images/specific/himatsubushi/TipsPrefab.png b/assets/images/specific/himatsubushi/TipsPrefab.png new file mode 100644 index 0000000..184edb6 Binary files /dev/null and b/assets/images/specific/himatsubushi/TipsPrefab.png differ diff --git a/assets/images/specific/meakashi/TipsPrefab.png b/assets/images/specific/meakashi/TipsPrefab.png new file mode 100644 index 0000000..e347529 Binary files /dev/null and b/assets/images/specific/meakashi/TipsPrefab.png differ diff --git a/assets/images/specific/onikakushi/TipsPrefab.png b/assets/images/specific/onikakushi/TipsPrefab.png new file mode 100644 index 0000000..6444415 Binary files /dev/null and b/assets/images/specific/onikakushi/TipsPrefab.png differ diff --git a/assets/images/specific/tatarigoroshi/TipsPrefab.png b/assets/images/specific/tatarigoroshi/TipsPrefab.png new file mode 100644 index 0000000..0b74ffd Binary files /dev/null and b/assets/images/specific/tatarigoroshi/TipsPrefab.png differ diff --git a/assets/images/specific/tsumihoroboshi/TipsPrefab.png b/assets/images/specific/tsumihoroboshi/TipsPrefab.png new file mode 100644 index 0000000..a409941 Binary files /dev/null and b/assets/images/specific/tsumihoroboshi/TipsPrefab.png differ diff --git a/assets/images/specific/watanagashi/TipsPrefab.png b/assets/images/specific/watanagashi/TipsPrefab.png new file mode 100644 index 0000000..35f7c9e Binary files /dev/null and b/assets/images/specific/watanagashi/TipsPrefab.png differ diff --git a/assets/text-edits.json b/assets/text-edits.json new file mode 100644 index 0000000..1c2e12e --- /dev/null +++ b/assets/text-edits.json @@ -0,0 +1,50 @@ +[ + { + "CurrentEnglish": "Updated", + "CurrentJapanese": "新規", + "NewEnglish": "Remake", + "NewJapanese": "リメーク" + }, + { + "CurrentEnglish": "Original", + "CurrentJapanese": "オリジナル", + "NewEnglish": "Console", + "NewJapanese": "ゲーム機" + }, + { + "CurrentEnglish": "Standard 640x480", + "CurrentJapanese": "標準 640x480", + "NewEnglish": "Standard 854x480", + "NewJapanese": "標準 854x480" + }, + { + "CurrentEnglish": "800x600", + "CurrentJapanese": "800x600", + "NewEnglish": "1067x600", + "NewJapanese": "1067x600" + }, + { + "CurrentEnglish": "1024x768", + "CurrentJapanese": "1024x768", + "NewEnglish": "1366x768", + "NewJapanese": "1366x768" + }, + { + "CurrentEnglish": "Watanagashi 12-3", + "CurrentJapanese": "綿流し編 12日目3", + "NewEnglish": "Watanagashi Day 12-3", + "NewJapanese": "綿流し編 12日目3" + }, + { + "CurrentEnglish": "Himatsubushi 2-2", + "CurrentJapanese": "暇潰し編 2日目2", + "NewEnglish": "Himatsubushi Day 2-2", + "NewJapanese": "暇潰し編 2日目2" + }, + { + "CurrentEnglish": "Himatsubushi 2-3", + "CurrentJapanese": "暇潰し編 2日目3", + "NewEnglish": "Himatsubushi Day 2-3", + "NewJapanese": "暇潰し編 2日目3" + } +] diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..b113e78 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,89 @@ +use std::env; +use std::process::Command; +use std::fs; +use std::path::Path; + +fn main() { + let args: Vec = env::args().collect(); + let chapter = &args[1]; + let platform = &args[2]; + + 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"); + } + fs::create_dir_all("output/assets").expect("Failed to recreate directory"); + + // 1. texts + let output = Command::new("python") + .env("PYTHONIOENCODING", "utf-8") + .arg("../ui-editing-scripts/UnityTextModifier.py") + .arg(&assets) + .arg("assets/text-edits.json") + .arg(&directory) + .output() + .expect("failed to execute UnityTextModifier.py"); + + if output.status.success() { + println!("{}", String::from_utf8_lossy(&output.stdout)); + } else { + println!("{}", String::from_utf8_lossy(&output.stderr)); + } + + // 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); + 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) { + 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"); + } +}