SDL2lazy
SlTextureManager.h
Go to the documentation of this file.
1 // part of SDL2lazy
2 // author: Ulrike Hager
3 
8 #ifndef SLTEXTUREMANAGER_H
9 #define SLTEXTUREMANAGER_H
10 
11 #include <memory>
12 #include <string>
13 #include <vector>
14 
15 #include <SDL2/SDL.h>
16 #include <SDL2/SDL_image.h>
17 #include <SDL2/SDL_ttf.h>
18 
19 
20 
21 class SlManager;
22 class SlSprite;
23 class SlTexture;
24 class SlValueParser;
25 class SlFont;
26 
27 
29 {
30  public:
33  SlTextureManager(SlManager* manager);
34 
36 
39  SlTextureManager(const SlTextureManager&) = delete;
43 
46  SlTexture* createTextureFromFile(const std::string& name, const std::string& filename);
50  SlTexture* createTextureFromRectangle(const std::string& name, int width, int height, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha = 0xFF);
54  SlTexture* createTextureFromSpriteOnTexture(const std::string& name, const std::string& backgroundTexture, const std::string& foregroundSprite);
57 SlTexture* createTextureFromText(const std::string& name, const std::string& fontname, const std::string& message, int width);
64  SlTexture* createTextureFromTile(const std::string& name, const std::string& sprite, int width, int height);
68  void deleteTexture(const std::string& name);
72  std::shared_ptr<SlFont> findFont(const std::string& name);
76  SlTexture* findTexture(const std::string& name);
79  std::shared_ptr<SlFont> parseFont(std::ifstream& input);
82  SlTexture* parseTexture(std::ifstream& input);
86 
87  protected:
90  SlTextureManager(void);
93  void addTexture(SlTexture* toAdd);
96  void clear();
97 
98 
99  private:
103  std::vector<SlTexture*> textures_;
106  SlManager* mngr_ = nullptr;
109 std::vector<std::shared_ptr<SlFont>> fonts_ ;
110 
111 };
112 
113 
114 
115 
116 #endif // SLTEXTUREMANAGER_H
SlValueParser * valParser
Definition: SlTextureManager.h:85
std::shared_ptr< SlFont > parseFont(std::ifstream &input)
Definition: SlTextureManager.cc:231
SlTexture * createTextureFromTile(const std::string &name, const std::string &sprite, int width, int height)
Definition: SlTextureManager.cc:163
void deleteTexture(const std::string &name)
Definition: SlTextureManager.cc:184
SlTexture * findTexture(const std::string &name)
Definition: SlTextureManager.cc:216
SlTextureManager & operator=(const SlTextureManager &)=delete
void clear()
Definition: SlTextureManager.cc:61
SlTexture * createTextureFromText(const std::string &name, const std::string &fontname, const std::string &message, int width)
Definition: SlTextureManager.cc:137
SlTexture * createTextureFromFile(const std::string &name, const std::string &filename)
Definition: SlTextureManager.cc:74
std::vector< std::shared_ptr< SlFont > > fonts_
Definition: SlTextureManager.h:109
Definition: SlValueParser.h:21
SlTexture * parseTexture(std::ifstream &input)
Definition: SlTextureManager.cc:306
Definition: SlSprite.h:59
Definition: SlTextureManager.h:28
SlTexture * createTextureFromRectangle(const std::string &name, int width, int height, uint8_t red, uint8_t green, uint8_t blue, uint8_t alpha=0xFF)
Definition: SlTextureManager.cc:92
SlTextureManager(void)
Definition: SlTextureManager.cc:25
SlManager * mngr_
Definition: SlTextureManager.h:106
void addTexture(SlTexture *toAdd)
Definition: SlTextureManager.cc:52
std::vector< SlTexture * > textures_
Definition: SlTextureManager.h:103
Definition: SlManager.h:29
Definition: SlTexture.h:27
std::shared_ptr< SlFont > findFont(const std::string &name)
Definition: SlTextureManager.cc:199
Definition: SlFont.h:20
SlTexture * createTextureFromSpriteOnTexture(const std::string &name, const std::string &backgroundTexture, const std::string &foregroundSprite)
Definition: SlTextureManager.cc:110