MyGUI  3.0.1
MyGUI_ResourceImageSet.h
Go to the documentation of this file.
1 
7 /*
8  This file is part of MyGUI.
9 
10  MyGUI is free software: you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  MyGUI is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with MyGUI. If not, see <http://www.gnu.org/licenses/>.
22 */
23 #ifndef __MYGUI_RESOURCE_IMAGE_SET_H__
24 #define __MYGUI_RESOURCE_IMAGE_SET_H__
25 
26 #include "MyGUI_Prerequest.h"
27 #include "MyGUI_Macros.h"
28 #include "MyGUI_XmlDocument.h"
29 #include "MyGUI_IResource.h"
30 #include "MyGUI_ImageInfo.h"
31 #include "MyGUI_Enumerator.h"
32 #include "MyGUI_ResourceManager.h"
33 #include "MyGUI_GenericFactory.h"
34 
35 namespace MyGUI
36 {
37 
40 
41  struct IndexImage
42  {
43  std::string name;
44  float rate;
45  std::vector<IntPoint> frames;
46  };
47  typedef std::vector<IndexImage> VectorIndexImage;
48 
49  struct GroupImage
50  {
51  std::string name;
52  std::string texture;
55  };
56  typedef std::vector<GroupImage> VectorGroupImage;
58 
60  public IResource
61  {
63 
65 
66  private:
67  ResourceImageSet() { }
68  virtual ~ResourceImageSet() { }
69 
70  virtual void deserialization(xml::ElementPtr _node, Version _version);
71 
72  //-------------------------------------------------------------//
73  private:
74  size_t getGroupIndex(const std::string& _name)
75  {
76  for (size_t index=0; index<mGroups.size(); ++index)
77  {
78  if (mGroups[index].name == _name) return index;
79  }
80  return ITEM_NONE;
81  }
82 
83  size_t getGroupIndex(const IntSize& _size)
84  {
85  for (size_t index=0; index<mGroups.size(); ++index)
86  {
87  if (mGroups[index].size == _size) return index;
88  }
89  return ITEM_NONE;
90  }
91 
92  size_t getImageIndex(GroupImage& _group, const std::string& _name)
93  {
94  VectorIndexImage& indexes = _group.indexes;
95  for (size_t index=0; index<indexes.size(); ++index)
96  {
97  if (indexes[index].name == _name) return index;
98  }
99  return ITEM_NONE;
100  }
101 
102  const IntSize& getGroupSize(size_t _index)
103  {
104  if (_index >= mGroups.size()) return mSizeEmpty;
105  return mGroups[_index].size;
106  }
107 
108  const IntSize& getGroupSize(const std::string& _group)
109  {
110  for (size_t index=0; index<mGroups.size(); ++index)
111  {
112  if (mGroups[index].name == _group) return mGroups[index].size;
113  }
114  return mSizeEmpty;
115  }
116 
117  public:
118  ImageIndexInfo getIndexInfo(const std::string& _group, const std::string& _index);
119  ImageIndexInfo getIndexInfo(size_t _group, const std::string& _index);
120  ImageIndexInfo getIndexInfo(const std::string& _group, size_t _index);
121  ImageIndexInfo getIndexInfo(size_t _group, size_t _index);
122  ImageIndexInfo getIndexInfo(const IntSize& _group, size_t _index);
123  ImageIndexInfo getIndexInfo(const IntSize& _group, const std::string& _index);
124 
127 
128  private:
129  VectorGroupImage mGroups;
130 
131  static std::string mTextureEmpty;
132  static IntSize mSizeEmpty;
133  static std::vector<IntPoint> mFramesEmpty;
134 
135  };
136 
137 } // namespace MyGUI
138 
139 #endif // __MYGUI_RESOURCE_IMAGE_SET_H__