From c9c32c0955bf393714ff6011c1286f98c65fdb4b Mon Sep 17 00:00:00 2001 From: Kitetsu Date: Sun, 5 Nov 2023 22:31:06 +0100 Subject: [PATCH] CLIENT-MENU: Modif now text button can reappeared even if the scene is changed MINOR --- src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp b/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp index 58357699..06488006 100644 --- a/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp +++ b/src/Client/Systems/Menus/Menu/ButtonCallbacks.cpp @@ -189,13 +189,15 @@ namespace Menu { Scene::SceneManager::getInstance().stop(); } + static const std::size_t MAX_TEXT_OF_SCENE = 9; + void createServer() { auto arrInputBox = Registry::getInstance().getComponents(); + auto idsText = Registry::getInstance().getEntitiesByComponents({typeid(Raylib::TextShared)}); auto ids = Registry::getInstance().getEntitiesByComponents({typeid(Types::InputBox)}); - static bool isExist = false; - if (Nitwork::NitworkClient::getInstance().serverAlreadyCreated() && !isExist) { + if (Nitwork::NitworkClient::getInstance().serverAlreadyCreated() && idsText.size() < MAX_TEXT_OF_SCENE) { try { nlohmann::json jsonData = Json::getInstance().getDataByJsonType( ResourcesManager::getPathByJsonType(JsonType::CREATE_SERVER), @@ -204,7 +206,6 @@ namespace Menu { } catch (std::runtime_error &err) { Logger::warn(err.what()); } - isExist = true; return; } for (auto id : ids) {