FIFE
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
atlasloader.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2005-2013 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 
45  struct AtlasData {
48  };
49 
50  class Atlas {
51  public:
52  Atlas(const std::string& name)
53  : m_name(name) {;}
54  ~Atlas() {;}
55 
56 
59  size_t getImageCount() const;
60 
64 
67  ImagePtr getImage(const std::string& id);
68 
71  ImagePtr getImage(uint32_t index);
72 
77  bool addImage(const std::string& imagename, const AtlasData& data);
78 
82  void setPackedImage(const ImagePtr& image);
83 
84  const std::string& getName() const;
85  protected:
86  typedef std::map<std::string, AtlasData> SubimageMap;
89 
90  // Unique atlas name
91  std::string m_name;
92  };
93 
94  class AtlasLoader : public IAtlasLoader {
95  public:
96  AtlasLoader(Model* model, VFS* vfs, ImageManager* imageManager);
97 
98  virtual ~AtlasLoader();
99 
103  virtual bool isLoadable(const std::string& filename);
104 
108  virtual AtlasPtr load(const std::string& filename);
109 
110  private:
114  std::string m_atlasFilename;
115 
116  void parseObject(Atlas* atlas, TiXmlElement* root, bool exists);
117  };
118 
123  AtlasLoader* createDefaultAtlasLoader(Model* model, VFS* vfs, ImageManager* imageManager);
124 }
125 
126 #endif
virtual ~AtlasLoader()
Definition: atlasloader.cpp:91
ImagePtr m_image
Definition: atlasloader.h:88
ImageManager.
Definition: imagemanager.h:54
ImagePtr image
Definition: atlasloader.h:47
ImagePtr & getPackedImage()
Returns an (packed) Image for this atlas.
Definition: atlasloader.cpp:55
std::map< std::string, AtlasData > SubimageMap
Definition: atlasloader.h:86
virtual bool isLoadable(const std::string &filename)
Definition: atlasloader.cpp:94
AtlasLoader(Model *model, VFS *vfs, ImageManager *imageManager)
Definition: atlasloader.cpp:87
AtlasLoader * createDefaultAtlasLoader(Model *model, VFS *vfs, ImageManager *imageManager)
convenience function for creating the default fife atlas loader deleting the object returned from thi...
ImageManager * m_imageManager
Definition: atlasloader.h:113
void parseObject(Atlas *atlas, TiXmlElement *root, bool exists)
virtual AtlasPtr load(const std::string &filename)
void setPackedImage(const ImagePtr &image)
Sets the image for atlas to use it for rendering.
Definition: atlasloader.cpp:79
std::string m_name
Definition: atlasloader.h:91
A model is a facade for everything in the model.
Definition: model.h:53
SubimageMap m_subimages
Definition: atlasloader.h:87
const std::string & getName() const
Definition: atlasloader.cpp:83
the main VFS (virtual file system) class
Definition: vfs.h:58
std::string m_atlasFilename
Definition: atlasloader.h:114
Atlas(const std::string &name)
Definition: atlasloader.h:52
ImagePtr getImage(const std::string &id)
Return an Image of given id.
Definition: atlasloader.cpp:59
unsigned int uint32_t
Definition: core.h:40
size_t getImageCount() const
Returns the number of subimages that belongs to this atlas.
Definition: atlasloader.cpp:51
bool addImage(const std::string &imagename, const AtlasData &data)
Adds new information about subimage that belongs to this atlas.
Definition: atlasloader.cpp:75