mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-06 12:58:45 +08:00
add new settings
This commit is contained in:
@@ -106,6 +106,10 @@ pub struct Arg {
|
||||
#[arg(long, global = true)]
|
||||
/// CatSystem2 engine int archive password
|
||||
pub cat_system_int_encrypt_password: Option<String>,
|
||||
#[cfg(feature = "cat-system-img")]
|
||||
#[arg(long, global = true, action = ArgAction::SetTrue)]
|
||||
/// Draw CatSystem2 image on canvas (if canvas width and height are specified in file)
|
||||
pub cat_system_image_canvas: bool,
|
||||
#[command(subcommand)]
|
||||
/// Command
|
||||
pub command: Command,
|
||||
|
||||
@@ -1260,6 +1260,8 @@ fn main() {
|
||||
bgi_img_scramble: arg.bgi_img_scramble.clone(),
|
||||
#[cfg(feature = "cat-system-arc")]
|
||||
cat_system_int_encrypt_password: arg.cat_system_int_encrypt_password.clone(),
|
||||
#[cfg(feature = "cat-system-img")]
|
||||
cat_system_image_canvas: arg.cat_system_image_canvas,
|
||||
};
|
||||
match &arg.command {
|
||||
args::Command::Export { input, output } => {
|
||||
|
||||
@@ -67,10 +67,11 @@ struct Hg3Entry {
|
||||
pub struct Hg3Image {
|
||||
data: MemReader,
|
||||
entries: Vec<(Hg3Entry, usize, usize)>,
|
||||
draw_canvas: bool,
|
||||
}
|
||||
|
||||
impl Hg3Image {
|
||||
pub fn new(buf: Vec<u8>, _config: &ExtraConfig) -> Result<Self> {
|
||||
pub fn new(buf: Vec<u8>, config: &ExtraConfig) -> Result<Self> {
|
||||
let mut reader = MemReader::new(buf);
|
||||
let mut magic = [0u8; 4];
|
||||
reader.read_exact(&mut magic)?;
|
||||
@@ -102,6 +103,7 @@ impl Hg3Image {
|
||||
Ok(Hg3Image {
|
||||
data: reader,
|
||||
entries,
|
||||
draw_canvas: config.cat_system_image_canvas,
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -133,7 +135,19 @@ impl Script for Hg3Image {
|
||||
m_info: entry.clone(),
|
||||
m_pixel_size: entry.bpp / 8,
|
||||
};
|
||||
Ok(reader.unpack()?)
|
||||
let mut img = reader.unpack()?;
|
||||
if self.draw_canvas {
|
||||
if entry.canvas_width > 0 && entry.canvas_height > 0 {
|
||||
img = draw_on_canvas(
|
||||
img,
|
||||
entry.canvas_width,
|
||||
entry.canvas_height,
|
||||
entry.offset_x,
|
||||
entry.offset_y,
|
||||
)?;
|
||||
}
|
||||
}
|
||||
Ok(img)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,7 +280,7 @@ impl<'a> Hg3Reader<'a> {
|
||||
self.m_input.pos = self.m_info.header_size as usize;
|
||||
let mut image_type = [0; 8];
|
||||
self.m_input.read_exact(&mut image_type)?;
|
||||
if &image_type == b"img0000\0" {
|
||||
if &image_type == b"img0000 | ||||