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

smush.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 COPYRIGHT
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/grim/movie/codecs/smush_decoder.h"
00024 #include "engines/grim/movie/smush.h"
00025 
00026 #include "engines/grim/resource.h"
00027 #include "engines/grim/grim.h"
00028 
00029 namespace Grim {
00030 
00031 MoviePlayer *CreateSmushPlayer(bool demo) {
00032     return new SmushPlayer(demo);
00033 }
00034 
00035 SmushPlayer::SmushPlayer(bool demo) : MoviePlayer(), _demo(demo) {
00036     _smushDecoder = new SmushDecoder();
00037     _videoDecoder = _smushDecoder;
00038     //_smushDecoder->setDemo(_demo);
00039 }
00040 
00041 bool SmushPlayer::loadFile(const Common::String &filename) {
00042     if (!_demo)
00043         return _videoDecoder->loadStream(g_resourceloader->openNewStreamFile(filename.c_str()));
00044     else
00045         return _videoDecoder->loadFile(filename);
00046 }
00047 
00048 void SmushPlayer::init() {
00049     if (_demo) {
00050         _x = _smushDecoder->getX();
00051         _y = _smushDecoder->getY();
00052     } else {
00053         _smushDecoder->setLooping(_videoLooping);
00054     }
00055     MoviePlayer::init();
00056 }
00057 
00058 void SmushPlayer::handleFrame() {
00059     // Force the last frame to stay in place for it's duration:
00060     if (_videoDecoder->endOfVideo() && _videoDecoder->getTime() >= (uint32)_videoDecoder->getDuration().msecs()) {
00061         // If we're not supposed to loop (or looping fails) then end the video
00062         if (!_videoLooping) {
00063             _videoFinished = true;
00064             g_grim->setMode(GrimEngine::NormalMode);
00065             deinit();
00066             return;
00067         } else {
00068             _smushDecoder->rewind(); // This doesnt handle if looping fails.
00069             _smushDecoder->start();
00070         }
00071     }
00072 }
00073 
00074 void SmushPlayer::postHandleFrame() {
00075     if (_demo) {
00076         _x = _smushDecoder->getX();
00077         _y = _smushDecoder->getY();
00078     }
00079 }
00080 
00081 void SmushPlayer::restore(SaveGame *state) {
00082     if (isPlaying()) {
00083         _smushDecoder->seek((uint32)_movieTime);
00084         _smushDecoder->start();
00085         timerCallback(this);
00086     }
00087 }
00088 
00089 } // end of namespace Grim


Generated on Sat Feb 16 2019 05:01:04 for ResidualVM by doxygen 1.7.1
curved edge   curved edge