Guest User

Untitled

a guest
Jun 23rd, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. require 'gosu'
  2. require 'YAML'
  3.  
  4. require 'Platform'
  5. require 'Tileset'
  6.  
  7. # TODO: Make a FontManager similar to ImageManager. I'm creating waaaay too many identical Gosu::Font objects.
  8.  
  9. module OperationLambda
  10. module ImageManager
  11. ImagesDir = File.join(Platform::ApplicationMediaDir,'images')
  12. StandardDir = File.join(ImagesDir,'standard')
  13. LoadedTilesets = []
  14. StandardImages = {}
  15.  
  16. module_function
  17.  
  18. def load_images
  19. standard_defs_file = File.join(StandardDir,'standard.yaml')
  20. standard_defs = YAML.load_file(standard_defs_file)
  21. window = MainWindow.instance
  22. standard_defs.each do |key,file|
  23. path = File.join(StandardDir,file)
  24. StandardImages[key] = Gosu::Image.new(window,path,true)
  25. end
  26. end
  27.  
  28. def load_tileset(set)
  29. if set[:cat] == :user
  30. dir = Platform::UserTilesetDir
  31. else
  32. dir = Platform::ApplicationTilesetDir
  33. end
  34. LoadedTilesets.push(Tileset.new(set[:dir],dir))
  35. end
  36.  
  37. def tile(key)
  38. LoadedTilesets[0][key]
  39. end
  40.  
  41. def image(key)
  42. return StandardImages[key] || raise("No image available for #{key} in #{StandardImages.inspect}")
  43. end
  44.  
  45. end
  46. end
Add Comment
Please, Sign In to add comment