#ifndef _RESOURCES_H
#define _RESOURCES_H

#include "includes.h"
#include <map>
#include <vector>

namespace PixelKit
{
	class Resources
	{
	public:
		/*!
		 * @brief Returns a cached texture loaded from an image file.
		 * @param filename File to load the texture from.
		 */
		static SDL_Texture* spriteNamed(std::string filename);
		
		/*!
		 * @brief Returns a cached RWOps from an animation definition file.
		 * @param filename File to load the animation from.
		 */
		static SDL_RWops* animationNamed(std::string filename);
		
		/*!
		 * @brief Returns a cached Mix_Chink from an audio file.
		 * @param filename File to load the sound effect from.
		 */
		static Mix_Chunk* audioEffectNamed(std::string filename);
		
		/*!
		 * @brief Returns a cached Mix_Music object from an audio file.
		 * @param filename File to load the music from.
		 */
		static Mix_Music* musicNamed(std::string filename);
		
		/*!
		 * @brief Cache a set of Sprite files for faster access during gameplay.
		 * @param files Vector of files to load.
		 */
		static void preloadSprites(std::vector<std::string> files);
		
		/*!
		 * @brief Cache a set of animation definitions for faster access during gameplay.
		 * @param files Vector of files to load.
		 */
		static void preloadAnimations(std::vector<std::string> files);
		
		/*!
		 * @brief Cache a set of sound effects for faster access during gameplay.
		 * @param files Vector of files to load.
		 */
		static void preloadSoundEffects(std::vector<std::string> files);
		
		/*!
		 * @brief Cache a set of music files for faster access during gameplay.
		 * @param files Vector of files to load.
		 */
		static void preloadMusicFiles(std::vector<std::string> files);
		
		/*!
		 * @brief Remove every item from the three caches (animations, sprites and sounds)
		 */
		static void flushCache();
		
		/*!
		 * @brief The renderer used to create hardware textures.
		 */
		static SDL_Renderer *currentRenderer;
		
	private:
		static std::map<std::string, SDL_Texture*> _sprites;
		static std::map<std::string, SDL_RWops*> _animations;
		static std::map<std::string, Mix_Chunk*> _audioEffects;
		static std::map<std::string, Mix_Music*> _musicFiles;
	};
}

#endif