2025-02-19 19:34:13 -05:00
|
|
|
use crate::set_property::SetEntry;
|
2025-02-23 14:38:35 -05:00
|
|
|
use binrw::{binrw, BinRead, BinResult};
|
|
|
|
|
|
|
|
#[binrw::parser(reader, endian)]
|
2025-02-23 14:43:10 -05:00
|
|
|
fn custom_parser(size_in_bytes: u32) -> BinResult<Vec<SetEntry>> {
|
2025-02-23 14:38:35 -05:00
|
|
|
let mut result = Vec::<SetEntry>::new();
|
|
|
|
|
|
|
|
let mut current = reader.stream_position().unwrap();
|
|
|
|
let end = current + size_in_bytes as u64 - 4;
|
|
|
|
|
|
|
|
while current < end {
|
2025-02-23 14:43:10 -05:00
|
|
|
result.push(SetEntry::read_options(reader, endian, ()).unwrap());
|
2025-02-23 14:38:35 -05:00
|
|
|
current = reader.stream_position().unwrap();
|
|
|
|
}
|
|
|
|
Ok(result)
|
|
|
|
}
|
2025-02-19 19:34:13 -05:00
|
|
|
|
|
|
|
#[binrw]
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct ArrayProperty {
|
2025-02-23 14:38:35 -05:00
|
|
|
// Plus this int
|
|
|
|
pub size_in_bytes: u32,
|
|
|
|
|
2025-02-19 19:34:13 -05:00
|
|
|
#[br(temp)]
|
|
|
|
#[bw(ignore)]
|
|
|
|
#[br(pad_before = 4)]
|
|
|
|
pub key_name_length: u32,
|
|
|
|
#[br(count = key_name_length)]
|
|
|
|
#[bw(map = |x : &String | x.as_bytes())]
|
|
|
|
#[br(map = | x: Vec<u8> | String::from_utf8(x).unwrap().trim_matches(char::from(0)).to_string())]
|
|
|
|
pub key_name: String,
|
|
|
|
|
|
|
|
#[br(pad_before = 1)]
|
2025-02-23 14:38:35 -05:00
|
|
|
pub unk: u32,
|
2025-02-19 19:34:13 -05:00
|
|
|
|
2025-02-23 14:43:10 -05:00
|
|
|
#[br(parse_with = custom_parser, args(size_in_bytes))]
|
2025-02-19 19:34:13 -05:00
|
|
|
pub entries: Vec<SetEntry>,
|
|
|
|
}
|