~starkingdoms/starkingdoms

ref: d38879d908c92d0cf37432bf754340d4b58e05e4 starkingdoms/client/src/textures/loader_slow.rs -rw-r--r-- 584 bytes
d38879d9 — c0repwn3r [wip] spacetime build - add built spritesheets 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
use crate::textures::{TextureManager, TextureSize};
use std::error::Error;
use log::debug;

#[derive(Debug)]
pub struct TextureLoader {
    size: TextureSize
}
impl TextureManager for TextureLoader {
    fn load(size: TextureSize) -> Result<Self, Box<dyn Error>> where Self: Sized {
        debug!("Using slow texture loader, textures will be loaded on-the-fly");
        Ok(TextureLoader {
            size
        })
    }

    fn get_texture(&self, texture_id: &str) -> Option<String> {
        Some(format!("/../assets/final/{}/{}.png", self.size.to_string(), texture_id))
    }
}