52 : m_vfs(vfs), m_imageManager(imageManager), m_animationManager(animationManager) {
57 bfs::path animPath(filename);
59 std::string animationFilename = animPath.string();
60 TiXmlDocument animFile;
70 if (animFile.Error()) {
85 TiXmlElement* root = animFile.RootElement();
87 if (root && root->ValueStr() ==
"assets") {
88 if (root->FirstChildElement(
"animation")) {
97 bfs::path animPath(filename);
99 std::string animationFilename = animPath.string();
122 catch (NotFound& e) {
134 TiXmlElement* root = doc.RootElement();
136 if (root && root->ValueStr() ==
"assets") {
137 animation =
loadAnimation(filename, root->FirstChildElement(
"animation"));
144 bfs::path animPath(filename);
146 std::string animationFilename = animPath.string();
150 std::vector<AnimationPtr> animationVector;
160 return animationVector;
169 catch (NotFound& e) {
176 return animationVector;
181 TiXmlElement* root = doc.RootElement();
183 if (root && root->ValueStr() ==
"assets") {
184 for (TiXmlElement* animationElem = root->FirstChildElement(
"animation"); animationElem; animationElem = animationElem->NextSiblingElement(
"animation")) {
187 animationVector.push_back(animation);
192 return animationVector;
197 if (!animationElem) {
201 bfs::path animPath(filename);
202 std::string animationFilename = animPath.string();
204 bool alreadyLoaded =
false;
206 const std::string* animationId = animationElem->Attribute(std::string(
"id"));
218 animPath = bfs::path(animationFilename);
233 int actionFrame = -1;
238 int success = animationElem->QueryValueAttribute(
"direction", &direction);
239 if (success == TIXML_SUCCESS) {
242 success = animationElem->QueryValueAttribute(
"action_frame", &actionFrame);
243 if (success == TIXML_SUCCESS) {
246 animationElem->QueryValueAttribute(
"delay", &animDelay);
247 animationElem->QueryValueAttribute(
"x_offset", &animXoffset);
248 animationElem->QueryValueAttribute(
"y_offset", &animYoffset);
250 for (TiXmlElement* frameElement = animationElem->FirstChildElement(
"frame"); frameElement; frameElement = frameElement->NextSiblingElement(
"frame")) {
251 const std::string* sourceId = frameElement->Attribute(std::string(
"source"));
253 bfs::path framePath(filename);
257 if (!bfs::exists(framePath)) {
258 framePath = bfs::path(*sourceId);
261 framePath = bfs::path(*sourceId);
272 int frameXoffset = 0;
273 success = frameElement->QueryValueAttribute(
"x_offset", &frameXoffset);
274 if (success == TIXML_SUCCESS) {
280 int frameYoffset = 0;
281 success = frameElement->QueryValueAttribute(
"y_offset", &frameYoffset);
282 if (success == TIXML_SUCCESS) {
289 success = frameElement->QueryValueAttribute(
"delay", &frameDelay);
290 if (success == TIXML_SUCCESS) {
291 animation->
addFrame(imagePtr, frameDelay);
293 animation->
addFrame(imagePtr, animDelay);
virtual ImagePtr create(IResourceLoader *loader=0)
Creates a blank Image but does not load it immediately.
virtual bool exists(const std::string &name)
Checks to see if an Image exists.
virtual std::vector< AnimationPtr > loadMultiple(const std::string &filename)
void setXShift(int32_t xshift)
AnimationLoader(VFS *vfs, ImageManager *imageManager, AnimationManager *animationManager)
AnimationManager * m_animationManager
void setDirection(uint32_t direction)
Animation direction tells how this animation is associated with movement when played starting from fr...
RawData * open(const std::string &path)
Open a file.
static Logger _log(LM_AUDIO)
virtual AnimationPtr getPtr(const std::string &name)
void setActionFrame(int32_t num)
Sets the action frame.
virtual ImagePtr getPtr(const std::string &name)
#define FL_ERR(logger, msg)
uint32_t getDataLength() const
get the complete datalength
virtual AnimationPtr create(IResourceLoader *loader=0)
Creates a blank Animation but does not load it immediately.
bool HasParentPath(const bfs::path &path)
Helper function to determine if a path object has a parent path.
bfs::path GetParentPath(const bfs::path &path)
Helper function to retrieve a parent path object from a path object.
virtual AnimationPtr load(const std::string &filename)
std::string readString(size_t len)
read a string with len bytes, not assuming a terminating 0 Appends a null terminator character to the...
void addFrame(ImagePtr image, uint32_t duration)
Adds new frame into animation Frames must be added starting from first frame.
the main VFS (virtual file system) class
virtual bool exists(const std::string &name)
Checks to see if an Animation exists.
uint32_t getFrameCount() const
Get the number of frames.
void setYShift(int32_t yshift)
AnimationPtr loadAnimation(const std::string &filename, TiXmlElement *animationElem)
ImageManager * m_imageManager
virtual bool isLoadable(const std::string &filename)
Used to access diffrent kinds of data.