FIFE  6e1afdbeda11afe9ac53e6023a4be96ef88f1dc6
atlasloader.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2017 by the FIFE team *
3  * http://www.fifengine.net *
4  * This file is part of FIFE. *
5  * *
6  * FIFE is free software; you can redistribute it and/or *
7  * modify it under the terms of the GNU Lesser General Public *
8  * License as published by the Free Software Foundation; either *
9  * version 2.1 of the License, or (at your option) any later version. *
10  * *
11  * This library is distributed in the hope that it will be useful, *
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
14  * Lesser General Public License for more details. *
15  * *
16  * You should have received a copy of the GNU Lesser General Public *
17  * License along with this library; if not, write to the *
18  * Free Software Foundation, Inc., *
19  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
20  ***************************************************************************/
21 
22 #ifndef FIFE_ATLAS_LOADER_H
23 #define FIFE_ATLAS_LOADER_H
24 
25 // Standard C++ library includes
26 
27 // 3rd party library includes
28 
29 // FIFE includes
30 // These includes are split up in two parts, separated by one empty line
31 // First block: files included from the FIFE root src directory
32 // Second block: files included from the same folder
33 #include "util/structures/rect.h"
34 #include "video/image.h"
35 #include "video/imagemanager.h"
36 
37 #include "iatlasloader.h"
38 
39 class TiXmlElement;
40 
41 namespace FIFE {
42  class VFS;
43  class ImageManager;
44  class AnimationManager;
45 
46  struct AtlasData {
49  };
50 
51  class Atlas {
52  public:
53  Atlas(const std::string& name)
54  : m_name(name) {;}
55  ~Atlas() {;}
56 
57 
60  size_t getImageCount() const;
61 
64  ImagePtr& getPackedImage();
65 
68  ImagePtr getImage(const std::string& id);
69 
72  ImagePtr getImage(uint32_t index);
73 
78  bool addImage(const std::string& imagename, const AtlasData& data);
79 
83  void setPackedImage(const ImagePtr& image);
84 
85  const std::string& getName() const;
86  protected:
87  typedef std::map<std::string, AtlasData> SubimageMap;
88  SubimageMap m_subimages;
90 
91  // Unique atlas name
92  std::string m_name;
93  };
94 
95  class AtlasLoader : public IAtlasLoader {
96  public:
97  AtlasLoader(Model* model, VFS* vfs, ImageManager* imageManager, AnimationManager* animationManager);
98 
99  virtual ~AtlasLoader();
100 
104  virtual bool isLoadable(const std::string& filename);
105 
109  virtual AtlasPtr load(const std::string& filename);
110 
114  virtual std::vector<AtlasPtr> loadMultiple(const std::string& filename);
115 
116  private:
117  AtlasPtr loadAtlas(const std::string& filename, TiXmlElement* atlasElem);
118 
123  };
124 
129  AtlasLoader* createDefaultAtlasLoader(Model* model, VFS* vfs, ImageManager* imageManager, AnimationManager* animationManager);
130 }
131 
132 #endif
ImagePtr m_image
Definition: atlasloader.h:89
ImageManager.
Definition: imagemanager.h:54
ImagePtr image
Definition: atlasloader.h:48
std::map< std::string, AtlasData > SubimageMap
Definition: atlasloader.h:87
AtlasLoader * createDefaultAtlasLoader(Model *model, VFS *vfs, ImageManager *imageManager, AnimationManager *animationManager)
convenience function for creating the default fife atlas loader deleting the object returned from thi...
AnimationManager.
ImageManager * m_imageManager
Definition: atlasloader.h:121
std::string m_name
Definition: atlasloader.h:92
A model is a facade for everything in the model.
Definition: model.h:54
SubimageMap m_subimages
Definition: atlasloader.h:88
the main VFS (virtual file system) class
Definition: vfs.h:58
Atlas(const std::string &name)
Definition: atlasloader.h:53
unsigned int uint32_t
Definition: core.h:40
AnimationManager * m_animationManager
Definition: atlasloader.h:122