summaryrefslogtreecommitdiff
path: root/assetFactory
diff options
context:
space:
mode:
Diffstat (limited to 'assetFactory')
-rw-r--r--assetFactory/assetFactory.cpp13
-rw-r--r--assetFactory/assetFactory.h1
2 files changed, 14 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)
{
diff --git a/assetFactory/assetFactory.h b/assetFactory/assetFactory.h
index 9e5d205..e449ce2 100644
--- a/assetFactory/assetFactory.h
+++ b/assetFactory/assetFactory.h
@@ -22,6 +22,7 @@ public:
AssetFactory();
[[nodiscard]] static std::shared_ptr<AssetFactory> loadXML(const std::filesystem::path &);
+ [[nodiscard]] static Assets loadAll(const std::filesystem::path &);
[[nodiscard]] ColourAlpha parseColour(std::string_view) const;
[[nodiscard]] GLuint getMaterialIndex(std::string_view) const;
[[nodiscard]] Asset::TexturePtr getTexture() const;