scummvm/engines/fullpipe/modal.cpp

283 lines
6.6 KiB
C++
Raw Normal View History

2013-08-08 13:25:47 +03:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/
#include "fullpipe/fullpipe.h"
#include "fullpipe/modal.h"
#include "fullpipe/messages.h"
#include "fullpipe/constants.h"
#include "fullpipe/motion.h"
2013-08-08 13:25:47 +03:00
#include "fullpipe/scenes.h"
2013-10-28 23:03:43 +02:00
#include "fullpipe/gameloader.h"
2013-08-08 13:25:47 +03:00
#include "graphics/palette.h"
#include "video/avi_decoder.h"
2013-08-08 13:25:47 +03:00
namespace Fullpipe {
2013-09-18 19:26:02 +04:00
ModalIntro::ModalIntro() {
2013-08-08 13:25:47 +03:00
_field_8 = 0;
_countDown = 0;
_stillRunning = 0;
2013-08-08 13:25:47 +03:00
if (g_vars->sceneIntro_skipIntro) {
_introFlags = 4;
} else {
_introFlags = 33;
_countDown = 150;
PictureObject *pict = g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0);
2013-08-08 13:25:47 +03:00
pict->setFlags(pict->_flags & 0xFFFB);
}
2013-08-08 13:25:47 +03:00
g_vars->sceneIntro_skipIntro = false;
_sfxVolume = g_fp->_sfxVolume;
2013-08-08 13:25:47 +03:00
}
ModalIntro::~ModalIntro() {
g_fp->stopAllSounds();
g_fp->_sfxVolume = _sfxVolume;
}
2013-09-18 19:26:02 +04:00
bool ModalIntro::handleMessage(ExCommand *message) {
2013-08-08 13:25:47 +03:00
if (message->_messageKind != 17)
return false;
if (message->_messageNum != 36)
return false;
2013-09-06 15:58:05 +03:00
if (message->_keyCode != 13 && message->_keyCode != 27 && message->_keyCode != 32)
2013-08-08 13:25:47 +03:00
return false;
if (_stillRunning) {
2013-08-08 13:25:47 +03:00
if (!(_introFlags & 0x10)) {
_countDown = 0;
g_vars->sceneIntro_needBlackout = true;
return true;
}
g_vars->sceneIntro_playing = false;
g_vars->sceneIntro_needBlackout = true;
}
return true;
}
bool ModalIntro::init(int counterdiff) {
2013-10-28 23:03:43 +02:00
if (!g_vars->sceneIntro_playing) {
if (!_stillRunning) {
finish();
return false;
2013-10-28 23:03:43 +02:00
}
if (_introFlags & 0x10)
g_fp->_gameLoader->updateSystems(42);
2013-10-28 23:03:43 +02:00
_introFlags |= 2;
return true;
}
if (_introFlags & 4) {
ModalVideoPlayer *player = new ModalVideoPlayer();
g_fp->_modalObject = player;
2013-10-28 23:03:43 +02:00
player->_parentObj = this;
player->play("intro.avi");
_countDown--;
if (_countDown > 0 )
return true;
if (_stillRunning <= 0) {
2013-10-28 23:03:43 +02:00
_countDown = 0;
_stillRunning = 0;
2013-10-28 23:03:43 +02:00
_introFlags = (_introFlags & 0xfb) | 0x40;
return true;
}
_introFlags |= 2;
return true;
}
if (_introFlags & 0x40) {
ModalVideoPlayer *player = new ModalVideoPlayer();
g_fp->_modalObject = player;
2013-10-28 23:03:43 +02:00
player->_parentObj = this;
player->play("intro2.avi");
_countDown--;
if (_countDown > 0)
return true;
if (_stillRunning <= 0) {
2013-10-28 23:03:43 +02:00
_countDown = 50;
_stillRunning = 0;
2013-10-28 23:03:43 +02:00
_introFlags = (_introFlags & 0xbf) | 9;
return true;
}
2013-10-28 23:03:43 +02:00
_introFlags |= 2;
return true;
}
if (_introFlags & 8) {
_countDown--;
if (_countDown > 0 )
return true;
if (_stillRunning > 0) {
2013-10-28 23:03:43 +02:00
_introFlags |= 2;
return true;
}
_countDown = 150;
_introFlags = (_introFlags & 0xf7) | 0x21;
g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb;
2013-10-28 23:03:43 +02:00
}
if (!(_introFlags & 0x20)) {
if (_introFlags & 0x10) {
if (!_stillRunning) {
2013-10-28 23:03:43 +02:00
_introFlags |= 1;
g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_PIPETITLE, 0)->_flags &= 0xfffb;
g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb;
2013-10-28 23:03:43 +02:00
chainQueue(QU_INTR_STARTINTRO, 1);
}
g_fp->_gameLoader->updateSystems(42);
2013-10-28 23:03:43 +02:00
}
return true;
}
_countDown--;
if (_countDown <= 0) {
if (_stillRunning > 0) {
2013-10-28 23:03:43 +02:00
_introFlags |= 2;
return true;
}
_introFlags = (_introFlags & 0xdf) | 0x10;
g_fp->accessScene(SC_INTRO1)->getPictureObjectById(PIC_IN1_GAMETITLE, 0)->_flags &= 0xfffb;
2013-10-28 23:03:43 +02:00
_stillRunning = 0;
2013-10-28 23:03:43 +02:00
}
return true;
}
void ModalIntro::update() {
if (g_fp->_currentScene) {
if (_introFlags & 1) {
//sceneFade(virt, g_currentScene, 1);
_stillRunning = 255;
_introFlags &= 0xfe;
if (_introFlags & 0x20)
g_fp->playSound(SND_INTR_019, 0);
} else if (_introFlags & 2) {
if (g_vars->sceneIntro_needBlackout) {
//vrtRectangle(*(_DWORD *)virt, 0, 0, 0, 800, 600);
g_vars->sceneIntro_needBlackout = 0;
_stillRunning = 0;
_introFlags &= 0xfd;
} else {
//sceneFade(virt, g_currentScene, 0);
_stillRunning = 0;
_introFlags &= 0xfd;
}
} else if (_stillRunning) {
g_fp->_currentScene->draw();
}
}
}
void ModalIntro::finish() {
g_fp->_gameLoader->unloadScene(SC_INTRO2);
g_fp->_currentScene = g_fp->accessScene(SC_INTRO1);
g_fp->_gameLoader->preloadScene(SC_INTRO1, TrubaDown);
2013-10-28 23:06:13 +02:00
if (g_fp->_currentScene)
g_fp->_gameLoader->updateSystems(42);
2013-10-28 23:03:43 +02:00
}
void ModalVideoPlayer::play(const char *filename) {
// TODO: Videos are encoded using Intel Indeo 5 (IV50), which isn't supported yet
Video::AVIDecoder *aviDecoder = new Video::AVIDecoder();
if (!aviDecoder->loadFile(filename))
return;
uint16 x = (g_system->getWidth() - aviDecoder->getWidth()) / 2;
uint16 y = (g_system->getHeight() - aviDecoder->getHeight()) / 2;
bool skipVideo = false;
aviDecoder->start();
while (!g_fp->shouldQuit() && !aviDecoder->endOfVideo() && !skipVideo) {
if (aviDecoder->needsUpdate()) {
const Graphics::Surface *frame = aviDecoder->decodeNextFrame();
if (frame) {
g_fp->_system->copyRectToScreen(frame->getPixels(), frame->pitch, x, y, frame->w, frame->h);
if (aviDecoder->hasDirtyPalette())
g_fp->_system->getPaletteManager()->setPalette(aviDecoder->getPalette(), 0, 256);
g_fp->_system->updateScreen();
}
}
Common::Event event;
while (g_fp->_system->getEventManager()->pollEvent(event)) {
if ((event.type == Common::EVENT_KEYDOWN && (event.kbd.keycode == Common::KEYCODE_ESCAPE ||
event.kbd.keycode == Common::KEYCODE_RETURN ||
event.kbd.keycode == Common::KEYCODE_SPACE))
|| event.type == Common::EVENT_LBUTTONUP)
skipVideo = true;
}
g_fp->_system->delayMillis(aviDecoder->getTimeToNextFrame());
}
}
void FullpipeEngine::openMap() {
warning("STUB: FullpipeEngine::openMap()");
}
void FullpipeEngine::openHelp() {
warning("STUB: FullpipeEngine::openHelp()");
}
void FullpipeEngine::openMainMenu() {
warning("STUB: FullpipeEngine::openMainMenu()");
}
2013-08-08 13:25:47 +03:00
} // End of namespace Fullpipe