#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" #include "System/Renderer/RenderSystem.hpp" namespace RAY2D = RAY::Drawables::Drawables2D; namespace BBM { std::shared_ptr Runner::loadSettingsMenuScene() { auto scene = std::make_shared(); static const std::map sounds = { {SoundComponent::JUMP, "assets/sounds/click.ogg"} }; scene->addEntity("Control entity") .addComponent() .addComponent() .addComponent("assets/musics/music_title.ogg") .addComponent(sounds); scene->addEntity("background") .addComponent() .addComponent("assets/plain_menu_background.png"); scene->addEntity("logo") .addComponent(1920 / 3, 180, 0) .addComponent("assets/logo_small.png"); auto &music = scene->addEntity("music text") .addComponent(1920 / 2.5, 1080 - 540, 0) .addComponent("Music Volume", 70, RAY::Vector2(), BLACK) .addComponent() .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(BLACK); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(ORANGE); }); auto &musicUp = scene->addEntity("music up button") .addComponent(1920 / 1.5, 1080 - 540, 0) .addComponent("assets/buttons/button_plus.png") .addComponent("assets/musics/music_title.ogg") .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_plus.png"); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { auto &component = entity.getComponent(); component.turnUpVolume(); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_plus_hovered.png"); }); auto &musicDown = scene->addEntity("music down button") .addComponent(1920 / 3, 1080 - 540, 0) .addComponent("assets/buttons/button_minus.png") .addComponent("assets/musics/music_title.ogg") .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_minus.png"); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { auto &component = entity.getComponent(); component.turnDownVolume(); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_minus_hovered.png"); }); auto &sound = scene->addEntity("sound text") .addComponent(1920 / 2.5, 1080 - 360, 0) .addComponent("Sound Volume", 70, RAY::Vector2(), BLACK) .addComponent() .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(BLACK); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(ORANGE); }); auto &soundUp = scene->addEntity("sound up button") .addComponent(1920 / 1.5, 1080 - 360, 0) .addComponent("assets/buttons/button_plus.png") .addComponent(sounds) .addComponent([](WAL::Entity &entity, WAL::Wal &) { auto &component = entity.getComponent(); component.turnUpVolume(); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_plus.png"); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_plus_hovered.png"); }); auto &soundDown = scene->addEntity("sound down button") .addComponent(1920 / 3, 1080 - 360, 0) .addComponent("assets/buttons/button_minus.png") .addComponent(sounds) .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_minus.png"); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { auto &component = entity.getComponent(); component.turnDownVolume(); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { RAY::Texture *texture = dynamic_cast(entity.getComponent().drawable.get()); texture->use("assets/buttons/button_minus_hovered.png"); }); auto &debug = scene->addEntity("debug text") .addComponent(1920 / 2.5, 1080 - 180, 0) .addComponent("Debug Mode: Off", 70, RAY::Vector2(), BLACK) .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); if (text->getString().find("Off") != std::string::npos) { text->setText("Debug Mode: On"); wal.getSystem().setDebug(true); } else { text->setText("Debug Mode: Off"); wal.getSystem().setDebug(false); } }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(BLACK); }) .addComponent([](WAL::Entity &entity, WAL::Wal &) { entity.getComponent().drawable->setColor(ORANGE); }); auto &back = scene->addEntity("back to menu") .addComponent(10, 1080 - 85, 0) .addComponent("assets/buttons/button_back.png") .addComponent([](WAL::Entity &entity, WAL::Wal &) { gameState.nextScene = BBM::GameState::SceneID::MainMenuScene; }) .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"); }); //needed material //music //sound music.getComponent().setButtonLinks(nullptr, &sound, &musicDown, &musicUp); musicDown.getComponent().setButtonLinks(&debug, &sound, nullptr, &music); musicUp.getComponent().setButtonLinks(&debug, &sound, &music); sound.getComponent().setButtonLinks(&music, &debug, &soundDown, &soundUp); soundDown.getComponent().setButtonLinks(&music, &debug, nullptr, &sound); soundUp.getComponent().setButtonLinks(&music, &debug, &sound); debug.getComponent().setButtonLinks(&sound, &back, &back); back.getComponent().setButtonLinks(&debug, nullptr, nullptr, &debug); return scene; } }