add source
This commit is contained in:
parent
2c7ced7151
commit
c1ac2eb1d8
@ -8,7 +8,7 @@ edition = "2021"
|
||||
[features]
|
||||
legacy = ["dep:lazy-regex"]
|
||||
#roblox = []
|
||||
#source = []
|
||||
source = []
|
||||
|
||||
[dependencies]
|
||||
lazy-regex = { version = "3.1.0", optional = true }
|
||||
|
@ -0,0 +1,51 @@
|
||||
use std::io::Read;
|
||||
use std::path::PathBuf;
|
||||
use std::collections::HashMap;
|
||||
use crate::texture::{Texture,Textures};
|
||||
use strafesnet_common::model::{MeshId,TextureId};
|
||||
|
||||
pub struct TextureLoader{
|
||||
texture_paths:HashMap<PathBuf,TextureId>,
|
||||
}
|
||||
impl TextureLoader{
|
||||
pub fn acquire_texture_id(&mut self,name:&str)->TextureId{
|
||||
let texture_id=TextureId::new(self.texture_paths.len() as u32);
|
||||
*self.texture_paths.entry(name.into()).or_insert(texture_id)
|
||||
}
|
||||
}
|
||||
pub struct MeshLoader{
|
||||
mesh_paths:HashMap<PathBuf,MeshId>,
|
||||
}
|
||||
impl MeshLoader{
|
||||
pub fn acquire_mesh_id(&mut self,name:&str)->MeshId{
|
||||
let texture_id=MeshId::new(self.mesh_paths.len() as u32);
|
||||
*self.mesh_paths.entry(name.into()).or_insert(texture_id)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct Loader{
|
||||
texture_loader:TextureLoader,
|
||||
mesh_loader:MeshLoader,
|
||||
}
|
||||
impl Loader{
|
||||
pub fn new()->Self{
|
||||
Self{
|
||||
texture_loader:TextureLoader{texture_paths:HashMap::new()},
|
||||
mesh_loader:MeshLoader{mesh_paths:HashMap::new()},
|
||||
}
|
||||
}
|
||||
pub fn get_inner_mut(&mut self)->(&mut TextureLoader,&mut MeshLoader){
|
||||
(&mut self.texture_loader,&mut self.mesh_loader)
|
||||
}
|
||||
}
|
||||
|
||||
impl Loader{
|
||||
pub fn load_textures(&self)->Result<Textures,std::io::Error>{
|
||||
Ok(Textures::new(Vec::new()))
|
||||
}
|
||||
//load_meshes should look like load_textures
|
||||
/*
|
||||
pub fn load_meshes(&mut self)->Result<Meshes,std::io::Error>{
|
||||
}
|
||||
*/
|
||||
}
|
Loading…
Reference in New Issue
Block a user