Guest User

Untitled

a guest
Jan 18th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. use std::Path;
  2. use std::collections::HashMap;
  3. use std::sync::Mutex;
  4. use std::io::{BufReader, BufRead};
  5.  
  6. pub enum ResourceType {
  7. Sprite,
  8. Sound,
  9. Script,
  10. Text,
  11. Binary
  12. }
  13.  
  14. pub struct ResourceFile {
  15. path: Path,
  16. type: ResourceType,
  17. }
  18.  
  19. macro_rules! load_resource {
  20. (
  21. (
  22. $($file:literal, $type:expr)$(,)?
  23. )+
  24. ) => {
  25. lazy_static! {
  26. static ref RESOURCES: Mutex<HashMap<String, ResourceFile>> = {
  27. let mut m = HashMap::new();
  28. $(
  29. m.insert(Path::new($file), $type);
  30. )+
  31. }
  32. }
  33. };
  34. }
  35.  
  36. macro_rules! read_resource_manifest {
  37. (
  38. (
  39. $($manifest:literal)$(,)?
  40. )+
  41. ) => {
  42. $(
  43. let file = try!(File::open($manifest));
  44. let mut buff = BufReader::new(&file);
  45. for line in file.lines() {
  46. load_resource! {
  47. line.unwrap();
  48. }
  49. }
  50. )+
  51. }
  52. }
Add Comment
Please, Sign In to add comment