// Copyright (c) 2023 Dominic Masters // // This software is released under the MIT License. // https://opensource.org/licenses/MIT #include "SceneAssetGenerator.hpp" using namespace Dawn; void SceneAssetGenerator::generate( std::map &assetMap, int32_t &assetNumber, std::vector *initBody, std::vector *assetsBody, struct SceneAsset *asset, std::string tabs ) { std::string assetType = ""; asset->usageName = "asset" + std::to_string(assetNumber++); switch(asset->type) { case SCENE_ASSET_TYPE_TEXTURE: assetType = "TextureAsset"; assetMap[asset->fileName] = "&" + asset->usageName + "->texture"; break; case SCENE_ASSET_TYPE_TRUETYPE_FONT: assetType = "TrueTypeAsset"; assetMap[asset->fileName] = "&" + asset->usageName + "->font"; break; default: assertUnreachable(); } line(initBody, "auto " + asset->usageName + " = man->get<" + assetType + ">(\"" + asset->fileName + "\");", ""); line(assetsBody, "assets.push_back(man->get<" + assetType + ">(\"" + asset->fileName + "\"));", ""); }