From 824231bfd6ade114692f2653cc8c816945dab0f1 Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 1 Jul 2024 17:15:48 +0300 Subject: [PATCH] refactor: moved funcs to assetload --- src/assets/Assets.hpp | 16 ++++++++-------- src/engine.cpp | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/assets/Assets.hpp b/src/assets/Assets.hpp index f94adbd9..fa497fcb 100644 --- a/src/assets/Assets.hpp +++ b/src/assets/Assets.hpp @@ -17,19 +17,19 @@ class Assets; namespace assetload { /// @brief final work to do in the main thread using postfunc = std::function; + + using setupfunc = std::function; + + template + void assets_setup(const Assets*); } -template -void assets_setup(const Assets*); - -using assetssetupfunc = std::function; - class Assets { std::vector animations; using assets_map = std::unordered_map>; std::unordered_map assets; - std::vector setupFuncs; + std::vector 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 -void assets_setup(const Assets* assets) { +void assetload::assets_setup(const Assets* assets) { if (auto mapPtr = assets->getMap()) { for (const auto& entry : **mapPtr) { static_cast(entry.second.get())->setup(assets); diff --git a/src/engine.cpp b/src/engine.cpp index 9e5c7235..8033c798 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -245,7 +245,7 @@ void Engine::loadAssets() { Shader::preprocessor->setPaths(resPaths.get()); auto new_assets = std::make_unique(); - new_assets->addSetupFunc(assets_setup); + new_assets->addSetupFunc(assetload::assets_setup); AssetsLoader loader(new_assets.get(), resPaths.get()); AssetsLoader::addDefaults(loader, content.get());