#include #include #include "Runner.hpp" #include #include "Component/Music/MusicComponent.hpp" #include "Component/Sound/SoundComponent.hpp" #include "Component/Controllable/ControllableComponent.hpp" #include "Component/Position/PositionComponent.hpp" #include "Component/Keyboard/KeyboardComponent.hpp" #include "Component/Renderer/Drawable2DComponent.hpp" #include "Component/Button/ButtonComponent.hpp" #include "Drawables/2D/Text.hpp" namespace RAY2D = RAY::Drawables::Drawables2D; namespace BBM { std::shared_ptr Runner::loadPauseMenuScene() { static const std::map sounds = { {SoundComponent::JUMP, "assets/sounds/click.ogg"} }; auto scene = std::make_shared(); addMenuControl(*scene); scene->addEntity("Control entity") .addComponent("assets/musics/music_player_select.ogg") .addComponent(sounds); scene->addEntity("background") .addComponent() .addComponent("assets/plain_menu_background.png"); scene->addEntity("pause text") .addComponent(1920 / 2.5, 180, 0) .addComponent("PAUSE", 120, RAY::Vector2(), ORANGE); auto &play = scene->addEntity("play button") .addComponent(1920 / 6.5, 1080 - 360, 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 / 1.5, 1080 - 360, 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 //music play.getComponent().setButtonLinks(nullptr, nullptr, nullptr, &settings); settings.getComponent().setButtonLinks(nullptr, nullptr, &play, &exit); exit.getComponent().setButtonLinks(nullptr, nullptr, &settings, nullptr); return scene; } }