summaryrefslogtreecommitdiffstats
path: root/src/AssetManager.hpp
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-05 15:21:42 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2018-08-05 15:21:42 +0200
commitf3e01e3a318fea8d7065468df09e32c1765bfef8 (patch)
tree8840f61192ba65b92912405940f948755305af2e /src/AssetManager.hpp
parentRemoved previous implementation of texture atlas (diff)
downloadAltCraft-f3e01e3a318fea8d7065468df09e32c1765bfef8.tar
AltCraft-f3e01e3a318fea8d7065468df09e32c1765bfef8.tar.gz
AltCraft-f3e01e3a318fea8d7065468df09e32c1765bfef8.tar.bz2
AltCraft-f3e01e3a318fea8d7065468df09e32c1765bfef8.tar.lz
AltCraft-f3e01e3a318fea8d7065468df09e32c1765bfef8.tar.xz
AltCraft-f3e01e3a318fea8d7065468df09e32c1765bfef8.tar.zst
AltCraft-f3e01e3a318fea8d7065468df09e32c1765bfef8.zip
Diffstat (limited to '')
-rw-r--r--src/AssetManager.hpp51
1 files changed, 8 insertions, 43 deletions
diff --git a/src/AssetManager.hpp b/src/AssetManager.hpp
index 3975b37..2940b5f 100644
--- a/src/AssetManager.hpp
+++ b/src/AssetManager.hpp
@@ -119,60 +119,25 @@ struct AssetTexture : Asset {
size_t id;
};
-class AssetManager {
- std::map<std::string, BlockId> assetIds;
- std::map<BlockId, std::string> blockIdToBlockName;
- std::unique_ptr<AssetTreeNode> assetTree;
- std::unique_ptr<TextureAtlas> atlas;
-public:
- AssetManager();
-
- ~AssetManager();
-
- void LoadIds();
-
- static AssetManager& Instance();
+namespace AssetManager {
+ void InitAssetManager();
const BlockModel *GetBlockModelByBlockId(BlockId block);
std::string GetAssetNameByBlockId(BlockId block);
- void ParseBlockModels();
-
- void LoadAssets();
+ Asset *GetAssetPtr(const std::string &assetName);
template <typename T>
- T *GetAsset(const std::string &assetName) {
- AssetTreeNode *node;
- if (assetName[0] != '/')
- node = GetAssetByAssetName('/'+assetName);
- else
- node = GetAssetByAssetName(assetName);
- if (!node)
- return nullptr;
- return dynamic_cast<T*>(node->asset.get());
+ T *GetAsset(const std::string &assetName) {
+ return dynamic_cast<T*>(GetAssetPtr(assetName));
}
- void ParseAsset(AssetTreeNode &node);
-
- void ParseAssetBlockModel(AssetTreeNode &node);
-
void RecursiveWalkAsset(const std::string &assetPath, std::function<void(AssetTreeNode&)> fnc);
AssetTreeNode *GetAssetByAssetName(const std::string &assetName);
+
+ GLuint GetTextureAtlasId();
- void LoadTextures();
-
- void ParseAssetTexture(AssetTreeNode &node);
-
- inline GLuint GetTextureAtlasId() {
- return atlas->GetRawTextureId();
- }
-
- inline TextureCoord GetTexture(const std::string assetName) {
- AssetTexture *asset = GetAsset<AssetTexture>(assetName);
- if (!asset)
- return {};
- return atlas->GetTexture(asset->id);
- }
+ TextureCoord GetTexture(const std::string assetName);
};