#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" #include "Component/Stat/StatComponent.hpp" namespace RAY2D = RAY::Drawables::Drawables2D; namespace BBM { std::shared_ptr Runner::loadSettingsMenuScene() { auto scene = std::make_shared(); static const std::map sounds = { {SoundComponent::BOMB, "assets/sounds/click.ogg"} }; addMenuControl(*scene, sounds); auto &audio = scene->addEntity("Control entity") .addComponent("assets/musics/music_title.ogg") .addComponent(sounds); scene->addEntity("background") .addComponent() .addComponent("assets/backgrounds/settings.png"); scene->addEntity("white background") .addComponent(1920 / 3 - 30, 400, 0) .addComponent(Vector2f(), Vector2f(800, 800), RAY::Color(WHITE).setA(150)); scene->addEntity("logo") .addComponent(1920 / 3, 100, 0) .addComponent("assets/logo_small.png"); auto &music = scene->addEntity("music text") .addComponent(1920 / 2.5, 1080 - 100 - 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 - 100 - 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 - 100 - 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"); }); scene->addEntity("music level text") .addComponent(1920 / 2.5, 1080 - 100 - 460, 0) .addComponent(RAY::Vector2(), RAY::Vector2(30, 10), BLACK) .addComponent([audio](Drawable2DComponent &drawble) { const MusicComponent *musicCmp = audio.tryGetComponent(); if (!musicCmp) return; RAY2D::Rectangle *rect = dynamic_cast(drawble.drawable.get()); if (!rect) return; rect->setWidth((13 * 36.5) * musicCmp->volume); }); auto &sound = scene->addEntity("sound text") .addComponent(1920 / 2.5, 1080 - 100 - 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 - 100 - 360, 0) .addComponent("assets/buttons/button_plus.png") .addComponent(sounds) .addComponent() .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 - 100 - 360, 0) .addComponent("assets/buttons/button_minus.png") .addComponent(sounds) .addComponent() .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"); }); scene->addEntity("sound level text") .addComponent(1920 / 2.5, 1080 - 100 - 280, 0) .addComponent(RAY::Vector2(), RAY::Vector2(30, 10), BLACK) .addComponent([audio](Drawable2DComponent &drawable) { const auto *soundCmp = audio.tryGetComponent(); if (!soundCmp) return; auto *rect = dynamic_cast(drawable.drawable.get()); if (!rect) return; rect->setWidth((13 * 36.5) * soundCmp->volume); }); auto &debug = scene->addEntity("debug text") .addComponent(1920 / 2.5, 1080 - 100 - 180, 0) .addComponent("Debug Mode: Off", 70, RAY::Vector2(), BLACK) .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { auto *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 &fullscreen = scene->addEntity("fullscreen text") .addComponent(1920 / 2.5, 1080 - 100 - 50, 0) .addComponent("Fullscreen: Off", 70, RAY::Vector2(), BLACK) .addComponent([](WAL::Entity &entity, WAL::Wal &wal) { RAY2D::Text *text = dynamic_cast(entity.getComponent().drawable.get()); RAY::Window &window = RAY::Window::getInstance(); if (text->getString().find("Off") != std::string::npos) { text->setText("Fullscreen: On"); window.setDimensions(RAY::Vector2(1920, 1080)); } else { text->setText("Fullscreen: Off"); window.setDimensions(RAY::Vector2(1280, 720)); } window.toggleFullscreen(); }) .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 = gameState.previousScene; }) .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, &fullscreen); fullscreen.getComponent().setButtonLinks(&debug, &back, &back); back.getComponent().setButtonLinks(&fullscreen, nullptr, nullptr, &fullscreen); return scene; } }