Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- use std::Path;
- use std::collections::HashMap;
- use std::sync::Mutex;
- use std::io::{BufReader, BufRead};
- pub enum ResourceType {
- Sprite,
- Sound,
- Script,
- Text,
- Binary
- }
- pub struct ResourceFile {
- path: Path,
- type: ResourceType,
- }
- macro_rules! load_resource {
- (
- (
- $($file:literal, $type:expr)$(,)?
- )+
- ) => {
- lazy_static! {
- static ref RESOURCES: Mutex<HashMap<String, ResourceFile>> = {
- let mut m = HashMap::new();
- $(
- m.insert(Path::new($file), $type);
- )+
- }
- }
- };
- }
- macro_rules! read_resource_manifest {
- (
- (
- $($manifest:literal)$(,)?
- )+
- ) => {
- $(
- let file = try!(File::open($manifest));
- let mut buff = BufReader::new(&file);
- for line in file.lines() {
- load_resource! {
- line.unwrap();
- }
- }
- )+
- }
- }
Add Comment
Please, Sign In to add comment