2016-04-11 21:38:03 +00:00
|
|
|
#ifndef __SKIZZLE_MANAGER_HPP__
|
|
|
|
#define __SKIZZLE_MANAGER_HPP__
|
2016-03-28 15:23:47 +00:00
|
|
|
|
|
|
|
#include "resource_manager.hpp"
|
2016-04-18 10:05:45 +00:00
|
|
|
#include <SFGUI/SFGUI.hpp>
|
|
|
|
#include <SFGUI/Widgets.hpp>
|
|
|
|
#include <SFML/Graphics.hpp>
|
2016-03-28 17:57:55 +00:00
|
|
|
#include <memory>
|
2016-04-11 19:11:34 +00:00
|
|
|
#include <stack>
|
2016-03-28 15:23:47 +00:00
|
|
|
|
2016-04-12 16:11:36 +00:00
|
|
|
class State;
|
|
|
|
|
2016-03-28 15:23:47 +00:00
|
|
|
/**
|
2016-04-09 13:53:12 +00:00
|
|
|
* Gestionnaire principal de tous les états, vues et
|
2016-03-28 15:23:47 +00:00
|
|
|
* ressources du jeu
|
|
|
|
*/
|
|
|
|
class Manager {
|
|
|
|
private:
|
|
|
|
sf::RenderWindow window;
|
2016-04-18 10:05:45 +00:00
|
|
|
sf::Time previous_time;
|
|
|
|
sfg::SFGUI sfgui;
|
|
|
|
sfg::Desktop desktop;
|
|
|
|
|
2016-04-12 18:11:51 +00:00
|
|
|
unsigned int framerate;
|
2016-04-10 10:27:06 +00:00
|
|
|
ResourceManager resource_manager;
|
|
|
|
|
2016-03-28 15:23:47 +00:00
|
|
|
sf::Clock clock;
|
2016-04-10 18:34:29 +00:00
|
|
|
sf::View gui_view;
|
2016-04-08 00:35:17 +00:00
|
|
|
sf::String title;
|
2016-03-28 15:23:47 +00:00
|
|
|
|
2016-04-17 13:25:21 +00:00
|
|
|
State* previous_state;
|
2016-04-11 19:11:34 +00:00
|
|
|
std::stack<std::unique_ptr<State>> states;
|
2016-03-28 15:23:47 +00:00
|
|
|
|
2016-03-28 17:57:55 +00:00
|
|
|
public:
|
2016-04-09 23:29:42 +00:00
|
|
|
/**
|
|
|
|
* Énumération des modificateurs
|
|
|
|
*/
|
|
|
|
enum class Modifier {CONTROL, ALT, SHIFT, SYSTEM};
|
|
|
|
|
2016-04-10 02:47:02 +00:00
|
|
|
/**
|
|
|
|
* Taux maximal de frames par seconde
|
|
|
|
*/
|
|
|
|
static const unsigned int FPS;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Temps idéal entre deux frames
|
|
|
|
*/
|
|
|
|
static const sf::Time FRAME_TIME;
|
|
|
|
|
2016-04-12 16:11:36 +00:00
|
|
|
/**
|
|
|
|
* Taille d'une case de la grille du jeu
|
|
|
|
*/
|
|
|
|
static const float GRID;
|
|
|
|
|
2016-03-28 15:23:47 +00:00
|
|
|
Manager();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Démarre la boucle principale du jeu
|
|
|
|
*/
|
|
|
|
void start();
|
|
|
|
|
2016-04-08 00:35:17 +00:00
|
|
|
/**
|
2016-04-11 19:11:34 +00:00
|
|
|
* Empile l'état donné
|
2016-04-05 23:13:00 +00:00
|
|
|
*/
|
2016-04-11 19:11:34 +00:00
|
|
|
void pushState(std::unique_ptr<State> set_state);
|
2016-04-05 23:13:00 +00:00
|
|
|
|
2016-03-28 17:57:55 +00:00
|
|
|
/**
|
2016-04-11 19:11:34 +00:00
|
|
|
* Dépile l'état actuel
|
2016-03-28 17:57:55 +00:00
|
|
|
*/
|
2016-04-11 19:11:34 +00:00
|
|
|
void popState();
|
2016-03-28 17:57:55 +00:00
|
|
|
|
2016-03-28 15:23:47 +00:00
|
|
|
/**
|
|
|
|
* Renvoie la fenêtre actuellement utilisée pour le dessin
|
|
|
|
*/
|
|
|
|
sf::RenderWindow& getWindow();
|
|
|
|
|
2016-04-12 18:11:51 +00:00
|
|
|
/**
|
|
|
|
* Récupère le framerate (maximal) actuel
|
|
|
|
*/
|
|
|
|
unsigned int getFramerate();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifie le framerate (maximal) actuel
|
|
|
|
*/
|
|
|
|
void setFramerate(unsigned int set_framerate);
|
|
|
|
|
2016-03-28 15:23:47 +00:00
|
|
|
/**
|
2016-04-03 18:19:48 +00:00
|
|
|
* Renvoie le temps actuel du jeu
|
2016-03-28 15:23:47 +00:00
|
|
|
*/
|
2016-04-03 18:19:48 +00:00
|
|
|
sf::Time getCurrentTime() const;
|
2016-03-28 15:23:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renvoie le gestionnaire de ressources
|
|
|
|
*/
|
|
|
|
ResourceManager& getResourceManager();
|
|
|
|
|
2016-04-05 15:50:28 +00:00
|
|
|
/**
|
2016-04-10 18:34:29 +00:00
|
|
|
* Passage en vue de l'interface
|
|
|
|
* (coin en haut à gauche, zoom 1:1)
|
2016-04-18 10:05:45 +00:00
|
|
|
* @deprecated
|
2016-04-05 15:50:28 +00:00
|
|
|
*/
|
2016-04-10 18:34:29 +00:00
|
|
|
void useGUIView();
|
2016-04-05 15:50:28 +00:00
|
|
|
|
2016-04-18 10:05:45 +00:00
|
|
|
/**
|
|
|
|
* Renvoie le bureau pour l'affichage de l'interface
|
|
|
|
*/
|
|
|
|
sfg::Desktop& getDesktop();
|
|
|
|
|
2016-04-05 18:07:58 +00:00
|
|
|
/**
|
|
|
|
* Renvoie le titre actuel de la fenêtre
|
|
|
|
*/
|
2016-04-06 11:41:12 +00:00
|
|
|
sf::String getTitle();
|
2016-04-05 18:07:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Modifie le titre actuel de la fenêtre
|
|
|
|
*/
|
2016-04-06 11:41:12 +00:00
|
|
|
void setTitle(sf::String set_title);
|
2016-04-05 18:07:58 +00:00
|
|
|
|
2016-03-28 15:23:47 +00:00
|
|
|
/**
|
|
|
|
* Renvoie un booléen attestant de l'appui sur la
|
|
|
|
* touche donnée ou non
|
|
|
|
*/
|
|
|
|
bool isKeyPressed(sf::Keyboard::Key key) const;
|
2016-04-09 23:29:42 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Renvoie un booléen attestant de l'appui sur le
|
|
|
|
* modificateur
|
|
|
|
*/
|
|
|
|
bool isKeyPressed(Modifier modifier) const;
|
2016-03-28 15:23:47 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|