diff --git a/lib/Ray/sources/Window.cpp b/lib/Ray/sources/Window.cpp index 418c09ab..55aae251 100644 --- a/lib/Ray/sources/Window.cpp +++ b/lib/Ray/sources/Window.cpp @@ -49,6 +49,7 @@ bool RAY::Window::open(void) } InitWindow(this->_dimensions.x, this->_dimensions.y, this->_title.c_str()); this->_isOpen = true; + this->setExitKey(Controller::Keyboard::Key::KEY_NULL); return true; } @@ -176,4 +177,9 @@ void RAY::Window::drawFPS(const RAY::Vector2 &position) bool RAY::Window::isReady() const { return IsWindowReady(); +} + +void RAY::Window::setExitKey(RAY::Controller::Keyboard::Key key) +{ + SetExitKey(key); } \ No newline at end of file diff --git a/lib/Ray/sources/Window.hpp b/lib/Ray/sources/Window.hpp index f0e30e33..525f2992 100644 --- a/lib/Ray/sources/Window.hpp +++ b/lib/Ray/sources/Window.hpp @@ -131,6 +131,11 @@ namespace RAY { //! @return true if the window's context has been correctly initialized bool isReady() const; + //! @param key if this key is pressed, the window will close + //! @info Default is ESC key + //! @info Calling this function override the previous closing key + void setExitKey(Controller::Keyboard::Key key); + private: //! @brief Creates window, and opens it if openNow is set to true diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index 65166902..7a0e2458 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -171,7 +171,6 @@ namespace BBM .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { wal.shouldClose = true; - //close window }); play.getComponent().setButtonLinks(&exit, &settings); @@ -186,17 +185,79 @@ namespace BBM std::shared_ptr Runner::loadPauseMenuScene() { auto scene = std::make_shared(); + + scene->addEntity("Control entity") + .addComponent() + .addComponent(); + scene->addEntity("background") + .addComponent() + .addComponent("assets/plain_menu_background.png"); + scene->addEntity("logo") + .addComponent(1920 / 3, 180, 0) + .addComponent("assets/logo_small.png"); + auto &play = scene->addEntity("play button") + .addComponent(1920 / 2.5, 1080 - 540, 0) + .addComponent("assets/buttons/button_back.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_back_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::GameScene; + }); + auto &settings = scene->addEntity("settings button") + .addComponent(1920 / 2.5, 1080 - 360, 0) + .addComponent("assets/buttons/button_settings.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_settings.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_settings_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + gameState.nextScene = BBM::GameState::SceneID::SettingsScene; + }); + auto &exit = scene->addEntity("exit button") + .addComponent(1920 / 2.5, 1080 - 180, 0) + .addComponent("assets/buttons/button_exit.png") + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_exit.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &) + { + RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); + + texture->use("assets/buttons/button_exit_hovered.png"); + }) + .addComponent([](WAL::Entity &entity, WAL::Wal &wal) + { + gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; + }); //needed material - //return button - //return button assets - //settings button - //settings button assets - //quit button - //quit button assets - //plain background - //logo //music //sound + play.getComponent().setButtonLinks(&exit, &settings); + settings.getComponent().setButtonLinks(&play, &exit); + exit.getComponent().setButtonLinks(&settings, &play); return scene; }