bool Text::unpersist(InputPersistenceBlock &reader) { bool result = true; result &= RenderObject::unpersist(reader); // Read color and alpha reader.read(_modulationColor); // Run all methods on loading relevant members. // So, the layout is automatically updated and all necessary logic is executed. Common::String font; reader.readString(font); setFont(font); Common::String text; reader.readString(text); setText(text); bool autoWrap; reader.read(autoWrap); setAutoWrap(autoWrap); uint32 autoWrapThreshold; reader.read(autoWrapThreshold); setAutoWrapThreshold(autoWrapThreshold); result &= RenderObject::unpersistChildren(reader); return reader.isGood() && result; }
bool Text::unpersist(InputPersistenceBlock &reader) { bool result = true; result &= RenderObject::unpersist(reader); // Farbe und Alpha einlesen. reader.read(_modulationColor); // Beim Laden der anderen Member werden die Set-Methoden benutzt statt der tatsächlichen Member. // So wird das Layout automatisch aktualisiert und auch alle anderen notwendigen Methoden ausgeführt. Common::String font; reader.readString(font); setFont(font); Common::String text; reader.readString(text); setText(text); bool autoWrap; reader.read(autoWrap); setAutoWrap(autoWrap); uint autoWrapThreshold; reader.read(autoWrapThreshold); setAutoWrapThreshold(autoWrapThreshold); result &= RenderObject::unpersistChildren(reader); return reader.isGood() && result; }
bool RenderObject::unpersist(InputPersistenceBlock &reader) { // Typ und Handle wurden schon von RecreatePersistedRenderObject() ausgelesen. Jetzt werden die restlichen Objekteigenschaften ausgelesen. reader.read(_x); reader.read(_y); reader.read(_absoluteX); reader.read(_absoluteY); reader.read(_z); reader.read(_width); reader.read(_height); reader.read(_visible); reader.read(_childChanged); reader.read(_initSuccess); reader.read(_bbox.left); reader.read(_bbox.top); reader.read(_bbox.right); reader.read(_bbox.bottom); reader.read(_oldBbox.left); reader.read(_oldBbox.top); reader.read(_oldBbox.right); reader.read(_oldBbox.bottom); reader.read(_oldX); reader.read(_oldY); reader.read(_oldZ); reader.read(_oldVisible); uint parentHandle; reader.read(parentHandle); _parentPtr = RenderObjectPtr<RenderObject>(parentHandle); reader.read(_refreshForced); updateAbsolutePos(); updateObjectState(); return reader.isGood(); }
bool AnimationTemplateRegistry::unpersist(InputPersistenceBlock &reader) { bool result = true; // Das nächste zu vergebene Handle wieder herstellen. reader.read(_nextHandle); // Alle vorhandenen BS_AnimationTemplates zerstören. while (!_handle2PtrMap.empty()) delete _handle2PtrMap.begin()->_value; // Anzahl an BS_AnimationTemplates einlesen. uint animationTemplateCount; reader.read(animationTemplateCount); // Alle gespeicherten BS_AnimationTemplates wieder herstellen. for (uint i = 0; i < animationTemplateCount; ++i) { // Handle lesen. uint handle; reader.read(handle); // BS_AnimationTemplate wieder herstellen. result &= (AnimationTemplate::create(reader, handle) != 0); } return reader.isGood() && result; }
bool AnimationTemplate::unpersist(InputPersistenceBlock &reader) { bool result = true; // Parent wieder herstellen. result &= AnimationDescription::unpersist(reader); // Frameanzahl lesen. uint frameCount; reader.read(frameCount); // Frames einzeln wieder herstellen. for (uint i = 0; i < frameCount; ++i) { Frame frame; reader.read(frame.hotspotX); reader.read(frame.hotspotY); reader.read(frame.flipV); reader.read(frame.flipH); reader.readString(frame.fileName); reader.readString(frame.action); _frames.push_back(frame); } // Die Animations-Resource wird für die gesamte Lebensdauer des Objektes gelockt Common::String sourceAnimation; reader.readString(sourceAnimation); _sourceAnimationPtr = requestSourceAnimation(sourceAnimation); reader.read(_valid); return _sourceAnimationPtr && reader.isGood() && result; }
bool InputEngine::unpersist(InputPersistenceBlock &reader) { Common::String callbackFunctionName; // Read number of command callbacks and their names. // Note: We do this only for compatibility with older engines resp. // the original engine. uint32 commandCallbackCount; reader.read(commandCallbackCount); assert(commandCallbackCount == 1); reader.readString(callbackFunctionName); assert(callbackFunctionName == "LuaCommandCB"); // Read number of character callbacks and their names. // Note: We do this only for compatibility with older engines resp. // the original engine. uint32 characterCallbackCount; reader.read(characterCallbackCount); assert(characterCallbackCount == 1); reader.readString(callbackFunctionName); assert(callbackFunctionName == "LuaCharacterCB"); return reader.isGood(); }
bool RenderObject::unpersistChildren(InputPersistenceBlock &reader) { bool result = true; // Kinderanzahl einlesen. uint childrenCount; reader.read(childrenCount); if (!reader.isGood()) return false; // Alle Kinder rekursiv wieder herstellen. for (uint i = 0; i < childrenCount; ++i) { if (!recreatePersistedRenderObject(reader).isValid()) return false; } return result && reader.isGood(); }
bool SoundEngine::unpersist(InputPersistenceBlock &reader) { _mixer->stopAll(); if (reader.getVersion() < 2) return true; reader.read(_maxHandleId); for (uint i = 0; i < SOUND_HANDLES; i++) { reader.read(_handles[i].id); Common::String fileName; int32 sndType; float volume; float pan; bool loop; int32 loopStart; int32 loopEnd; uint32 layer; reader.readString(fileName); reader.read(sndType); reader.read(volume); reader.read(pan); reader.read(loop); reader.read(loopStart); reader.read(loopEnd); reader.read(layer); if (reader.isGood()) { if (sndType != -1) playSoundEx(fileName, (SOUND_TYPES)sndType, volume, pan, loop, loopStart, loopEnd, layer, i); } else return false; } return reader.isGood(); }
bool StaticBitmap::unpersist(InputPersistenceBlock &reader) { bool result = true; result &= Bitmap::unpersist(reader); Common::String resourceFilename; reader.readString(resourceFilename); // We may not have saves, and we actually do not need to // restore them. So do not even try to load them. if (!resourceFilename.hasPrefix("/saves")) result &= initBitmapResource(resourceFilename); result &= RenderObject::unpersistChildren(reader); return reader.isGood() && result; }
bool Polygon::unpersist(InputPersistenceBlock &reader) { int storedvertexCount; reader.read(storedvertexCount); Common::Array<Vertex> storedvertices; for (int i = 0; i < storedvertexCount; ++i) { int x, y; reader.read(x); reader.read(y); storedvertices.push_back(Vertex(x, y)); } init(storedvertexCount, &storedvertices[0]); return reader.isGood(); }
bool Bitmap::unpersist(InputPersistenceBlock &reader) { bool result = true; result &= RenderObject::unpersist(reader); reader.read(_flipH); reader.read(_flipV); reader.read(_scaleFactorX); reader.read(_scaleFactorY); reader.read(_modulationColor); reader.read(_originalWidth); reader.read(_originalHeight); forceRefresh(); return reader.isGood() && result; }
bool Region::unpersist(InputPersistenceBlock &reader) { reader.read(_valid); reader.read(_position.x); reader.read(_position.y); _polygons.clear(); uint32 PolygonCount; reader.read(PolygonCount); for (uint i = 0; i < PolygonCount; ++i) { _polygons.push_back(Polygon(reader)); } reader.read(_boundingBox.left); reader.read(_boundingBox.top); reader.read(_boundingBox.right); reader.read(_boundingBox.bottom); return reader.isGood(); }
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 WalkRegion::unpersist(InputPersistenceBlock &reader) { bool result = true; // The parent object was already loaded in the constructor of BS_Region, so at // this point only the additional data from BS_WalkRegion needs to be loaded // Node load uint32 nodeCount; reader.read(nodeCount); _nodes.clear(); _nodes.resize(nodeCount); Common::Array<Vertex>::iterator it = _nodes.begin(); while (it != _nodes.end()) { reader.read(it->x); reader.read(it->y); ++it; } // Visibility matrix load uint32 rowCount; reader.read(rowCount); _visibilityMatrix.clear(); _visibilityMatrix.resize(rowCount); Common::Array< Common::Array<int> >::iterator rowIter = _visibilityMatrix.begin(); while (rowIter != _visibilityMatrix.end()) { uint32 colCount; reader.read(colCount); rowIter->resize(colCount); Common::Array<int>::iterator colIter = rowIter->begin(); while (colIter != rowIter->end()) { int32 t; reader.read(t); *colIter = t; ++colIter; } ++rowIter; } return result && reader.isGood(); }
bool DynamicBitmap::unpersist(InputPersistenceBlock &reader) { #if 0 bool result = true; result &= Bitmap::unpersist(reader); result &= createRenderedImage(_width, _height); warning("Unpersisting a BS_DynamicBitmap. Bitmap contents are missing."); // Initialize a transparent image. byte *transparentImageData = (byte *)calloc(_width * _height * 4, 1); _image->setContent(transparentImageData, _width * _height); free(transparentImageData); result &= RenderObject::unpersistChildren(reader); return reader.isGood() && result; #endif error("Request to unpersist a dynamic bitmap (video) - probably a corrupted saved game or a bug"); }
RenderObjectPtr<RenderObject> RenderObject::recreatePersistedRenderObject(InputPersistenceBlock &reader) { RenderObjectPtr<RenderObject> result; // Typ und Handle auslesen. uint type; uint handle; reader.read(type); reader.read(handle); if (!reader.isGood()) return result; switch (type) { case TYPE_PANEL: result = (new Panel(reader, this->getHandle(), handle))->getHandle(); break; case TYPE_STATICBITMAP: result = (new StaticBitmap(reader, this->getHandle(), handle))->getHandle(); break; case TYPE_DYNAMICBITMAP: // Videos are not normally saved: this probably indicates a bug, thus die here. //result = (new DynamicBitmap(reader, this->getHandle(), handle))->getHandle(); error("Request to recreate a video. This is either a corrupted saved game, or a bug"); break; case TYPE_TEXT: result = (new Text(reader, this->getHandle(), handle))->getHandle(); break; case TYPE_ANIMATION: result = (new Animation(reader, this->getHandle(), handle))->getHandle(); break; default: error("Cannot recreate render object of unknown type %d.", type); } return result; }
RenderObjectPtr<RenderObject> RenderObject::recreatePersistedRenderObject(InputPersistenceBlock &reader) { RenderObjectPtr<RenderObject> result; // Typ und Handle auslesen. uint type; uint handle; reader.read(type); reader.read(handle); if (!reader.isGood()) return result; switch (type) { case TYPE_PANEL: result = (new Panel(reader, this->getHandle(), handle))->getHandle(); break; case TYPE_STATICBITMAP: result = (new StaticBitmap(reader, this->getHandle(), handle))->getHandle(); break; case TYPE_DYNAMICBITMAP: result = (new DynamicBitmap(reader, this->getHandle(), handle))->getHandle(); break; case TYPE_TEXT: result = (new Text(reader, this->getHandle(), handle))->getHandle(); break; case TYPE_ANIMATION: result = (new Animation(reader, this->getHandle(), handle))->getHandle(); break; default: BS_LOG_ERRORLN("Cannot recreate render object of unknown type %d.", type); } return result; }