mirror of
https://github.com/lifegpc/msg-tool.git
synced 2026-06-07 05:18:44 +08:00
Add pimg extract support
This commit is contained in:
@@ -96,6 +96,24 @@ impl PsbValueFixed {
|
||||
self.set_str(&value);
|
||||
}
|
||||
|
||||
pub fn as_u8(&self) -> Option<u8> {
|
||||
self.as_i64().map(|n| n.try_into().ok()).flatten()
|
||||
}
|
||||
|
||||
pub fn as_u32(&self) -> Option<u32> {
|
||||
self.as_i64().map(|n| n as u32)
|
||||
}
|
||||
|
||||
pub fn as_i64(&self) -> Option<i64> {
|
||||
match self {
|
||||
PsbValueFixed::Number(n) => match n {
|
||||
PsbNumber::Integer(n) => Some(*n),
|
||||
_ => None,
|
||||
},
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_str(&self) -> Option<&str> {
|
||||
match self {
|
||||
PsbValueFixed::String(s) => Some(s.string()),
|
||||
@@ -138,6 +156,13 @@ impl PsbValueFixed {
|
||||
_ => ListIterMut::empty(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn resource_id(&self) -> Option<u64> {
|
||||
match self {
|
||||
PsbValueFixed::Resource(r) => Some(r.resource_ref),
|
||||
_ => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Index<usize> for PsbValueFixed {
|
||||
|
||||
Reference in New Issue
Block a user