blob: f3e183f1216ef0edd40c3cac0f7d6f8d31acb8af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
#ifndef OPENMB_APPS_OPENMB_RENDERER_TEXTUREMANAGER_H
#define OPENMB_APPS_OPENMB_RENDERER_TEXTUREMANAGER_H
#include "Texture.hpp"
#include <filesystem>
#include <map>
#include <string>
#include <vector>
namespace renderer {
class TextureManager {
public:
TextureManager();
~TextureManager() = default;
void scanDirectory( const std::string& basePath );
std::vector<std::string> getCategories() const;
std::vector<std::string> getSubcategories( const std::string& category ) const;
std::vector<std::string> getTextureNames( const std::string& category, const std::string& subcategory ) const;
Texture* getTexture( const std::string& category, const std::string& subcategory,
const std::string& textureName );
Texture* getCurrentTexture();
void setCurrentTexture( const std::string& category, const std::string& subcategory,
const std::string& textureName );
const std::string& getCurrentCategory () const { return mCurrentCategory; }
const std::string& getCurrentSubcategory () const { return mCurrentSubcategory; }
const std::string& getCurrentTextureName () const { return mCurrentTextureName; }
int getCurrentTextureId() const;
Texture* getTextureById( int textureId );
private:
struct TextureEntry {
std::string mFullPath;
Texture mTexture;
bool mLoaded;
};
std::string mBasePath;
std::map<std::string, std::map<std::string, std::map<std::string, TextureEntry>>> mTextures;
std::string mCurrentCategory;
std::string mCurrentSubcategory;
std::string mCurrentTextureName;
Texture* mCurrentTexture;
int mCurrentTextureId;
std::map<int, std::tuple<std::string, std::string, std::string>> mTextureIdToPath;
int mNextTextureId;
};
} // namespace renderer
#endif
|