From 562bfdeb5ed9628ddfc7eae7335b584f87cd3feb Mon Sep 17 00:00:00 2001 From: guillaume abel Date: Fri, 3 Nov 2023 23:14:00 +0100 Subject: [PATCH] ECS: Add current progress --- src/Client/Systems/Menu/Menu.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/Client/Systems/Menu/Menu.cpp b/src/Client/Systems/Menu/Menu.cpp index 50843f1d..b6baf11d 100644 --- a/src/Client/Systems/Menu/Menu.cpp +++ b/src/Client/Systems/Menu/Menu.cpp @@ -23,23 +23,30 @@ namespace Menu { static void initFromSprite(nlohmann::json &elem) { + Logger::fatal("start initFromSprite"); Types::SpriteDatas spriteDatas( Json::getInstance().getDataFromJson(elem, "spritePath"), Json::getInstance().getDataFromJson(elem, "width"), Json::getInstance().getDataFromJson(elem, "height"), FRONTLAYER, static_cast(FRONT)); + Logger::fatal("initFromSprite2"); Types::Rect rect = {Types::Rect(Json::getInstance().getDataFromJson(elem, "rect"))}; nlohmann::basic_json<> animRectData = Json::getInstance().getDataFromJson>(elem, "animRect"); + Logger::fatal("initFromSprite2"); Types::AnimRect animRect(rect, animRectData); Registry::getInstance().getComponents().insertBack(animRect); + Logger::fatal("initFromSprite3"); Registry::getInstance().getComponents().insertBack(spriteDatas); + Logger::fatal("initFromSprite4"); Registry::getInstance().getComponents().insertBack(rect); + Logger::fatal("end initFromSprite"); } static void initInputBox(nlohmann::json &elem) { + Logger::fatal("start initInputBox"); std::size_t id = Registry::getInstance().addEntity(); Types::Position position(Json::getInstance().getDataFromJson(elem, "position")); @@ -77,13 +84,16 @@ namespace Menu { Registry::getInstance().getComponents().insertBack(inputBox); Registry::getInstance().getComponents().insertBack(position); Registry::getInstance().getComponents().insertBack(collisionRect); + Logger::fatal("end initInputBox"); } static void initButtonFromSprite(nlohmann::json &elem, std::function &callback) { + Logger::fatal("start initButtonFromSprite"); nlohmann::basic_json<> animRectData = Json::getInstance().getDataFromJson>(elem, "animRect"); Types::Button button(callback); + Logger::fatal("initButtonFromSprite2"); Registry::getInstance().addEntity(); Types::SpriteDatas spriteDatas( @@ -92,23 +102,29 @@ namespace Menu { Json::getInstance().getDataFromJson(elem, "height"), FRONTLAYER, static_cast(FRONT)); + Logger::fatal("initButtonFromSprite3"); Types::Rect rect = {Types::Rect(Json::getInstance().getDataFromJson(elem, "rect"))}; Types::Position position = { Types::Position(Json::getInstance().getDataFromJson(elem, "position"))}; Types::CollisionRect collisionRect = {Types::CollisionRect( Json::getInstance().getDataFromJson(elem, "collisionRect"))}; + Logger::fatal("initButtonFromSprite4"); Types::AnimRect animRect(rect, animRectData, Types::RectListType::MOVE); + Logger::fatal("initButtonFromSprite5"); Registry::getInstance().getComponents().insertBack(position); Registry::getInstance().getComponents().insertBack(rect); Registry::getInstance().getComponents().insertBack(animRect); + Logger::fatal("initButtonFromSprite6"); Registry::getInstance().getComponents().insertBack(collisionRect); Registry::getInstance().getComponents().insertBack(spriteDatas); Registry::getInstance().getComponents().insertBack(button); + Logger::fatal("end initButtonFromSprite"); } static void initButtonFromRectangle(nlohmann::json &elem, std::function &callback) { + Logger::fatal("start initButtonFromRect"); std::size_t id = Registry::getInstance().addEntity(); Types::Position position = { @@ -124,25 +140,30 @@ namespace Menu { Registry::getInstance().getComponents().insertBack(collisionRect); Registry::getInstance().getComponents().insertBack(button); Registry::getInstance().setToFrontLayers(id); + Logger::fatal("end initButtonFromRect"); } static void initButton(nlohmann::json &elem, std::function &callback) { + Logger::fatal("start initButton"); if (Json::isDataExist(elem, "spritePath")) { initButtonFromSprite(elem, callback); } else { initButtonFromRectangle(elem, callback); } + Logger::fatal("end initButton"); } void MenuBuilder::initMenuEntity(nlohmann::json &elem, std::function callback) { + Logger::fatal("start initMenuEntity"); switch (Json::getInstance().getDataFromJson(elem, "type")) { case ObjectType::BUTTON: initButton(elem, callback); break; case ObjectType::TEXT: break; // no clickable text for now case ObjectType::INPUT_BOX: initInputBox(elem); break; default: Logger::error("Object type is undefined, check your json data"); break; } + Logger::fatal("end initMenuEntity"); } bool checkClick(std::size_t &idEntity)