refactor: moved funcs to assetload
This commit is contained in:
parent
4a3487f17b
commit
824231bfd6
@ -17,19 +17,19 @@ class Assets;
|
||||
namespace assetload {
|
||||
/// @brief final work to do in the main thread
|
||||
using postfunc = std::function<void(Assets*)>;
|
||||
|
||||
using setupfunc = std::function<void(const Assets*)>;
|
||||
|
||||
template<class T>
|
||||
void assets_setup(const Assets*);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
void assets_setup(const Assets*);
|
||||
|
||||
using assetssetupfunc = std::function<void(const Assets*)>;
|
||||
|
||||
class Assets {
|
||||
std::vector<TextureAnimation> animations;
|
||||
|
||||
using assets_map = std::unordered_map<std::string, std::shared_ptr<void>>;
|
||||
std::unordered_map<std::type_index, assets_map> assets;
|
||||
std::vector<assetssetupfunc> setupFuncs;
|
||||
std::vector<assetload::setupfunc> setupFuncs;
|
||||
public:
|
||||
Assets() {}
|
||||
Assets(const Assets&) = delete;
|
||||
@ -72,13 +72,13 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void addSetupFunc(assetssetupfunc setupfunc) {
|
||||
void addSetupFunc(assetload::setupfunc setupfunc) {
|
||||
setupFuncs.push_back(setupfunc);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
void assets_setup(const Assets* assets) {
|
||||
void assetload::assets_setup(const Assets* assets) {
|
||||
if (auto mapPtr = assets->getMap<T>()) {
|
||||
for (const auto& entry : **mapPtr) {
|
||||
static_cast<T*>(entry.second.get())->setup(assets);
|
||||
|
||||
@ -245,7 +245,7 @@ void Engine::loadAssets() {
|
||||
Shader::preprocessor->setPaths(resPaths.get());
|
||||
|
||||
auto new_assets = std::make_unique<Assets>();
|
||||
new_assets->addSetupFunc(assets_setup<rigging::RigConfig>);
|
||||
new_assets->addSetupFunc(assetload::assets_setup<rigging::RigConfig>);
|
||||
AssetsLoader loader(new_assets.get(), resPaths.get());
|
||||
AssetsLoader::addDefaults(loader, content.get());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user