summaryrefslogtreecommitdiffstats
path: root/src/AssetManager.cpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-06-30 08:09:00 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-06-30 08:33:23 +0200
commit27d0fe2f7d4c3d7b2a650f869a9a7d566c46b2d7 (patch)
tree5239fb9dab5d51bd6a2f5b019b5b0326c09e45c8 /src/AssetManager.cpp
parentReplaced fallback model to diamond block model (diff)
downloadAltCraft-27d0fe2f7d4c3d7b2a650f869a9a7d566c46b2d7.tar
AltCraft-27d0fe2f7d4c3d7b2a650f869a9a7d566c46b2d7.tar.gz
AltCraft-27d0fe2f7d4c3d7b2a650f869a9a7d566c46b2d7.tar.bz2
AltCraft-27d0fe2f7d4c3d7b2a650f869a9a7d566c46b2d7.tar.lz
AltCraft-27d0fe2f7d4c3d7b2a650f869a9a7d566c46b2d7.tar.xz
AltCraft-27d0fe2f7d4c3d7b2a650f869a9a7d566c46b2d7.tar.zst
AltCraft-27d0fe2f7d4c3d7b2a650f869a9a7d566c46b2d7.zip
Diffstat (limited to 'src/AssetManager.cpp')
-rw-r--r--src/AssetManager.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/AssetManager.cpp b/src/AssetManager.cpp
index f5284a4..28d6050 100644
--- a/src/AssetManager.cpp
+++ b/src/AssetManager.cpp
@@ -11,7 +11,7 @@
namespace fs = std::experimental::filesystem::v1;
-//const fs::path pathToAssets = "./assets/";
+const fs::path pathToAssets = "./assets/";
//const fs::path pathToAssetsList = "./items.json";
//const fs::path pathToTextureIndex = "./textures.json";
const std::string pathToAssetsList = "./items.json";
@@ -20,10 +20,11 @@ const std::string pathToTextureIndex = "./textures.json";
const fs::path pathToModels = "./assets/minecraft/models/";
AssetManager::AssetManager() {
+ LoadAssets();
LoadIds();
LoadTextureResources();
LoadBlockModels();
- ParseBlockModels();
+ ParseBlockModels();
}
void AssetManager::LoadIds() {
@@ -536,4 +537,29 @@ void AssetManager::ParseBlockModels() {
}
}
}
-} \ No newline at end of file
+}
+
+std::unique_ptr<Asset> ParseAsset(const fs::path &file) {
+ return std::unique_ptr<Asset>();
+}
+
+void WalkDirEntry(const fs::directory_entry &dirEntry, AssetTreeNode *node) {
+ for (auto &file : fs::directory_iterator(dirEntry)) {
+ node->childs.push_back(std::make_unique<AssetTreeNode>());
+ AssetTreeNode *fileNode = node->childs.back().get();
+ fileNode->parent = node;
+ fileNode->name = file.path().stem().string();
+ if (fs::is_directory(file)) {
+ WalkDirEntry(file, fileNode);
+ }
+ else {
+ fileNode->asset = ParseAsset(file);
+ }
+ }
+}
+
+void AssetManager::LoadAssets() {
+ assetTree = std::make_unique<AssetTreeNode>();
+ assetTree->name = "/";
+ WalkDirEntry(fs::directory_entry(pathToAssets), assetTree.get());
+}