From 8947b84b7ee7f038459e92a7088d62bbdef31539 Mon Sep 17 00:00:00 2001 From: lifegpc Date: Wed, 13 Aug 2025 16:15:41 +0800 Subject: [PATCH] Add a new option to disable new willplus script parser --- Cargo.lock | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- src/args.rs | 6 ++++++ src/main.rs | 2 ++ src/scripts/will_plus/ws2.rs | 18 ++++++++++-------- src/types.rs | 6 ++++++ 7 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3d7b592..73fb832 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -796,7 +796,7 @@ dependencies = [ [[package]] name = "msg_tool" -version = "0.1.2" +version = "0.1.3" dependencies = [ "anyhow", "byteorder", diff --git a/Cargo.toml b/Cargo.toml index b36d8fa..fe4281a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "msg_tool" -version = "0.1.2" +version = "0.1.3" edition = "2024" repository = "https://github.com/lifegpc/msg-tool" description = "A command-line tool for exporting, importing, packing, and unpacking script files." diff --git a/README.md b/README.md index e802b9f..57dbcdb 100644 --- a/README.md +++ b/README.md @@ -158,10 +158,10 @@ msg-tool create -t | `kirikiri-tlg`/`kr-tlg` | `kirikiri-img` | Kirikiri TLG Image File (.tlg) | ✔️ | ❌ | ❌ | ❌ | ❌ | | | `kirikiri-pimg`/`kr-pimg` | `kirikiri-img` | Kirikiri Multiple Image File (.pimg) | ❌ | ❌ | ✔️ | ❌ | ❌ | | | `kirikiri-dref`/`kr-dref` | `kirikiri-img` | Kirikiri DPAK-referenced Image File (.dref) | ✔️ | ❌ | ❌ | ❌ | ❌ | | -### WillPlus +### WillPlus / AdvHD | Script Type | Feature Name | Name | Export | Import | Custom Export | Custom Import | Create | Remarks | |---|---|---|---|---|---|---|---|---| -| `will-plus-ws2` | `will-plus` | WillPlus Script File (.ws2) | ✔️ | ✔️ | ❌ | ❌ | ❌ | | +| `will-plus-ws2`/`adv-hd-ws2` | `will-plus` | WillPlus/AdvHD Script File (.ws2) | ✔️ | ✔️ | ❌ | ❌ | ❌ | | ### Yaneurao Itufuru | Script Type | Feature Name | Name | Export | Import | Custom Export | Custom Import | Create | Remarks | |---|---|---|---|---|---|---|---|---| diff --git a/src/args.rs b/src/args.rs index 6b57986..99c3d2f 100644 --- a/src/args.rs +++ b/src/args.rs @@ -338,6 +338,12 @@ pub struct Arg { /// Entis GLS srcxml script language, used to extract messages from srcxml script. /// If not specified, the first language will be used. pub entis_gls_srcxml_lang: Option, + #[cfg(feature = "will-plus")] + #[arg(long, global = true)] + /// Disable disassembly for WillPlus ws2 script. + /// Use another parser to parse the script. + /// Should only be used when the default parser not works well. + pub will_plus_ws2_no_disasm: bool, #[command(subcommand)] /// Command pub command: Command, diff --git a/src/main.rs b/src/main.rs index 01728ba..7fa01ce 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1753,6 +1753,8 @@ fn main() { }), #[cfg(feature = "entis-gls")] entis_gls_srcxml_lang: arg.entis_gls_srcxml_lang.clone(), + #[cfg(feature = "will-plus")] + will_plus_ws2_no_disasm: arg.will_plus_ws2_no_disasm, }; match &arg.command { args::Command::Export { input, output } => { diff --git a/src/scripts/will_plus/ws2.rs b/src/scripts/will_plus/ws2.rs index 086717d..b01ceb6 100644 --- a/src/scripts/will_plus/ws2.rs +++ b/src/scripts/will_plus/ws2.rs @@ -33,14 +33,16 @@ impl ScriptBuilder for Ws2ScriptBuilder { config: &ExtraConfig, _archive: Option<&Box>, ) -> Result> { - match Ws2DisasmScript::new(&buf, encoding, config, false) { - Ok(script) => return Ok(Box::new(script)), - Err(e) => { - eprintln!( - "WARNING: Failed to disassemble WS2 script: {}. An another parser is used.", - e - ); - crate::COUNTER.inc_warning(); + if !config.will_plus_ws2_no_disasm { + match Ws2DisasmScript::new(&buf, encoding, config, false) { + Ok(script) => return Ok(Box::new(script)), + Err(e) => { + eprintln!( + "WARNING: Failed to disassemble WS2 script: {}. An another parser is used.", + e + ); + crate::COUNTER.inc_warning(); + } } } Ok(Box::new(Ws2Script::new(buf, encoding, config, false)?)) diff --git a/src/types.rs b/src/types.rs index 3f7f01c..8f19091 100644 --- a/src/types.rs +++ b/src/types.rs @@ -339,6 +339,11 @@ pub struct ExtraConfig { /// Entis GLS srcxml script language, used to extract messages from srcxml script. /// If not specified, the first language will be used. pub entis_gls_srcxml_lang: Option, + #[cfg(feature = "will-plus")] + /// Disable disassembly for WillPlus ws2 script. + /// Use another parser to parse the script. + /// Should only be used when the default parser not works well. + pub will_plus_ws2_no_disasm: bool, } #[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord)] @@ -470,6 +475,7 @@ pub enum ScriptType { /// Kirikiri MDF (zlib compressed) file KirikiriMdf, #[cfg(feature = "will-plus")] + #[value(alias("adv-hd-ws2"))] /// WillPlus ws2 script WillPlusWs2, #[cfg(feature = "yaneurao-itufuru")]