From 47cd9d863fb09acb82d2428f881d61242f8ab437 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Fri, 14 Apr 2023 17:33:02 +0100 Subject: Load all assets in red dir with asset factory --- assetFactory/assetFactory.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'assetFactory/assetFactory.cpp') 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 AssetFactory::AssetFactory() : shapes { @@ -29,6 +30,18 @@ AssetFactory::loadXML(const std::filesystem::path & filename) return Persistence::SAXParsePersistence {}.loadState>(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) { -- cgit v1.2.3