Added meta generation recognisation for scene and font extension types on load up

Check for std::optional value exist
This commit is contained in:
Xiao Qi 2022-11-14 18:31:56 +08:00
parent 874977775d
commit 3cc5ed0dec
1 changed files with 33 additions and 2 deletions

View File

@ -560,6 +560,34 @@ namespace SHADE
assetCollection.emplace(newAsset.id, newAsset); assetCollection.emplace(newAsset.id, newAsset);
SHAssetMetaHandler::WriteMetaData(newAsset); SHAssetMetaHandler::WriteMetaData(newAsset);
return newAsset.id;
}
else if (ext == SCENE_EXTENSION)
{
SHAsset newAsset{
path.stem().string(),
GenerateAssetID(AssetType::SCENE),
AssetType::SCENE,
path,
false
};
assetCollection.emplace(newAsset.id, newAsset);
SHAssetMetaHandler::WriteMetaData(newAsset);
return newAsset.id;
}
else if (ext == FONT_EXTENSION)
{
SHAsset newAsset{
path.stem().string(),
GenerateAssetID(AssetType::FONT),
AssetType::FONT,
path,
false
};
assetCollection.emplace(newAsset.id, newAsset);
SHAssetMetaHandler::WriteMetaData(newAsset);
return newAsset.id; return newAsset.id;
} }
} }
@ -571,8 +599,11 @@ namespace SHADE
for (auto& file : toGenNew) for (auto& file : toGenNew)
{ {
auto newID{ GenerateNewMeta(file->path).value() }; auto newID{ GenerateNewMeta(file->path) };
file->assetMeta = &assetCollection[newID]; if (newID.has_value())
{
file->assetMeta = &assetCollection[newID.value()];
}
} }
for (auto& asset : std::ranges::views::values(assetCollection)) for (auto& asset : std::ranges::views::values(assetCollection))