Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef RESOURCEMANAGER_H
- #define RESOURCEMANAGER_H
- #include "Common.h"
- struct Level;
- struct ArtReference { sf::Texture tex; int ref; };
- struct FontReference { sf::Font font; void* data; PHYSFS_uint32 size; int ref; };
- struct SfxReference { sf::Sound sound; sf::SoundBuffer buf; int ref; };
- struct MusicReference { sf::Music music; void* data; PHYSFS_uint32 size; int ref; };
- class ResourceManager
- {
- private:
- typedef std::map<std::string, ArtReference> ArtMap;
- typedef std::map<std::string, FontReference> FontMap;
- typedef std::map<std::string, MusicReference> MusicMap;
- typedef std::map<std::string, SfxReference> SfxMap;
- ArtMap m_loadedArt;
- FontMap m_loadedFonts;
- MusicMap m_loadedMusic;
- SfxMap m_loadedSfx;
- sf::Texture emptyTexture;
- sf::Font emptyFont;
- sf::Sound emptySound;
- sf::Music emptyMusic;
- public:
- ResourceManager();
- ~ResourceManager();
- void init(const char *argv0);
- void finish();
- sf::Texture& art(const std::string& name);
- void unrefArt(const std::string& name);
- sf::Font& font(const std::string& name);
- void unrefFont(const std::string& name);
- sf::Sound& sfx(const std::string& name);
- void unrefSfx(const std::string& name);
- sf::Music& music(const std::string& name);
- void unrefMusic(const std::string& name);
- Level* lvl(const std::string& name);
- };
- #endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement