diff --git a/.gitignore b/.gitignore index 1dba557..3d96047 100644 --- a/.gitignore +++ b/.gitignore @@ -207,3 +207,4 @@ _deps # End of https://www.toptal.com/developers/gitignore/api/c++,c,clion,cmake build/* +.idea/ diff --git a/libs/B-luga-graphics/include/B-luga-graphics/GraphicsCustomTypes.hpp b/libs/B-luga-graphics/include/B-luga-graphics/GraphicsCustomTypes.hpp index 376e4c2..e4c1189 100644 --- a/libs/B-luga-graphics/include/B-luga-graphics/GraphicsCustomTypes.hpp +++ b/libs/B-luga-graphics/include/B-luga-graphics/GraphicsCustomTypes.hpp @@ -51,8 +51,9 @@ namespace Types { }; struct Button { - Button(std::function &fct) : callback(fct) {}; + Button(std::function &fct, const std::string &name = "") : callback(fct), _name(name){}; std::function callback; + std::string _name; }; struct InputBox { diff --git a/libs/B-luga-graphics/include/B-luga-graphics/GraphicsSystems.hpp b/libs/B-luga-graphics/include/B-luga-graphics/GraphicsSystems.hpp index 2f59e9f..8362ea8 100644 --- a/libs/B-luga-graphics/include/B-luga-graphics/GraphicsSystems.hpp +++ b/libs/B-luga-graphics/include/B-luga-graphics/GraphicsSystems.hpp @@ -39,6 +39,7 @@ namespace Systems::GraphicsSystems { Raylib::Window::initWindow(screenWidth, screenHeight, "R-Bus"); Raylib::Window::setWindowState(Raylib::ConfigFlags::WINDOW_RESIZABLE); Raylib::Frame::setTargetFPS(Raylib::Window::getMonitorRefreshRate(Raylib::Window::getCurrentMonitor())); + Raylib::KeyboardInput::setExitKey(Raylib::KeyboardKey::KB_F4); Raylib::Audio::initAudioDevice(); } diff --git a/libs/B-luga-graphics/include/B-luga-graphics/SpriteSystems.hpp b/libs/B-luga-graphics/include/B-luga-graphics/SpriteSystems.hpp index 08c6fda..1fdcaf2 100644 --- a/libs/B-luga-graphics/include/B-luga-graphics/SpriteSystems.hpp +++ b/libs/B-luga-graphics/include/B-luga-graphics/SpriteSystems.hpp @@ -127,7 +127,7 @@ namespace Systems { Maths::intToFloatConservingDecimals(position.y)); size = calculateSize(sprite); sprite.drawPro( - Raylib::Rectangle(0.F, 0.F, sprite.getTextureWidth(), sprite.getTextureHeight()), + Raylib::Rectangle(0.F, 0.F, static_cast(sprite.getTextureWidth()), static_cast(sprite.getTextureHeight())), Raylib::Rectangle(spritePos.x, spritePos.y, size.x, size.y), Raylib::Vector2(origin.x, origin.y), rotation, @@ -212,6 +212,7 @@ namespace Systems { auto ids = arrSpriteDatas.getExistingsId(); for (auto id : ids) { + Logger::fatal("Creating sprite with id: " + std::to_string(id) + " and path: " + arrSpriteDatas[id].fileName); auto &spriteDatas = arrSpriteDatas[id]; Raylib::SpriteShared sprite = Raylib::Sprite::fromFile( spriteDatas.fileName, diff --git a/libs/B-luga-graphics/include/B-luga-graphics/TextSystems.hpp b/libs/B-luga-graphics/include/B-luga-graphics/TextSystems.hpp index d629807..204c657 100644 --- a/libs/B-luga-graphics/include/B-luga-graphics/TextSystems.hpp +++ b/libs/B-luga-graphics/include/B-luga-graphics/TextSystems.hpp @@ -43,6 +43,10 @@ namespace Systems { Registry::getInstance().getComponents(); Registry::components arrFsz = Registry::getInstance().getComponents(); + Registry::components arrInputBox = + Registry::getInstance().getComponents(); + Registry::components arrButton = + Registry::getInstance().getComponents(); Types::FontSize defaultFsz = {text->getFontSize()}; setFontSizeResponsive(text, defaultFsz); @@ -54,7 +58,7 @@ namespace Systems { Maths::floatToIntConservingDecimals(text->getPosition().x), Maths::floatToIntConservingDecimals(text->getPosition().y)}; setPositionResponsive(text, defaultPosition); - if (arrPosition.exist(id)) { + if (arrPosition.exist(id) && !arrInputBox.exist(id) && !arrButton.exist(id)) { setPositionResponsive(text, arrPosition[id]); } text->setColor(text->getColor()); diff --git a/libs/B-luga/include/B-luga/Json.hpp b/libs/B-luga/include/B-luga/Json.hpp index e3704cd..c16ddb7 100644 --- a/libs/B-luga/include/B-luga/Json.hpp +++ b/libs/B-luga/include/B-luga/Json.hpp @@ -73,6 +73,35 @@ class Json { return (data); } + void findKeyRecursively( + const nlohmann::json &data, + const std::string &key, + std::vector &results) + { + if (data.is_object()) { + for (auto it = data.begin(); it != data.end(); ++it) { + if (it.key() == key) { + results.push_back(it.value().dump()); + } + findKeyRecursively(it.value(), key, results); + } + } else if (data.is_array()) { + for (const auto &item : data) { + findKeyRecursively(item, key, results); + } + } + } + + std::vector getDatasByKey(std::vector dataTypes, const std::string &key) + { + std::vector datas; + for (const auto &dataType : dataTypes) { + auto jsonData = getDataByJsonType(dataType); + findKeyRecursively(jsonData, key, datas); + } + return datas; + } + nlohmann::basic_json<> getDataByJsonType(const std::string &dataType, const std::string &index) { const std::string path_resolved = PathResolver::resolve(dataType); diff --git a/libs/B-luga/include/B-luga/Registry.hpp b/libs/B-luga/include/B-luga/Registry.hpp index 6063380..aa16723 100644 --- a/libs/B-luga/include/B-luga/Registry.hpp +++ b/libs/B-luga/include/B-luga/Registry.hpp @@ -233,6 +233,7 @@ class Registry { for (auto group : _allies) { std::vector ids = registry.getEntitiesWithOneOfComponents({group.second}); if (std::find(ids.begin(), ids.end(), fstId) != ids.end() && std::find(ids.begin(), ids.end(), scdId) != ids.end()) { + Logger::fatal("This is an ally"); return true; } }