16 std::vector<IntPoint> ResourceImageSet::mFramesEmpty;
18 ResourceImageSet::ResourceImageSet()
22 ResourceImageSet::~ResourceImageSet()
26 void ResourceImageSet::deserialization(
xml::ElementPtr _node, Version _version)
28 Base::deserialization(_node, _version);
31 xml::ElementEnumerator group_node = _node->getElementEnumerator();
32 while (group_node.next(
"Group"))
35 group.name = group_node->findAttribute(
"name");
37 group.texture = group_node->findAttribute(
"texture");
39 if (_version >= Version(1, 1))
46 xml::ElementEnumerator index_node = group_node->getElementEnumerator();
47 while (index_node.next(
"Index"))
50 index.name = index_node->findAttribute(
"name");
53 xml::ElementEnumerator frame_node = index_node->getElementEnumerator();
54 while (frame_node.next(
"Frame"))
58 if ((count < 1) || (count > 256)) count = 1;
61 index.frames.push_back(point);
66 group.indexes.push_back(index);
75 size_t index_group = getGroupIndex(_group);
79 size_t index_image = getImageIndex(group, _index);
91 if (_group < mGroups.size())
94 size_t index_image = getImageIndex(group, _index);
106 size_t index_group = getGroupIndex(_group);
110 if (_index < group.
indexes.size())
121 if (_group < mGroups.size())
124 if (_index < group.
indexes.size())
135 size_t index_group = getGroupIndex(_group);
139 if (_index < group.
indexes.size())
150 size_t index_group = getGroupIndex(_group);
154 size_t index_image = getImageIndex(group, _index);
164 size_t ResourceImageSet::getGroupIndex(
const std::string& _name)
166 for (
size_t index = 0; index < mGroups.size(); ++index)
168 if (mGroups[index].name == _name)
174 size_t ResourceImageSet::getGroupIndex(
const IntSize& _size)
176 for (
size_t index = 0; index < mGroups.size(); ++index)
178 if (mGroups[index].size == _size)
184 size_t ResourceImageSet::getImageIndex(GroupImage& _group,
const std::string& _name)
187 for (
size_t index = 0; index < indexes.size(); ++index)
189 if (indexes[index].name == _name)
195 const IntSize& ResourceImageSet::getGroupSize(
size_t _index)
197 if (_index >= mGroups.size())
199 return mGroups[_index].size;
202 const IntSize& ResourceImageSet::getGroupSize(
const std::string& _group)
204 for (
size_t index = 0; index < mGroups.size(); ++index)
206 if (mGroups[index].name == _group)
207 return mGroups[index].size;
219 mGroups.push_back(_group);