Merge branch 'rust'

# Conflicts:
#	README.md
This commit is contained in:
Jáchym Toušek
2018-09-07 19:35:20 +02:00
46 changed files with 169 additions and 2 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
/output
/target
**/*.rs.bk

4
Cargo.lock generated Normal file
View File

@@ -0,0 +1,4 @@
[[package]]
name = "ui-compiler"
version = "0.1.0"

6
Cargo.toml Normal file
View File

@@ -0,0 +1,6 @@
[package]
name = "ui-compiler"
version = "0.1.0"
authors = ["Jáchym Toušek <enumag@gmail.com>"]
[dependencies]

View File

@@ -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 <chapter> <platform>
```
`<chapter>` is simply `onikakushi`, `watanagashi` and so on.
`<platform>` 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.

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 47 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 359 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 212 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 184 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 41 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 183 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 177 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.6 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 MiB

50
assets/text-edits.json Normal file
View File

@@ -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"
}
]

89
src/main.rs Normal file
View File

@@ -0,0 +1,89 @@
use std::env;
use std::process::Command;
use std::fs;
use std::path::Path;
fn main() {
let args: Vec<String> = 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");
}
}