diff --git a/.gitignore b/.gitignore index ea8c4bf..b4e58e1 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ /target +*.exe +*.zip diff --git a/Cargo.lock b/Cargo.lock index 094aa5e..5c89fcc 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -60,6 +60,15 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +[[package]] +name = "colored" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fde0e0ec90c9dfb3b4b1a0891a7dcd0e2bffde2f7efed5fe7c9bb00e5bfb915e" +dependencies = [ + "windows-sys", +] + [[package]] name = "console" version = "0.15.11" @@ -295,8 +304,9 @@ checksum = "30bde2b3dc3671ae49d8e2e9f044c7c005836e7a023ee57cffa25ab82764bb9e" [[package]] name = "mhws-tex-decompressor" -version = "0.1.2" +version = "0.1.3" dependencies = [ + "colored", "dialoguer", "eyre", "indicatif", diff --git a/Cargo.toml b/Cargo.toml index 69c9745..7df5806 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "mhws-tex-decompressor" -version = "0.1.2" +version = "0.1.3" edition = "2024" [dependencies] @@ -16,3 +16,4 @@ eyre = "0.6" indicatif = "0.17" rayon = "1.10" parking_lot = "0.12" +colored = "3.0" diff --git a/src/main.rs b/src/main.rs index ab64636..7d6abbf 100644 --- a/src/main.rs +++ b/src/main.rs @@ -9,6 +9,7 @@ use std::{ time::Duration, }; +use colored::Colorize; use dialoguer::{Input, Select, theme::ColorfulTheme}; use indicatif::{HumanBytes, ProgressBar, ProgressStyle}; use parking_lot::Mutex; @@ -24,16 +25,24 @@ use ree_pak_core::{ const FILE_NAME_LIST: &[u8] = include_bytes!("../assets/MHWs_STM_Release.list.zst"); fn main() { + std::panic::set_hook(Box::new(panic_hook)); + println!("Version v{} - Tool by @Eigeen", env!("CARGO_PKG_VERSION")); if let Err(e) = main_entry() { - eprintln!("Error: {e}"); + eprintln!("{}: {}", "Error".red().bold(), e); wait_for_exit(); std::process::exit(1); } wait_for_exit(); } +fn panic_hook(info: &std::panic::PanicHookInfo) { + eprintln!("{}: {}", "Panic".red().bold(), info); + wait_for_exit(); + std::process::exit(1); +} + fn main_entry() -> eyre::Result<()> { let input: String = Input::with_theme(&ColorfulTheme::default()) .show_default(true) @@ -52,9 +61,7 @@ fn main_entry() -> eyre::Result<()> { const FALSE_TRUE_SELECTION: [&str; 2] = ["False", "True"]; let use_full_package_mode = Select::with_theme(&ColorfulTheme::default()) - .with_prompt( - "Package all files, including non-tex parts (suitable for replacing original files)", - ) + .with_prompt("Package all files, including non-tex files (for replacing original files)") .default(0) .items(&FALSE_TRUE_SELECTION) .interact() @@ -62,8 +69,8 @@ fn main_entry() -> eyre::Result<()> { let use_full_package_mode = use_full_package_mode == 1; let use_feature_clone = Select::with_theme(&ColorfulTheme::default()) - .with_prompt("Clone feature flags from original file? (experimental)") - .default(0) + .with_prompt("Clone feature flags from original file?") + .default(1) .items(&FALSE_TRUE_SELECTION) .interact() .unwrap(); @@ -176,10 +183,12 @@ fn main_entry() -> eyre::Result<()> { }; bar.finish(); - println!("Done!"); - println!( - "You should rename the output file like `re_chunk_000.pak.sub_000.pak.patch_xxx.pak`, or manage it by your favorite mod manager." - ); + println!("{}", "Done!".cyan().bold()); + if !use_full_package_mode { + println!( + "You should rename the output file like `re_chunk_000.pak.sub_000.pak.patch_xxx.pak`, or manage it by your favorite mod manager." + ); + } Ok(()) } @@ -212,6 +221,7 @@ where fn wait_for_exit() { let _: String = Input::with_theme(&ColorfulTheme::default()) + .with_prompt("Press Enter to exit") .allow_empty(true) .interact_text() .unwrap();