Skip to content

Commit

Permalink
Use std::all_of in LoadAll
Browse files Browse the repository at this point in the history
  • Loading branch information
brdvd committed Nov 9, 2024
1 parent 4188cc4 commit 620f513
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions src/resources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,18 @@ bool Resources::AddCustom(const std::vector<std::string> &extraFonts)

bool Resources::LoadAll()
{
bool success = true;
std::string path = Resources::GetPath() + "/";
for (const std::filesystem::directory_entry &entry : std::filesystem::directory_iterator(path)) {
const std::filesystem::path path = entry.path();
if (path.has_extension() && path.has_stem() && path.extension() == ".xml") {
const std::string fontName = path.stem().string();
if (!IsFontLoaded(fontName)) {
success = success && LoadFont(fontName);
return std::ranges::all_of(
std::filesystem::directory_iterator(path), [this](const std::filesystem::directory_entry &entry) {
const std::filesystem::path &path = entry.path();
if (path.has_extension() && path.has_stem() && path.extension() == ".xml") {
const std::string fontName = path.stem().string();
if (!this->IsFontLoaded(fontName) && !this->LoadFont(fontName)) {
return false;
}
}
}
}
return success;
return true;
});
}

void Resources::SetFallbackFont(const std::string &fontName)
Expand All @@ -167,7 +167,7 @@ bool Resources::SetCurrentFont(const std::string &fontName, bool allowLoading)
m_currentFontName = fontName;
return true;
}

return false;
}

Expand Down

0 comments on commit 620f513

Please sign in to comment.