expose texture index

This commit is contained in:
Robin Appelman 2023-12-15 22:33:04 +01:00
commit 8039f921da
2 changed files with 7 additions and 0 deletions

View file

@ -100,6 +100,11 @@ impl<'a> SkinTable<'a> {
.get(*texture_index as usize)
.map(|info| info.name.as_str())
}
pub fn texture_index(&self, index: i32) -> Option<usize> {
let texture_index = self.table.get(index as usize)?;
Some(*texture_index as usize)
}
}
pub struct Mesh<'a> {

View file

@ -125,6 +125,7 @@ impl ReadRelative for Mesh {
#[derive(Debug, Clone)]
pub struct TextureInfo {
pub name: String,
pub name_index: i32,
pub search_paths: Vec<String>,
}
@ -134,6 +135,7 @@ impl ReadRelative for TextureInfo {
fn read(data: &[u8], header: Self::Header) -> Result<Self> {
Ok(TextureInfo {
name: String::read(&data[header.name_index as usize..], ())?.replace('\\', "/"),
name_index: header.name_index,
search_paths: Vec::new(),
})
}