mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-08 05:48:46 +08:00
Move Pimg/Dref to emote
Revert part of last commit
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//! Kirikiri DPAK-referenced Image File (.dref)
|
||||
//! Emote DPAK-referenced Image File (.dref)
|
||||
use crate::ext::io::*;
|
||||
use crate::ext::psb::*;
|
||||
use crate::scripts::base::*;
|
||||
@@ -13,7 +13,7 @@ use std::path::{Path, PathBuf};
|
||||
use url::Url;
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Kirikiri DREF Script Builder
|
||||
/// Emote DREF Script Builder
|
||||
pub struct DrefBuilder {}
|
||||
|
||||
impl DrefBuilder {
|
||||
@@ -47,7 +47,7 @@ impl ScriptBuilder for DrefBuilder {
|
||||
}
|
||||
|
||||
fn script_type(&self) -> &'static ScriptType {
|
||||
&ScriptType::KirikiriDref
|
||||
&ScriptType::EmoteDref
|
||||
}
|
||||
|
||||
fn is_image(&self) -> bool {
|
||||
@@ -177,7 +177,7 @@ impl DpakLoader {
|
||||
}
|
||||
}
|
||||
|
||||
/// Kirikiri DREF Script
|
||||
/// Emote DREF Script
|
||||
pub struct Dref {
|
||||
urls: Vec<Url>,
|
||||
dir: PathBuf,
|
||||
2
src/scripts/emote/mod.rs
Normal file
2
src/scripts/emote/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub mod dref;
|
||||
pub mod pimg;
|
||||
@@ -1,4 +1,4 @@
|
||||
//! Kirikiri Multiple Image File (.pimg)
|
||||
//! Emote Multiple Image File (.pimg)
|
||||
use crate::ext::io::*;
|
||||
use crate::ext::psb::*;
|
||||
use crate::scripts::base::*;
|
||||
@@ -13,7 +13,7 @@ use std::io::{Read, Seek};
|
||||
use std::path::Path;
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Kirikiri PImg Script Builder
|
||||
/// Emote PImg Script Builder
|
||||
pub struct PImgBuilder {}
|
||||
|
||||
impl PImgBuilder {
|
||||
@@ -75,7 +75,7 @@ impl ScriptBuilder for PImgBuilder {
|
||||
}
|
||||
|
||||
fn script_type(&self) -> &'static ScriptType {
|
||||
&ScriptType::KirikiriPimg
|
||||
&ScriptType::EmotePimg
|
||||
}
|
||||
|
||||
fn is_this_format(&self, filename: &str, buf: &[u8], buf_len: usize) -> Option<u8> {
|
||||
@@ -97,7 +97,7 @@ impl ScriptBuilder for PImgBuilder {
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
/// Kirikiri PImg Script
|
||||
/// Emote PImg Script
|
||||
pub struct PImg {
|
||||
psb: VirtualPsbFixed,
|
||||
overlay: Option<bool>,
|
||||
@@ -1,4 +1,2 @@
|
||||
//! Kirikiri Images
|
||||
pub mod dref;
|
||||
pub mod pimg;
|
||||
pub mod tlg;
|
||||
|
||||
@@ -8,6 +8,8 @@ pub mod bgi;
|
||||
pub mod cat_system;
|
||||
#[cfg(feature = "circus")]
|
||||
pub mod circus;
|
||||
#[cfg(feature = "emote-img")]
|
||||
pub mod emote;
|
||||
#[cfg(feature = "entis-gls")]
|
||||
pub mod entis_gls;
|
||||
#[cfg(feature = "escude")]
|
||||
@@ -70,10 +72,10 @@ lazy_static::lazy_static! {
|
||||
Box::new(kirikiri::ks::KsBuilder::new()),
|
||||
#[cfg(feature = "kirikiri-img")]
|
||||
Box::new(kirikiri::image::tlg::TlgImageBuilder::new()),
|
||||
#[cfg(feature = "kirikiri-img")]
|
||||
Box::new(kirikiri::image::pimg::PImgBuilder::new()),
|
||||
#[cfg(feature = "kirikiri-img")]
|
||||
Box::new(kirikiri::image::dref::DrefBuilder::new()),
|
||||
#[cfg(feature = "emote-img")]
|
||||
Box::new(emote::pimg::PImgBuilder::new()),
|
||||
#[cfg(feature = "emote-img")]
|
||||
Box::new(emote::dref::DrefBuilder::new()),
|
||||
#[cfg(feature = "kirikiri")]
|
||||
Box::new(kirikiri::mdf::MdfBuilder::new()),
|
||||
#[cfg(feature = "will-plus")]
|
||||
|
||||
16
src/types.rs
16
src/types.rs
@@ -428,6 +428,14 @@ pub enum ScriptType {
|
||||
#[cfg(feature = "circus-img")]
|
||||
/// Circus Differential Image
|
||||
CircusCrxd,
|
||||
#[cfg(feature = "emote-img")]
|
||||
#[value(alias("pimg"))]
|
||||
/// Emote PIMG image
|
||||
EmotePimg,
|
||||
#[cfg(feature = "emote-img")]
|
||||
#[value(alias("dref"))]
|
||||
/// Emote DREF(DPAK-referenced) image
|
||||
EmoteDref,
|
||||
#[cfg(feature = "entis-gls")]
|
||||
/// Entis GLS srcxml Script
|
||||
EntisGls,
|
||||
@@ -462,14 +470,6 @@ pub enum ScriptType {
|
||||
#[value(alias("kr-tlg"))]
|
||||
/// Kirikiri TLG image
|
||||
KirikiriTlg,
|
||||
#[cfg(feature = "kirikiri-img")]
|
||||
#[value(alias("kr-pimg"))]
|
||||
/// Kirikiri PIMG image
|
||||
KirikiriPimg,
|
||||
#[cfg(feature = "kirikiri-img")]
|
||||
#[value(alias("kr-dref"))]
|
||||
/// Kirikiri DREF(DPAK-referenced) image
|
||||
KirikiriDref,
|
||||
#[cfg(feature = "kirikiri")]
|
||||
#[value(alias("kr-mdf"))]
|
||||
/// Kirikiri MDF (zlib compressed) file
|
||||
|
||||
@@ -88,8 +88,7 @@ pub fn decode_to_string(
|
||||
Encoding::Auto => decode_to_string(Encoding::Utf8, data, check)
|
||||
.or_else(|_| decode_to_string(Encoding::Cp932, data, check))
|
||||
.or_else(|_| decode_to_string(Encoding::Gb2312, data, check)),
|
||||
// Keep same behavior as Windows API (Code Page 65001)
|
||||
Encoding::Utf8 => Ok(String::from_utf8_lossy(data).into_owned()),
|
||||
Encoding::Utf8 => Ok(String::from_utf8(data.to_vec())?),
|
||||
Encoding::Cp932 => {
|
||||
let result = encoding::codec::japanese::Windows31JEncoding
|
||||
.decode(
|
||||
|
||||
Reference in New Issue
Block a user