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

fmvscreen.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 "common/rect.h"
00024 
00025 #include "engines/stark/ui/world/fmvscreen.h"
00026 
00027 #include "engines/stark/gfx/driver.h"
00028 #include "engines/stark/gfx/surfacerenderer.h"
00029 #include "engines/stark/gfx/texture.h"
00030 
00031 #include "engines/stark/services/archiveloader.h"
00032 #include "engines/stark/services/services.h"
00033 #include "engines/stark/services/userinterface.h"
00034 #include "engines/stark/services/settings.h"
00035 
00036 namespace Stark {
00037 
00038 FMVScreen::FMVScreen(Gfx::Driver *gfx, Cursor *cursor) :
00039         SingleWindowScreen(Screen::kScreenFMV, gfx, cursor) {
00040     _position = Common::Rect(Gfx::Driver::kOriginalWidth, Gfx::Driver::kOriginalHeight);
00041     _visible = true;
00042 
00043     _decoder = new Video::BinkDecoder();
00044     _decoder->setDefaultHighColorFormat(Gfx::Driver::getRGBAPixelFormat());
00045     _decoder->setSoundType(Audio::Mixer::kSFXSoundType);
00046 
00047     _texture = _gfx->createTexture();
00048     _texture->setSamplingFilter(StarkSettings->getImageSamplingFilter());
00049 
00050     _surfaceRenderer = _gfx->createSurfaceRenderer();
00051 }
00052 
00053 FMVScreen::~FMVScreen() {
00054     delete _decoder;
00055     delete _texture;
00056     delete _surfaceRenderer;
00057 }
00058 
00059 void FMVScreen::play(const Common::String &name) {
00060     Common::SeekableReadStream *stream = nullptr;
00061 
00062     // Play the low-resolution video, if possible
00063     if (!StarkSettings->getBoolSetting(Settings::kHighFMV) && StarkSettings->hasLowResFMV()) {
00064         Common::String lowResName = name;
00065         lowResName.erase(lowResName.size() - 4);
00066         lowResName += "_lo_res.bbb";
00067 
00068         stream = StarkArchiveLoader->getExternalFile(lowResName, "Global/");
00069         if (!stream) {
00070             debug("Could not open %s", lowResName.c_str());
00071         }
00072     }
00073 
00074     // Play the original video
00075     if (!stream) {
00076         stream = StarkArchiveLoader->getExternalFile(name, "Global/");
00077     }
00078 
00079     if (!stream) {
00080         warning("Could not open %s", name.c_str());
00081         return;
00082     }
00083 
00084     _decoder->loadStream(stream);
00085     if (!_decoder->isVideoLoaded()) {
00086         error("Could not open %s", name.c_str());
00087     }
00088     _decoder->start();
00089 }
00090 
00091 void FMVScreen::onGameLoop() {
00092     if (isPlaying()) {
00093         if (_decoder->needsUpdate()) {
00094             const Graphics::Surface *decodedSurface = _decoder->decodeNextFrame();
00095             _texture->update(decodedSurface);
00096         }
00097     } else {
00098         stop();
00099     }
00100 }
00101 
00102 void FMVScreen::onRender() {
00103     _surfaceRenderer->render(_texture, Common::Point(0, Gfx::Driver::kTopBorderHeight),
00104             Gfx::Driver::kGameViewportWidth, Gfx::Driver::kGameViewportHeight);
00105 }
00106 
00107 bool FMVScreen::isPlaying() {
00108     return _decoder->isPlaying() && !_decoder->endOfVideo();
00109 }
00110 
00111 void FMVScreen::stop() {
00112     _decoder->stop();
00113     StarkUserInterface->onFMVStopped();
00114 }
00115 
00116 
00117 } // End of namespace Stark


Generated on Sat Mar 16 2019 05:01:32 for ResidualVM by doxygen 1.7.1
curved edge   curved edge