From b192dcec842cf043ae936c446bb252259b415ab5 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Wed, 7 Jun 2017 19:21:39 +0500 Subject: 2017-06-07 --- src/core/AssetManager.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) (limited to 'src/core/AssetManager.cpp') diff --git a/src/core/AssetManager.cpp b/src/core/AssetManager.cpp index eaa002f..bcf50bc 100644 --- a/src/core/AssetManager.cpp +++ b/src/core/AssetManager.cpp @@ -3,9 +3,11 @@ namespace fs = std::experimental::filesystem; -const fs::path pathToAssets = "./assets/"; -const fs::path pathToAssetsList = "./items.json"; -const fs::path pathToTextureIndex = "./textures.json"; +//const fs::path pathToAssets = "./assets/"; +//const fs::path pathToAssetsList = "./items.json"; +//const fs::path pathToTextureIndex = "./textures.json"; +const std::string pathToAssetsList = "./items.json"; +const std::string pathToTextureIndex = "./textures.json"; AssetManager::AssetManager() { LoadIds(); @@ -63,7 +65,7 @@ TextureCoordinates AssetManager::GetTextureByAssetName(std::string AssetName) { std::string AssetManager::GetTextureAssetNameByBlockId(BlockTextureId block) { //Block sides: 0 - bottom, 1 - top, 2 - north, 3 - south, 4 - west, 5 - east 6 - every side - std::map lookupTable = { + const std::map lookupTable = { {BlockTextureId(0, 0), "minecraft/textures/blocks/air"}, {BlockTextureId(1, 0), "minecraft/textures/blocks/stone"}, {BlockTextureId(1, 1), "minecraft/textures/blocks/stone_granite"}, @@ -78,7 +80,11 @@ std::string AssetManager::GetTextureAssetNameByBlockId(BlockTextureId block) { {BlockTextureId(3, 0), "minecraft/textures/blocks/dirt"}, {BlockTextureId(4, 0), "minecraft/textures/blocks/cobblestone"}, }; - return lookupTable[block]; + auto ret = lookupTable.find(block); + if (ret == lookupTable.end()) + return ""; + else + return ret->second; } GLuint AssetManager::GetTextureAtlas() { @@ -86,5 +92,6 @@ GLuint AssetManager::GetTextureAtlas() { } TextureCoordinates AssetManager::GetTextureByBlock(BlockTextureId block) { - return this->GetTextureByAssetName(this->GetTextureAssetNameByBlockId(block)); + std::string assetName = this->GetTextureAssetNameByBlockId(block); + return this->GetTextureByAssetName(assetName); } -- cgit v1.2.3