1
Fork 0
mirror of https://github.com/redstrate/Physis.git synced 2025-04-24 21:37:46 +00:00
physis/src/exh.rs

81 lines
1.5 KiB
Rust
Raw Normal View History

2022-07-27 21:21:50 -04:00
use std::io::Cursor;
2022-07-21 19:58:58 -04:00
use crate::gamedata::MemoryBuffer;
use binrw::binread;
use crate::common::Language;
use binrw::BinRead;
#[binread]
#[br(magic = b"EXHF")]
#[br(big)]
pub struct EXHHeader {
version : u16,
pub(crate) data_offset : u16,
column_count : u16,
page_count : u16,
language_count : u16,
#[br(pad_before = 6)]
#[br(pad_after = 8)]
pub(crate) row_count : u32
}
#[binread]
#[br(repr(u16))]
pub enum ColumnDataType {
String = 0x0,
Bool = 0x1,
Int8 = 0x2,
UInt8 = 0x3,
Int16 = 0x4,
UInt16 = 0x5,
Int32 = 0x6,
UInt32 = 0x7,
Float32 = 0x9,
Int64 = 0xA,
UInt64 = 0xB,
PackedBool0 = 0x19,
PackedBool1 = 0x1A,
PackedBool2 = 0x1B,
PackedBool3 = 0x1C,
PackedBool4 = 0x1D,
PackedBool5 = 0x1E,
PackedBool6 = 0x1F,
PackedBool7 = 0x20,
}
#[binread]
#[br(big)]
pub struct ExcelColumnDefinition {
pub data_type : ColumnDataType,
pub offset : u16,
}
#[binread]
#[br(big)]
pub struct ExcelDataPagination {
pub start_id : u32,
row_count : u32,
}
#[binread]
#[br(big)]
pub struct EXH {
pub header : EXHHeader,
2022-07-21 19:58:58 -04:00
#[br(count = header.column_count)]
pub column_definitions : Vec<ExcelColumnDefinition>,
2022-07-21 19:58:58 -04:00
#[br(count = header.page_count)]
pub pages : Vec<ExcelDataPagination>,
2022-07-21 19:58:58 -04:00
#[br(count = header.language_count)]
languages : Vec<Language>
}
impl EXH {
pub fn from_existing(buffer : &MemoryBuffer) -> Option<EXH> {
2022-08-16 11:50:18 -04:00
EXH::read(&mut Cursor::new(&buffer)).ok()
2022-07-21 19:58:58 -04:00
}
}