From d41670ae40c758c565c0b62d9e9f42a2356fab51 Mon Sep 17 00:00:00 2001 From: "arthur.jamet" Date: Mon, 7 Jun 2021 17:10:33 +0200 Subject: [PATCH] some buttons for the settings menu --- sources/Component/Button/ButtonComponent.hpp | 22 +++++++- sources/Runner/Runner.cpp | 56 ++++++++++++++++++-- 2 files changed, 74 insertions(+), 4 deletions(-) diff --git a/sources/Component/Button/ButtonComponent.hpp b/sources/Component/Button/ButtonComponent.hpp index 3ce02284..90329b89 100644 --- a/sources/Component/Button/ButtonComponent.hpp +++ b/sources/Component/Button/ButtonComponent.hpp @@ -7,6 +7,7 @@ #include "Models/Callback.hpp" #include "Component/Component.hpp" #include "Entity/Entity.hpp" +#include namespace BBM { @@ -18,6 +19,15 @@ namespace BBM public: //! @brief onEvent callback WAL::Callback onEvent; + + //! @brief button which is at the top of this button + WAL::Entity *_up; + //! @brief button which is below of this button + WAL::Entity *_down; + //! @brief button which is on the right of this button + WAL::Entity *_right; + //! @brief button which is on the left of this button + WAL::Entity *_left; //! @inherit WAL::Component *clone(WAL::Entity &entity) const override @@ -33,9 +43,19 @@ namespace BBM //! @brief Constructor with the 3 callback ButtonComponent(WAL::Entity &entity, WAL::Callback callback) : WAL::Component(entity), - onEvent(callback) + onEvent(callback), _up(nullptr), _down(nullptr), _left(nullptr), _right(nullptr) { } + ButtonComponent &setButtonLinks(WAL::Entity *up = nullptr, WAL::Entity *down = nullptr, + WAL::Entity *left = nullptr, WAL::Entity *right = nullptr) + { + this->_up = up; + this->_down = down; + this->_right = right; + this->_left = left; + return *this; + } + //! @brief A Controllable component is copy constructable. ButtonComponent(const ButtonComponent &) = default; //! @brief default destructor diff --git a/sources/Runner/Runner.cpp b/sources/Runner/Runner.cpp index d8ef36f1..c1d60ba5 100644 --- a/sources/Runner/Runner.cpp +++ b/sources/Runner/Runner.cpp @@ -181,6 +181,55 @@ namespace BBM std::shared_ptr loadSettingsMenuScene() { 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"); + + WAL::Entity music(*scene, "music text"); + music.addComponent(1920 / 2.5, 1080 - 540, 0) + .addComponent("Music Volume", 70, RAY::Vector2(), ORANGE) + .addComponent() + .addComponent([](WAL::Entity &entity) + { + entity.getComponent().drawable->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity) + { + entity.getComponent().drawable->setColor(ORANGE); + }); + + WAL::Entity sound(*scene, "sound text"); + sound.addComponent(1920 / 2.5, 1080 - 360, 0) + .addComponent("Sound Volume", 70, RAY::Vector2(), ORANGE) + .addComponent() + .addComponent([](WAL::Entity &entity) + { + entity.getComponent().drawable->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity) + { + entity.getComponent().drawable->setColor(ORANGE); + }); + + WAL::Entity debug(*scene, "debug text"); + debug.addComponent(1920 / 2.5, 1080 - 180, 0) + .addComponent("Debug Mode", 70, RAY::Vector2(), ORANGE) + .addComponent() + .addComponent([](WAL::Entity &entity) + { + entity.getComponent().drawable->setColor(BLACK); + }) + .addComponent([](WAL::Entity &entity) + { + entity.getComponent().drawable->setColor(ORANGE); + }); //needed material // music logo // sound logo @@ -193,10 +242,11 @@ namespace BBM // unticked box // back button // back button asset - //plain background - //logo //music //sound + scene->getEntities().push_back(music); + scene->getEntities().push_back(sound); + scene->getEntities().push_back(debug); return scene; } @@ -225,7 +275,7 @@ namespace BBM WAL::Wal wal; addSystems(wal); enableRaylib(wal); - wal.scene = loadMainMenuScene(); + wal.scene = loadSettingsMenuScene(); try { wal.run(updateState);