Copy images
This commit is contained in:
39
src/main.rs
39
src/main.rs
@@ -1,38 +1,29 @@
|
|||||||
use std::env;
|
use std::env;
|
||||||
use std::collections::HashMap;
|
|
||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
|
let chapter = &args[1];
|
||||||
let platform = &args[2];
|
let platform = &args[2];
|
||||||
|
|
||||||
let mut chapters = HashMap::new();
|
let arc_type = if chapter == "onikakushi" || chapter == "watanagashi" || chapter == "tatarigoroshi" || chapter == "himatsubushi" { "question_arcs" } else { "answer_arcs" };
|
||||||
|
|
||||||
chapters.insert("oni".to_string(), "onikakushi");
|
|
||||||
chapters.insert("wata".to_string(), "watanagashi");
|
|
||||||
chapters.insert("tata".to_string(), "tatarigoroshi-steam");
|
|
||||||
chapters.insert("tata-mg".to_string(), "tatarigoroshi-mg");
|
|
||||||
chapters.insert("hima".to_string(), "himatsubushi");
|
|
||||||
chapters.insert("mea".to_string(), "meakashi");
|
|
||||||
chapters.insert("tsumi".to_string(), "tsumihoroboshi");
|
|
||||||
|
|
||||||
let chapter = chapters.get(&args[1]).expect("Unknown chapter");
|
|
||||||
let assets = format!("assets/vanilla/{}/{}/sharedassets0.assets", chapter, platform);
|
let assets = format!("assets/vanilla/{}/{}/sharedassets0.assets", chapter, platform);
|
||||||
let directory = "output/assets";
|
let directory = "output/assets";
|
||||||
|
|
||||||
if Path::new(&directory).exists() {
|
if Path::new(&directory).exists() {
|
||||||
fs::remove_dir_all(&directory).expect("Failed to remove directory");
|
fs::remove_dir_all("output/assets").expect("Failed to remove directory");
|
||||||
}
|
}
|
||||||
fs::create_dir_all(&directory).expect("Failed to recreate directory");
|
fs::create_dir_all("output/assets").expect("Failed to recreate directory");
|
||||||
|
|
||||||
|
// 1. texts
|
||||||
let output = Command::new("python")
|
let output = Command::new("python")
|
||||||
.env("PYTHONIOENCODING", "utf-8")
|
.env("PYTHONIOENCODING", "utf-8")
|
||||||
.arg("../ui-editing-scripts/UnityTextModifier.py")
|
.arg("../ui-editing-scripts/UnityTextModifier.py")
|
||||||
.arg(format!("{}", assets))
|
.arg(format!("{}", &assets))
|
||||||
.arg(format!("assets/text-edits.json"))
|
.arg(format!("assets/text-edits.json"))
|
||||||
.arg(format!("{}", directory))
|
.arg(format!("{}", &directory))
|
||||||
.output()
|
.output()
|
||||||
.expect("failed to execute UnityTextModifier.py");
|
.expect("failed to execute UnityTextModifier.py");
|
||||||
|
|
||||||
@@ -41,4 +32,20 @@ fn main() {
|
|||||||
} else {
|
} else {
|
||||||
println!("{}", String::from_utf8_lossy(&output.stderr));
|
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");
|
||||||
|
|
||||||
|
// 3. fonts
|
||||||
|
}
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user