2016-04-11 21:38:03 +00:00
|
|
|
#ifndef __SKIZZLE_RESOURCE_MANAGER_HPP__
|
|
|
|
#define __SKIZZLE_RESOURCE_MANAGER_HPP__
|
2016-03-22 19:03:19 +00:00
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
2016-03-30 11:32:49 +00:00
|
|
|
#include <SFML/Audio.hpp>
|
2016-04-10 10:27:06 +00:00
|
|
|
#include <boost/filesystem.hpp>
|
2016-04-09 20:36:07 +00:00
|
|
|
#include <unordered_map>
|
2016-03-22 19:03:19 +00:00
|
|
|
#include <string>
|
2016-04-09 20:36:07 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <memory>
|
|
|
|
|
2016-04-10 03:10:27 +00:00
|
|
|
/**
|
|
|
|
* Gestionnaire de ressources du jeu. Conserve des
|
|
|
|
* références vers toutes les ressources pour éviter
|
|
|
|
* de les charger deux fois, permet l'accès uniforme
|
|
|
|
* aux ressources
|
|
|
|
*/
|
2016-03-22 19:03:19 +00:00
|
|
|
class ResourceManager {
|
|
|
|
private:
|
2016-04-10 10:27:06 +00:00
|
|
|
bool preloaded;
|
2016-04-09 20:36:07 +00:00
|
|
|
|
2016-04-10 10:27:06 +00:00
|
|
|
boost::filesystem::path textures_path;
|
|
|
|
boost::filesystem::path fonts_path;
|
|
|
|
boost::filesystem::path levels_path;
|
|
|
|
boost::filesystem::path musics_path;
|
2016-04-19 15:51:42 +00:00
|
|
|
|
2016-04-19 22:37:44 +00:00
|
|
|
std::unordered_map<std::string, std::shared_ptr<sf::Image>> images;
|
|
|
|
std::unordered_map<std::string, std::shared_ptr<sf::Texture>> textures;
|
|
|
|
std::unordered_map<std::string, std::shared_ptr<sf::Font>> fonts;
|
2016-03-30 11:32:49 +00:00
|
|
|
sf::Music music;
|
2016-04-19 15:51:42 +00:00
|
|
|
|
2016-04-12 13:48:06 +00:00
|
|
|
float music_volume;
|
|
|
|
bool playing_state;
|
|
|
|
std::string current_music;
|
2016-03-22 19:03:19 +00:00
|
|
|
|
|
|
|
public:
|
2016-03-30 18:40:59 +00:00
|
|
|
ResourceManager();
|
2016-03-22 19:03:19 +00:00
|
|
|
|
|
|
|
/**
|
2016-04-10 10:27:06 +00:00
|
|
|
* Précharge toutes les ressources préchargeables
|
|
|
|
*/
|
|
|
|
void preload();
|
|
|
|
|
2016-04-19 15:51:42 +00:00
|
|
|
/**
|
|
|
|
* Récupère une image préchargée
|
|
|
|
*/
|
2016-04-19 22:37:44 +00:00
|
|
|
std::shared_ptr<sf::Image> getImage(std::string name);
|
2016-04-19 15:51:42 +00:00
|
|
|
|
2016-04-10 10:27:06 +00:00
|
|
|
/**
|
|
|
|
* Récupère une texture préchargée
|
2016-03-22 19:03:19 +00:00
|
|
|
*/
|
2016-04-19 22:37:44 +00:00
|
|
|
std::shared_ptr<sf::Texture> getTexture(std::string name);
|
2016-03-30 11:32:49 +00:00
|
|
|
|
2016-04-05 15:37:43 +00:00
|
|
|
/**
|
2016-04-10 10:27:06 +00:00
|
|
|
* Récupère une police préchargée
|
2016-04-05 15:37:43 +00:00
|
|
|
*/
|
2016-04-19 22:37:44 +00:00
|
|
|
std::shared_ptr<sf::Font> getFont(std::string name);
|
2016-04-05 15:37:43 +00:00
|
|
|
|
2016-03-30 11:32:49 +00:00
|
|
|
/**
|
2016-04-10 07:41:26 +00:00
|
|
|
* Récupère le chemin vers le fichier du niveau portant le
|
|
|
|
* nom passé en argument
|
2016-03-30 11:32:49 +00:00
|
|
|
*/
|
2016-04-10 07:41:26 +00:00
|
|
|
std::string getLevelPath(std::string name);
|
2016-03-30 11:32:49 +00:00
|
|
|
|
2016-04-11 01:50:08 +00:00
|
|
|
/**
|
|
|
|
* Récupère la liste de tous les niveaux
|
|
|
|
*/
|
|
|
|
std::vector<std::string> getLevelList();
|
|
|
|
|
2016-03-30 11:32:49 +00:00
|
|
|
/**
|
2016-04-09 20:36:07 +00:00
|
|
|
* Démarre la musique de fond donnée
|
2016-03-30 11:32:49 +00:00
|
|
|
*/
|
2016-04-09 20:36:07 +00:00
|
|
|
void playMusic(std::string name);
|
2016-03-30 11:32:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Arrête la musique de fond
|
|
|
|
*/
|
|
|
|
void stopMusic();
|
2016-04-09 20:36:07 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Récupère le volume de la musique de fond
|
|
|
|
*/
|
|
|
|
float getMusicVolume();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifie le volume de la musique de fond
|
|
|
|
*/
|
|
|
|
void setMusicVolume(float set_music_volume);
|
2016-03-22 19:03:19 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|