2010-12-01 21:05:08 +00: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.
|
|
|
|
*
|
2021-12-26 18:47:58 +01:00
|
|
|
* 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 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-02-18 02:34:22 +01:00
|
|
|
*
|
2010-12-01 21:05:08 +00:00
|
|
|
* 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.
|
2014-02-18 02:34:22 +01:00
|
|
|
*
|
2010-12-01 21:05:08 +00:00
|
|
|
* You should have received a copy of the GNU General Public License
|
2021-12-26 18:47:58 +01:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2010-12-01 21:05:08 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2011-08-07 16:48:40 +02:00
|
|
|
#include "mohawk/cursors.h"
|
2010-12-01 21:05:08 +00:00
|
|
|
#include "mohawk/myst.h"
|
|
|
|
#include "mohawk/myst_areas.h"
|
2012-03-10 13:50:27 -05:00
|
|
|
#include "mohawk/myst_graphics.h"
|
2017-07-21 12:25:09 +02:00
|
|
|
#include "mohawk/myst_sound.h"
|
2010-12-01 21:05:08 +00:00
|
|
|
#include "mohawk/video.h"
|
|
|
|
#include "mohawk/myst_stacks/preview.h"
|
|
|
|
|
2011-04-24 11:34:27 +03:00
|
|
|
#include "common/system.h"
|
2020-07-04 03:13:05 +05:30
|
|
|
#include "common/translation.h"
|
2010-12-01 21:05:08 +00:00
|
|
|
#include "gui/message.h"
|
|
|
|
|
|
|
|
namespace Mohawk {
|
2011-02-15 21:24:05 +01:00
|
|
|
namespace MystStacks {
|
2010-12-01 21:05:08 +00:00
|
|
|
|
2018-03-31 12:52:08 +02:00
|
|
|
Preview::Preview(MohawkEngine_Myst *vm) :
|
2018-05-28 20:22:29 +02:00
|
|
|
Myst(vm, kDemoPreviewStack) {
|
2010-12-01 21:05:08 +00:00
|
|
|
setupOpcodes();
|
2011-08-07 16:48:40 +02:00
|
|
|
_vm->_cursor->hideCursor();
|
2018-03-31 12:52:08 +02:00
|
|
|
|
|
|
|
_libraryState = 0;
|
|
|
|
_library = nullptr;
|
|
|
|
|
|
|
|
_speechRunning = false;
|
|
|
|
_speechStep = 0;
|
|
|
|
_currentCue = 0;
|
|
|
|
_speechNextTime = 0;
|
2010-12-01 21:05:08 +00:00
|
|
|
}
|
|
|
|
|
2011-02-15 21:42:00 +01:00
|
|
|
Preview::~Preview() {
|
2010-12-01 21:05:08 +00:00
|
|
|
}
|
|
|
|
|
2011-02-15 21:42:00 +01:00
|
|
|
void Preview::setupOpcodes() {
|
2010-12-01 21:05:08 +00:00
|
|
|
// "Stack-Specific" Opcodes
|
2017-07-22 13:53:32 +02:00
|
|
|
OVERRIDE_OPCODE(196, Preview, o_fadeToBlack);
|
|
|
|
OVERRIDE_OPCODE(197, Preview, o_fadeFromBlack);
|
|
|
|
OVERRIDE_OPCODE(198, Preview, o_stayHere);
|
|
|
|
OVERRIDE_OPCODE(199, Preview, o_speechStop);
|
2010-12-01 21:05:08 +00:00
|
|
|
|
|
|
|
// "Init" Opcodes
|
2017-07-22 13:53:32 +02:00
|
|
|
OVERRIDE_OPCODE(209, Preview, o_libraryBookcaseTransformDemo_init);
|
|
|
|
REGISTER_OPCODE(298, Preview, o_speech_init);
|
|
|
|
REGISTER_OPCODE(299, Preview, o_library_init);
|
2010-12-01 21:05:08 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 20:18:23 +02:00
|
|
|
void Preview::disablePersistentScripts() {
|
|
|
|
Myst::disablePersistentScripts();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preview::runPersistentScripts() {
|
|
|
|
Myst::runPersistentScripts();
|
|
|
|
|
|
|
|
if (_speechRunning)
|
|
|
|
speech_run();
|
|
|
|
}
|
|
|
|
|
2017-07-22 12:12:02 +02:00
|
|
|
void Preview::o_fadeToBlack(uint16 var, const ArgumentsArray &args) {
|
2011-08-14 09:16:30 +02:00
|
|
|
_vm->_gfx->fadeToBlack();
|
2010-12-01 21:05:08 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 12:12:02 +02:00
|
|
|
void Preview::o_fadeFromBlack(uint16 var, const ArgumentsArray &args) {
|
2011-08-15 08:52:11 +02:00
|
|
|
|
2017-07-21 12:56:20 +02:00
|
|
|
_vm->_gfx->fadeFromBlack();
|
2010-12-01 21:05:08 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 12:12:02 +02:00
|
|
|
void Preview::o_stayHere(uint16 var, const ArgumentsArray &args) {
|
2011-08-14 09:16:30 +02:00
|
|
|
// Nuh-uh! No leaving the library in the demo!
|
2020-07-04 03:13:05 +05:30
|
|
|
GUI::MessageDialog dialog(_("You can't leave the library in the demo."));
|
2011-08-14 09:16:30 +02:00
|
|
|
dialog.runModal();
|
2010-12-01 21:05:08 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 12:12:02 +02:00
|
|
|
void Preview::o_speechStop(uint16 var, const ArgumentsArray &args) {
|
2017-07-21 12:56:20 +02:00
|
|
|
_vm->_sound->stopSpeech();
|
2011-08-14 09:16:30 +02:00
|
|
|
_speechRunning = false;
|
2018-04-25 16:03:21 -07:00
|
|
|
_globals.currentAge = kMystLibrary;
|
2010-12-01 21:05:08 +00:00
|
|
|
}
|
|
|
|
|
2011-08-13 20:18:23 +02:00
|
|
|
void Preview::speechUpdateCue() {
|
|
|
|
// This is a callback in the original, handling audio events.
|
2017-07-21 12:56:20 +02:00
|
|
|
if (!_vm->_sound->isSpeechPlaying()) {
|
2011-08-13 20:18:23 +02:00
|
|
|
return;
|
|
|
|
}
|
2010-12-01 21:05:08 +00:00
|
|
|
|
2017-07-21 12:56:20 +02:00
|
|
|
uint samples = _vm->_sound->getSpeechNumSamplesPlayed();
|
2011-08-13 20:18:23 +02:00
|
|
|
for (int16 i = 0; i < _cueList.pointCount; i++) {
|
|
|
|
if (_cueList.points[i].sampleFrame > samples)
|
|
|
|
return;
|
|
|
|
if (i > _currentCue - 1) {
|
|
|
|
_currentCue++;
|
|
|
|
debugC(kDebugScript, "Sneak speech advanced to cue %d", _currentCue);
|
|
|
|
}
|
2010-12-01 21:05:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-13 20:18:23 +02:00
|
|
|
void Preview::speech_run() {
|
2018-06-11 20:01:12 +02:00
|
|
|
uint32 time = _vm->getTotalPlayTime();
|
2011-08-13 20:18:23 +02:00
|
|
|
|
|
|
|
// Update current speech sound cue
|
|
|
|
speechUpdateCue();
|
|
|
|
|
|
|
|
switch (_speechStep) {
|
|
|
|
case 0: // Start Voice Over... which controls book opening
|
|
|
|
_currentCue = 0;
|
2017-07-21 12:56:20 +02:00
|
|
|
_vm->_sound->playSpeech(3001, &_cueList);
|
2011-08-13 20:18:23 +02:00
|
|
|
|
|
|
|
_speechStep++;
|
|
|
|
break;
|
|
|
|
case 1: // Open book
|
|
|
|
if (_currentCue >= 1) {
|
2012-12-15 11:49:41 +01:00
|
|
|
_vm->changeToCard(3001, kTransitionDissolve);
|
2011-08-13 20:18:23 +02:00
|
|
|
|
|
|
|
_speechStep++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2: // Go to Myst
|
|
|
|
if (_currentCue >= 2) {
|
|
|
|
_vm->_gfx->fadeToBlack();
|
2012-12-15 11:49:41 +01:00
|
|
|
_vm->changeToCard(3002, kNoTransition);
|
2011-08-13 20:18:23 +02:00
|
|
|
_vm->_gfx->fadeFromBlack();
|
|
|
|
|
|
|
|
_speechStep++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 3: // Start blinking the library
|
|
|
|
if (_currentCue >= 3) {
|
|
|
|
_libraryState = 1;
|
|
|
|
_speechNextTime = 0;
|
|
|
|
_speechStep++;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 4: // Library blinking, zoom in library
|
|
|
|
if (_currentCue >= 4) {
|
|
|
|
_library->drawConditionalDataToScreen(0);
|
|
|
|
|
2012-12-15 11:49:41 +01:00
|
|
|
_vm->changeToCard(3003, kTransitionDissolve);
|
2011-08-13 20:18:23 +02:00
|
|
|
|
|
|
|
_speechNextTime = time + 2000;
|
|
|
|
_speechStep++;
|
|
|
|
} else {
|
|
|
|
if (time < _speechNextTime)
|
|
|
|
break;
|
|
|
|
|
|
|
|
_library->drawConditionalDataToScreen(_libraryState);
|
|
|
|
_libraryState = (_libraryState + 1) % 2;
|
|
|
|
_speechNextTime = time + 500;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 5: // Go to library near view
|
|
|
|
if (time < _speechNextTime)
|
|
|
|
break;
|
|
|
|
|
2012-12-15 11:49:41 +01:00
|
|
|
_vm->changeToCard(3004, kTransitionDissolve);
|
2011-08-13 20:18:23 +02:00
|
|
|
_speechNextTime = time + 2000;
|
|
|
|
_speechStep++;
|
|
|
|
break;
|
|
|
|
case 6: // Fade to courtyard
|
|
|
|
if (time < _speechNextTime)
|
|
|
|
break;
|
|
|
|
|
|
|
|
_vm->_gfx->fadeToBlack();
|
2012-12-15 11:49:41 +01:00
|
|
|
_vm->changeToCard(3005, kNoTransition);
|
2011-08-13 20:18:23 +02:00
|
|
|
_vm->_gfx->fadeFromBlack();
|
|
|
|
_speechNextTime = time + 1000;
|
|
|
|
_speechStep++;
|
|
|
|
break;
|
|
|
|
case 7: // Walk to library
|
|
|
|
case 8:
|
|
|
|
case 9:
|
|
|
|
case 10:
|
|
|
|
case 11:
|
|
|
|
case 12:
|
|
|
|
case 13:
|
|
|
|
if (time < _speechNextTime)
|
|
|
|
break;
|
|
|
|
|
2012-12-15 11:49:41 +01:00
|
|
|
_vm->changeToCard(3006 + _speechStep - 7, kTransitionDissolve);
|
2011-08-13 20:18:23 +02:00
|
|
|
_speechNextTime = time + 2000;
|
|
|
|
_speechStep++;
|
|
|
|
break;
|
|
|
|
case 14: // Go to playable library card
|
|
|
|
if (time < _speechNextTime)
|
|
|
|
break;
|
|
|
|
|
2012-12-15 11:49:41 +01:00
|
|
|
_vm->changeToCard(4329, kTransitionDissolve);
|
2011-08-13 20:18:23 +02:00
|
|
|
|
|
|
|
_speechRunning = false;
|
2018-04-25 16:03:21 -07:00
|
|
|
_globals.currentAge = kMystLibrary;
|
2011-08-13 20:18:23 +02:00
|
|
|
|
|
|
|
_vm->_cursor->showCursor();
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
warning("Unknown speech step");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-07-22 12:12:02 +02:00
|
|
|
void Preview::o_speech_init(uint16 var, const ArgumentsArray &args) {
|
2011-08-13 20:18:23 +02:00
|
|
|
// Used for Card 3000 (Closed Myst Book)
|
|
|
|
_speechStep = 0;
|
|
|
|
_speechRunning = true;
|
|
|
|
}
|
|
|
|
|
2017-07-22 12:12:02 +02:00
|
|
|
void Preview::o_library_init(uint16 var, const ArgumentsArray &args) {
|
2010-12-01 21:05:08 +00:00
|
|
|
// Used for Card 3002 (Myst Island Overview)
|
2016-02-06 17:41:50 +01:00
|
|
|
_library = getInvokingResource<MystAreaImageSwitch>();
|
2010-12-01 21:05:08 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 12:12:02 +02:00
|
|
|
void Preview::o_libraryBookcaseTransformDemo_init(uint16 var, const ArgumentsArray &args) {
|
2012-12-16 13:20:50 +01:00
|
|
|
if (_libraryBookcaseChanged) {
|
2016-02-06 17:41:50 +01:00
|
|
|
MystAreaActionSwitch *resource = getInvokingResource<MystAreaActionSwitch>();
|
2016-02-06 13:54:02 +01:00
|
|
|
_libraryBookcaseMovie = static_cast<MystAreaVideo *>(resource->getSubResource(getVar(303)));
|
2017-04-08 07:38:49 +02:00
|
|
|
_libraryBookcaseSoundId = args[0];
|
2012-12-16 13:20:50 +01:00
|
|
|
_libraryBookcaseMoving = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void Preview::libraryBookcaseTransform_run() {
|
|
|
|
if (_libraryBookcaseChanged)
|
|
|
|
_state.libraryBookcaseDoor = !_state.libraryBookcaseDoor;
|
|
|
|
|
|
|
|
Myst::libraryBookcaseTransform_run();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-02-15 21:24:05 +01:00
|
|
|
} // End of namespace MystStacks
|
2010-12-01 21:05:08 +00:00
|
|
|
} // End of namespace Mohawk
|