bool AnimationResource::parserCallback_animation(ParserNode *node) { if (!parseIntegerKey(node->values["fps"], 1, &_FPS) || (_FPS < MIN_FPS) || (_FPS > MAX_FPS)) { return parserError("Illegal or missing fps attribute in <animation> tag in \"%s\". Assuming default (\"%d\").", getFileName().c_str(), DEFAULT_FPS); } // Loop type value const char *loopTypeString = node->values["type"].c_str(); if (strcmp(loopTypeString, "oneshot") == 0) { _animationType = Animation::AT_ONESHOT; } else if (strcmp(loopTypeString, "loop") == 0) { _animationType = Animation::AT_LOOP; } else if (strcmp(loopTypeString, "jojo") == 0) { _animationType = Animation::AT_JOJO; } else { BS_LOG_WARNINGLN("Illegal type value (\"%s\") in <animation> tag in \"%s\". Assuming default (\"loop\").", loopTypeString, getFileName().c_str()); _animationType = Animation::AT_LOOP; } // Calculate the milliseconds required per frame // FIXME: Double check variable naming. Based on the constant, it may be microseconds _millisPerFrame = 1000000 / _FPS; return true; }
bool DynamicBitmap::persist(OutputPersistenceBlock &writer) { bool result = true; result &= Bitmap::persist(writer); // Bilddaten werden nicht gespeichert. Dies ist auch nicht weiter von bedeutung, da BS_DynamicBitmap nur vom Videoplayer benutzt wird. // Während ein Video abläuft kann niemals gespeichert werden. BS_DynamicBitmap kann nur der Vollständigkeit halber persistiert werden. BS_LOG_WARNINGLN("Persisting a BS_DynamicBitmap. Bitmap content is not persisted."); result &= RenderObject::persistChildren(writer); return result; }
bool DynamicBitmap::unpersist(InputPersistenceBlock &reader) { bool result = true; result &= Bitmap::unpersist(reader); // Ein RenderedImage mit den gespeicherten Maßen erstellen. result &= createRenderedImage(_width, _height); // Bilddaten werden nicht gespeichert (s.o.). BS_LOG_WARNINGLN("Unpersisting a BS_DynamicBitmap. Bitmap contents are missing."); // Bild mit durchsichtigen Bilddaten initialisieren. byte *transparentImageData = (byte *)calloc(_width * _height * 4, 1); _image->setContent(transparentImageData, _width * _height); free(transparentImageData); result &= RenderObject::unpersistChildren(reader); return reader.isGood() && result; }
bool AnimationResource::parserCallback_frame(ParserNode *node) { Frame frame; const char *fileString = node->values["file"].c_str(); if (!fileString) { BS_LOG_ERRORLN("<frame> tag without file attribute occurred in \"%s\".", getFileName().c_str()); return false; } frame.fileName = _pPackage->getAbsolutePath(fileString); if (frame.fileName.empty()) { BS_LOG_ERRORLN("Could not create absolute path for file specified in <frame> tag in \"%s\": \"%s\".", getFileName().c_str(), fileString); return false; } const char *actionString = node->values["action"].c_str(); if (actionString) frame.action = actionString; const char *hotspotxString = node->values["hotspotx"].c_str(); const char *hotspotyString = node->values["hotspoty"].c_str(); if ((!hotspotxString && hotspotyString) || (hotspotxString && !hotspotyString)) BS_LOG_WARNINGLN("%s attribute occurred without %s attribute in <frame> tag in \"%s\". Assuming default (\"0\").", hotspotxString ? "hotspotx" : "hotspoty", !hotspotyString ? "hotspoty" : "hotspotx", getFileName().c_str()); frame.hotspotX = 0; if (hotspotxString && !parseIntegerKey(hotspotxString, 1, &frame.hotspotX)) BS_LOG_WARNINGLN("Illegal hotspotx value (\"%s\") in frame tag in \"%s\". Assuming default (\"%s\").", hotspotxString, getFileName().c_str(), frame.hotspotX); frame.hotspotY = 0; if (hotspotyString && !parseIntegerKey(hotspotyString, 1, &frame.hotspotY)) BS_LOG_WARNINGLN("Illegal hotspoty value (\"%s\") in frame tag in \"%s\". Assuming default (\"%s\").", hotspotyString, getFileName().c_str(), frame.hotspotY); Common::String flipVString = node->values["flipv"]; if (!flipVString.empty()) { if (!parseBooleanKey(flipVString, frame.flipV)) { BS_LOG_WARNINGLN("Illegal flipv value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").", flipVString.c_str(), getFileName().c_str()); frame.flipV = false; } } else frame.flipV = false; Common::String flipHString = node->values["fliph"]; if (!flipHString.empty()) { if (!parseBooleanKey(flipVString, frame.flipV)) { BS_LOG_WARNINGLN("Illegal fliph value (\"%s\") in <frame> tag in \"%s\". Assuming default (\"false\").", flipHString.c_str(), getFileName().c_str()); frame.flipH = false; } } else frame.flipH = false; _frames.push_back(frame); return true; }