ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

scroll.cpp

Go to the documentation of this file.
00001 /* ResidualVM - A 3D game interpreter
00002  *
00003  * ResidualVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the AUTHORS
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #include "engines/stark/resources/scroll.h"
00024 
00025 #include "engines/stark/formats/xrc.h"
00026 #include "engines/stark/resources/location.h"
00027 #include "engines/stark/services/stateprovider.h"
00028 
00029 namespace Stark {
00030 namespace Resources {
00031 
00032 Scroll::~Scroll() {
00033 }
00034 
00035 Scroll::Scroll(Object *parent, byte subType, uint16 index, const Common::String &name) :
00036         Object(parent, subType, index, name),
00037         _coordinate(0),
00038         _field_30(0),
00039         _field_34(0),
00040         _bookmarkIndex(0),
00041         _active(false) {
00042     _type = TYPE;
00043 }
00044 
00045 void Scroll::applyToLocationImmediate() {
00046     Location *location = findParent<Location>();
00047     location->scrollToCoordinateImmediate(_coordinate);
00048 }
00049 
00050 void Scroll::start() {
00051     _active = true;
00052 
00053     Location *location = findParent<Location>();
00054     location->setHasActiveScroll();
00055 }
00056 
00057 void Scroll::stop() {
00058     _active = false;
00059 }
00060 
00061 bool Scroll::isActive() {
00062     return _active;
00063 }
00064 
00065 void Scroll::onGameLoop() {
00066     Object::onGameLoop();
00067 
00068     if (_active) {
00069         Location *location = findParent<Location>();
00070         bool complete = location->scrollToCoordinateSmooth(_coordinate);
00071         if (complete) {
00072             _active = false;
00073             location->stopAllScrolls();
00074         }
00075     }
00076 }
00077 
00078 void Scroll::readData(Formats::XRCReadStream *stream) {
00079     _coordinate = stream->readUint32LE();
00080     _field_30 = stream->readUint32LE();
00081     _field_34 = stream->readUint32LE();
00082     _bookmarkIndex = stream->readUint32LE();
00083 }
00084 
00085 void Scroll::saveLoadCurrent(ResourceSerializer *serializer) {
00086     serializer->syncAsUint32LE(_active);
00087 
00088     if (serializer->isLoading() && _active) {
00089         start();
00090     }
00091 }
00092 
00093 void Scroll::printData() {
00094     debug("coordinate: %d", _coordinate);
00095     debug("field_30: %d", _field_30);
00096     debug("field_34: %d", _field_34);
00097     debug("bookmarkIndex: %d", _bookmarkIndex);
00098 }
00099 
00100 } // End of namespace Resources
00101 } // End of namespace Stark


Generated on Sat May 18 2019 05:01:19 for ResidualVM by doxygen 1.7.1
curved edge   curved edge