5 Commits

Author SHA1 Message Date
ad98236e06 colorful and better interaction
Use colored texts.
Default enable feature clone.
Add panic hook to avoid program exit.
2025-03-30 21:20:05 +08:00
9d703833e4 Merge branch 'main' of github.com:eigeen/mhws-tex-decompressor 2025-03-30 20:56:03 +08:00
40f9ea4572 wait for exit when success 2025-03-30 20:55:32 +08:00
3009d73726 Merge pull request #2 from xuanplus/patch-1
Update main.rs to remove quotes
2025-03-22 11:15:39 +08:00
Haoxuan Di
108d8bce92 Update main.rs
remove quotes for dropping file to terminal
2025-03-22 11:11:43 +08:00
4 changed files with 39 additions and 13 deletions

2
.gitignore vendored
View File

@@ -1 +1,3 @@
/target
*.exe
*.zip

12
Cargo.lock generated
View File

@@ -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",

View File

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

View File

@@ -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,13 +25,22 @@ 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<()> {
@@ -39,7 +49,9 @@ fn main_entry() -> eyre::Result<()> {
.default("re_chunk_000.pak.sub_000.pak".to_string())
.with_prompt("Input .pak file path")
.interact_text()
.unwrap();
.unwrap()
.trim_matches(|c| c == '\"' || c == '\'')
.to_string();
let input_path = Path::new(&input);
if !input_path.is_file() {
@@ -49,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()
@@ -59,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();
@@ -173,10 +183,12 @@ fn main_entry() -> eyre::Result<()> {
};
bar.finish();
println!("Done!");
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(())
}
@@ -209,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();