content pack dependency levels draft

This commit is contained in:
MihailRis
2024-04-04 06:09:43 +03:00
parent 13ae6c6950
commit f298d6ef1d
4 changed files with 32 additions and 16 deletions
+10 -9
View File
@@ -205,11 +205,11 @@ Engine::~Engine() {
inline const std::string checkPacks(
const std::unordered_set<std::string>& packs,
const std::vector<std::string>& dependencies
const std::vector<DependencyPack>& dependencies
) {
for (const std::string& str : dependencies) {
if (packs.find(str) == packs.end()) {
return str;
for (const auto& dependency : dependencies) {
if (packs.find(dependency.id) == packs.end()) {
return dependency.id;
}
}
return "";
@@ -232,6 +232,7 @@ void Engine::loadContent() {
existingPacks.insert(item.id);
}
// FIXME: dependency levels
while (existingPacks.size() > loadedPacks.size()) {
for (auto& pack : srcPacks) {
if(loadedPacks.find(pack.id) != loadedPacks.end()) {
@@ -252,14 +253,14 @@ void Engine::loadContent() {
}
content.reset(contentBuilder.build());
resPaths.reset(new ResPaths(resdir, resRoots));
Shader::preprocessor->setPaths(resPaths.get());
resPaths = std::make_unique<ResPaths>(resdir, resRoots);
langs::setup(resdir, langs::current->getId(), contentPacks);
std::unique_ptr<Assets> new_assets(new Assets());
std::cout << "-- loading assets" << std::endl;
auto new_assets = std::make_unique<Assets>();
Shader::preprocessor->setPaths(resPaths.get());
AssetsLoader loader(new_assets.get(), resPaths.get());
AssetsLoader::addDefaults(loader, content.get());
while (loader.hasNext()) {
@@ -268,7 +269,7 @@ void Engine::loadContent() {
throw std::runtime_error("could not to load assets");
}
}
assets->extend(*new_assets.get());
assets->extend(*new_assets);
onAssetsLoaded();
}