Skip to content

Commit

Permalink
Merge branch 'main' of github.com:X-R-G-B/B-luga
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Nov 5, 2023
2 parents 9998859 + 1e32baa commit 6236e42
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -207,3 +207,4 @@ _deps
# End of https://www.toptal.com/developers/gitignore/api/c++,c,clion,cmake

build/*
.idea/
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@ namespace Types {
};

struct Button {
Button(std::function<void()> &fct) : callback(fct) {};
Button(std::function<void()> &fct, const std::string &name = "") : callback(fct), _name(name){};
std::function<void()> callback;
std::string _name;
};

struct InputBox {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<float>(sprite.getTextureWidth()), static_cast<float>(sprite.getTextureHeight())),
Raylib::Rectangle(spritePos.x, spritePos.y, size.x, size.y),
Raylib::Vector2(origin.x, origin.y),
rotation,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 5 additions & 1 deletion libs/B-luga-graphics/include/B-luga-graphics/TextSystems.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ namespace Systems {
Registry::getInstance().getComponents<Types::Position>();
Registry::components<Types::FontSize> arrFsz =
Registry::getInstance().getComponents<Types::FontSize>();
Registry::components<Types::InputBox> arrInputBox =
Registry::getInstance().getComponents<Types::InputBox>();
Registry::components<Types::Button> arrButton =
Registry::getInstance().getComponents<Types::Button>();

Types::FontSize defaultFsz = {text->getFontSize()};
setFontSizeResponsive(text, defaultFsz);
Expand All @@ -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());
Expand Down
29 changes: 29 additions & 0 deletions libs/B-luga/include/B-luga/Json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,35 @@ class Json {
return (data);
}

void findKeyRecursively(
const nlohmann::json &data,
const std::string &key,
std::vector<std::string> &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<std::string> getDatasByKey(std::vector<std::string> dataTypes, const std::string &key)
{
std::vector<std::string> 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);
Expand Down
1 change: 1 addition & 0 deletions libs/B-luga/include/B-luga/Registry.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ class Registry {
for (auto group : _allies) {
std::vector<std::size_t> 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;
}
}
Expand Down

0 comments on commit 6236e42

Please sign in to comment.