diff --git a/assets/Json/menu.json b/assets/Json/menu.json index 621bffe3..c932200b 100644 --- a/assets/Json/menu.json +++ b/assets/Json/menu.json @@ -51,6 +51,67 @@ } ] }, + { + "type": "text", + "text": "Go Back ('ESC')", + "color": "red", + "size": 1.5, + "position": { + "x": 350, + "y": 875 + } + }, + { + "type": "button", + "spritePath": "assets/Menu/button.png", + "width": 1600, + "height": 1000, + "callback": "exitGame", + "rect": { + "x": 0.0, + "y": 0.0, + "width": 1366.0, + "height": 406.0 + }, + "position": { + "x": 100, + "y": 500 + }, + "collisionRect": { + "width": 1600, + "height": 1000, + "offsetX": 0, + "offsetY": 0 + }, + "animRect": [ + { + "type": "hover", + "time": 80, + "noIncr": true, + "list": [ + { + "x": 1366.0, + "y": 0.0, + "width": 1366.0, + "height": 406.0 + } + ] + }, + { + "type": "selected", + "time": 80, + "noIncr": true, + "list": [ + { + "x" : 2732.0, + "y": 0.0, + "width": 1366.0, + "height": 406.0 + } + ] + } + ] + }, { "type": "button", "callback": "changeParallax", diff --git a/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp b/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp index abae175e..990033ca 100644 --- a/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp +++ b/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp @@ -184,6 +184,12 @@ namespace Menu { Scene::SceneManager::getInstance().changeScene(MENU); } + + void exitGame() + { + Scene::SceneManager::getInstance().stop(); + } + void createServer() { auto arrInputBox = Registry::getInstance().getComponents(); diff --git a/src/Client/Systems/Menus/Menu/ButtonCallbacks.hpp b/src/Client/Systems/Menus/Menu/ButtonCallbacks.hpp index 1e47978d..33a8ad33 100644 --- a/src/Client/Systems/Menus/Menu/ButtonCallbacks.hpp +++ b/src/Client/Systems/Menus/Menu/ButtonCallbacks.hpp @@ -27,7 +27,8 @@ namespace Menu { GO_CREATE_SERVER, CREATE_SERVER, GO_MENU, - CHANGE_PARALLAX + CHANGE_PARALLAX, + EXIT_GAME }; NLOHMANN_JSON_SERIALIZE_ENUM( @@ -45,7 +46,8 @@ namespace Menu { {GO_CREATE_SERVER, "goCreateServer" }, {CREATE_SERVER, "createServer" }, {GO_MENU, "goToMenu" }, - {CHANGE_PARALLAX, "changeParallax" } + {CHANGE_PARALLAX, "changeParallax" }, + {EXIT_GAME, "exitGame" }, }); void initConnection(); @@ -74,6 +76,8 @@ namespace Menu { void changeParallax(); + void exitGame(); + const std::unordered_map> callbacks = { {CallbackType::DEFAULT_CALLBACK, &defaultCallBack}, {CallbackType::INIT_CONNECTION, &initConnection}, @@ -86,6 +90,7 @@ namespace Menu { {CallbackType::SEND_READY, &sendReadyPacket}, {CallbackType::GO_CREATE_SERVER, &goCreateServer}, {CallbackType::CREATE_SERVER, &createServer}, + {CallbackType::EXIT_GAME, &exitGame}, { CallbackType::GO_MENU, &goMenu,