From 5fd1a336c6127f1c2630bc205ae8a3d03ddd6b4c Mon Sep 17 00:00:00 2001 From: lifegpc Date: Sat, 15 Nov 2025 21:52:46 +0800 Subject: [PATCH] Add a new argument to BGI script --- src/args.rs | 5 +++++ src/main.rs | 2 ++ src/scripts/bgi/script.rs | 10 ++++++++++ src/types.rs | 4 ++++ 4 files changed, 21 insertions(+) diff --git a/src/args.rs b/src/args.rs index 7f53c0f..4f458d6 100644 --- a/src/args.rs +++ b/src/args.rs @@ -578,6 +578,11 @@ pub struct Arg { /// Disable adler32 checksum for Kirikiri XP3 archive when creating. /// This will keep compatibility with https://github.com/arcusmaximus/KirikiriTools tool. pub xp3_no_adler: bool, + #[cfg(feature = "bgi")] + #[arg(long, global = true)] + /// Add an additional space at the end of message in BGI scripts when importing. + /// This may help BGI engine to display the message correctly in save/load screen for some games. + pub bgi_add_space: bool, #[command(subcommand)] /// Command pub command: Command, diff --git a/src/main.rs b/src/main.rs index c9a5960..363804b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -3055,6 +3055,8 @@ fn main() { musica_compress: arg.musica_compress, #[cfg(feature = "kirikiri-arc")] xp3_no_adler: arg.xp3_no_adler, + #[cfg(feature = "bgi")] + bgi_add_space: arg.bgi_add_space, }); match &arg.command { args::Command::Export { input, output } => { diff --git a/src/scripts/bgi/script.rs b/src/scripts/bgi/script.rs index 1b725de..387a063 100644 --- a/src/scripts/bgi/script.rs +++ b/src/scripts/bgi/script.rs @@ -68,6 +68,7 @@ pub struct BGIScript { import_duplicate: bool, append: bool, custom_yaml: bool, + add_space: bool, } impl std::fmt::Debug for BGIScript { @@ -101,6 +102,7 @@ impl BGIScript { import_duplicate: config.bgi_import_duplicate, append: !config.bgi_disable_append, custom_yaml: config.custom_yaml, + add_space: config.bgi_add_space, }) } else { let mut is_v1_instr = false; @@ -126,6 +128,7 @@ impl BGIScript { import_duplicate: config.bgi_import_duplicate, append: !config.bgi_disable_append, custom_yaml: config.custom_yaml, + add_space: config.bgi_add_space, }) } } @@ -226,6 +229,13 @@ impl Script for BGIScript { encoding: Encoding, replacement: Option<&'a ReplacementTable>, ) -> Result<()> { + if self.add_space { + for mes in messages.iter_mut() { + if !mes.message.ends_with(' ') { + mes.message.push(' '); + } + } + } if !self.import_duplicate { let mut used = HashMap::new(); let mut extra = HashMap::new(); diff --git a/src/types.rs b/src/types.rs index bd2e4e0..f1644b5 100644 --- a/src/types.rs +++ b/src/types.rs @@ -519,6 +519,10 @@ pub struct ExtraConfig { #[cfg(feature = "musica-arc")] /// Whether to compress files in Musica paz archive when packing paz archive. pub musica_compress: bool, + #[cfg(feature = "bgi")] + /// Add an additional space at the end of message in BGI scripts when importing. + /// This may help BGI engine to display the message correctly in save/load screen for some games. + pub bgi_add_space: bool, } #[derive(Clone, Copy, Debug, ValueEnum, PartialEq, Eq, PartialOrd, Ord)]