Ajout des fonctions pour changer le titre
This commit is contained in:
		
							parent
							
								
									bdb61b81bd
								
							
						
					
					
						commit
						9e0a0e8ba4
					
				|  | @ -41,6 +41,11 @@ public: | |||
|     Editor(Manager& manager); | ||||
|     virtual ~Editor(); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Charge un niveau de jeu depuis le fichier donné | ||||
|      */ | ||||
|     virtual void load(std::ifstream& file); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Demande le passage à la frame suivante sur | ||||
|      * cette vue | ||||
|  |  | |||
|  | @ -21,6 +21,11 @@ public: | |||
|     Game(Manager& manager); | ||||
|     virtual ~Game(); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Charge un niveau de jeu depuis le fichier donné | ||||
|      */ | ||||
|     virtual void load(std::ifstream& file); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Demande le passage à la frame suivante sur | ||||
|      * cette vue | ||||
|  |  | |||
|  | @ -34,12 +34,12 @@ public: | |||
|     /**
 | ||||
|      * Charge un niveau de jeu depuis le fichier donné | ||||
|      */ | ||||
|     void load(std::ifstream& file); | ||||
|     virtual void load(std::ifstream& file); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Sauvegarde la configuration actuelle comme un niveau | ||||
|      */ | ||||
|     void save(); | ||||
|     virtual void save(); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Récupère le nom du niveau | ||||
|  |  | |||
|  | @ -14,6 +14,7 @@ private: | |||
|     sf::RenderWindow window; | ||||
|     sf::Clock clock; | ||||
|     sf::View window_view; | ||||
|     std::string title; | ||||
| 
 | ||||
|     ResourceManager resource_manager; | ||||
|     std::vector<sf::Event> events; | ||||
|  | @ -64,6 +65,16 @@ public: | |||
|      */ | ||||
|     void setWindowView(sf::View set_window_view); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Renvoie le titre actuel de la fenêtre | ||||
|      */ | ||||
|     std::string getTitle(); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Modifie le titre actuel de la fenêtre | ||||
|      */ | ||||
|     void setTitle(std::string set_title); | ||||
| 
 | ||||
|     /**
 | ||||
|      * Renvoie un booléen attestant de l'appui sur la | ||||
|      * touche donnée ou non | ||||
|  |  | |||
|  | @ -12,6 +12,11 @@ Editor::Editor(Manager& manager) : Level(manager) { | |||
| 
 | ||||
| Editor::~Editor() {} | ||||
| 
 | ||||
| void Editor::load(std::ifstream& file) { | ||||
|     Level::load(file); | ||||
|     manager.setTitle("Edition de " + getName()); | ||||
| } | ||||
| 
 | ||||
| void Editor::frame() { | ||||
|     const std::vector<sf::Event>& events = manager.getEvents(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -11,6 +11,11 @@ Game::Game(Manager& manager) : Level(manager), next_frame_time(manager.getCurren | |||
| 
 | ||||
| Game::~Game() {} | ||||
| 
 | ||||
| void Game::load(std::ifstream& file) { | ||||
|     Level::load(file); | ||||
|     manager.setTitle(getName()); | ||||
| } | ||||
| 
 | ||||
| void Game::frame() { | ||||
|     sf::Time current_time = manager.getCurrentTime(); | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,9 +3,7 @@ | |||
| Manager::Manager() : window( | ||||
|     sf::VideoMode(704, 480), "Skizzle", sf::Style::Default, | ||||
|     sf::ContextSettings(0, 0, 2) | ||||
| ), view(NULL) { | ||||
|     window_view = window.getView(); | ||||
| } | ||||
| ), window_view(window.getView()), title(""), view(NULL) {} | ||||
| 
 | ||||
| void Manager::start() { | ||||
|     while (window.isOpen()) { | ||||
|  | @ -70,6 +68,20 @@ void Manager::setWindowView(sf::View set_window_view) { | |||
|     window_view = set_window_view; | ||||
| } | ||||
| 
 | ||||
| std::string Manager::getTitle() { | ||||
|     return title; | ||||
| } | ||||
| 
 | ||||
| void Manager::setTitle(std::string set_title) { | ||||
|     title = set_title; | ||||
| 
 | ||||
|     if (title.empty()) { | ||||
|         window.setTitle("Skizzle"); | ||||
|     } else { | ||||
|         window.setTitle("Skizzle - " + title); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| bool Manager::isKeyPressed(sf::Keyboard::Key key) const { | ||||
|     return sf::Keyboard::isKeyPressed(key) && window.hasFocus(); | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue