Add support to import comu message to scn scripts

This commit is contained in:
2025-07-01 16:54:16 +08:00
parent 30feefffbd
commit 263c156d03
6 changed files with 152 additions and 3 deletions

View File

@@ -5,6 +5,7 @@ use emote_psb::types::number::*;
use emote_psb::types::reference::*;
use emote_psb::types::string::*;
use emote_psb::types::*;
use std::cmp::PartialEq;
use std::collections::HashMap;
use std::ops::{Index, IndexMut};
@@ -158,7 +159,7 @@ impl IndexMut<usize> for PsbValueFixed {
&mut l.values[index]
} else {
l.values.push(NONE);
&mut l.values[index]
l.values.last_mut().unwrap()
}
}
_ => {
@@ -246,6 +247,27 @@ impl Clone for PsbValueFixed {
}
}
impl PartialEq<String> for PsbValueFixed {
fn eq(&self, other: &String) -> bool {
self == other.as_str()
}
}
impl PartialEq<str> for PsbValueFixed {
fn eq(&self, other: &str) -> bool {
match self {
PsbValueFixed::String(s) => s.string() == other,
_ => false,
}
}
}
impl<'a> PartialEq<&'a str> for PsbValueFixed {
fn eq(&self, other: &&'a str) -> bool {
self == *other
}
}
pub trait PsbValueExt {
fn to_psb_fixed(self) -> PsbValueFixed;
}
@@ -306,6 +328,25 @@ impl PsbListFixed {
}
}
impl Index<usize> for PsbListFixed {
type Output = PsbValueFixed;
fn index(&self, index: usize) -> &Self::Output {
self.values.get(index).unwrap_or(&NONE)
}
}
impl IndexMut<usize> for PsbListFixed {
fn index_mut(&mut self, index: usize) -> &mut Self::Output {
if index < self.values.len() {
&mut self.values[index]
} else {
self.values.push(NONE);
self.values.last_mut().unwrap()
}
}
}
pub struct ListIter<'a> {
inner: std::slice::Iter<'a, PsbValueFixed>,
}