@@ -40,14 +40,14 @@ namespace
40
40
return " (Row: " + std::to_string (row) + " )" ;
41
41
}
42
42
43
- using ImageSheetMap = AnimationSet::ImageSheetMap ;
44
- using ActionsMap = AnimationSet::ActionsMap ;
43
+ using ImageSheets = AnimationSet::ImageSheets ;
44
+ using Actions = AnimationSet::Actions ;
45
45
46
46
47
- std::tuple<ImageSheetMap, ActionsMap > processXml (const std::string& filePath, ImageCache& imageCache);
48
- ImageSheetMap processImageSheets (const std::string& basePath, const Xml::XmlElement* element, ImageCache& imageCache);
49
- ActionsMap processActions (const ImageSheetMap& imageSheetMap , const Xml::XmlElement* element, ImageCache& imageCache);
50
- std::vector<AnimationSet::Frame> processFrames (const ImageSheetMap& imageSheetMap , const Xml::XmlElement* element, ImageCache& imageCache);
47
+ std::tuple<ImageSheets, Actions > processXml (const std::string& filePath, ImageCache& imageCache);
48
+ ImageSheets processImageSheets (const std::string& basePath, const Xml::XmlElement* element, ImageCache& imageCache);
49
+ Actions processActions (const ImageSheets& imageSheets , const Xml::XmlElement* element, ImageCache& imageCache);
50
+ std::vector<AnimationSet::Frame> processFrames (const ImageSheets& imageSheets , const Xml::XmlElement* element, ImageCache& imageCache);
51
51
}
52
52
53
53
@@ -68,17 +68,17 @@ AnimationSet::AnimationSet(std::string fileName) :
68
68
69
69
70
70
AnimationSet::AnimationSet (std::string fileName, ImageCache& imageCache) :
71
- mImageSheetMap {},
71
+ mImageSheets {},
72
72
mActions {}
73
73
{
74
- auto [imageSheetMap , actions] = processXml (fileName, imageCache);
75
- mImageSheetMap = std::move (imageSheetMap );
74
+ auto [imageSheets , actions] = processXml (fileName, imageCache);
75
+ mImageSheets = std::move (imageSheets );
76
76
mActions = std::move (actions);
77
77
}
78
78
79
79
80
- AnimationSet::AnimationSet (ImageSheetMap imageSheetMap, ActionsMap actions) :
81
- mImageSheetMap {std::move (imageSheetMap )},
80
+ AnimationSet::AnimationSet (ImageSheets imageSheets, Actions actions) :
81
+ mImageSheets {std::move (imageSheets )},
82
82
mActions {std::move (actions)}
83
83
{
84
84
}
@@ -109,7 +109,7 @@ namespace
109
109
*
110
110
* \param filePath File path of the sprite XML definition file.
111
111
*/
112
- std::tuple<ImageSheetMap, ActionsMap > processXml (const std::string& filePath, ImageCache& imageCache)
112
+ std::tuple<ImageSheets, Actions > processXml (const std::string& filePath, ImageCache& imageCache)
113
113
{
114
114
try
115
115
{
@@ -144,9 +144,9 @@ namespace
144
144
// Here instead of going through each element and calling a processing function to handle
145
145
// it, we just iterate through all nodes to find sprite sheets. This allows us to define
146
146
// image sheets anywhere in the sprite file.
147
- auto imageSheetMap = processImageSheets (basePath, xmlRootElement, imageCache);
148
- auto actions = processActions (imageSheetMap , xmlRootElement, imageCache);
149
- return std::tuple{std::move (imageSheetMap ), std::move (actions)};
147
+ auto imageSheets = processImageSheets (basePath, xmlRootElement, imageCache);
148
+ auto actions = processActions (imageSheets , xmlRootElement, imageCache);
149
+ return std::tuple{std::move (imageSheets ), std::move (actions)};
150
150
}
151
151
catch (const std::runtime_error& error)
152
152
{
@@ -163,9 +163,9 @@ namespace
163
163
* element in a sprite definition, these elements can appear
164
164
* anywhere in a Sprite XML definition.
165
165
*/
166
- ImageSheetMap processImageSheets (const std::string& basePath, const Xml::XmlElement* element, ImageCache& imageCache)
166
+ ImageSheets processImageSheets (const std::string& basePath, const Xml::XmlElement* element, ImageCache& imageCache)
167
167
{
168
- ImageSheetMap imageSheetMap ;
168
+ ImageSheets imageSheets ;
169
169
170
170
for (const auto * node = element->firstChildElement (" imagesheet" ); node; node = node->nextSiblingElement (" imagesheet" ))
171
171
{
@@ -183,27 +183,27 @@ namespace
183
183
throw std::runtime_error (" Sprite imagesheet definition has `src` of length zero: " + endTag (node->row ()));
184
184
}
185
185
186
- if (imageSheetMap .find (id) != imageSheetMap .end ())
186
+ if (imageSheets .find (id) != imageSheets .end ())
187
187
{
188
188
throw std::runtime_error (" Sprite image sheet redefinition: id: '" + id + " ' " + endTag (node->row ()));
189
189
}
190
190
191
191
const auto imagePath = basePath + src;
192
- imageSheetMap .try_emplace (id, imagePath);
192
+ imageSheets .try_emplace (id, imagePath);
193
193
imageCache.load (imagePath);
194
194
}
195
195
196
- return imageSheetMap ;
196
+ return imageSheets ;
197
197
}
198
198
199
199
200
200
/* *
201
201
* Iterates through all elements of a Sprite XML definition looking
202
202
* for 'action' elements and processes them.
203
203
*/
204
- ActionsMap processActions (const ImageSheetMap& imageSheetMap , const Xml::XmlElement* element, ImageCache& imageCache)
204
+ Actions processActions (const ImageSheets& imageSheets , const Xml::XmlElement* element, ImageCache& imageCache)
205
205
{
206
- ActionsMap actions;
206
+ Actions actions;
207
207
208
208
for (const auto * action = element->firstChildElement (" action" ); action; action = action->nextSiblingElement (" action" ))
209
209
{
@@ -219,7 +219,7 @@ namespace
219
219
throw std::runtime_error (" Sprite Action redefinition: '" + actionName + " ' " + endTag (action->row ()));
220
220
}
221
221
222
- actions[actionName] = processFrames (imageSheetMap , action, imageCache);
222
+ actions[actionName] = processFrames (imageSheets , action, imageCache);
223
223
224
224
if (actions[actionName].empty ())
225
225
{
@@ -234,7 +234,7 @@ namespace
234
234
/* *
235
235
* Parses through all <frame> tags within an <action> tag in a Sprite Definition.
236
236
*/
237
- std::vector<AnimationSet::Frame> processFrames (const ImageSheetMap& imageSheetMap , const Xml::XmlElement* element, ImageCache& imageCache)
237
+ std::vector<AnimationSet::Frame> processFrames (const ImageSheets& imageSheets , const Xml::XmlElement* element, ImageCache& imageCache)
238
238
{
239
239
std::vector<AnimationSet::Frame> frameList;
240
240
@@ -258,8 +258,8 @@ namespace
258
258
{
259
259
throw std::runtime_error (" Sprite Frame definition has 'sheetid' of length zero: " + endTag (currentRow));
260
260
}
261
- const auto iterator = imageSheetMap .find (sheetId);
262
- if (iterator == imageSheetMap .end ())
261
+ const auto iterator = imageSheets .find (sheetId);
262
+ if (iterator == imageSheets .end ())
263
263
{
264
264
throw std::runtime_error (" Sprite Frame definition references undefined imagesheet: '" + sheetId + " ' " + endTag (currentRow));
265
265
}
0 commit comments