diff options
Diffstat (limited to 'engines/fullpipe/modal.cpp')
-rw-r--r-- | engines/fullpipe/modal.cpp | 601 |
1 files changed, 593 insertions, 8 deletions
diff --git a/engines/fullpipe/modal.cpp b/engines/fullpipe/modal.cpp index d1bda9dd40..3faa035c60 100644 --- a/engines/fullpipe/modal.cpp +++ b/engines/fullpipe/modal.cpp @@ -30,11 +30,14 @@ #include "fullpipe/modal.h" #include "fullpipe/constants.h" +#include "fullpipe/objectnames.h" #include "graphics/palette.h" +#include "graphics/surface.h" #include "video/avi_decoder.h" #include "engines/savestate.h" +#include "engines/advancedDetector.h" namespace Fullpipe { @@ -225,6 +228,134 @@ void ModalIntro::update() { void ModalIntro::finish() { g_fp->_gameLoader->unloadScene(SC_INTRO2); + + g_fp->_currentScene = g_fp->accessScene(SC_INTRO1); + g_fp->_gameLoader->preloadScene(SC_INTRO1, TrubaDown); + + if (g_fp->_currentScene) + g_fp->_gameLoader->updateSystems(42); +} + +ModalIntroDemo::ModalIntroDemo() { + _field_8 = 0; + _countDown = 50; + _stillRunning = 0; + _introFlags = 9; + g_vars->sceneIntro_skipIntro = false; + _sfxVolume = g_fp->_sfxVolume; +} + +ModalIntroDemo::~ModalIntroDemo() { + g_fp->stopAllSounds(); + g_fp->_sfxVolume = _sfxVolume; +} + +bool ModalIntroDemo::handleMessage(ExCommand *message) { + if (message->_messageKind != 17) + return false; + + if (message->_messageNum != 36) + return false; + + if (message->_param != 13 && message->_param != 27 && message->_param != 32) + return false; + + if (_introFlags & 0x8) { + _countDown = 0; + g_vars->sceneIntro_needBlackout = true; + return true; + } else if (_stillRunning) { + g_vars->sceneIntro_playing = false; + g_vars->sceneIntro_needBlackout = true; + } + + return true; +} + +bool ModalIntroDemo::init(int counterdiff) { + if (!g_vars->sceneIntro_playing) { + if (!_stillRunning) { + finish(); + return false; + } + + if (_introFlags & 0x10) + g_fp->_gameLoader->updateSystems(42); + + _introFlags |= 2; + + return true; + } + + if (_introFlags & 8) { + _countDown--; + + if (_countDown > 0) + return true; + + if (_stillRunning > 0) { + _introFlags |= 2; + return true; + } + + _countDown = 150; + _introFlags = (_introFlags & 0xf7) | 0x21; + g_fp->accessScene(SC_INTRO1)->getPictureObjectById(522, 0)->_flags &= 0xfffb; + } else { + if (!(_introFlags & 0x20)) + return true; + + _countDown--; + + if (_countDown > 0) + return true; + + if (_stillRunning > 0) { + _introFlags |= 2; + return true; + } + + _introFlags &= 0xDF; + + g_vars->sceneIntro_playing = false; + _stillRunning = 0; + } + + return true; +} + +void ModalIntroDemo::update() { + if (g_fp->_currentScene) { + if (_introFlags & 1) { + if (g_vars->sceneIntro_needBlackout) { + g_fp->drawAlphaRectangle(0, 0, 800, 600, 0); + g_vars->sceneIntro_needBlackout = 0; + } else { + g_fp->sceneFade(g_fp->_currentScene, true); + } + _stillRunning = 255; + _introFlags &= 0xfe; + + if (_introFlags & 0x20) + g_fp->playSound(SND_INTR_019, 0); + } else if (_introFlags & 2) { + if (g_vars->sceneIntro_needBlackout) { + g_fp->drawAlphaRectangle(0, 0, 800, 600, 0); + g_vars->sceneIntro_needBlackout = 0; + _stillRunning = 0; + _introFlags &= 0xfd; + } else { + g_fp->sceneFade(g_fp->_currentScene, false); + _stillRunning = 0; + _introFlags &= 0xfd; + } + } else if (_stillRunning) { + g_fp->_currentScene->draw(); + } + } +} + +void ModalIntroDemo::finish() { g_fp->_currentScene = g_fp->accessScene(SC_INTRO1); g_fp->_gameLoader->preloadScene(SC_INTRO1, TrubaDown); @@ -248,7 +379,11 @@ void ModalVideoPlayer::play(const char *filename) { 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); + Graphics::Surface *frameCopy = frame->convertTo(g_system->getScreenFormat()); + g_fp->_system->copyRectToScreen(frameCopy->getPixels(), frameCopy->pitch, + x, y, frameCopy->w, frameCopy->h); + frameCopy->free(); + delete frameCopy; if (aviDecoder->hasDirtyPalette()) g_fp->_system->getPaletteManager()->setPalette(aviDecoder->getPalette(), 0, 256); @@ -274,6 +409,7 @@ ModalMap::ModalMap() { _mapScene = 0; _pic = NULL; _picI03 = NULL; + _highlightedPic = NULL; _isRunning = false; _rect1 = g_fp->_sceneRect; _x = g_fp->_currentScene->_x; @@ -300,6 +436,9 @@ ModalMap::~ModalMap() { } bool ModalMap::init(int counterdiff) { + if (_picI03) + return init2(counterdiff); + g_fp->setCursor(PIC_CSR_ITN); if (_flag) { @@ -327,6 +466,105 @@ bool ModalMap::init(int counterdiff) { return _isRunning; } +bool ModalMap::init2(int counterdiff) { + g_fp->setCursor(PIC_CSR_DEFAULT); + + _dragX = (int)((double)_dragX * 0.6666666666666666); + _dragY = (int)((double)_dragY * 0.6666666666666666); + + if (800 - g_fp->_mouseScreenPos.x < 67) { + g_fp->setCursor(PIC_CSR_GOR); + + _dragX = g_fp->_mouseScreenPos.x - 733; + _dragY = (int)((double)_dragY * 0.6666666666666666); + } + + if (g_fp->_mouseScreenPos.x < 67) { + g_fp->setCursor(PIC_CSR_GOL); + + this->_dragX = g_fp->_mouseScreenPos.x - 67; + this->_dragY = (int)((double)_dragY * 0.6666666666666666); + } + + if (g_fp->_mouseScreenPos.y < 67) { + g_fp->setCursor(PIC_CSR_GOU); + + _dragX = (int)((double)_dragX * 0.6666666666666666); + _dragY = g_fp->_mouseScreenPos.y - 67; + } + + if (600 - g_fp->_mouseScreenPos.y < 87) { + g_fp->setCursor(PIC_CSR_GOD); + + _dragX = (int)((double)_dragX * 0.6666666666666666); + _dragY = g_fp->_mouseScreenPos.y - 513; + } + + g_fp->_sceneRect.translate(_dragX, _dragY); + _mapScene->updateScrolling2(); + _rect2 = g_fp->_sceneRect; + + PictureObject *hpic = getSceneHPicture(_mapScene->getPictureObjectAtPos(g_fp->_mouseVirtX, g_fp->_mouseVirtY)); + + if (hpic != _highlightedPic) { + if (_highlightedPic) { + _highlightedPic->_flags &= 0xFFFB; + _picI03->_flags &= 0xFFFB; + } + + _highlightedPic = hpic; + + if (hpic) { + PreloadItem pitem; + + pitem.preloadId1 = g_fp->_currentScene->_sceneId; + pitem.sceneId = findMapSceneId(hpic->_id); + + if (pitem.preloadId1 == pitem.sceneId || checkScenePass(&pitem)) { + _highlightedPic->_flags |= 4; + + g_fp->playSound(SND_CMN_070, 0); + } else { + Common::Point p1, p2; + + _picI03->getDimensions(&p1); + _highlightedPic->getDimensions(&p2); + + _picI03->setOXY(_highlightedPic->_ox + p2.x / 2 - p1.x / 2, _highlightedPic->_oy + p2.y / 2 - p1.y / 2); + _picI03->_flags |= 4; + } + } + } + + if (this->_highlightedPic) { + g_fp->setCursor(PIC_CSR_ITN); + + _hotSpotDelay--; + + if (_hotSpotDelay <= 0) { + _hotSpotDelay = 12; + + if (_pic) + _pic->_flags ^= 4; + } + } + + return _isRunning; +} + +int ModalMap::findMapSceneId(int picId) { + for (uint i = 0; i < g_fp->_gameLoader->_preloadItems.size(); i++) { + PreloadItem *pitem = g_fp->_gameLoader->_preloadItems[i]; + + if (pitem->preloadId1 == SC_MAP && pitem->preloadId2 == picId) { + return pitem->sceneId; + } + } + + return 0; +} + + void ModalMap::update() { g_fp->_sceneRect = _rect2; @@ -341,6 +579,13 @@ bool ModalMap::handleMessage(ExCommand *cmd) { switch (cmd->_messageNum) { case 29: + if (_picI03) { + if (_highlightedPic) + clickButton(_highlightedPic); + + return false; + } + _flag = 1; _mouseX = g_fp->_mouseScreenPos.x; _mouseY = g_fp->_mouseScreenPos.y; @@ -351,6 +596,9 @@ bool ModalMap::handleMessage(ExCommand *cmd) { return false; case 30: + if (_picI03) + return false; + _flag = 0; return false; @@ -394,7 +642,7 @@ void ModalMap::initMap() { pic->_flags &= 0xfffb; } - pic = getScenePicture(); + pic = getScenePicture(g_fp->_currentScene->_sceneId); Common::Point point; Common::Point point2; @@ -407,6 +655,8 @@ void ModalMap::initMap() { _rect2.right = _rect2.left + 800; _rect2.bottom = _rect2.top + 600; + g_fp->_sceneRect = _rect2; + _mapScene->updateScrolling2(); _pic = _mapScene->getPictureObjectById(PIC_MAP_I02, 0); @@ -426,8 +676,6 @@ void ModalMap::initMap() { if (_picI03) { _picI03->_flags &= 0xFFFB; - } else { - warning("No PIC_MAP_I03"); } g_system->warpMouse(400, 300); @@ -437,10 +685,61 @@ void ModalMap::initMap() { g_fp->setArcadeOverlay(PIC_CSR_MAP); } -PictureObject *ModalMap::getScenePicture() { +void ModalMap::clickButton(PictureObject *pic) { + if (g_fp->_currentScene == g_fp->_loaderScene) { + _isRunning = 0; + return; + } + + PreloadItem *pitem = 0; + + for (uint i = 0; i < g_fp->_gameLoader->_preloadItems.size(); i++) + if (g_fp->_gameLoader->_preloadItems[i]->preloadId2 == SC_MAP) { + pitem = g_fp->_gameLoader->_preloadItems[i]; + break; + } + + if (!pitem) { + PreloadItem preload; + + preload.preloadId2 = SC_MAP; + g_fp->_gameLoader->addPreloadItem(&preload); + pitem = g_fp->_gameLoader->_preloadItems[g_fp->_gameLoader->_preloadItems.size() - 1]; + } + + PreloadItem *pitem2 = 0; + + for (uint i = 0; i < g_fp->_gameLoader->_preloadItems.size(); i++) + if (g_fp->_gameLoader->_preloadItems[i]->preloadId1 == SC_MAP && + g_fp->_gameLoader->_preloadItems[i]->preloadId2 == pic->_id) { + pitem2 = g_fp->_gameLoader->_preloadItems[i]; + break; + } + + if (pitem && pitem2) { + pitem->preloadId1 = g_fp->_currentScene->_sceneId; + pitem->sceneId = pitem2->sceneId; + pitem->param = pitem2->param; + + if (pitem->preloadId1 == pitem2->sceneId) { + _isRunning = 0; + } else if (checkScenePass(pitem)) { + _isRunning = 0; + + if (!g_fp->isSaveAllowed()) { + //g_fp->_gameLoader->loadAndDecryptSave("savetmp.sav"); + } + g_fp->_gameLoader->preloadScene(pitem->preloadId1, SC_MAP); + } else { + g_fp->playSound(SND_CMN_056, 0); + } + } +} + +PictureObject *ModalMap::getScenePicture(int sceneId) { int picId = 0; - switch (g_fp->_currentScene->_sceneId) { + switch (sceneId) { case SC_1: picId = PIC_MAP_S01; break; @@ -651,6 +950,82 @@ PictureObject *ModalMap::getSceneHPicture(PictureObject *obj) { } } +bool ModalMap::isSceneEnabled(int sceneId) { + int id = getScenePicture(sceneId)->_id; + + for (int i = 0; i < 200; i++) { + int mapPic = g_fp->_mapTable[i] >> 16; + if (!mapPic) + return false; + + if (mapPic == id) + return (g_fp->_mapTable[i] & 0xffff) == 1; + } + + return false; +} + +bool ModalMap::checkScenePass(PreloadItem *item) { + bool res = true; + + switch (item->preloadId1) { + case SC_13: + if (!isSceneEnabled(SC_14)) + res = false; + break; + + case SC_27: + if (item->sceneId == SC_25) { + item->param = TrubaRight; + } else { + res = false; + } + break; + + case SC_25: + if (g_fp->getObjectState(sO_Board_25) != g_fp->getObjectEnumState(sO_Board_25, sO_NearDudesStairs)) { + res = false; + } + } + + switch (item->sceneId) { + case SC_13: + if (isSceneEnabled(SC_14)) { + item->param = TrubaLeft; + break; + } + item->param = TrubaUp; + break; + + case SC_27: + res = false; + break; + + case SC_25: + if (g_fp->getObjectState(sO_Pool) != g_fp->getObjectEnumState(sO_Pool, sO_Empty)) { + if (g_fp->getObjectState(sO_Pool) != g_fp->getObjectEnumState(sO_Pool, sO_HalfFull)) + res = false; + } + break; + + case SC_29: + if (isSceneEnabled(SC_30)) { + item->param = TrubaLeft; + break; + } + item->param = TrubaUp; + break; + } + + if ((item->sceneId != SC_37 && item->preloadId1 != SC_37) + || (g_fp->getObjectState(sO_Jawcrucnher) != g_fp->getObjectEnumState(sO_Jawcrucnher, sO_WithoutCarpet))) { + return res; + } else { + res = false; + } + return res; +} + void FullpipeEngine::openMap() { if (!_modalObject) { ModalMap *map = new ModalMap; @@ -1412,7 +1787,10 @@ void ModalHelp::launch() { _mainMenuScene = g_fp->accessScene(SC_MAINMENU); if (_mainMenuScene) { - _bg = _mainMenuScene->getPictureObjectById(PIC_HLP_BGR, 0)->_picture; + if (g_fp->isDemo() && g_fp->getLanguage() == Common::RU_RUS) + _bg = _mainMenuScene->getPictureObjectById(364, 0)->_picture; + else + _bg = _mainMenuScene->getPictureObjectById(PIC_HLP_BGR, 0)->_picture; _isRunning = 1; } } @@ -1432,6 +1810,28 @@ ModalQuery::~ModalQuery() { } bool ModalQuery::create(Scene *sc, Scene *bgScene, int id) { + if (g_fp->isDemo() && g_fp->getLanguage() == Common::RU_RUS) { + _bg = sc->getPictureObjectById(386, 0); + + if (!_bg) + return false; + + _okBtn = sc->getPictureObjectById(392, 0); + + if (!_okBtn) + return false; + + _cancelBtn = sc->getPictureObjectById(396, 0); + + if (!_cancelBtn) + return 0; + + _queryResult = -1; + _bgScene = bgScene; + + return true; + } + if (id == PIC_MEX_BGR) { _bg = sc->getPictureObjectById(PIC_MEX_BGR, 0); @@ -1446,7 +1846,7 @@ bool ModalQuery::create(Scene *sc, Scene *bgScene, int id) { _cancelBtn = sc->getPictureObjectById(PIC_MEX_CANCEL, 0); if (!_cancelBtn) - return 0; + return false; } else { if (id != PIC_MOV_BGR) return false; @@ -1521,6 +1921,18 @@ bool ModalQuery::init(int counterdiff) { if (_queryResult == -1) { return true; } else { + if (g_fp->isDemo() && g_fp->getLanguage() == Common::RU_RUS) { + if (!_queryResult) + return false; + + ModalDemo *demo = new ModalDemo; + demo->launch(); + + g_fp->_modalObject = demo; + + return true; + } + if (_bg->_id == PIC_MEX_BGR) { _cancelBtn->_flags &= 0xFFFB; _okBtn->_flags &= 0xFFFB; @@ -1893,6 +2305,168 @@ void ModalSaveGame::saveload() { } } +ModalDemo::ModalDemo() { + _bg = 0; + _button = 0; + _text = 0; + + if (g_fp->getLanguage() == Common::RU_RUS) { + _clickedQuit = 0; + _countdown = -10; + } else { + _clickedQuit = -1; + _countdown = 1000; + } + _scene = 0; +} + +ModalDemo::~ModalDemo() { + if (_bg) + _bg->_flags &= 0xFFFB; + + _button->_flags &= 0xFFFB; + _text->_flags &= 0xFFFB; +} + +bool ModalDemo::launch() { + Scene *sc = g_fp->accessScene(SC_MAINMENU); + + if (g_fp->getLanguage() == Common::RU_RUS) { + _scene = sc; + + for (uint i = 1; i < sc->_picObjList.size(); i++) { + if (((PictureObject *)sc->_picObjList[i])->_id == 399) + sc->_picObjList[i]->_flags |= 4; + else + sc->_picObjList[i]->_flags &= 0xFFFB; + } + + _button = sc->getPictureObjectById(443, 0); + _text = sc->getPictureObjectById(402, 0); + + _countdown = -10; + + return true; + } + + _bg = sc->getPictureObjectById(PIC_POST_BGR, 0); + + if (!_bg) + return false; + + _button = sc->getPictureObjectById(PIC_POST_BUTTON, 0); + _text = sc->getPictureObjectById(PIC_POST_TEXT, 0); + + _clickedQuit = -1; + + // fadeout + warning("STUB: ModelDemo: fadeout"); + update(); + + g_fp->stopAllSoundStreams(); + g_fp->stopAllSounds(); + g_fp->playSound(SND_CMN_056, 0); + g_fp->playSound(SND_CMN_069, 1); + + return true; +} + +bool ModalDemo::init(int counterDiff) { + if (g_fp->getLanguage() == Common::RU_RUS) + return init2(counterDiff); + + g_fp->_cursorId = PIC_CSR_DEFAULT; + + if (_button->isPointInside(g_fp->_mouseScreenPos.x, g_fp->_mouseScreenPos.y)) { + if (!(_button->_flags & 4)) + g_fp->playSound(SND_CMN_070, 0); + + _button->_flags |= 4; + + g_fp->_cursorId = PIC_CSR_ITN; + } else { + _button->_flags &= 0xFFFB; + } + + g_fp->setCursor(g_fp->_cursorId); + + _countdown -= counterDiff; + + if (_countdown <= 0) + _countdown = 1000; + + if (_clickedQuit == -1) + return true; + + g_system->openUrl("http://www.amazon.de/EuroVideo-Bildprogramm-GmbH-Full-Pipe/dp/B003TO51YE/ref=sr_1_1?ie=UTF8&s=videogames&qid=1279207213&sr=8-1"); + + g_fp->_gameContinue = false; + + return false; +} + +bool ModalDemo::init2(int counterDiff) { + if (_clickedQuit) { + g_system->openUrl("http://pipestudio.ru/fullpipe/"); + + g_fp->_gameContinue = false; + + return false; + } + + if (_countdown > 0) { + _countdown--; + } else { + _text->_flags ^= 4; + _countdown = 24; + } + + if (_button->isPointInside(g_fp->_mouseScreenPos.x, g_fp->_mouseScreenPos.y)) { + _button->_flags |= 4; + + g_fp->_cursorId = PIC_CSR_ITN; + } else { + _button->_flags &= 0xFFFB; + + g_fp->_cursorId = PIC_CSR_DEFAULT; + } + + return true; +} + +void ModalDemo::update() { + if (g_fp->getLanguage() == Common::RU_RUS) { + if (_countdown == -10) + g_fp->sceneFade(_scene, true); + + _scene->draw(); + + return; + } + + _bg->draw(); + + if (_button->_flags & 4) + _button->draw(); + + if (_text->_flags & 4) + _text->draw(); +} + +bool ModalDemo::handleMessage(ExCommand *cmd) { + if (cmd->_messageKind != 17) + return false; + + if (cmd->_messageNum == 29) { + if (_button->isPointInside(g_fp->_mouseScreenPos.x, g_fp->_mouseScreenPos.y)) + _clickedQuit = 1; + } else if (cmd->_messageNum == 36 && (cmd->_param == 27 || g_fp->getLanguage() == Common::RU_RUS)) { + _clickedQuit = 1; + } + + return false; +} + void FullpipeEngine::openHelp() { if (!_modalObject) { ModalHelp *help = new ModalHelp; @@ -1904,6 +2478,17 @@ void FullpipeEngine::openHelp() { } void FullpipeEngine::openMainMenu() { + if (isDemo() && getLanguage() == Common::RU_RUS) { + ModalQuery *q = new ModalQuery; + + Scene *sc = accessScene(SC_MAINMENU); + + q->create(sc, 0, 0); + + g_fp->_modalObject = q; + + return; + } ModalMainMenu *menu = new ModalMainMenu; menu->_parentObj = g_fp->_modalObject; |