Edited include format

master
Mark 2023-12-25 08:17:05 -08:00
parent 5279eeb7d4
commit b7d12ac875
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
2 changed files with 10 additions and 9 deletions

2
assets

@ -1 +1 @@
Subproject commit 66b7aab8af273cac9b805d813f2e5cb70a920000 Subproject commit fa116c0e4056200ad945d241a9980e49ada293fc

View File

@ -1,10 +1,11 @@
use anyhow::Result; use anyhow::Result;
use std::{collections::HashMap, fs::File, io::Read, path::Path}; use std::{collections::HashMap, fs::File, io::Read, path::Path, path::PathBuf};
use super::{rawtexture::RawTexture, Texture, TextureArrayConfig}; use super::{rawtexture::RawTexture, Texture, TextureArrayConfig};
mod fields { mod fields {
use super::{File, Path, RawTexture, Read, Result, TextureArrayConfig};
use super::{File, HashMap, Path, PathBuf, RawTexture, Read, Result, TextureArrayConfig};
use serde::Deserialize; use serde::Deserialize;
// Config is used outside of this file, // Config is used outside of this file,
@ -13,7 +14,7 @@ mod fields {
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct Index { pub struct Index {
pub config: TextureArrayConfig, pub config: TextureArrayConfig,
pub include: Option<Vec<String>>, pub include: Option<HashMap<PathBuf, String>>,
pub texture: Vec<Texture>, pub texture: Vec<Texture>,
} }
@ -31,7 +32,7 @@ mod fields {
#[derive(Deserialize)] #[derive(Deserialize)]
pub struct SubIndex { pub struct SubIndex {
pub include: Option<Vec<String>>, pub include: Option<HashMap<PathBuf, String>>,
pub texture: Vec<Texture>, pub texture: Vec<Texture>,
} }
@ -152,8 +153,8 @@ impl TextureLoader {
// Load included files // Load included files
if let Some(include) = index.include { if let Some(include) = index.include {
for i in include { for (path, sub_prefix) in include {
let sub_root = texture_root.join(&i); let sub_root = texture_root.join(&path);
let index: fields::SubIndex = { let index: fields::SubIndex = {
let mut texture_index_string = String::new(); let mut texture_index_string = String::new();
let _ = File::open(sub_root.join(Self::INDEX_NAME))? let _ = File::open(sub_root.join(Self::INDEX_NAME))?
@ -167,9 +168,9 @@ impl TextureLoader {
index, index,
&sub_root, &sub_root,
if prefix.is_empty() { if prefix.is_empty() {
i sub_prefix
} else { } else {
format!("{prefix}::{i}") format!("{prefix}::{sub_prefix}")
}, },
)?; )?;
for (s, data) in sub_textures { for (s, data) in sub_textures {