refactor: add GUI instance reference to UI nodes
This commit is contained in:
@@ -19,13 +19,14 @@
|
||||
#include "items/ItemDef.hpp"
|
||||
#include "Assets.hpp"
|
||||
#include "assetload_funcs.hpp"
|
||||
#include "engine/Engine.hpp"
|
||||
|
||||
namespace fs = std::filesystem;
|
||||
|
||||
static debug::Logger logger("assets-loader");
|
||||
|
||||
AssetsLoader::AssetsLoader(Assets* assets, const ResPaths* paths)
|
||||
: assets(assets), paths(paths) {
|
||||
AssetsLoader::AssetsLoader(Engine& engine, Assets& assets, const ResPaths* paths)
|
||||
: engine(engine), assets(assets), paths(paths) {
|
||||
addLoader(AssetType::SHADER, assetload::shader);
|
||||
addLoader(AssetType::TEXTURE, assetload::texture);
|
||||
addLoader(AssetType::FONT, assetload::font);
|
||||
@@ -73,7 +74,7 @@ void AssetsLoader::loadNext() {
|
||||
aloader_func loader = getLoader(entry.tag);
|
||||
auto postfunc =
|
||||
loader(this, paths, entry.filename, entry.alias, entry.config);
|
||||
postfunc(assets);
|
||||
postfunc(&assets);
|
||||
entries.pop();
|
||||
} catch (std::runtime_error& err) {
|
||||
logger.error() << err.what();
|
||||
@@ -101,7 +102,7 @@ static void add_layouts(
|
||||
AssetType::LAYOUT,
|
||||
file.string(),
|
||||
name,
|
||||
std::make_shared<LayoutCfg>(env)
|
||||
std::make_shared<LayoutCfg>(&loader.getEngine().getGUI(), env)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -296,6 +297,10 @@ bool AssetsLoader::loadExternalTexture(
|
||||
return false;
|
||||
}
|
||||
|
||||
Engine& AssetsLoader::getEngine() {
|
||||
return engine;
|
||||
}
|
||||
|
||||
const ResPaths* AssetsLoader::getPaths() const {
|
||||
return paths;
|
||||
}
|
||||
@@ -324,7 +329,7 @@ std::shared_ptr<Task> AssetsLoader::startTask(runnable onDone) {
|
||||
std::make_shared<util::ThreadPool<aloader_entry, assetload::postfunc>>(
|
||||
"assets-loader-pool",
|
||||
[=]() { return std::make_shared<LoaderWorker>(this); },
|
||||
[=](const assetload::postfunc& func) { func(assets); }
|
||||
[this](const assetload::postfunc& func) { func(&assets); }
|
||||
);
|
||||
pool->setOnComplete(std::move(onDone));
|
||||
while (!entries.empty()) {
|
||||
|
||||
Reference in New Issue
Block a user