Add title support for scn script

This commit is contained in:
2025-09-09 17:21:41 +08:00
parent e25d97f041
commit dafc1c6e15
5 changed files with 120 additions and 0 deletions

View File

@@ -55,6 +55,36 @@ pub enum PsbValueFixed {
CompilerBinaryTree,
}
impl From<String> for PsbValueFixed {
fn from(value: String) -> Self {
PsbValueFixed::String(PsbString::from(value))
}
}
impl From<bool> for PsbValueFixed {
fn from(value: bool) -> Self {
PsbValueFixed::Bool(value)
}
}
impl From<i64> for PsbValueFixed {
fn from(value: i64) -> Self {
PsbValueFixed::Number(PsbNumber::Integer(value))
}
}
impl From<f64> for PsbValueFixed {
fn from(value: f64) -> Self {
PsbValueFixed::Number(PsbNumber::Double(value))
}
}
impl From<f32> for PsbValueFixed {
fn from(value: f32) -> Self {
PsbValueFixed::Number(PsbNumber::Float(value))
}
}
impl PsbValueFixed {
/// Converts this value to original PSB value type.
pub fn to_psb(self, warn_on_none: bool) -> PsbValue {
@@ -204,6 +234,20 @@ impl PsbValueFixed {
}
}
/// Pushes a new member to a list. If this value is not a list, it will be converted to a list.
pub fn push_member<T: Into<PsbValueFixed>>(&mut self, value: T) {
match self {
PsbValueFixed::List(l) => {
l.values.push(value.into());
}
_ => {
*self = PsbValueFixed::List(PsbListFixed {
values: vec![value.into()],
});
}
}
}
/// Returns the resource ID if this value is a resource reference.
pub fn resource_id(&self) -> Option<u64> {
match self {