2009-12-29 23:18:24 +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.
|
|
|
|
*
|
|
|
|
* 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 "common/config-manager.h"
|
2010-05-04 11:59:22 +00:00
|
|
|
#include "common/debug-channels.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/system.h"
|
2010-09-12 21:35:49 +00:00
|
|
|
#include "common/translation.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/textconsole.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-25 04:49:11 +00:00
|
|
|
#include "mohawk/cursors.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
#include "mohawk/graphics.h"
|
|
|
|
#include "mohawk/myst.h"
|
2010-11-29 20:51:04 +00:00
|
|
|
#include "mohawk/myst_areas.h"
|
2010-11-29 20:49:14 +00:00
|
|
|
#include "mohawk/myst_scripts.h"
|
2010-12-26 15:10:33 +00:00
|
|
|
#include "mohawk/myst_state.h"
|
2009-12-30 23:02:14 +00:00
|
|
|
#include "mohawk/dialogs.h"
|
2010-01-22 03:43:57 +00:00
|
|
|
#include "mohawk/resource.h"
|
2010-02-17 19:59:08 +00:00
|
|
|
#include "mohawk/resource_cache.h"
|
2010-12-21 18:16:20 +00:00
|
|
|
#include "mohawk/sound.h"
|
2010-05-23 18:33:55 +00:00
|
|
|
#include "mohawk/video.h"
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-11-29 21:34:59 +00:00
|
|
|
// The stacks
|
2010-12-01 02:11:11 +00:00
|
|
|
#include "mohawk/myst_stacks/channelwood.h"
|
2010-11-30 15:01:26 +00:00
|
|
|
#include "mohawk/myst_stacks/credits.h"
|
2010-12-01 17:56:36 +00:00
|
|
|
#include "mohawk/myst_stacks/demo.h"
|
2010-12-01 14:46:59 +00:00
|
|
|
#include "mohawk/myst_stacks/dni.h"
|
2010-12-01 17:56:36 +00:00
|
|
|
#include "mohawk/myst_stacks/intro.h"
|
2010-12-01 21:05:08 +00:00
|
|
|
#include "mohawk/myst_stacks/makingof.h"
|
2010-12-01 02:45:31 +00:00
|
|
|
#include "mohawk/myst_stacks/mechanical.h"
|
2010-11-29 21:34:59 +00:00
|
|
|
#include "mohawk/myst_stacks/myst.h"
|
2010-12-01 21:05:08 +00:00
|
|
|
#include "mohawk/myst_stacks/preview.h"
|
2010-11-29 21:34:59 +00:00
|
|
|
#include "mohawk/myst_stacks/selenitic.h"
|
2010-12-01 15:24:54 +00:00
|
|
|
#include "mohawk/myst_stacks/slides.h"
|
2010-11-30 22:02:03 +00:00
|
|
|
#include "mohawk/myst_stacks/stoneship.h"
|
2010-11-29 21:34:59 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
namespace Mohawk {
|
|
|
|
|
|
|
|
MohawkEngine_Myst::MohawkEngine_Myst(OSystem *syst, const MohawkGameDescription *gamedesc) : MohawkEngine(syst, gamedesc) {
|
2010-04-27 21:40:52 +00:00
|
|
|
DebugMan.addDebugChannel(kDebugVariable, "Variable", "Track Variable Accesses");
|
|
|
|
DebugMan.addDebugChannel(kDebugSaveLoad, "SaveLoad", "Track Save/Load Function");
|
|
|
|
DebugMan.addDebugChannel(kDebugView, "View", "Track Card File (VIEW) Parsing");
|
|
|
|
DebugMan.addDebugChannel(kDebugHint, "Hint", "Track Cursor Hints (HINT) Parsing");
|
|
|
|
DebugMan.addDebugChannel(kDebugResource, "Resource", "Track Resource (RLST) Parsing");
|
|
|
|
DebugMan.addDebugChannel(kDebugINIT, "Init", "Track Card Init Script (INIT) Parsing");
|
|
|
|
DebugMan.addDebugChannel(kDebugEXIT, "Exit", "Track Card Exit Script (EXIT) Parsing");
|
|
|
|
DebugMan.addDebugChannel(kDebugScript, "Script", "Track Script Execution");
|
|
|
|
DebugMan.addDebugChannel(kDebugHelp, "Help", "Track Help File (HELP) Parsing");
|
|
|
|
DebugMan.addDebugChannel(kDebugCache, "Cache", "Track Resource Cache Accesses");
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
// Engine tweaks
|
2011-01-03 20:40:07 +00:00
|
|
|
// Disabling this makes engine behavior as per
|
2009-12-29 23:18:24 +00:00
|
|
|
// original, including bugs, missing bits etc. :)
|
|
|
|
_tweaksEnabled = true;
|
|
|
|
|
2011-05-15 15:22:09 +00:00
|
|
|
_currentCursor = 0;
|
|
|
|
_mainCursor = kDefaultMystCursor;
|
2009-12-29 23:18:24 +00:00
|
|
|
_showResourceRects = false;
|
|
|
|
_curCard = 0;
|
|
|
|
_needsUpdate = false;
|
|
|
|
_curResource = -1;
|
2010-12-19 07:02:02 +00:00
|
|
|
_hoverResource = 0;
|
2010-11-29 20:53:14 +00:00
|
|
|
_dragResource = 0;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-11-09 11:02:06 +00:00
|
|
|
_gfx = NULL;
|
|
|
|
_console = NULL;
|
|
|
|
_scriptParser = NULL;
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState = NULL;
|
2010-11-09 11:02:06 +00:00
|
|
|
_loadDialog = NULL;
|
|
|
|
_optionsDialog = NULL;
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
_cursorHintCount = 0;
|
|
|
|
_cursorHints = NULL;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-11-30 14:45:31 +00:00
|
|
|
_prevStack = NULL;
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
_view.conditionalImageCount = 0;
|
|
|
|
_view.conditionalImages = NULL;
|
|
|
|
_view.soundList = NULL;
|
|
|
|
_view.soundListVolume = NULL;
|
|
|
|
_view.scriptResCount = 0;
|
|
|
|
_view.scriptResources = NULL;
|
|
|
|
|
2010-05-04 11:56:52 +00:00
|
|
|
if ((getFeatures() & GF_ME) && getPlatform() == Common::kPlatformMacintosh) {
|
|
|
|
const Common::FSNode gameDataDir(ConfMan.get("path"));
|
|
|
|
SearchMan.addSubDirectoryMatching(gameDataDir, "CD Data");
|
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MohawkEngine_Myst::~MohawkEngine_Myst() {
|
2010-11-09 11:02:06 +00:00
|
|
|
DebugMan.clearAllDebugChannels();
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
delete _gfx;
|
|
|
|
delete _console;
|
|
|
|
delete _scriptParser;
|
2010-12-26 14:31:03 +00:00
|
|
|
delete _gameState;
|
2009-12-29 23:18:24 +00:00
|
|
|
delete _loadDialog;
|
|
|
|
delete _optionsDialog;
|
2010-11-30 14:45:31 +00:00
|
|
|
delete _prevStack;
|
2010-12-04 11:54:08 +00:00
|
|
|
delete _rnd;
|
2010-11-09 11:02:06 +00:00
|
|
|
|
|
|
|
delete[] _cursorHints;
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
delete[] _view.conditionalImages;
|
|
|
|
delete[] _view.scriptResources;
|
2010-11-09 11:02:06 +00:00
|
|
|
|
2011-01-03 20:40:07 +00:00
|
|
|
for (uint32 i = 0; i < _resources.size(); i++)
|
|
|
|
delete _resources[i];
|
|
|
|
|
|
|
|
_resources.clear();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-02-17 19:59:08 +00:00
|
|
|
// Uses cached data objects in preference to disk access
|
2010-11-30 15:07:00 +00:00
|
|
|
Common::SeekableReadStream *MohawkEngine_Myst::getResource(uint32 tag, uint16 id) {
|
2010-04-06 23:38:43 +00:00
|
|
|
Common::SeekableReadStream *ret = _cache.search(tag, id);
|
2010-02-17 19:59:08 +00:00
|
|
|
|
2010-04-06 23:38:43 +00:00
|
|
|
if (ret)
|
|
|
|
return ret;
|
2010-02-17 19:59:08 +00:00
|
|
|
|
|
|
|
for (uint32 i = 0; i < _mhk.size(); i++)
|
|
|
|
if (_mhk[i]->hasResource(tag, id)) {
|
2010-11-20 23:53:14 +00:00
|
|
|
ret = _mhk[i]->getResource(tag, id);
|
2010-02-17 19:59:08 +00:00
|
|
|
_cache.add(tag, id, ret);
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2010-04-06 23:38:43 +00:00
|
|
|
error("Could not find a \'%s\' resource with ID %04x", tag2str(tag), id);
|
2010-02-17 19:59:08 +00:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::cachePreload(uint32 tag, uint16 id) {
|
2010-04-06 23:38:43 +00:00
|
|
|
if (!_cache.enabled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
for (uint32 i = 0; i < _mhk.size(); i++) {
|
|
|
|
// Check for MJMP in Myst ME
|
|
|
|
if ((getFeatures() & GF_ME) && tag == ID_MSND && _mhk[i]->hasResource(ID_MJMP, id)) {
|
2010-11-20 23:53:14 +00:00
|
|
|
Common::SeekableReadStream *tempData = _mhk[i]->getResource(ID_MJMP, id);
|
2010-04-06 23:38:43 +00:00
|
|
|
uint16 msndId = tempData->readUint16LE();
|
|
|
|
delete tempData;
|
2010-02-17 19:59:08 +00:00
|
|
|
|
2010-04-06 23:38:43 +00:00
|
|
|
// We've found where the real MSND data is, so go get that
|
2010-11-20 23:53:14 +00:00
|
|
|
tempData = _mhk[i]->getResource(tag, msndId);
|
2010-04-06 23:38:43 +00:00
|
|
|
_cache.add(tag, id, tempData);
|
|
|
|
delete tempData;
|
|
|
|
return;
|
|
|
|
}
|
2010-02-17 19:59:08 +00:00
|
|
|
|
|
|
|
if (_mhk[i]->hasResource(tag, id)) {
|
2010-11-20 23:53:14 +00:00
|
|
|
Common::SeekableReadStream *tempData = _mhk[i]->getResource(tag, id);
|
2010-02-17 19:59:08 +00:00
|
|
|
_cache.add(tag, id, tempData);
|
|
|
|
delete tempData;
|
|
|
|
return;
|
|
|
|
}
|
2010-04-06 23:38:43 +00:00
|
|
|
}
|
2010-02-17 19:59:08 +00:00
|
|
|
|
2010-04-06 23:38:43 +00:00
|
|
|
warning("cachePreload: Could not find a \'%s\' resource with ID %04x", tag2str(tag), id);
|
2010-02-17 19:59:08 +00:00
|
|
|
}
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
static const char *mystFiles[] = {
|
|
|
|
"channel.dat",
|
|
|
|
"credits.dat",
|
|
|
|
"demo.dat",
|
|
|
|
"dunny.dat",
|
|
|
|
"intro.dat",
|
|
|
|
"making.dat",
|
|
|
|
"mechan.dat",
|
|
|
|
"myst.dat",
|
|
|
|
"selen.dat",
|
|
|
|
"slides.dat",
|
|
|
|
"sneak.dat",
|
|
|
|
"stone.dat"
|
|
|
|
};
|
|
|
|
|
|
|
|
// Myst Hardcoded Movie Paths
|
|
|
|
// Mechanical Stack Movie "sstairs" referenced in executable, but not used?
|
|
|
|
|
|
|
|
// NOTE: cl1wg1.mov etc. found in the root directory in versions of Myst
|
2011-01-18 17:08:17 +00:00
|
|
|
// Original are duplicates of those in qtw/myst directory and thus not necessary.
|
|
|
|
// However, this *is* a problem for Myst ME Mac. Right now it will use the qtw/myst
|
|
|
|
// video, but this is most likely going to fail for the standalone Mac version.
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
// The following movies are not referenced in RLST or hardcoded into the executables.
|
|
|
|
// It is likely they are unused:
|
|
|
|
// qtw/mech/lwrgear2.mov + lwrgears.mov: I have no idea what these are; perhaps replaced by an animated image in-game?
|
|
|
|
// qtw/myst/gar4wbf1.mov: gar4wbf2.mov has two butterflies instead of one
|
|
|
|
// qtw/myst/libelev.mov: libup.mov is basically the same with sound
|
|
|
|
|
2010-11-23 22:32:39 +00:00
|
|
|
Common::String MohawkEngine_Myst::wrapMovieFilename(const Common::String &movieName, uint16 stack) {
|
2010-01-19 19:21:31 +00:00
|
|
|
// The Macintosh release of Myst ME stores its videos in a different folder
|
2011-01-18 17:08:17 +00:00
|
|
|
// WORKAROUND: The gear rotation videos are not in the CD Data folder. See above comments.
|
2011-01-18 17:03:21 +00:00
|
|
|
if ((getFeatures() & GF_ME) && getPlatform() == Common::kPlatformMacintosh && !movieName.matchString("cl1wg?"))
|
2010-01-19 19:21:31 +00:00
|
|
|
return Common::String("CD Data/m/") + movieName + ".mov";
|
|
|
|
|
2011-01-18 17:08:17 +00:00
|
|
|
Common::String prefix;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
switch (stack) {
|
2009-12-30 07:14:09 +00:00
|
|
|
case kIntroStack:
|
|
|
|
prefix = "intro/";
|
|
|
|
break;
|
|
|
|
case kChannelwoodStack:
|
|
|
|
// The Windmill videos like to hide in a different folder
|
|
|
|
if (movieName.contains("wmill"))
|
|
|
|
prefix = "channel2/";
|
|
|
|
else
|
|
|
|
prefix = "channel/";
|
|
|
|
break;
|
|
|
|
case kDniStack:
|
|
|
|
prefix = "dunny/";
|
|
|
|
break;
|
|
|
|
case kMechanicalStack:
|
|
|
|
prefix = "mech/";
|
|
|
|
break;
|
|
|
|
case kMystStack:
|
|
|
|
prefix = "myst/";
|
|
|
|
break;
|
|
|
|
case kSeleniticStack:
|
|
|
|
prefix = "selen/";
|
|
|
|
break;
|
|
|
|
case kStoneshipStack:
|
|
|
|
prefix = "stone/";
|
|
|
|
break;
|
|
|
|
default:
|
2011-01-18 17:08:17 +00:00
|
|
|
// Masterpiece Edition Only Movies
|
2009-12-30 07:14:09 +00:00
|
|
|
break;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return Common::String("qtw/") + prefix + movieName + ".mov";
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error MohawkEngine_Myst::run() {
|
|
|
|
MohawkEngine::run();
|
|
|
|
|
|
|
|
_gfx = new MystGraphics(this);
|
|
|
|
_console = new MystConsole(this);
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState = new MystGameState(this, _saveFileMan);
|
2010-09-12 21:35:49 +00:00
|
|
|
_loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"));
|
2009-12-29 23:18:24 +00:00
|
|
|
_loadDialog->setSaveMode(false);
|
|
|
|
_optionsDialog = new MystOptionsDialog(this);
|
2010-11-25 04:49:11 +00:00
|
|
|
_cursor = new MystCursorManager(this);
|
2011-05-17 10:02:53 +00:00
|
|
|
_rnd = new Common::RandomSource("myst");
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2011-05-15 15:38:47 +00:00
|
|
|
// Cursor is visible by default
|
|
|
|
_cursor->showCursor();
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
// Load game from launcher/command line if requested
|
2010-12-07 18:21:05 +00:00
|
|
|
if (ConfMan.hasKey("save_slot") && canLoadGameStateCurrently()) {
|
2009-12-29 23:18:24 +00:00
|
|
|
uint32 gameToLoad = ConfMan.getInt("save_slot");
|
2010-12-26 14:31:03 +00:00
|
|
|
Common::StringArray savedGamesList = _gameState->generateSaveGameList();
|
2009-12-29 23:18:24 +00:00
|
|
|
if (gameToLoad > savedGamesList.size())
|
|
|
|
error ("Could not find saved game");
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState->load(savedGamesList[gameToLoad]);
|
2010-12-07 18:21:05 +00:00
|
|
|
} else {
|
|
|
|
// Start us on the first stack.
|
|
|
|
if (getGameType() == GType_MAKINGOF)
|
2011-01-07 19:26:31 +00:00
|
|
|
changeToStack(kMakingOfStack, 1, 0, 0);
|
2010-12-07 18:21:05 +00:00
|
|
|
else if (getFeatures() & GF_DEMO)
|
2011-01-07 19:26:31 +00:00
|
|
|
changeToStack(kDemoStack, 2000, 0, 0);
|
2010-12-07 18:21:05 +00:00
|
|
|
else
|
2011-01-07 19:26:31 +00:00
|
|
|
changeToStack(kIntroStack, 1, 0, 0);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 18:33:58 +00:00
|
|
|
// Load Help System (Masterpiece Edition Only)
|
|
|
|
if (getFeatures() & GF_ME) {
|
|
|
|
MohawkArchive *mhk = new MohawkArchive();
|
2011-06-28 15:58:52 +00:00
|
|
|
if (!mhk->openFile("help.dat"))
|
2010-12-07 18:33:58 +00:00
|
|
|
error("Could not load help.dat");
|
|
|
|
_mhk.push_back(mhk);
|
|
|
|
}
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
// Test Load Function...
|
|
|
|
loadHelp(10000);
|
|
|
|
|
|
|
|
Common::Event event;
|
|
|
|
while (!shouldQuit()) {
|
|
|
|
// Update any background videos
|
2011-01-18 20:30:16 +00:00
|
|
|
_needsUpdate = _video->updateMovies();
|
2010-11-29 21:00:05 +00:00
|
|
|
_scriptParser->runPersistentScripts();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
while (_eventMan->pollEvent(event)) {
|
|
|
|
switch (event.type) {
|
2011-01-13 19:30:00 +00:00
|
|
|
case Common::EVENT_MOUSEMOVE: {
|
2009-12-30 07:14:09 +00:00
|
|
|
_needsUpdate = true;
|
2011-01-13 19:30:00 +00:00
|
|
|
bool mouseClicked = _system->getEventManager()->getButtonState() & 1;
|
|
|
|
|
2010-11-29 20:53:14 +00:00
|
|
|
// Keep the same resource when dragging
|
2011-01-13 19:30:00 +00:00
|
|
|
if (!mouseClicked) {
|
2010-11-29 20:53:14 +00:00
|
|
|
checkCurrentResource();
|
|
|
|
}
|
2011-01-13 19:30:00 +00:00
|
|
|
if (_curResource >= 0 && _resources[_curResource]->isEnabled() && mouseClicked) {
|
2010-11-29 21:03:02 +00:00
|
|
|
debug(2, "Sending mouse move event to resource %d", _curResource);
|
2011-01-22 17:26:09 +00:00
|
|
|
_resources[_curResource]->handleMouseDrag();
|
2010-11-29 20:50:40 +00:00
|
|
|
}
|
2009-12-30 07:14:09 +00:00
|
|
|
break;
|
2011-01-13 19:30:00 +00:00
|
|
|
}
|
2009-12-30 07:14:09 +00:00
|
|
|
case Common::EVENT_LBUTTONUP:
|
2010-11-29 20:55:11 +00:00
|
|
|
if (_curResource >= 0 && _resources[_curResource]->isEnabled()) {
|
2010-11-29 21:03:02 +00:00
|
|
|
debug(2, "Sending mouse up event to resource %d", _curResource);
|
2011-01-22 17:26:09 +00:00
|
|
|
_resources[_curResource]->handleMouseUp();
|
2009-12-30 07:14:09 +00:00
|
|
|
}
|
2010-12-05 08:36:41 +00:00
|
|
|
checkCurrentResource();
|
2009-12-30 07:14:09 +00:00
|
|
|
break;
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
2010-11-29 20:55:11 +00:00
|
|
|
if (_curResource >= 0 && _resources[_curResource]->isEnabled()) {
|
2010-11-29 21:03:02 +00:00
|
|
|
debug(2, "Sending mouse up event to resource %d", _curResource);
|
2011-01-22 17:26:09 +00:00
|
|
|
_resources[_curResource]->handleMouseDown();
|
2009-12-30 07:14:09 +00:00
|
|
|
}
|
2010-01-25 01:39:44 +00:00
|
|
|
break;
|
2009-12-30 07:14:09 +00:00
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
switch (event.kbd.keycode) {
|
|
|
|
case Common::KEYCODE_d:
|
|
|
|
if (event.kbd.flags & Common::KBD_CTRL) {
|
|
|
|
_console->attach();
|
|
|
|
_console->onFrame();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
break;
|
2009-12-30 07:14:09 +00:00
|
|
|
case Common::KEYCODE_SPACE:
|
|
|
|
pauseGame();
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_F4:
|
|
|
|
_showResourceRects = !_showResourceRects;
|
|
|
|
if (_showResourceRects)
|
|
|
|
drawResourceRects();
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_F5:
|
2011-05-14 17:26:33 +00:00
|
|
|
_needsPageDrop = false;
|
2011-05-15 12:53:05 +00:00
|
|
|
_needsShowMap = false;
|
|
|
|
|
2009-12-30 07:14:09 +00:00
|
|
|
runDialog(*_optionsDialog);
|
2011-05-14 17:26:33 +00:00
|
|
|
|
|
|
|
if (_needsPageDrop) {
|
|
|
|
dropPage();
|
|
|
|
_needsPageDrop = false;
|
|
|
|
}
|
2011-05-15 12:53:05 +00:00
|
|
|
|
|
|
|
if (_needsShowMap) {
|
|
|
|
_scriptParser->showMap();
|
|
|
|
_needsShowMap = false;
|
|
|
|
}
|
2009-12-30 07:14:09 +00:00
|
|
|
break;
|
2009-12-29 23:18:24 +00:00
|
|
|
default:
|
|
|
|
break;
|
2009-12-30 07:14:09 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_needsUpdate) {
|
|
|
|
_system->updateScreen();
|
|
|
|
_needsUpdate = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cut down on CPU usage
|
|
|
|
_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Common::kNoError;
|
|
|
|
}
|
|
|
|
|
2011-01-08 12:34:41 +00:00
|
|
|
bool MohawkEngine_Myst::skippableWait(uint32 duration) {
|
|
|
|
uint32 end = _system->getMillis() + duration;
|
|
|
|
bool skipped = false;
|
|
|
|
|
|
|
|
while (_system->getMillis() < end && !skipped) {
|
|
|
|
Common::Event event;
|
|
|
|
while (_system->getEventManager()->pollEvent(event)) {
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
skipped = true;
|
|
|
|
break;
|
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
switch (event.kbd.keycode) {
|
|
|
|
case Common::KEYCODE_SPACE:
|
|
|
|
pauseGame();
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_ESCAPE:
|
|
|
|
skipped = true;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Cut down on CPU usage
|
|
|
|
_system->delayMillis(10);
|
|
|
|
}
|
|
|
|
|
|
|
|
return skipped;
|
|
|
|
}
|
|
|
|
|
2011-01-07 19:26:31 +00:00
|
|
|
void MohawkEngine_Myst::changeToStack(uint16 stack, uint16 card, uint16 linkSrcSound, uint16 linkDstSound) {
|
2009-12-29 23:18:24 +00:00
|
|
|
debug(2, "changeToStack(%d)", stack);
|
|
|
|
|
|
|
|
_curStack = stack;
|
|
|
|
|
2011-05-15 15:22:09 +00:00
|
|
|
// Fill screen with black and empty cursor
|
|
|
|
_cursor->setCursor(0);
|
|
|
|
_system->fillScreen(_system->getScreenFormat().RGBToColor(0, 0, 0));
|
|
|
|
_system->updateScreen();
|
|
|
|
|
2011-01-07 19:26:31 +00:00
|
|
|
_sound->stopSound();
|
2011-01-18 21:10:58 +00:00
|
|
|
_sound->stopBackgroundMyst();
|
2011-01-07 19:26:31 +00:00
|
|
|
if (linkSrcSound)
|
|
|
|
_sound->playSoundBlocking(linkSrcSound);
|
|
|
|
|
2010-11-30 14:45:31 +00:00
|
|
|
// Delete the previous stack and move the current stack to the previous one
|
|
|
|
// There's probably a better way to do this, but the script classes shouldn't
|
|
|
|
// take up much memory.
|
|
|
|
delete _prevStack;
|
|
|
|
_prevStack = _scriptParser;
|
2010-11-29 20:49:14 +00:00
|
|
|
|
|
|
|
switch (_curStack) {
|
2010-12-01 02:11:11 +00:00
|
|
|
case kChannelwoodStack:
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState->_globals.currentAge = 4;
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Channelwood(this);
|
2010-12-01 02:11:11 +00:00
|
|
|
break;
|
2010-11-30 15:01:26 +00:00
|
|
|
case kCreditsStack:
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Credits(this);
|
2010-11-30 15:01:26 +00:00
|
|
|
break;
|
2010-12-01 17:56:36 +00:00
|
|
|
case kDemoStack:
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Demo(this);
|
2010-12-01 17:56:36 +00:00
|
|
|
break;
|
2010-12-01 14:46:59 +00:00
|
|
|
case kDniStack:
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState->_globals.currentAge = 6;
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Dni(this);
|
2010-12-01 14:46:59 +00:00
|
|
|
break;
|
2010-12-01 17:56:36 +00:00
|
|
|
case kIntroStack:
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Intro(this);
|
2010-12-01 17:56:36 +00:00
|
|
|
break;
|
2010-12-01 21:05:08 +00:00
|
|
|
case kMakingOfStack:
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::MakingOf(this);
|
2010-12-01 21:05:08 +00:00
|
|
|
break;
|
2010-12-01 02:45:31 +00:00
|
|
|
case kMechanicalStack:
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState->_globals.currentAge = 3;
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Mechanical(this);
|
2010-12-01 02:45:31 +00:00
|
|
|
break;
|
2010-12-01 21:05:08 +00:00
|
|
|
case kMystStack:
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState->_globals.currentAge = 2;
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Myst(this);
|
2010-12-01 21:05:08 +00:00
|
|
|
break;
|
|
|
|
case kDemoPreviewStack:
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Preview(this);
|
2010-12-01 21:05:08 +00:00
|
|
|
break;
|
2010-11-29 20:49:14 +00:00
|
|
|
case kSeleniticStack:
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState->_globals.currentAge = 0;
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Selenitic(this);
|
2010-11-29 20:49:14 +00:00
|
|
|
break;
|
2010-12-01 15:24:54 +00:00
|
|
|
case kDemoSlidesStack:
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Slides(this);
|
2010-12-01 15:24:54 +00:00
|
|
|
break;
|
2010-11-30 22:02:03 +00:00
|
|
|
case kStoneshipStack:
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState->_globals.currentAge = 1;
|
2011-02-15 20:42:00 +00:00
|
|
|
_scriptParser = new MystStacks::Stoneship(this);
|
2010-11-30 22:02:03 +00:00
|
|
|
break;
|
2010-11-29 20:49:14 +00:00
|
|
|
default:
|
2010-12-01 21:05:08 +00:00
|
|
|
error("Unknown Myst stack");
|
2010-11-29 20:49:14 +00:00
|
|
|
}
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
// If the array is empty, add a new one. Otherwise, delete the first
|
|
|
|
// entry which is the stack file (the second, if there, is the help file).
|
|
|
|
if (_mhk.empty())
|
2010-01-22 03:43:57 +00:00
|
|
|
_mhk.push_back(new MohawkArchive());
|
2009-12-29 23:18:24 +00:00
|
|
|
else {
|
|
|
|
delete _mhk[0];
|
2010-01-22 03:43:57 +00:00
|
|
|
_mhk[0] = new MohawkArchive();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2011-06-28 15:58:52 +00:00
|
|
|
if (!_mhk[0]->openFile(mystFiles[_curStack]))
|
2010-11-22 18:07:33 +00:00
|
|
|
error("Could not open %s", mystFiles[_curStack]);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
if (getPlatform() == Common::kPlatformMacintosh)
|
|
|
|
_gfx->loadExternalPictureFile(_curStack);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
_runExitScript = false;
|
2010-02-17 19:59:08 +00:00
|
|
|
|
2010-11-19 21:25:36 +00:00
|
|
|
// Clear the resource cache and the image cache
|
2010-02-17 19:59:08 +00:00
|
|
|
_cache.clear();
|
2010-11-19 21:25:36 +00:00
|
|
|
_gfx->clearCache();
|
2011-01-07 19:26:31 +00:00
|
|
|
|
|
|
|
// Play Flyby Entry Movie on Masterpiece Edition. The Macintosh version is currently hooked
|
|
|
|
// up to the Cinepak versions of the video (the 'c' suffix) until the SVQ1 decoder is completed.
|
|
|
|
const char *flyby = 0;
|
|
|
|
if (getFeatures() & GF_ME) {
|
|
|
|
switch (_curStack) {
|
|
|
|
case kSeleniticStack:
|
|
|
|
if (getPlatform() == Common::kPlatformMacintosh)
|
|
|
|
flyby = "FLY_SEc";
|
|
|
|
else
|
|
|
|
flyby = "selenitic flyby";
|
|
|
|
break;
|
|
|
|
case kStoneshipStack:
|
|
|
|
if (getPlatform() == Common::kPlatformMacintosh)
|
|
|
|
flyby = "FLY_STc";
|
|
|
|
else
|
|
|
|
flyby = "stoneship flyby";
|
|
|
|
break;
|
|
|
|
// Myst Flyby Movie not used in Original Masterpiece Edition Engine
|
|
|
|
case kMystStack:
|
|
|
|
if (_tweaksEnabled) {
|
|
|
|
if (getPlatform() == Common::kPlatformMacintosh)
|
|
|
|
flyby = "FLY_MYc";
|
|
|
|
else
|
|
|
|
flyby = "myst flyby";
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case kMechanicalStack:
|
|
|
|
if (getPlatform() == Common::kPlatformMacintosh)
|
|
|
|
flyby = "FLY_MEc";
|
|
|
|
else
|
|
|
|
flyby = "mech age flyby";
|
|
|
|
break;
|
|
|
|
case kChannelwoodStack:
|
|
|
|
if (getPlatform() == Common::kPlatformMacintosh)
|
|
|
|
flyby = "FLY_CHc";
|
|
|
|
else
|
|
|
|
flyby = "channelwood flyby";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (flyby)
|
2011-01-18 20:30:16 +00:00
|
|
|
_video->playMovieBlockingCentered(wrapMovieFilename(flyby, kMasterpieceOnly));
|
2011-01-07 19:26:31 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
changeToCard(card, true);
|
|
|
|
|
|
|
|
if (linkDstSound)
|
|
|
|
_sound->playSoundBlocking(linkDstSound);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 20:58:10 +00:00
|
|
|
uint16 MohawkEngine_Myst::getCardBackgroundId() {
|
|
|
|
uint16 imageToDraw = 0;
|
|
|
|
|
|
|
|
if (_view.conditionalImageCount == 0)
|
|
|
|
imageToDraw = _view.mainImage;
|
|
|
|
else {
|
|
|
|
for (uint16 i = 0; i < _view.conditionalImageCount; i++) {
|
|
|
|
uint16 varValue = _scriptParser->getVar(_view.conditionalImages[i].var);
|
|
|
|
if (varValue < _view.conditionalImages[i].numStates)
|
|
|
|
imageToDraw = _view.conditionalImages[i].values[varValue];
|
|
|
|
}
|
2010-11-29 20:56:39 +00:00
|
|
|
}
|
2010-11-29 20:58:10 +00:00
|
|
|
|
|
|
|
return imageToDraw;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::drawCardBackground() {
|
2011-05-14 15:31:22 +00:00
|
|
|
_gfx->copyImageToBackBuffer(getCardBackgroundId(), Common::Rect(0, 0, 544, 332));
|
2010-11-29 20:56:39 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 20:59:17 +00:00
|
|
|
void MohawkEngine_Myst::changeToCard(uint16 card, bool updateScreen) {
|
2009-12-29 23:18:24 +00:00
|
|
|
debug(2, "changeToCard(%d)", card);
|
|
|
|
|
2010-11-29 21:00:05 +00:00
|
|
|
_scriptParser->disablePersistentScripts();
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
_video->stopVideos();
|
|
|
|
|
|
|
|
// Run exit script from last card (if present)
|
|
|
|
if (_runExitScript)
|
|
|
|
runExitScript();
|
|
|
|
|
|
|
|
_runExitScript = true;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
unloadCard();
|
|
|
|
|
2010-11-19 21:25:36 +00:00
|
|
|
// Clear the resource cache and image cache
|
2010-02-17 19:59:08 +00:00
|
|
|
_cache.clear();
|
2010-11-19 21:25:36 +00:00
|
|
|
_gfx->clearCache();
|
2010-02-17 19:59:08 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
_curCard = card;
|
|
|
|
|
|
|
|
// Load a bunch of stuff
|
|
|
|
loadCard();
|
|
|
|
loadResources();
|
|
|
|
loadCursorHints();
|
|
|
|
|
|
|
|
// Handle images
|
2010-11-29 20:56:39 +00:00
|
|
|
drawCardBackground();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
// Handle sound
|
|
|
|
int16 soundAction = 0;
|
|
|
|
uint16 soundActionVolume = 0;
|
|
|
|
|
|
|
|
if (_view.sound == kMystSoundActionConditional) {
|
2010-11-29 20:49:42 +00:00
|
|
|
uint16 soundVarValue = _scriptParser->getVar(_view.soundVar);
|
2009-12-29 23:18:24 +00:00
|
|
|
if (soundVarValue >= _view.soundCount)
|
|
|
|
warning("Conditional sound variable outside range");
|
|
|
|
else {
|
|
|
|
soundAction = _view.soundList[soundVarValue];
|
|
|
|
soundActionVolume = _view.soundListVolume[soundVarValue];
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
soundAction = _view.sound;
|
|
|
|
soundActionVolume = _view.soundVolume;
|
|
|
|
}
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
if (soundAction == kMystSoundActionContinue)
|
|
|
|
debug(2, "Continuing with current sound");
|
|
|
|
else if (soundAction == kMystSoundActionChangeVolume) {
|
|
|
|
debug(2, "Continuing with current sound, changing volume");
|
2011-01-18 21:10:58 +00:00
|
|
|
_sound->changeBackgroundVolumeMyst(soundActionVolume);
|
2009-12-29 23:18:24 +00:00
|
|
|
} else if (soundAction == kMystSoundActionStop) {
|
|
|
|
debug(2, "Stopping sound");
|
2011-01-18 21:10:58 +00:00
|
|
|
_sound->stopBackgroundMyst();
|
2009-12-29 23:18:24 +00:00
|
|
|
} else if (soundAction > 0) {
|
|
|
|
debug(2, "Playing new sound %d", soundAction);
|
2011-01-18 21:10:58 +00:00
|
|
|
_sound->replaceBackgroundMyst(soundAction, soundActionVolume);
|
2009-12-29 23:18:24 +00:00
|
|
|
} else {
|
|
|
|
error("Unknown sound action %d", soundAction);
|
|
|
|
}
|
|
|
|
|
2011-01-09 15:31:08 +00:00
|
|
|
if (_view.flags & kMystZipDestination)
|
|
|
|
_gameState->addZipDest(_curStack, card);
|
|
|
|
|
2010-11-29 20:52:33 +00:00
|
|
|
// Run the entrance script (if present)
|
|
|
|
runInitScript();
|
|
|
|
|
2010-11-17 19:58:19 +00:00
|
|
|
// Update the images of each area too
|
|
|
|
drawResourceImages();
|
|
|
|
|
2010-12-06 20:29:45 +00:00
|
|
|
for (uint16 i = 0; i < _resources.size(); i++)
|
|
|
|
_resources[i]->handleCardChange();
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
// TODO: Handle Script Resources
|
|
|
|
|
2010-11-29 20:59:17 +00:00
|
|
|
// Make sure the screen is updated
|
|
|
|
if (updateScreen) {
|
2010-12-14 19:11:16 +00:00
|
|
|
_gfx->copyBackBufferToScreen(Common::Rect(544, 333));
|
|
|
|
_system->updateScreen();
|
2010-11-29 20:59:17 +00:00
|
|
|
}
|
2010-12-16 16:12:38 +00:00
|
|
|
|
2011-05-15 15:22:09 +00:00
|
|
|
// Make sure we have the right cursor showing
|
|
|
|
_dragResource = 0;
|
|
|
|
_hoverResource = 0;
|
|
|
|
_curResource = -1;
|
|
|
|
checkCurrentResource();
|
|
|
|
|
2010-12-16 16:12:38 +00:00
|
|
|
// Debug: Show resource rects
|
|
|
|
if (_showResourceRects)
|
|
|
|
drawResourceRects();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::drawResourceRects() {
|
|
|
|
for (uint16 i = 0; i < _resources.size(); i++) {
|
|
|
|
_resources[i]->getRect().debugPrint(0);
|
2010-12-16 16:12:38 +00:00
|
|
|
_resources[i]->drawBoundingRect();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_system->updateScreen();
|
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::checkCurrentResource() {
|
|
|
|
// See what resource we're over
|
|
|
|
bool foundResource = false;
|
2010-12-19 07:02:02 +00:00
|
|
|
const Common::Point &mouse = _system->getEventManager()->getMousePos();
|
|
|
|
|
|
|
|
// Tell previous resource the mouse is no longer hovering it
|
|
|
|
if (_hoverResource && !_hoverResource->contains(mouse)) {
|
|
|
|
_hoverResource->handleMouseLeave();
|
|
|
|
_hoverResource = 0;
|
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
for (uint16 i = 0; i < _resources.size(); i++)
|
2010-12-19 07:02:02 +00:00
|
|
|
if (_resources[i]->contains(mouse)) {
|
|
|
|
if (_hoverResource != _resources[i] && _resources[i]->type == kMystHoverArea) {
|
|
|
|
_hoverResource = static_cast<MystResourceType13 *>(_resources[i]);
|
|
|
|
_hoverResource->handleMouseEnter();
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-19 07:02:02 +00:00
|
|
|
if (!foundResource && _resources[i]->canBecomeActive()) {
|
|
|
|
_curResource = i;
|
|
|
|
foundResource = true;
|
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the resource to none if we're not over any
|
|
|
|
if (!foundResource)
|
|
|
|
_curResource = -1;
|
|
|
|
|
|
|
|
checkCursorHints();
|
|
|
|
}
|
|
|
|
|
2010-12-18 08:07:16 +00:00
|
|
|
MystResource *MohawkEngine_Myst::updateCurrentResource() {
|
|
|
|
checkCurrentResource();
|
|
|
|
|
|
|
|
if (_curResource >= 0)
|
|
|
|
return _resources[_curResource];
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
void MohawkEngine_Myst::loadCard() {
|
|
|
|
debugC(kDebugView, "Loading Card View:");
|
|
|
|
|
2010-11-30 15:07:00 +00:00
|
|
|
Common::SeekableReadStream *viewStream = getResource(ID_VIEW, _curCard);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
// Card Flags
|
|
|
|
_view.flags = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "Flags: 0x%04X", _view.flags);
|
|
|
|
|
|
|
|
// The Image Block (Reminiscent of Riven PLST resources)
|
|
|
|
_view.conditionalImageCount = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "Conditional Image Count: %d", _view.conditionalImageCount);
|
|
|
|
if (_view.conditionalImageCount != 0) {
|
|
|
|
_view.conditionalImages = new MystCondition[_view.conditionalImageCount];
|
|
|
|
for (uint16 i = 0; i < _view.conditionalImageCount; i++) {
|
|
|
|
debugC(kDebugView, "\tImage %d:", i);
|
|
|
|
_view.conditionalImages[i].var = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\t\tVar: %d", _view.conditionalImages[i].var);
|
|
|
|
_view.conditionalImages[i].numStates = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\t\tNumber of States: %d", _view.conditionalImages[i].numStates);
|
|
|
|
_view.conditionalImages[i].values = new uint16[_view.conditionalImages[i].numStates];
|
|
|
|
for (uint16 j = 0; j < _view.conditionalImages[i].numStates; j++) {
|
|
|
|
_view.conditionalImages[i].values[j] = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\t\tState %d -> Value %d", j, _view.conditionalImages[i].values[j]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_view.mainImage = 0;
|
|
|
|
} else {
|
|
|
|
_view.mainImage = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "Main Image: %d", _view.mainImage);
|
|
|
|
}
|
|
|
|
|
|
|
|
// The Sound Block (Reminiscent of Riven SLST resources)
|
|
|
|
_view.sound = viewStream->readSint16LE();
|
|
|
|
debugCN(kDebugView, "Sound Control: %d = ", _view.sound);
|
|
|
|
if (_view.sound > 0) {
|
|
|
|
debugC(kDebugView, "Play new Sound, change volume");
|
|
|
|
debugC(kDebugView, "\tSound: %d", _view.sound);
|
|
|
|
_view.soundVolume = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\tVolume: %d", _view.soundVolume);
|
|
|
|
} else if (_view.sound == kMystSoundActionContinue)
|
|
|
|
debugC(kDebugView, "Continue current sound");
|
|
|
|
else if (_view.sound == kMystSoundActionChangeVolume) {
|
|
|
|
debugC(kDebugView, "Continue current sound, change volume");
|
|
|
|
_view.soundVolume = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\tVolume: %d", _view.soundVolume);
|
|
|
|
} else if (_view.sound == kMystSoundActionStop) {
|
|
|
|
debugC(kDebugView, "Stop sound");
|
|
|
|
} else if (_view.sound == kMystSoundActionConditional) {
|
|
|
|
debugC(kDebugView, "Conditional sound list");
|
|
|
|
_view.soundVar = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\tVar: %d", _view.soundVar);
|
|
|
|
_view.soundCount = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\tCount: %d", _view.soundCount);
|
|
|
|
_view.soundList = new int16[_view.soundCount];
|
|
|
|
_view.soundListVolume = new uint16[_view.soundCount];
|
|
|
|
|
|
|
|
for (uint16 i = 0; i < _view.soundCount; i++) {
|
|
|
|
_view.soundList[i] = viewStream->readSint16LE();
|
|
|
|
debugC(kDebugView, "\t\tCondition %d: Action %d", i, _view.soundList[i]);
|
|
|
|
if (_view.soundList[i] == kMystSoundActionChangeVolume || _view.soundList[i] >= 0) {
|
|
|
|
_view.soundListVolume[i] = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\t\tCondition %d: Volume %d", i, _view.soundListVolume[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
debugC(kDebugView, "Unknown");
|
|
|
|
warning("Unknown sound control value in card");
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resources that scripts can call upon
|
|
|
|
_view.scriptResCount = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "Script Resource Count: %d", _view.scriptResCount);
|
|
|
|
if (_view.scriptResCount != 0) {
|
|
|
|
_view.scriptResources = new MystView::ScriptResource[_view.scriptResCount];
|
|
|
|
for (uint16 i = 0; i < _view.scriptResCount; i++) {
|
|
|
|
debugC(kDebugView, "\tResource %d:", i);
|
|
|
|
_view.scriptResources[i].type = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\t\t Type: %d", _view.scriptResources[i].type);
|
|
|
|
|
|
|
|
switch (_view.scriptResources[i].type) {
|
2009-12-30 07:14:09 +00:00
|
|
|
case 1:
|
|
|
|
debugC(kDebugView, "\t\t\t\t= Image");
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
debugC(kDebugView, "\t\t\t\t= Sound");
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
debugC(kDebugView, "\t\t\t\t= Resource List");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
debugC(kDebugView, "\t\t\t\t= Unknown");
|
|
|
|
break;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_view.scriptResources[i].type == 3) {
|
|
|
|
_view.scriptResources[i].var = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\t\t Var: %d", _view.scriptResources[i].var);
|
|
|
|
_view.scriptResources[i].count = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\t\t Resource List Count: %d", _view.scriptResources[i].count);
|
|
|
|
_view.scriptResources[i].u0 = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\t\t u0: %d", _view.scriptResources[i].u0);
|
|
|
|
_view.scriptResources[i].resource_list = new int16[_view.scriptResources[i].count];
|
|
|
|
|
|
|
|
for (uint16 j = 0; j < _view.scriptResources[i].count; j++) {
|
|
|
|
_view.scriptResources[i].resource_list[j] = viewStream->readSint16LE();
|
|
|
|
debugC(kDebugView, "\t\t Resource List %d: %d", j, _view.scriptResources[i].resource_list[j]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_view.scriptResources[i].resource_list = NULL;
|
|
|
|
_view.scriptResources[i].id = viewStream->readUint16LE();
|
|
|
|
debugC(kDebugView, "\t\t Id: %d", _view.scriptResources[i].id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Identifiers for other resources. 0 if non existent. There is always an RLST.
|
|
|
|
_view.rlst = viewStream->readUint16LE();
|
|
|
|
if (!_view.rlst)
|
|
|
|
error("RLST Index missing");
|
|
|
|
|
|
|
|
_view.hint = viewStream->readUint16LE();
|
|
|
|
_view.init = viewStream->readUint16LE();
|
|
|
|
_view.exit = viewStream->readUint16LE();
|
|
|
|
|
|
|
|
delete viewStream;
|
2010-02-17 19:59:08 +00:00
|
|
|
|
|
|
|
// Precache Card Resources
|
|
|
|
// TODO: Deal with Mac ME External Picture File
|
|
|
|
uint32 cacheImageType;
|
|
|
|
if (getFeatures() & GF_ME)
|
|
|
|
cacheImageType = ID_PICT;
|
|
|
|
else
|
|
|
|
cacheImageType = ID_WDIB;
|
|
|
|
|
|
|
|
// Precache Image Block data
|
|
|
|
if (_view.conditionalImageCount != 0) {
|
|
|
|
for (uint16 i = 0; i < _view.conditionalImageCount; i++)
|
|
|
|
for (uint16 j = 0; j < _view.conditionalImages[i].numStates; j++)
|
|
|
|
cachePreload(cacheImageType, _view.conditionalImages[i].values[j]);
|
|
|
|
} else
|
|
|
|
cachePreload(cacheImageType, _view.mainImage);
|
|
|
|
|
|
|
|
// Precache Sound Block data
|
|
|
|
if (_view.sound > 0)
|
|
|
|
cachePreload(ID_MSND, _view.sound);
|
|
|
|
else if (_view.sound == kMystSoundActionConditional) {
|
|
|
|
for (uint16 i = 0; i < _view.soundCount; i++) {
|
|
|
|
if (_view.soundList[i] > 0)
|
|
|
|
cachePreload(ID_MSND, _view.soundList[i]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Precache Script Resources
|
|
|
|
if (_view.scriptResCount != 0) {
|
|
|
|
for (uint16 i = 0; i < _view.scriptResCount; i++) {
|
|
|
|
switch (_view.scriptResources[i].type) {
|
|
|
|
case 1:
|
|
|
|
cachePreload(cacheImageType, _view.scriptResources[i].id);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
cachePreload(ID_MSND, _view.scriptResources[i].id);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
warning("TODO: Precaching of Script Resource List not supported");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
warning("Unknown Resource in Script Resource List Precaching");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::unloadCard() {
|
|
|
|
for (uint16 i = 0; i < _view.conditionalImageCount; i++)
|
|
|
|
delete[] _view.conditionalImages[i].values;
|
|
|
|
|
|
|
|
delete[] _view.conditionalImages;
|
|
|
|
_view.conditionalImageCount = 0;
|
|
|
|
_view.conditionalImages = NULL;
|
|
|
|
|
|
|
|
delete[] _view.soundList;
|
|
|
|
_view.soundList = NULL;
|
|
|
|
delete[] _view.soundListVolume;
|
|
|
|
_view.soundListVolume = NULL;
|
|
|
|
|
|
|
|
for (uint16 i = 0; i < _view.scriptResCount; i++)
|
|
|
|
delete[] _view.scriptResources[i].resource_list;
|
|
|
|
|
|
|
|
delete[] _view.scriptResources;
|
|
|
|
_view.scriptResources = NULL;
|
|
|
|
_view.scriptResCount = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::runInitScript() {
|
|
|
|
if (!_view.init) {
|
|
|
|
debugC(kDebugINIT, "No INIT Present");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
debugC(kDebugINIT, "Running INIT script");
|
|
|
|
|
2010-11-30 15:07:00 +00:00
|
|
|
Common::SeekableReadStream *initStream = getResource(ID_INIT, _view.init);
|
2010-11-18 05:47:16 +00:00
|
|
|
MystScript script = _scriptParser->readScript(initStream, kMystScriptInit);
|
2009-12-29 23:18:24 +00:00
|
|
|
delete initStream;
|
|
|
|
|
2010-11-18 05:47:16 +00:00
|
|
|
_scriptParser->runScript(script);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::runExitScript() {
|
|
|
|
if (!_view.exit) {
|
|
|
|
debugC(kDebugEXIT, "No EXIT Present");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
debugC(kDebugEXIT, "Running EXIT script");
|
|
|
|
|
2010-11-30 15:07:00 +00:00
|
|
|
Common::SeekableReadStream *exitStream = getResource(ID_EXIT, _view.exit);
|
2010-11-18 05:47:16 +00:00
|
|
|
MystScript script = _scriptParser->readScript(exitStream, kMystScriptExit);
|
2009-12-29 23:18:24 +00:00
|
|
|
delete exitStream;
|
|
|
|
|
2010-11-18 05:47:16 +00:00
|
|
|
_scriptParser->runScript(script);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::loadHelp(uint16 id) {
|
|
|
|
// The original version did not have the help system
|
|
|
|
if (!(getFeatures() & GF_ME))
|
|
|
|
return;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
// TODO: Help File contains 5 cards i.e. VIEW, RLST, etc.
|
|
|
|
// in addition to HELP resources.
|
|
|
|
// These are Ids 9930 to 9934
|
|
|
|
// Need to deal with loading and displaying these..
|
|
|
|
// Current engine structure only supports display of
|
|
|
|
// card from primary stack MHK
|
|
|
|
|
|
|
|
debugC(kDebugHelp, "Loading Help System Data");
|
|
|
|
|
2010-11-30 15:07:00 +00:00
|
|
|
Common::SeekableReadStream *helpStream = getResource(ID_HELP, id);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
uint16 count = helpStream->readUint16LE();
|
|
|
|
uint16 *u0 = new uint16[count];
|
2009-12-30 23:01:16 +00:00
|
|
|
Common::String helpText;
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
debugC(kDebugHelp, "\tcount: %d", count);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
for (uint16 i = 0; i < count; i++) {
|
|
|
|
u0[i] = helpStream->readUint16LE();
|
|
|
|
debugC(kDebugHelp, "\tu0[%d]: %d", i, u0[i]);
|
|
|
|
}
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
// TODO: Previous values i.e. u0[0] to u0[count - 2]
|
|
|
|
// appear to be resource ids in the help.dat file..
|
|
|
|
if (u0[count - 1] != count)
|
|
|
|
warning("loadHelp(): last u0 value is not equal to count");
|
|
|
|
|
|
|
|
do {
|
|
|
|
helpText += helpStream->readByte();
|
|
|
|
} while (helpText.lastChar() != 0);
|
|
|
|
helpText.deleteLastChar();
|
|
|
|
|
|
|
|
debugC(kDebugHelp, "\thelpText: \"%s\"", helpText.c_str());
|
|
|
|
|
|
|
|
delete[] u0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::loadCursorHints() {
|
|
|
|
for (uint16 i = 0; i < _cursorHintCount; i++)
|
|
|
|
delete[] _cursorHints[i].variableHint.values;
|
|
|
|
_cursorHintCount = 0;
|
|
|
|
delete[] _cursorHints;
|
|
|
|
_cursorHints = NULL;
|
|
|
|
|
|
|
|
if (!_view.hint) {
|
|
|
|
debugC(kDebugHint, "No HINT Present");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
debugC(kDebugHint, "Loading Cursor Hints:");
|
|
|
|
|
2010-11-30 15:07:00 +00:00
|
|
|
Common::SeekableReadStream *hintStream = getResource(ID_HINT, _curCard);
|
2009-12-29 23:18:24 +00:00
|
|
|
_cursorHintCount = hintStream->readUint16LE();
|
|
|
|
debugC(kDebugHint, "Cursor Hint Count: %d", _cursorHintCount);
|
|
|
|
_cursorHints = new MystCursorHint[_cursorHintCount];
|
|
|
|
|
|
|
|
for (uint16 i = 0; i < _cursorHintCount; i++) {
|
|
|
|
debugC(kDebugHint, "Cursor Hint %d:", i);
|
|
|
|
_cursorHints[i].id = hintStream->readUint16LE();
|
|
|
|
debugC(kDebugHint, "\tId: %d", _cursorHints[i].id);
|
|
|
|
_cursorHints[i].cursor = hintStream->readSint16LE();
|
|
|
|
debugC(kDebugHint, "\tCursor: %d", _cursorHints[i].cursor);
|
|
|
|
|
|
|
|
if (_cursorHints[i].cursor == -1) {
|
|
|
|
debugC(kDebugHint, "\tConditional Cursor Hints:");
|
|
|
|
_cursorHints[i].variableHint.var = hintStream->readUint16LE();
|
|
|
|
debugC(kDebugHint, "\tVar: %d", _cursorHints[i].variableHint.var);
|
|
|
|
_cursorHints[i].variableHint.numStates = hintStream->readUint16LE();
|
|
|
|
debugC(kDebugHint, "\tNumber of States: %d", _cursorHints[i].variableHint.numStates);
|
|
|
|
_cursorHints[i].variableHint.values = new uint16[_cursorHints[i].variableHint.numStates];
|
|
|
|
for (uint16 j = 0; j < _cursorHints[i].variableHint.numStates; j++) {
|
|
|
|
_cursorHints[i].variableHint.values[j] = hintStream->readUint16LE();
|
|
|
|
debugC(kDebugHint, "\t\t State %d: Cursor %d", j, _cursorHints[i].variableHint.values[j]);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
_cursorHints[i].variableHint.var = 0;
|
|
|
|
_cursorHints[i].variableHint.numStates = 0;
|
|
|
|
_cursorHints[i].variableHint.values = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
delete hintStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::setMainCursor(uint16 cursor) {
|
|
|
|
_currentCursor = _mainCursor = cursor;
|
2010-11-25 04:49:11 +00:00
|
|
|
_cursor->setCursor(_currentCursor);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::checkCursorHints() {
|
2010-12-07 19:41:49 +00:00
|
|
|
if (!_view.hint) {
|
|
|
|
// Default to the main cursor when no hints are present
|
|
|
|
if (_currentCursor != _mainCursor) {
|
|
|
|
_currentCursor = _mainCursor;
|
|
|
|
_cursor->setCursor(_currentCursor);
|
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
return;
|
2010-12-07 19:41:49 +00:00
|
|
|
}
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
// Check all the cursor hints to see if we're in a hotspot that contains a hint.
|
|
|
|
for (uint16 i = 0; i < _cursorHintCount; i++)
|
|
|
|
if (_cursorHints[i].id == _curResource && _resources[_cursorHints[i].id]->isEnabled()) {
|
|
|
|
if (_cursorHints[i].cursor == -1) {
|
2010-11-29 20:49:42 +00:00
|
|
|
uint16 var_value = _scriptParser->getVar(_cursorHints[i].variableHint.var);
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
if (var_value >= _cursorHints[i].variableHint.numStates)
|
|
|
|
warning("Variable %d Out of Range in variable HINT Resource %d", _cursorHints[i].variableHint.var, i);
|
|
|
|
else {
|
|
|
|
_currentCursor = _cursorHints[i].variableHint.values[var_value];
|
|
|
|
if (_currentCursor == 0)
|
|
|
|
_currentCursor = _mainCursor;
|
2010-11-25 04:49:11 +00:00
|
|
|
_cursor->setCursor(_currentCursor);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
} else if (_currentCursor != _cursorHints[i].cursor) {
|
|
|
|
if (_cursorHints[i].cursor == 0)
|
|
|
|
_currentCursor = _mainCursor;
|
|
|
|
else
|
|
|
|
_currentCursor = _cursorHints[i].cursor;
|
|
|
|
|
2010-11-25 04:49:11 +00:00
|
|
|
_cursor->setCursor(_currentCursor);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_currentCursor != _mainCursor) {
|
|
|
|
_currentCursor = _mainCursor;
|
2010-11-25 04:49:11 +00:00
|
|
|
_cursor->setCursor(_currentCursor);
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::setResourceEnabled(uint16 resourceId, bool enable) {
|
|
|
|
if (resourceId < _resources.size()) {
|
|
|
|
_resources[resourceId]->setEnabled(enable);
|
|
|
|
} else
|
|
|
|
warning("Attempt to change unknown resource enable state");
|
|
|
|
}
|
|
|
|
|
2010-11-17 19:58:19 +00:00
|
|
|
void MohawkEngine_Myst::drawResourceImages() {
|
|
|
|
for (uint16 i = 0; i < _resources.size(); i++)
|
2010-11-29 20:56:39 +00:00
|
|
|
if (_resources[i]->isDrawSubimages())
|
2010-11-17 19:58:19 +00:00
|
|
|
_resources[i]->drawDataToScreen();
|
|
|
|
}
|
|
|
|
|
2011-01-03 20:40:07 +00:00
|
|
|
void MohawkEngine_Myst::redrawResource(MystResourceType8 *resource, bool update) {
|
|
|
|
resource->drawConditionalDataToScreen(_scriptParser->getVar(resource->getType8Var()), update);
|
2010-11-29 20:54:36 +00:00
|
|
|
}
|
|
|
|
|
2010-12-11 17:00:22 +00:00
|
|
|
void MohawkEngine_Myst::redrawArea(uint16 var, bool update) {
|
2010-11-29 20:54:36 +00:00
|
|
|
for (uint16 i = 0; i < _resources.size(); i++)
|
2010-11-29 21:00:23 +00:00
|
|
|
if (_resources[i]->type == kMystConditionalImage && _resources[i]->getType8Var() == var)
|
2010-12-11 17:00:22 +00:00
|
|
|
redrawResource(static_cast<MystResourceType8 *>(_resources[i]), update);
|
2010-11-29 20:54:36 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 20:51:04 +00:00
|
|
|
MystResource *MohawkEngine_Myst::loadResource(Common::SeekableReadStream *rlstStream, MystResource *parent) {
|
2010-11-29 20:50:11 +00:00
|
|
|
MystResource *resource = 0;
|
2010-11-29 21:00:23 +00:00
|
|
|
ResourceType type = static_cast<ResourceType>(rlstStream->readUint16LE());
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
debugC(kDebugResource, "\tType: %d", type);
|
|
|
|
debugC(kDebugResource, "\tSub_Record: %d", (parent == NULL) ? 0 : 1);
|
|
|
|
|
|
|
|
switch (type) {
|
2010-11-29 21:00:23 +00:00
|
|
|
case kMystAction:
|
2010-11-29 20:51:04 +00:00
|
|
|
resource = new MystResourceType5(this, rlstStream, parent);
|
2010-11-29 20:50:11 +00:00
|
|
|
break;
|
2010-11-29 21:00:23 +00:00
|
|
|
case kMystVideo:
|
2010-11-29 20:51:04 +00:00
|
|
|
resource = new MystResourceType6(this, rlstStream, parent);
|
2010-11-29 20:50:11 +00:00
|
|
|
break;
|
2010-11-29 21:00:23 +00:00
|
|
|
case kMystSwitch:
|
2010-11-29 20:51:04 +00:00
|
|
|
resource = new MystResourceType7(this, rlstStream, parent);
|
2010-11-29 20:50:11 +00:00
|
|
|
break;
|
2010-11-29 21:00:23 +00:00
|
|
|
case kMystConditionalImage:
|
2010-11-29 20:51:04 +00:00
|
|
|
resource = new MystResourceType8(this, rlstStream, parent);
|
2010-11-29 20:50:11 +00:00
|
|
|
break;
|
2010-11-29 21:00:23 +00:00
|
|
|
case kMystSlider:
|
2010-11-29 20:51:04 +00:00
|
|
|
resource = new MystResourceType10(this, rlstStream, parent);
|
2010-11-29 20:50:11 +00:00
|
|
|
break;
|
2010-11-29 21:00:23 +00:00
|
|
|
case kMystDragArea:
|
2010-11-29 20:51:04 +00:00
|
|
|
resource = new MystResourceType11(this, rlstStream, parent);
|
2010-11-29 20:50:11 +00:00
|
|
|
break;
|
2010-11-29 21:03:02 +00:00
|
|
|
case kMystVideoInfo:
|
2010-11-29 20:51:04 +00:00
|
|
|
resource = new MystResourceType12(this, rlstStream, parent);
|
2010-11-29 20:50:11 +00:00
|
|
|
break;
|
2010-11-29 21:00:23 +00:00
|
|
|
case kMystHoverArea:
|
2010-11-29 20:51:04 +00:00
|
|
|
resource = new MystResourceType13(this, rlstStream, parent);
|
2010-11-29 20:50:11 +00:00
|
|
|
break;
|
2009-12-30 07:14:09 +00:00
|
|
|
default:
|
2010-11-29 21:00:23 +00:00
|
|
|
resource = new MystResource(this, rlstStream, parent);
|
|
|
|
break;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
2010-11-29 20:50:11 +00:00
|
|
|
|
|
|
|
resource->type = type;
|
|
|
|
|
|
|
|
return resource;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MohawkEngine_Myst::loadResources() {
|
2011-01-03 20:40:07 +00:00
|
|
|
for (uint32 i = 0; i < _resources.size(); i++)
|
|
|
|
delete _resources[i];
|
|
|
|
|
|
|
|
_resources.clear();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
|
|
|
if (!_view.rlst) {
|
|
|
|
debugC(kDebugResource, "No RLST present");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-11-30 15:07:00 +00:00
|
|
|
Common::SeekableReadStream *rlstStream = getResource(ID_RLST, _view.rlst);
|
2009-12-29 23:18:24 +00:00
|
|
|
uint16 resourceCount = rlstStream->readUint16LE();
|
|
|
|
debugC(kDebugResource, "RLST Resource Count: %d", resourceCount);
|
|
|
|
|
|
|
|
for (uint16 i = 0; i < resourceCount; i++) {
|
|
|
|
debugC(kDebugResource, "Resource #%d:", i);
|
2010-11-29 20:51:04 +00:00
|
|
|
_resources.push_back(loadResource(rlstStream, NULL));
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
2011-01-03 20:40:07 +00:00
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
delete rlstStream;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::Error MohawkEngine_Myst::loadGameState(int slot) {
|
2010-12-26 14:31:03 +00:00
|
|
|
if (_gameState->load(_gameState->generateSaveGameList()[slot]))
|
2009-12-29 23:18:24 +00:00
|
|
|
return Common::kNoError;
|
2010-12-07 18:21:05 +00:00
|
|
|
|
|
|
|
return Common::kUnknownError;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2011-06-02 12:11:38 +00:00
|
|
|
Common::Error MohawkEngine_Myst::saveGameState(int slot, const Common::String &desc) {
|
2010-12-26 14:31:03 +00:00
|
|
|
Common::StringArray saveList = _gameState->generateSaveGameList();
|
2009-12-29 23:18:24 +00:00
|
|
|
|
2010-01-25 01:39:44 +00:00
|
|
|
if ((uint)slot < saveList.size())
|
2010-12-26 14:31:03 +00:00
|
|
|
_gameState->deleteSave(saveList[slot]);
|
2010-01-25 01:39:44 +00:00
|
|
|
|
2010-12-26 14:31:03 +00:00
|
|
|
return _gameState->save(Common::String(desc)) ? Common::kNoError : Common::kUnknownError;
|
2009-12-29 23:18:24 +00:00
|
|
|
}
|
|
|
|
|
2010-12-07 18:15:07 +00:00
|
|
|
bool MohawkEngine_Myst::canLoadGameStateCurrently() {
|
|
|
|
// No loading in the demo/makingof
|
|
|
|
return !(getFeatures() & GF_DEMO) && getGameType() != GType_MAKINGOF;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool MohawkEngine_Myst::canSaveGameStateCurrently() {
|
|
|
|
// There's a limited number of stacks the game can save in
|
|
|
|
switch (_curStack) {
|
|
|
|
case kChannelwoodStack:
|
|
|
|
case kDniStack:
|
|
|
|
case kMechanicalStack:
|
|
|
|
case kMystStack:
|
|
|
|
case kSeleniticStack:
|
|
|
|
case kStoneshipStack:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-05-14 17:26:33 +00:00
|
|
|
void MohawkEngine_Myst::dropPage() {
|
|
|
|
uint16 page = _gameState->_globals.heldPage;
|
|
|
|
bool whitePage = page == 13;
|
|
|
|
bool bluePage = page - 1 < 6;
|
|
|
|
bool redPage = page - 7 < 6;
|
|
|
|
|
2011-05-15 11:24:32 +00:00
|
|
|
// Play drop page sound
|
|
|
|
_sound->replaceSoundMyst(800);
|
|
|
|
|
2011-05-14 17:26:33 +00:00
|
|
|
// Drop page
|
|
|
|
_gameState->_globals.heldPage = 0;
|
|
|
|
|
|
|
|
// Redraw page area
|
|
|
|
if (whitePage && _gameState->_globals.currentAge == 2) {
|
|
|
|
redrawArea(41);
|
|
|
|
} else if (bluePage) {
|
|
|
|
if (page == 6) {
|
|
|
|
if (_gameState->_globals.currentAge == 2)
|
|
|
|
redrawArea(24);
|
|
|
|
} else {
|
|
|
|
redrawArea(103);
|
|
|
|
}
|
|
|
|
} else if (redPage) {
|
|
|
|
if (page == 12) {
|
|
|
|
if (_gameState->_globals.currentAge == 2)
|
|
|
|
redrawArea(25);
|
|
|
|
} else if (page == 10) {
|
|
|
|
if (_gameState->_globals.currentAge == 1)
|
|
|
|
redrawArea(35);
|
|
|
|
} else {
|
|
|
|
redrawArea(102);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
setMainCursor(kDefaultMystCursor);
|
|
|
|
checkCursorHints();
|
|
|
|
}
|
|
|
|
|
2009-12-29 23:18:24 +00:00
|
|
|
} // End of namespace Mohawk
|