Advertisement
Guest User

ResourceManager.h

a guest
Apr 28th, 2012
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.32 KB | None | 0 0
  1. #ifndef RESOURCEMANAGER_H
  2. #define RESOURCEMANAGER_H
  3.  
  4. #include "Common.h"
  5.  
  6. struct Level;
  7.  
  8. struct ArtReference   { sf::Texture tex; int ref; };
  9. struct FontReference  { sf::Font font; void* data; PHYSFS_uint32 size; int ref; };
  10. struct SfxReference   { sf::Sound sound; sf::SoundBuffer buf; int ref; };
  11. struct MusicReference { sf::Music music; void* data; PHYSFS_uint32 size; int ref; };
  12.  
  13. class ResourceManager
  14. {
  15. private:
  16.     typedef std::map<std::string, ArtReference> ArtMap;
  17.     typedef std::map<std::string, FontReference> FontMap;
  18.     typedef std::map<std::string, MusicReference> MusicMap;
  19.     typedef std::map<std::string, SfxReference> SfxMap;
  20.  
  21.     ArtMap m_loadedArt;
  22.     FontMap m_loadedFonts;
  23.     MusicMap m_loadedMusic;
  24.     SfxMap m_loadedSfx;
  25.  
  26.     sf::Texture emptyTexture;
  27.     sf::Font emptyFont;
  28.     sf::Sound emptySound;
  29.     sf::Music emptyMusic;
  30.  
  31. public:
  32.     ResourceManager();
  33.     ~ResourceManager();
  34.     void init(const char *argv0);
  35.     void finish();
  36.     sf::Texture& art(const std::string& name);
  37.     void unrefArt(const std::string& name);
  38.     sf::Font& font(const std::string& name);
  39.     void unrefFont(const std::string& name);
  40.     sf::Sound& sfx(const std::string& name);
  41.     void unrefSfx(const std::string& name);
  42.     sf::Music& music(const std::string& name);
  43.     void unrefMusic(const std::string& name);
  44.     Level* lvl(const std::string& name);
  45. };
  46.  
  47. #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement