diff --git a/src/Client/Systems/Events/EventsSystems.cpp b/src/Client/Systems/Events/EventsSystems.cpp index 2a8379a6..f0e223fb 100644 --- a/src/Client/Systems/Events/EventsSystems.cpp +++ b/src/Client/Systems/Events/EventsSystems.cpp @@ -205,11 +205,11 @@ namespace Systems { { std::lock_guard lock(Registry::getInstance().mutex); Registry ®istry = Registry::getInstance(); - Registry::components arrMusics = registry.getComponents(); + auto &arrMusics = registry.getComponents(); for (auto &music : arrMusics) { - if (music.getPath() == musicPath && Raylib::KeyboardInput::isKeyPressed(Raylib::KeyboardKey::KB_M)) { - music.setNeedToPlay(true); + if (music->getPath() == musicPath && Raylib::KeyboardInput::isKeyPressed(Raylib::KeyboardKey::KB_M)) { + music->setNeedToPlay(true); } } } @@ -226,13 +226,13 @@ namespace Systems { auto soundEffectShoot3 = Raylib::Sound::fromFile(soundPathShoot3, soundVolume); Registry::getInstance().addEntity(); - Registry::getInstance().getComponents().insertBack(*music); + Registry::getInstance().getComponents().insertBack(music); Registry::getInstance().addEntity(); - Registry::getInstance().getComponents().insertBack(*soundEffectShoot); + Registry::getInstance().getComponents().insertBack(soundEffectShoot); Registry::getInstance().addEntity(); - Registry::getInstance().getComponents().insertBack(*soundEffectShoot2); + Registry::getInstance().getComponents().insertBack(soundEffectShoot2); Registry::getInstance().addEntity(); - Registry::getInstance().getComponents().insertBack(*soundEffectShoot3); + Registry::getInstance().getComponents().insertBack(soundEffectShoot3); SystemManagersDirector::getInstance().getSystemManager(managerId).removeSystem(systemId); } diff --git a/src/Client/Systems/Menu/ButtonCallbacks.cpp b/src/Client/Systems/Menu/ButtonCallbacks.cpp index 222c56dc..230f22b8 100644 --- a/src/Client/Systems/Menu/ButtonCallbacks.cpp +++ b/src/Client/Systems/Menu/ButtonCallbacks.cpp @@ -8,6 +8,7 @@ #include "B-luga-physics/ECSCustomTypes.hpp" #include "B-luga/Logger.hpp" #include "B-luga/SceneManager.hpp" +#include "B-luga-graphics/GraphicsCustomTypes.hpp" #include "ButtonCallbacks.hpp" #include "NitworkClient.hpp" diff --git a/src/Client/Systems/Menu/Menu.cpp b/src/Client/Systems/Menu/Menu.cpp index ab702827..50843f1d 100644 --- a/src/Client/Systems/Menu/Menu.cpp +++ b/src/Client/Systems/Menu/Menu.cpp @@ -52,7 +52,7 @@ namespace Menu { std::string name = Json::isDataExist(elem, "name") ? Json::getInstance().getDataFromJson(elem, "name") : ""; - Raylib::Text textComp(text); + auto textComp = Raylib::Text::fromText(text); std::size_t maxChar(Json::getInstance().getDataFromJson(elem, "maxChar")); Types::InputBox inputBox(text, name, maxChar); auto search = @@ -73,7 +73,7 @@ namespace Menu { initFromSprite(elem); } Registry::getInstance().getComponents().insertBack(fsz); - Registry::getInstance().getComponents().insertBack(textComp); + Registry::getInstance().getComponents().insertBack(textComp); Registry::getInstance().getComponents().insertBack(inputBox); Registry::getInstance().getComponents().insertBack(position); Registry::getInstance().getComponents().insertBack(collisionRect); @@ -174,10 +174,10 @@ namespace Menu { Maths::intToFloatConservingDecimals(arrPosition[id].y), Maths::intToFloatConservingDecimals(arrCollisionRect[id].width), Maths::intToFloatConservingDecimals(arrCollisionRect[id].height)); - Raylib::Vector2 mousePos(Raylib::getMousePosition().x, Raylib::getMousePosition().y); + Raylib::Vector2 mousePos(Raylib::MouseInput::getMousePosition().x, Raylib::MouseInput::getMousePosition().y); - mousePos.x = (mousePos.x * maxPercent) / Raylib::getScreenWidth(); - mousePos.y = (mousePos.y * maxPercent) / Raylib::getScreenHeight(); + mousePos.x = (mousePos.x * maxPercent) / Raylib::Window::getScreenWidth(); + mousePos.y = (mousePos.y * maxPercent) / Raylib::Window::getScreenHeight(); return Raylib::checkCollisionPointRec(mousePos, rect); } diff --git a/src/Client/Systems/Menu/MenuSystems.cpp b/src/Client/Systems/Menu/MenuSystems.cpp index 8ccb8491..79145eeb 100644 --- a/src/Client/Systems/Menu/MenuSystems.cpp +++ b/src/Client/Systems/Menu/MenuSystems.cpp @@ -8,7 +8,11 @@ #include "B-luga-physics/ECSCustomTypes.hpp" #include "B-luga/Maths/Maths.hpp" #include "B-luga/SceneManager.hpp" +#include "B-luga-graphics/AnimRect.hpp" +#include "B-luga-graphics/GraphicsCustomTypes.hpp" #include "MenuSystems.hpp" +#include "ResourcesManager.hpp" +#include "init.hpp" #include "Menu.hpp" namespace Systems { @@ -43,13 +47,13 @@ namespace Systems { static void insertText(std::size_t id, Registry::components &arrInputBox) { - Registry::components arrText = - Registry::getInstance().getComponents(); - int key = Raylib::getCharPressed(); + Registry::components arrText = + Registry::getInstance().getComponents(); + int key = Raylib::KeyboardInput::getCharPressed(); if ((key >= ' ') && (key <= '}') && (arrInputBox[id].text.size() < arrInputBox[id].maxChar)) { arrInputBox[id].text += static_cast(key); - arrText[id].setCurrentText(arrInputBox[id].text); + arrText[id]->setCurrentText(arrInputBox[id].text); } } @@ -58,7 +62,7 @@ namespace Systems { Registry::components arrInputBox = Registry::getInstance().getComponents(); std::vector ids = Registry::getInstance().getEntitiesByComponents( - {typeid(Types::InputBox), typeid(Raylib::Text)}); + {typeid(Types::InputBox), typeid(Raylib::TextShared)}); for (auto id : ids) { if (arrInputBox[id].selected == true) { @@ -71,7 +75,7 @@ namespace Systems { { std::size_t idEntity = 0; - if (Raylib::isMouseButtonPressed(Raylib::MouseButton::MOUSE_BTN_LEFT)) { + if (Raylib::MouseInput::isMouseButtonPressed(Raylib::MouseButton::MOUSE_BTN_LEFT)) { if (!::Menu::checkClick(idEntity)) { setAllInputBoxFalse(); return; @@ -82,12 +86,12 @@ namespace Systems { static void deleteInputBoxChar(std::size_t id, Registry::components &arrInputBox) { - Registry::components arrText = - Registry::getInstance().getComponents(); + auto &arrText = + Registry::getInstance().getComponents(); if (arrInputBox[id].text.size() > 0) { arrInputBox[id].text.pop_back(); - arrText[id].setCurrentText(arrInputBox[id].text); + arrText[id]->setCurrentText(arrInputBox[id].text); } } @@ -96,10 +100,10 @@ namespace Systems { Registry::components arrInputBox = Registry::getInstance().getComponents(); std::vector ids = Registry::getInstance().getEntitiesByComponents( - {typeid(Types::InputBox), typeid(Raylib::Text)}); + {typeid(Types::InputBox), typeid(Raylib::TextShared)}); for (auto id : ids) { - if (arrInputBox[id].selected && Raylib::isKeyPressed(Raylib::KeyboardKey::KB_BACKSPACE)) { + if (arrInputBox[id].selected && Raylib::KeyboardInput::isKeyPressed(Raylib::KeyboardKey::KB_BACKSPACE)) { deleteInputBoxChar(id, arrInputBox); } } @@ -142,28 +146,26 @@ namespace Systems { for (auto id : ids) { if (::Menu::checkIsInsideRect(id)) { arrAnimRect[id].changeRectList(Types::RectListType::HOVER); - Raylib::setMouseCursor(MOUSE_CURSOR_ARROW); - if (Raylib::isMouseButtonPressed(Raylib::MouseButton::MOUSE_BTN_LEFT)) { + if (Raylib::MouseInput::isMouseButtonPressed(Raylib::MouseButton::MOUSE_BTN_LEFT)) { arrButton[id].callback(); } return; } arrAnimRect[id].changeRectList(Types::RectListType::UNDEFINED); } - Raylib::setMouseCursor(MOUSE_CURSOR_DEFAULT); } void initMenu(std::size_t managerId, std::size_t systemId) { - if (Scene::SceneManager::getInstance().getCurrentScene() != Scene::Scene::MENU) { + if (Scene::SceneManager::getInstance().getCurrentScene() != Scenes::MENU) { SystemManagersDirector::getInstance().getSystemManager(managerId).removeSystem(systemId); return; } nlohmann::json connectButton = - Json::getInstance().getDataByVector({"menu", "connect"}, JsonType::MENU_DATA); - nlohmann::json inputBoxIp = Json::getInstance().getDataByVector({"menu", "ip"}, JsonType::MENU_DATA); + Json::getInstance().getDataByVector(ResourcesManager::getPathByJsonType(JsonType::MENU_DATA), {"menu", "connect"}); + nlohmann::json inputBoxIp = Json::getInstance().getDataByVector(ResourcesManager::getPathByJsonType(JsonType::MENU_DATA), {"menu", "ip"}); nlohmann::json inputBoxHost = - Json::getInstance().getDataByVector({"menu", "host"}, JsonType::MENU_DATA); + Json::getInstance().getDataByVector(ResourcesManager::getPathByJsonType(JsonType::MENU_DATA), {"menu", "host"}); try { ::Menu::MenuBuilder::getInstance().initMenuEntity( diff --git a/src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp b/src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp index 8da18937..17049506 100644 --- a/src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp +++ b/src/Client/Systems/Menus/SelectLobby/SelectLobbySystems.cpp @@ -115,9 +115,9 @@ namespace Systems::SelectLobbySystems { Registry::getInstance().getClock().decreaseSeconds(clockId, 1); // already created lobby auto idsLobbyStatus = - Registry::getInstance().getEntitiesByComponents({typeid(LobbyStatus), typeid(Raylib::Text)}); + Registry::getInstance().getEntitiesByComponents({typeid(LobbyStatus), typeid(Raylib::TextShared)}); auto &arrLobbyStatus = Registry::getInstance().getComponents(); - auto &arrLobbyText = Registry::getInstance().getComponents(); + auto &arrLobbyText = Registry::getInstance().getComponents(); // list of all lobby auto ids = Registry::getInstance().getEntitiesByComponents({typeid(struct lobby_s)}); auto &arrLobby = Registry::getInstance().getComponents(); @@ -129,8 +129,8 @@ namespace Systems::SelectLobbySystems { for (auto idLobbyStatus : idsLobbyStatus) { if (arrLobby[id].lobbyInfos.port == arrLobbyStatus[idLobbyStatus].port && std::string(arrLobby[id].lobbyInfos.ip) == arrLobbyStatus[idLobbyStatus].ip) { - x = arrLobbyText[idLobbyStatus].x(); - y = arrLobbyText[idLobbyStatus].y(); + x = arrLobbyText[idLobbyStatus]->x(); + y = arrLobbyText[idLobbyStatus]->y(); found = true; } } @@ -143,7 +143,7 @@ namespace Systems::SelectLobbySystems { + gameTypeToString(arrLobby[id].gameType); y += 5; auto text = Raylib::Text::fromText(text_t, Raylib::Vector2(x, y), 2, Raylib::Red); - arrLobbyText.insertBack(*text); + arrLobbyText.insertBack(text); } } } diff --git a/src/Game/CreateMissiles.cpp b/src/Game/CreateMissiles.cpp index b382333f..298bb6d2 100644 --- a/src/Game/CreateMissiles.cpp +++ b/src/Game/CreateMissiles.cpp @@ -40,16 +40,16 @@ namespace Systems { static void playBulletSound(Types::Missiles &typeOfMissile) { Json &json = Json::getInstance(); - Registry::components arrSounds = - Registry::getInstance().getComponents(); + Registry::components arrSounds = + Registry::getInstance().getComponents(); nlohmann::json bulletData = json.getJsonObjectById(ResourcesManager::getPathByJsonType(JsonType::BULLETS), getMissileId(typeOfMissile.type), "bullets"); const std::string soundPathShoot = json.getDataFromJson(bulletData, "soundPath"); for (auto &sound : arrSounds) { - if (sound.getPath() == soundPathShoot) { - sound.setNeedToPlay(true); + if (sound->getPath() == soundPathShoot) { + sound->setNeedToPlay(true); break; } }