diff --git a/project/Conf/Scenes/EndGameScene/button.json b/project/Conf/Scenes/EndGameScene/button.json index 6918e4c..65da523 100644 --- a/project/Conf/Scenes/EndGameScene/button.json +++ b/project/Conf/Scenes/EndGameScene/button.json @@ -2,8 +2,29 @@ "2-Continue": { "type": "button", "nbFrame": 3, - "position": [1770, 900, 0], + "position": [940, 900, 0], "audio": "Ressources/buttons/click_sound.ogg", - "texture": "Ressources/buttons/next_button.png" + "texture": "Ressources/buttons/little_button.png", + "text": { + "font": "Ressources/fonts/squarefont/Square.ttf", + "text": "Main Menu", + "color": [255, 255, 255, 255], + "fontSize": 40, + "position": [80, 40, 0] + } + }, + "3-Restart": { + "type": "button", + "nbFrame": 3, + "position": [1470, 900, 0], + "texture": "Ressources/buttons/little_button.png", + "audio": "Ressources/buttons/click_sound.ogg", + "text": { + "font": "Ressources/fonts/squarefont/Square.ttf", + "text": "Battle Again", + "color": [255, 255, 255, 255], + "fontSize": 40, + "position": [80, 40, 0] + } } } \ No newline at end of file diff --git a/project/Source/Core/Core.cpp b/project/Source/Core/Core.cpp index 6e641d7..c2d9576 100644 --- a/project/Source/Core/Core.cpp +++ b/project/Source/Core/Core.cpp @@ -82,7 +82,7 @@ void Core::loadMenuScenes() updateLoadingScreen("."); _menuScenes.emplace(Scene::Scenes::SELECT_PLAYER, std::make_shared(_settings, _gameSettings, _parallax, std::bind(&Scene::GameScene::applyGameParams, gameScene))); updateLoadingScreen(""); - _menuScenes.emplace(Scene::Scenes::END_GAME, std::make_shared(_settings, _gameSettings, _parallax)); + _menuScenes.emplace(Scene::Scenes::END_GAME, std::make_shared(_settings, _gameSettings, _parallax, std::bind(&Scene::GameScene::applyGameParams, gameScene))); updateLoadingScreen("."); _menuScenes.emplace(Scene::Scenes::SELECT_MAP, std::make_shared(_settings, _gameSettings, _parallax)); updateLoadingScreen(".."); diff --git a/project/Source/Scenes/GameScenes/EndGameScene.cpp b/project/Source/Scenes/GameScenes/EndGameScene.cpp index 8cf22bf..5ef1bd0 100644 --- a/project/Source/Scenes/GameScenes/EndGameScene.cpp +++ b/project/Source/Scenes/GameScenes/EndGameScene.cpp @@ -14,14 +14,22 @@ void Scene::EndGameScene::goToMainMenu() _nextScene = Scene::Scenes::MAIN_MENU; } -Scene::EndGameScene::EndGameScene(std::shared_ptr settings, std::shared_ptr gameSettings, std::vector> ¶llax) : AScene(settings), _gameSettings(gameSettings), _parallax(parallax) +void Scene::EndGameScene::restartGame() +{ + _restartGameCallBack(); + _nextScene = Scene::Scenes::GAME; +} + +Scene::EndGameScene::EndGameScene(std::shared_ptr settings, std::shared_ptr gameSettings, std::vector> ¶llax, std::function restartCallBack) : AScene(settings), _gameSettings(gameSettings), _parallax(parallax) { _buttons = loadObjects("Conf/Scenes/EndGameScene/button.json"); _buttons.at(0)->setCallBack(std::bind(&Scene::EndGameScene::goToMainMenu, this)); + _buttons.at(1)->setCallBack(std::bind(&Scene::EndGameScene::restartGame, this)); _texts = loadObjects("Conf/Scenes/EndGameScene/text.json"); _images = loadObjects("Conf/Scenes/EndGameScene/image.json"); _winner = loadObjects("Conf/Scenes/EndGameScene/winner.json"); _nextScene = Scene::Scenes::END_GAME; + _restartGameCallBack = restartCallBack; } Scene::Scenes Scene::EndGameScene::handleEvent() diff --git a/project/Source/Scenes/GameScenes/EndGameScene.hpp b/project/Source/Scenes/GameScenes/EndGameScene.hpp index a174ac7..8a3dbb4 100644 --- a/project/Source/Scenes/GameScenes/EndGameScene.hpp +++ b/project/Source/Scenes/GameScenes/EndGameScene.hpp @@ -26,7 +26,7 @@ namespace Scene { * @param settings Shared pointer to Settings class * @param gameSettings Shared pointer to Game Settings class */ - EndGameScene(std::shared_ptr settings, std::shared_ptr gameSettings, std::vector> ¶llax); + EndGameScene(std::shared_ptr settings, std::shared_ptr gameSettings, std::vector> ¶llax, std::function _restartCallBack); ~EndGameScene(); Scenes handleEvent() override; @@ -34,9 +34,14 @@ namespace Scene { /** * @brief Call back function executed when next button is pressed to set next scene to main menu scene - */ + */ void goToMainMenu(); + /** + * @brief Call back function executed to restart the game + */ + void restartGame(); + void drawPlayerNameAndScore(Object::PLAYER_ORDER player, std::size_t score, std::size_t nbText); void drawScore(); @@ -46,6 +51,7 @@ namespace Scene { std::vector> _winner; std::shared_ptr _gameSettings; int _winnerId; + std::function _restartGameCallBack; }; }