summaryrefslogtreecommitdiff
path: root/assetFactory/assetFactory.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 17:33:02 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-14 17:33:02 +0100
commit47cd9d863fb09acb82d2428f881d61242f8ab437 (patch)
tree29751ec3408213c1ce5f9e3570386c40971c2445 /assetFactory/assetFactory.cpp
parentUse asset factory models in test-render (diff)
downloadilt-47cd9d863fb09acb82d2428f881d61242f8ab437.tar.bz2
ilt-47cd9d863fb09acb82d2428f881d61242f8ab437.tar.xz
ilt-47cd9d863fb09acb82d2428f881d61242f8ab437.zip
Load all assets in red dir with asset factory
Diffstat (limited to 'assetFactory/assetFactory.cpp')
-rw-r--r--assetFactory/assetFactory.cpp13
1 files changed, 13 insertions, 0 deletions
diff --git a/assetFactory/assetFactory.cpp b/assetFactory/assetFactory.cpp
index 05f0634..af0cd54 100644
--- a/assetFactory/assetFactory.cpp
+++ b/assetFactory/assetFactory.cpp
@@ -11,6 +11,7 @@
#include "resource.h"
#include "saxParse-persistence.h"
#include "texturePacker.h"
+#include <numeric>
AssetFactory::AssetFactory() :
shapes {
@@ -29,6 +30,18 @@ AssetFactory::loadXML(const std::filesystem::path & filename)
return Persistence::SAXParsePersistence {}.loadState<std::shared_ptr<AssetFactory>>(file);
}
+AssetFactory::Assets
+AssetFactory::loadAll(const std::filesystem::path & root)
+{
+ return std::accumulate(std::filesystem::recursive_directory_iterator {root},
+ std::filesystem::recursive_directory_iterator {}, Assets {}, [](auto && out, auto && path) {
+ if (path.path().extension() == ".xml") {
+ out.merge(loadXML(path)->assets);
+ }
+ return std::move(out);
+ });
+}
+
AssetFactory::Colours
AssetFactory::parseX11RGB(const char * path)
{