Skip to content

Instantly share code, notes, and snippets.

@adrigm
Created November 10, 2013 23:03
Show Gist options
  • Save adrigm/7405117 to your computer and use it in GitHub Desktop.
Save adrigm/7405117 to your computer and use it in GitHub Desktop.
class AssetManager
{
static AssetManager* instance;
public:
static AssetManager* instance();
static void release();
void setPath(const std::string& thePath);
sf::Texture* getTexture(const std::string& theName);
sf::Texture* getTexture(const std::string& theName, sf::Texture* theTexture);
sf::Texture* getTextureFromImage(const std::string& theName, const sf::Image* theImage, const sf::IntRect& theRect = sf::IntRect());
void deleteTexture(const std::string& theName);
void deleteTexture(const sf::Texture* theTexture);
sf::Image* getImage(const std::string& theName);
sf::Image* getImageFromTexture(const std::string& theName, const sf::Texture* theTexture);
void deleteImage(const std::string& theName);
void deleteImage(const sf::Image* theImage);
sf::Font* getFont(const std::string& theName);
void deleteFont(const std::string& theName);
void deleteFont(const sf::Font* theFont);
sf::SoundBuffer* getSoundBuffer(const std::string& theName);
void deleteSoundBuffer(const std::string& theName);
void deleteSoundBuffer(const sf::SoundBuffer* theSoundBuffer);
sf::Music* getMusic(const std::string& theName);
void deleteMusic(const std::string& theName);
void deleteMusic(const sf::Music* theMusic);
ConfigReader* getConfig(const std::string& theName);
void deleteConfig(const std::string& theName);
void deleteConfig(const ConfigReader* theConfig);
void cleanup();
private:
// Variables
///////////////////////////////////////////////////////////////////////////
/// Directorio maestro donde buscar recursos
std::string m_masterDir;
/// Mapa de registro de todas las texturas
std::map<std::string, sf::Texture*> m_textures;
/// Mapa de registro de todas las imágenes
std::map<std::string, sf::Image*> m_images;
/// Mapa de registro de todas las fuentes
std::map<std::string, sf::Font*> m_fonts;
/// Mapa de registro de todos los buffers de sonido
std::map<std::string, sf::SoundBuffer*> m_sounds;
/// Mapa de registro de toda la música
std::map<std::string, sf::Music*> m_music;
/// Mapa de registro de todos los archivos de configuraciones
std::map<std::string, ConfigReader*> m_configs;
AssetManager();
AssetManager(const AssetManager&);
AssetManager& operator=(const AssetManager&);
~AssetManager();
}; // class AssetManager
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment