2007-05-30 21:56:52 +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.
|
2007-01-14 21:29:12 +00: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 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2007-02-21 21:42:37 +00:00
|
|
|
#include "common/config-manager.h"
|
2007-03-17 00:53:21 +00:00
|
|
|
#include "common/events.h"
|
|
|
|
#include "common/file.h"
|
|
|
|
#include "common/util.h"
|
2007-02-21 21:42:37 +00:00
|
|
|
|
|
|
|
#include "sound/mididrv.h"
|
|
|
|
#include "sound/mixer.h"
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
#include "parallaction/parallaction.h"
|
2007-05-06 08:52:27 +00:00
|
|
|
#include "parallaction/debug.h"
|
2007-05-01 16:21:16 +00:00
|
|
|
#include "parallaction/sound.h"
|
2007-05-13 14:38:05 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace Parallaction {
|
|
|
|
|
|
|
|
// FIXME: remove this
|
|
|
|
Parallaction *_vm = NULL;
|
|
|
|
|
|
|
|
// public stuff
|
2007-03-18 17:22:07 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
uint16 _mouseButtons = 0;
|
|
|
|
|
|
|
|
|
|
|
|
char _saveData1[30] = { '\0' };
|
|
|
|
uint16 _language = 0;
|
2007-03-11 14:14:08 +00:00
|
|
|
char _slideText[2][40];
|
2007-01-14 21:29:12 +00:00
|
|
|
uint32 _engineFlags = 0;
|
2007-03-11 00:04:50 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
uint16 _score = 1;
|
2007-10-13 21:49:38 +00:00
|
|
|
char _password[8];
|
2007-03-11 14:14:08 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
Command * _forwardedCommands[20] = {
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
|
|
|
char _forwardedAnimationNames[20][20];
|
|
|
|
uint16 _numForwards = 0;
|
2007-03-11 13:01:11 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
uint32 _commandFlags = 0;
|
|
|
|
uint16 _introSarcData3 = 200;
|
|
|
|
uint16 _introSarcData2 = 1;
|
|
|
|
|
|
|
|
// private stuff
|
|
|
|
|
2007-03-11 00:04:50 +00:00
|
|
|
|
2007-11-03 21:06:58 +00:00
|
|
|
Parallaction::Parallaction(OSystem *syst, const PARALLACTIONGameDescription *gameDesc) :
|
|
|
|
Engine(syst), _gameDescription(gameDesc), _char(this) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-09-11 09:20:39 +00:00
|
|
|
// FIXME: Fingolfin asks: why is there a FIXME here? Please either clarify what
|
|
|
|
// needs fixing, or remove it!
|
2007-01-14 21:29:12 +00:00
|
|
|
// FIXME
|
2007-07-29 21:08:39 +00:00
|
|
|
_vm = this;
|
2007-06-23 14:10:44 +00:00
|
|
|
|
2007-06-18 20:11:49 +00:00
|
|
|
_mouseHidden = false;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
Common::File::addDefaultDirectory( _gameDataPath );
|
|
|
|
|
2007-02-17 15:37:49 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugDialogue, "dialogue", "Dialogues debug level");
|
2007-09-16 08:43:34 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugParser, "parser", "Parser debug level");
|
2007-01-26 23:24:12 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugDisk, "disk", "Disk debug level");
|
|
|
|
Common::addSpecialDebugLevel(kDebugWalk, "walk", "Walk debug level");
|
2007-02-04 15:43:45 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugGraphics, "gfx", "Gfx debug level");
|
2007-09-16 08:43:34 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugExec, "exec", "Execution debug level");
|
2007-02-18 09:33:53 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugInput, "input", "Input debug level");
|
2007-05-12 12:56:35 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugAudio, "audio", "Audio debug level");
|
2007-05-13 12:41:42 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugMenu, "menu", "Menu debug level");
|
2007-10-21 13:10:36 +00:00
|
|
|
Common::addSpecialDebugLevel(kDebugInventory, "inventory", "Inventory debug level");
|
2007-09-19 13:55:05 +00:00
|
|
|
|
|
|
|
syst->getEventManager()->registerRandomSource(_rnd, "parallaction");
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Parallaction::~Parallaction() {
|
2007-05-06 08:52:27 +00:00
|
|
|
delete _debugger;
|
|
|
|
|
2007-08-11 13:07:21 +00:00
|
|
|
freeBackground();
|
2007-08-12 17:13:21 +00:00
|
|
|
delete _backgroundInfo;
|
2007-08-11 13:07:21 +00:00
|
|
|
|
2007-03-24 21:18:08 +00:00
|
|
|
delete _globalTable;
|
|
|
|
|
|
|
|
delete _callableNames;
|
2007-08-26 09:01:19 +00:00
|
|
|
delete _localFlagNames;
|
2007-03-24 21:18:08 +00:00
|
|
|
delete _zoneTypeNames;
|
|
|
|
delete _zoneFlagNames;
|
|
|
|
|
2007-06-05 11:49:01 +00:00
|
|
|
_animations.remove(&_char._ani);
|
2007-06-15 21:40:02 +00:00
|
|
|
|
2007-05-21 21:06:30 +00:00
|
|
|
freeLocation();
|
2007-06-15 21:40:02 +00:00
|
|
|
|
2007-05-21 21:06:30 +00:00
|
|
|
freeCharacter();
|
|
|
|
destroyInventory();
|
2007-06-05 11:49:01 +00:00
|
|
|
|
|
|
|
delete _gfx;
|
|
|
|
delete _soundMan;
|
2007-06-15 21:40:02 +00:00
|
|
|
delete _disk;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int Parallaction::init() {
|
|
|
|
|
2007-07-29 14:32:30 +00:00
|
|
|
_engineFlags = 0;
|
2007-03-24 21:18:08 +00:00
|
|
|
_objectsNames = NULL;
|
|
|
|
_globalTable = NULL;
|
2007-07-08 08:13:32 +00:00
|
|
|
_hasLocationSound = false;
|
2007-03-24 17:14:04 +00:00
|
|
|
_transCurrentHoverItem = 0;
|
|
|
|
_actionAfterWalk = false; // actived when the character needs to move before taking an action
|
|
|
|
_activeItem._index = 0;
|
|
|
|
_activeItem._id = 0;
|
|
|
|
_procCurrentHoverItem = -1;
|
|
|
|
_baseTime = 0;
|
2007-07-29 14:32:30 +00:00
|
|
|
_numLocations = 0;
|
|
|
|
_location._startPosition.x = -1000;
|
|
|
|
_location._startPosition.y = -1000;
|
|
|
|
_location._startFrame = 0;
|
|
|
|
_location._comment = NULL;
|
|
|
|
_location._endComment = NULL;
|
2007-03-24 17:14:04 +00:00
|
|
|
|
2007-08-11 13:07:21 +00:00
|
|
|
_backgroundInfo = 0;
|
2007-08-11 13:13:56 +00:00
|
|
|
_pathBuffer = 0;
|
2007-08-24 20:14:51 +00:00
|
|
|
_activeZone = 0;
|
2007-08-11 13:13:56 +00:00
|
|
|
|
2007-07-26 18:30:27 +00:00
|
|
|
_screenSize = _screenWidth * _screenHeight;
|
2007-08-11 13:13:56 +00:00
|
|
|
|
2007-08-12 17:13:21 +00:00
|
|
|
_backgroundInfo = new BackgroundInfo;
|
2007-07-26 18:30:27 +00:00
|
|
|
|
2007-07-29 14:32:30 +00:00
|
|
|
strcpy(_characterName1, "null");
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-26 09:01:19 +00:00
|
|
|
memset(_locationNames, 0, NUM_LOCATIONS * 32);
|
2007-03-11 14:14:08 +00:00
|
|
|
|
2007-07-29 14:32:30 +00:00
|
|
|
initInventory(); // needs to be pushed into subclass
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-08-25 20:34:10 +00:00
|
|
|
_hoverZone = NULL;
|
|
|
|
|
2007-07-29 19:17:53 +00:00
|
|
|
_animations.push_front(&_char._ani);
|
2007-03-12 20:41:25 +00:00
|
|
|
_gfx = new Gfx(this);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-05-06 08:52:27 +00:00
|
|
|
_debugger = new Debugger(this);
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-02-17 15:57:49 +00:00
|
|
|
// FIXME: the engine has 3 event loops. The following routine hosts the main one,
|
|
|
|
// and it's called from 8 different places in the code. There exist 2 more specialised
|
|
|
|
// loops which could possibly be merged into this one with some effort in changing
|
|
|
|
// caller code, i.e. adding condition checks.
|
2007-01-14 21:29:12 +00:00
|
|
|
//
|
2007-11-17 09:39:20 +00:00
|
|
|
uint16 Parallaction::readInput() {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
Common::Event e;
|
2007-01-14 21:29:12 +00:00
|
|
|
uint16 KeyDown = 0;
|
|
|
|
|
|
|
|
_mouseButtons = kMouseNone;
|
|
|
|
|
2007-03-17 00:53:21 +00:00
|
|
|
Common::EventManager *eventMan = _system->getEventManager();
|
|
|
|
while (eventMan->pollEvent(e)) {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
switch (e.type) {
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_KEYDOWN:
|
2007-05-06 08:52:27 +00:00
|
|
|
if (e.kbd.flags == Common::KBD_CTRL && e.kbd.keycode == 'd')
|
|
|
|
_debugger->attach();
|
2007-06-15 21:40:02 +00:00
|
|
|
if (getFeatures() & GF_DEMO) break;
|
2007-06-23 14:19:54 +00:00
|
|
|
if (e.kbd.keycode == Common::KEYCODE_l) KeyDown = kEvLoadGame;
|
|
|
|
if (e.kbd.keycode == Common::KEYCODE_s) KeyDown = kEvSaveGame;
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
2007-01-14 21:29:12 +00:00
|
|
|
_mouseButtons = kMouseLeftDown;
|
|
|
|
break;
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_LBUTTONUP:
|
2007-01-14 21:29:12 +00:00
|
|
|
_mouseButtons = kMouseLeftUp;
|
|
|
|
break;
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
2007-01-14 21:29:12 +00:00
|
|
|
_mouseButtons = kMouseRightDown;
|
|
|
|
break;
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_RBUTTONUP:
|
2007-01-14 21:29:12 +00:00
|
|
|
_mouseButtons = kMouseRightUp;
|
|
|
|
break;
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_MOUSEMOVE:
|
2007-03-18 17:22:07 +00:00
|
|
|
_mousePos = e.mouse;
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
2007-03-17 19:02:05 +00:00
|
|
|
case Common::EVENT_QUIT:
|
2007-10-27 21:29:38 +00:00
|
|
|
// TODO: don't quit() here, just have caller routines to check
|
|
|
|
// on kEngineQuit and exit gracefully to allow the engine to shut down
|
2007-05-21 21:06:30 +00:00
|
|
|
_engineFlags |= kEngineQuit;
|
2007-06-16 10:47:27 +00:00
|
|
|
g_system->quit();
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-05-06 08:52:27 +00:00
|
|
|
if (_debugger->isAttached())
|
|
|
|
_debugger->onFrame();
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
return KeyDown;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
// FIXME: see comment for readInput()
|
2007-01-14 21:29:12 +00:00
|
|
|
void waitUntilLeftClick() {
|
|
|
|
|
2007-11-01 21:23:48 +00:00
|
|
|
do {
|
2007-11-17 09:39:20 +00:00
|
|
|
_vm->readInput();
|
2007-07-28 13:27:48 +00:00
|
|
|
_vm->_gfx->updateScreen();
|
2007-07-28 14:21:16 +00:00
|
|
|
g_system->delayMillis(30);
|
2007-11-01 21:23:48 +00:00
|
|
|
} while (_mouseButtons != kMouseLeftUp);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction::runGame() {
|
|
|
|
|
2007-11-22 21:19:44 +00:00
|
|
|
_inputMode = kInputModeGame;
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
while ((_engineFlags & kEngineQuit) == 0) {
|
2007-11-17 09:39:20 +00:00
|
|
|
updateInput();
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
if (_activeZone) {
|
|
|
|
Zone *z = _activeZone; // speak Zone or sound
|
|
|
|
_activeZone = NULL;
|
2007-11-18 13:22:38 +00:00
|
|
|
runZone(z);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (_engineFlags & kEngineChangeLocation) {
|
2007-03-11 14:14:08 +00:00
|
|
|
changeLocation(_location._name);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-11-22 21:19:44 +00:00
|
|
|
if (_inputMode == kInputModeGame) {
|
|
|
|
eraseAnimations();
|
|
|
|
runScripts();
|
|
|
|
walk();
|
|
|
|
runJobs();
|
|
|
|
drawAnimations();
|
|
|
|
}
|
2007-11-18 21:16:27 +00:00
|
|
|
|
2007-11-14 22:24:26 +00:00
|
|
|
updateView();
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-11-14 22:24:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::updateView() {
|
|
|
|
|
|
|
|
if ((_engineFlags & kEnginePauseJobs) && (_engineFlags & kEngineInventory) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_gfx->animatePalette();
|
|
|
|
_gfx->swapBuffers();
|
|
|
|
g_system->delayMillis(30);
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction::processInput(InputData *data) {
|
|
|
|
|
|
|
|
switch (data->_event) {
|
|
|
|
case kEvEnterZone:
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(2, kDebugInput, "processInput: kEvEnterZone");
|
2007-11-21 20:04:14 +00:00
|
|
|
_gfx->setLabel(data->_label);
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvExitZone:
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(2, kDebugInput, "processInput: kEvExitZone");
|
2007-11-21 20:04:14 +00:00
|
|
|
_gfx->setLabel(0);
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvAction:
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(2, kDebugInput, "processInput: kEvAction");
|
2007-01-14 21:29:12 +00:00
|
|
|
_procCurrentHoverItem = -1;
|
|
|
|
_hoverZone = NULL;
|
|
|
|
pauseJobs();
|
2007-11-18 13:22:38 +00:00
|
|
|
runZone(data->_zone);
|
2007-01-14 21:29:12 +00:00
|
|
|
resumeJobs();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvOpenInventory:
|
|
|
|
_procCurrentHoverItem = -1;
|
2007-02-04 08:12:33 +00:00
|
|
|
_hoverZone = NULL;
|
2007-11-21 20:04:14 +00:00
|
|
|
_gfx->setLabel(0);
|
2007-09-02 18:34:11 +00:00
|
|
|
if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) == 0) {
|
2007-09-23 20:17:50 +00:00
|
|
|
setArrowCursor();
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
2007-11-19 20:23:01 +00:00
|
|
|
pauseJobs();
|
2007-01-14 21:29:12 +00:00
|
|
|
openInventory();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvCloseInventory: // closes inventory and possibly select item
|
|
|
|
closeInventory();
|
2007-09-23 20:17:50 +00:00
|
|
|
setInventoryCursor(data->_inventoryIndex);
|
2007-11-19 20:23:01 +00:00
|
|
|
resumeJobs();
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvHoverInventory:
|
|
|
|
highlightInventoryItem(_procCurrentHoverItem, 12); // disable
|
2007-01-15 20:11:49 +00:00
|
|
|
highlightInventoryItem(data->_inventoryIndex, 19); // enable
|
|
|
|
_procCurrentHoverItem = data->_inventoryIndex;
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
2007-09-23 20:17:50 +00:00
|
|
|
case kEvWalk:
|
2007-02-18 09:33:53 +00:00
|
|
|
debugC(2, kDebugInput, "processInput: kEvWalk");
|
2007-02-04 08:12:33 +00:00
|
|
|
_hoverZone = NULL;
|
2007-09-23 20:17:50 +00:00
|
|
|
setArrowCursor();
|
2007-09-22 18:45:43 +00:00
|
|
|
_char.scheduleWalk(data->_mousePos.x, data->_mousePos.y);
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvQuitGame:
|
|
|
|
_engineFlags |= kEngineQuit;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvSaveGame:
|
|
|
|
_hoverZone = NULL;
|
|
|
|
saveGame();
|
2007-09-23 20:17:50 +00:00
|
|
|
setArrowCursor();
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case kEvLoadGame:
|
|
|
|
_hoverZone = NULL;
|
|
|
|
loadGame();
|
2007-09-23 20:17:50 +00:00
|
|
|
setArrowCursor();
|
2007-01-14 21:29:12 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
|
|
|
|
|
2007-11-22 21:19:44 +00:00
|
|
|
void Parallaction::updateGameInput() {
|
2007-11-17 09:39:20 +00:00
|
|
|
|
2007-11-18 13:22:38 +00:00
|
|
|
int16 keyDown = readInput();
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-14 22:24:26 +00:00
|
|
|
debugC(3, kDebugInput, "translateInput: input flags (%i, %i, %i, %i)",
|
|
|
|
!_mouseHidden,
|
|
|
|
(_engineFlags & kEngineBlockInput) == 0,
|
|
|
|
(_engineFlags & kEngineWalking) == 0,
|
|
|
|
(_engineFlags & kEngineChangeLocation) == 0
|
|
|
|
);
|
|
|
|
|
|
|
|
if ((_mouseHidden) ||
|
|
|
|
(_engineFlags & kEngineBlockInput) ||
|
|
|
|
(_engineFlags & kEngineWalking) ||
|
|
|
|
(_engineFlags & kEngineChangeLocation)) {
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
return;
|
2007-11-14 22:24:26 +00:00
|
|
|
}
|
|
|
|
|
2007-11-18 13:22:38 +00:00
|
|
|
if (keyDown == kEvQuitGame) {
|
2007-01-14 21:29:12 +00:00
|
|
|
_input._event = kEvQuitGame;
|
2007-11-17 09:39:20 +00:00
|
|
|
} else
|
2007-11-18 13:22:38 +00:00
|
|
|
if (keyDown == kEvSaveGame) {
|
2007-01-14 21:29:12 +00:00
|
|
|
_input._event = kEvSaveGame;
|
2007-11-17 09:39:20 +00:00
|
|
|
} else
|
2007-11-18 13:22:38 +00:00
|
|
|
if (keyDown == kEvLoadGame) {
|
2007-01-14 21:29:12 +00:00
|
|
|
_input._event = kEvLoadGame;
|
2007-11-17 09:39:20 +00:00
|
|
|
} else {
|
|
|
|
_input._mousePos = _mousePos;
|
|
|
|
_input._event = kEvNone;
|
|
|
|
if (!translateGameInput()) {
|
|
|
|
translateInventoryInput();
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if (_input._event != kEvNone)
|
|
|
|
processInput(&_input);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-22 21:19:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::updateCommentInput() {
|
|
|
|
waitUntilLeftClick();
|
|
|
|
|
|
|
|
_gfx->hideDialogueStuff();
|
2007-11-22 21:51:33 +00:00
|
|
|
_gfx->setHalfbriteMode(false);
|
|
|
|
|
2007-11-22 21:19:44 +00:00
|
|
|
_inputMode = kInputModeGame;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::updateInput() {
|
|
|
|
|
|
|
|
switch (_inputMode) {
|
|
|
|
case kInputModeComment:
|
|
|
|
updateCommentInput();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case kInputModeGame:
|
|
|
|
updateGameInput();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
bool Parallaction::translateGameInput() {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if ((_engineFlags & kEnginePauseJobs) || (_engineFlags & kEngineInventory)) {
|
|
|
|
return false;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if (_actionAfterWalk) {
|
|
|
|
// if walking is over, then take programmed action
|
|
|
|
_input._event = kEvAction;
|
|
|
|
_actionAfterWalk = false;
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if (_mouseButtons == kMouseRightDown) {
|
|
|
|
// right button down shows inventory
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if (hitZone(kZoneYou, _mousePos.x, _mousePos.y) && (_activeItem._id != 0)) {
|
|
|
|
_activeItem._index = (_activeItem._id >> 16) & 0xFFFF;
|
|
|
|
_engineFlags |= kEngineDragging;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
_input._event = kEvOpenInventory;
|
|
|
|
_transCurrentHoverItem = -1;
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
// test if mouse is hovering on an interactive zone for the currently selected inventory item
|
|
|
|
Zone *z = hitZone(_activeItem._id, _mousePos.x, _mousePos.y);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if (((_mouseButtons == kMouseLeftUp) && (_activeItem._id == 0) && ((_engineFlags & kEngineWalking) == 0)) && ((z == NULL) || ((z->_type & 0xFFFF) != kZoneCommand))) {
|
|
|
|
_input._event = kEvWalk;
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if ((z != _hoverZone) && (_hoverZone != NULL)) {
|
|
|
|
_hoverZone = NULL;
|
|
|
|
_input._event = kEvExitZone;
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if (z == NULL) {
|
|
|
|
_input._event = kEvNone;
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if ((_hoverZone == NULL) && ((z->_flags & kFlagsNoName) == 0)) {
|
|
|
|
_hoverZone = z;
|
|
|
|
_input._event = kEvEnterZone;
|
|
|
|
_input._label = &z->_label;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((_mouseButtons == kMouseLeftUp) && ((_activeItem._id != 0) || ((z->_type & 0xFFFF) == kZoneCommand))) {
|
|
|
|
|
|
|
|
_input._zone = z;
|
|
|
|
if (z->_flags & kFlagsNoWalk) {
|
|
|
|
// character doesn't need to walk to take specified action
|
|
|
|
_input._event = kEvAction;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// action delayed: if Zone defined a moveto position the character is programmed to move there,
|
|
|
|
// else it will move to the mouse position
|
|
|
|
_input._event = kEvWalk;
|
|
|
|
_actionAfterWalk = true;
|
|
|
|
if (z->_moveTo.y != 0) {
|
|
|
|
_input._mousePos = z->_moveTo;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
beep();
|
|
|
|
setArrowCursor();
|
|
|
|
return true;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Parallaction::translateInventoryInput() {
|
|
|
|
|
|
|
|
if ((_engineFlags & kEngineInventory) == 0) {
|
|
|
|
return false;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
// in inventory
|
2007-03-18 17:22:07 +00:00
|
|
|
int16 _si = getHoverInventoryItem(_mousePos.x, _mousePos.y);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
if (_mouseButtons == kMouseRightUp) {
|
|
|
|
// right up hides inventory
|
|
|
|
|
|
|
|
_input._event = kEvCloseInventory;
|
2007-03-18 17:22:07 +00:00
|
|
|
_input._inventoryIndex = getHoverInventoryItem(_mousePos.x, _mousePos.y);
|
2007-01-14 21:29:12 +00:00
|
|
|
highlightInventoryItem(_transCurrentHoverItem, 12); // disable
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if ((_engineFlags & kEngineDragging) == 0) {
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
_engineFlags &= ~kEngineDragging;
|
2007-09-23 20:17:50 +00:00
|
|
|
Zone *z = hitZone(kZoneMerge, _activeItem._index, getInventoryItemIndex(_input._inventoryIndex));
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
if (z != NULL) {
|
2007-09-23 20:17:50 +00:00
|
|
|
dropItem(z->u.merge->_obj1);
|
|
|
|
dropItem(z->u.merge->_obj2);
|
2007-01-14 21:29:12 +00:00
|
|
|
addInventoryItem(z->u.merge->_obj3);
|
|
|
|
runCommands(z->_commands);
|
|
|
|
}
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
return true;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
if (_si == _transCurrentHoverItem) {
|
|
|
|
_input._event = kEvNone;
|
|
|
|
return true;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
_transCurrentHoverItem = _si;
|
|
|
|
_input._event = kEvHoverInventory;
|
2007-01-15 20:11:49 +00:00
|
|
|
_input._inventoryIndex = _si;
|
2007-11-17 09:39:20 +00:00
|
|
|
return true;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-11-17 09:39:20 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
uint32 Parallaction::getElapsedTime() {
|
|
|
|
return g_system->getMillis() - _baseTime;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::resetTimer() {
|
|
|
|
_baseTime = g_system->getMillis();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction::waitTime(uint32 t) {
|
|
|
|
|
|
|
|
uint32 v4 = 0;
|
|
|
|
|
|
|
|
while (v4 < t * (1000 / 18.2)) {
|
|
|
|
v4 = getElapsedTime();
|
|
|
|
}
|
|
|
|
|
|
|
|
resetTimer();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-06-18 20:11:49 +00:00
|
|
|
void Parallaction::showCursor(bool visible) {
|
|
|
|
_mouseHidden = !visible;
|
|
|
|
g_system->showMouse(visible);
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2007-03-24 21:18:08 +00:00
|
|
|
void Parallaction::freeCharacter() {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(1, kDebugExec, "freeCharacter()");
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-11-18 13:22:38 +00:00
|
|
|
delete _objectsNames;
|
|
|
|
_objectsNames = 0;
|
2007-03-18 10:25:46 +00:00
|
|
|
|
2007-09-22 18:45:43 +00:00
|
|
|
_char.free();
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-07-04 11:17:37 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-10 18:46:34 +00:00
|
|
|
/*
|
|
|
|
helper function to provide *descending* ordering of the job list
|
|
|
|
(higher priorities values comes first in the list)
|
|
|
|
*/
|
|
|
|
int compareJobPriority(const JobPointer &j1, const JobPointer &j2) {
|
2007-09-02 15:17:41 +00:00
|
|
|
return (j1->_job->_tag >= j2->_job->_tag ? -1 : 1);
|
2007-04-10 18:46:34 +00:00
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-09-02 15:17:41 +00:00
|
|
|
Job *Parallaction::addJob(uint functionId, void *parm, uint16 tag) {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(9, kDebugExec, "addJob(%i)", tag);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-18 20:18:19 +00:00
|
|
|
Job *v8 = new Job;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
v8->_parm = parm;
|
|
|
|
v8->_tag = tag;
|
|
|
|
v8->_finished = 0;
|
|
|
|
v8->_count = 0;
|
|
|
|
|
2007-09-02 15:17:41 +00:00
|
|
|
JobOpcode *op = createJobOpcode(functionId, v8);
|
|
|
|
|
|
|
|
_jobs.insertSorted(op, compareJobPriority);
|
2007-04-07 09:31:24 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
return v8;
|
|
|
|
}
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
void Parallaction::removeJob(Job *j) {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(9, kDebugExec, "addJob(%i)", j->_tag);
|
2007-05-13 12:41:42 +00:00
|
|
|
|
2007-04-06 18:44:58 +00:00
|
|
|
j->_finished = 1;
|
2007-01-14 21:29:12 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
void Parallaction::pauseJobs() {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(9, kDebugExec, "pausing jobs execution");
|
2007-05-13 12:41:42 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
_engineFlags |= kEnginePauseJobs;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
void Parallaction::resumeJobs() {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(9, kDebugExec, "resuming jobs execution");
|
2007-05-13 12:41:42 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
_engineFlags &= ~kEnginePauseJobs;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
void Parallaction::runJobs() {
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
if (_engineFlags & kEnginePauseJobs) return;
|
|
|
|
|
2007-04-10 18:46:34 +00:00
|
|
|
JobList::iterator it = _jobs.begin();
|
|
|
|
while (it != _jobs.end()) {
|
2007-09-02 15:17:41 +00:00
|
|
|
Job *job = (*it)->_job;
|
|
|
|
if (job->_finished == 1)
|
2007-04-10 18:46:34 +00:00
|
|
|
it = _jobs.erase(it);
|
|
|
|
else
|
|
|
|
it++;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-04-10 18:46:34 +00:00
|
|
|
it = _jobs.begin();
|
|
|
|
while (it != _jobs.end()) {
|
2007-09-02 15:17:41 +00:00
|
|
|
Job *job = (*it)->_job;
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(9, kDebugExec, "runJobs: %i", job->_tag);
|
2007-09-02 15:17:41 +00:00
|
|
|
(*(*it))();
|
2007-04-10 18:46:34 +00:00
|
|
|
it++;
|
2007-01-14 21:29:12 +00:00
|
|
|
}
|
|
|
|
|
2007-04-10 18:46:34 +00:00
|
|
|
|
2007-02-04 15:43:45 +00:00
|
|
|
return;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-02-19 13:07:18 +00:00
|
|
|
|
2007-08-26 09:01:19 +00:00
|
|
|
|
|
|
|
|
2007-08-24 20:14:51 +00:00
|
|
|
void Parallaction::pushParserTables(OpcodeSet *opcodes, Table *statements) {
|
2007-08-16 19:47:22 +00:00
|
|
|
_opcodes.push(_currentOpcodes);
|
|
|
|
_statements.push(_currentStatements);
|
|
|
|
|
|
|
|
_currentOpcodes = opcodes;
|
|
|
|
_currentStatements = statements;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::popParserTables() {
|
|
|
|
assert(_opcodes.size() > 0);
|
|
|
|
|
|
|
|
_currentOpcodes = _opcodes.pop();
|
|
|
|
_currentStatements = _statements.pop();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::parseStatement() {
|
|
|
|
assert(_currentOpcodes != 0);
|
|
|
|
|
|
|
|
_lookup = _currentStatements->lookup(_tokens[0]);
|
2007-08-26 09:01:19 +00:00
|
|
|
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(9, kDebugParser, "parseStatement: %s (lookup = %i)", _tokens[0], _lookup);
|
2007-08-26 09:01:19 +00:00
|
|
|
|
2007-08-24 20:14:51 +00:00
|
|
|
(*(*_currentOpcodes)[_lookup])();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Animation *Parallaction::findAnimation(const char *name) {
|
|
|
|
|
|
|
|
for (AnimationList::iterator it = _animations.begin(); it != _animations.end(); it++)
|
|
|
|
if (!scumm_stricmp((*it)->_label._text, name)) return *it;
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::freeAnimations() {
|
|
|
|
_animations.clear();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
int compareAnimationZ(const AnimationPointer &a1, const AnimationPointer &a2) {
|
|
|
|
if (a1->_z == a2->_z) return 0;
|
|
|
|
return (a1->_z < a2->_z ? -1 : 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::sortAnimations() {
|
|
|
|
_char._ani._z = _char._ani.height() + _char._ani._top;
|
|
|
|
_animations.sort(compareAnimationZ);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction::allocateLocationSlot(const char *name) {
|
|
|
|
// WORKAROUND: the original code erroneously incremented
|
|
|
|
// _currentLocationIndex, thus producing inconsistent
|
|
|
|
// savegames. This workaround modified the following loop
|
|
|
|
// and if-statement, so the code exactly matches the one
|
|
|
|
// in Big Red Adventure.
|
|
|
|
_currentLocationIndex = -1;
|
|
|
|
uint16 _di = 0;
|
|
|
|
while (_locationNames[_di][0] != '\0') {
|
|
|
|
if (!scumm_stricmp(_locationNames[_di], name)) {
|
|
|
|
_currentLocationIndex = _di;
|
|
|
|
}
|
|
|
|
_di++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (_di == 120)
|
|
|
|
error("No more location slots available. Please report this immediately to ScummVM team.");
|
|
|
|
|
|
|
|
if (_currentLocationIndex == -1) {
|
|
|
|
strcpy(_locationNames[_numLocations], name);
|
|
|
|
_currentLocationIndex = _numLocations;
|
|
|
|
|
|
|
|
_numLocations++;
|
|
|
|
_locationNames[_numLocations][0] = '\0';
|
|
|
|
_localFlags[_numLocations] = 0;
|
|
|
|
} else {
|
|
|
|
_localFlags[_currentLocationIndex] |= kFlagsVisited; // 'visited'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction::freeLocation() {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(2, kDebugExec, "freeLocation");
|
2007-08-24 20:14:51 +00:00
|
|
|
|
|
|
|
_soundMan->stopSfx(0);
|
|
|
|
_soundMan->stopSfx(1);
|
|
|
|
_soundMan->stopSfx(2);
|
|
|
|
_soundMan->stopSfx(3);
|
|
|
|
|
2007-08-26 09:01:19 +00:00
|
|
|
_localFlagNames->clear();
|
2007-08-24 20:14:51 +00:00
|
|
|
|
|
|
|
_location._walkNodes.clear();
|
|
|
|
|
|
|
|
freeZones();
|
|
|
|
freeAnimations();
|
|
|
|
|
2007-11-18 13:22:38 +00:00
|
|
|
free(_location._comment);
|
|
|
|
_location._comment = 0;
|
2007-08-24 20:14:51 +00:00
|
|
|
|
|
|
|
_location._commands.clear();
|
|
|
|
_location._aCommands.clear();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Parallaction::freeBackground() {
|
|
|
|
|
|
|
|
if (!_backgroundInfo)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_backgroundInfo->bg.free();
|
|
|
|
_backgroundInfo->mask.free();
|
|
|
|
_backgroundInfo->path.free();
|
|
|
|
|
|
|
|
_pathBuffer = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::setBackground(const char* name, const char* mask, const char* path) {
|
|
|
|
|
|
|
|
_disk->loadScenery(*_backgroundInfo, name, mask, path);
|
|
|
|
|
|
|
|
_gfx->setPalette(_backgroundInfo->palette);
|
|
|
|
_gfx->_palette.clone(_backgroundInfo->palette);
|
|
|
|
_gfx->setBackground(&_backgroundInfo->bg);
|
|
|
|
|
|
|
|
if (_backgroundInfo->mask.data)
|
|
|
|
_gfx->setMask(&_backgroundInfo->mask);
|
|
|
|
|
|
|
|
if (_backgroundInfo->path.data)
|
|
|
|
_pathBuffer = &_backgroundInfo->path;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Parallaction::showLocationComment(const char *text, bool end) {
|
|
|
|
|
|
|
|
_gfx->setFont(_dialogueFont);
|
|
|
|
|
|
|
|
int16 w, h;
|
|
|
|
_gfx->getStringExtent(const_cast<char*>(text), 130, &w, &h);
|
|
|
|
|
|
|
|
Common::Rect r(w + (end ? 5 : 10), h + 5);
|
|
|
|
r.moveTo(5, 5);
|
|
|
|
|
|
|
|
_gfx->floodFill(Gfx::kBitFront, r, 0);
|
|
|
|
r.grow(-2);
|
|
|
|
_gfx->floodFill(Gfx::kBitFront, r, 1);
|
|
|
|
_gfx->displayWrappedString(const_cast<char*>(text), 3, 5, 0, 130);
|
|
|
|
|
|
|
|
_gfx->updateScreen();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-08-16 19:47:22 +00:00
|
|
|
|
2007-08-24 20:14:51 +00:00
|
|
|
// displays transition before a new location
|
|
|
|
//
|
|
|
|
// clears screen (in white??)
|
|
|
|
// shows location comment (if any)
|
|
|
|
// waits for mouse click
|
|
|
|
// fades towards game palette
|
|
|
|
//
|
|
|
|
void Parallaction::doLocationEnterTransition() {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(2, kDebugExec, "doLocationEnterTransition");
|
2007-08-24 20:14:51 +00:00
|
|
|
|
2007-11-18 13:22:38 +00:00
|
|
|
if (!_location._comment) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-24 20:14:51 +00:00
|
|
|
if (_localFlags[_currentLocationIndex] & kFlagsVisited) {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(2, kDebugExec, "skipping location transition");
|
2007-08-24 20:14:51 +00:00
|
|
|
return; // visited
|
|
|
|
}
|
|
|
|
|
|
|
|
Palette pal(_gfx->_palette);
|
|
|
|
pal.makeGrayscale();
|
|
|
|
_gfx->setPalette(pal);
|
|
|
|
|
2007-11-19 20:23:01 +00:00
|
|
|
runScripts();
|
2007-11-18 21:32:22 +00:00
|
|
|
drawAnimations();
|
2007-08-24 20:14:51 +00:00
|
|
|
|
|
|
|
_gfx->swapBuffers();
|
|
|
|
_gfx->copyScreen(Gfx::kBitFront, Gfx::kBitBack);
|
|
|
|
|
|
|
|
showLocationComment(_location._comment, false);
|
|
|
|
waitUntilLeftClick();
|
|
|
|
|
|
|
|
_gfx->copyScreen(Gfx::kBitBack, Gfx::kBitFront );
|
|
|
|
|
|
|
|
// fades maximum intensity palette towards approximation of main palette
|
|
|
|
for (uint16 _si = 0; _si<6; _si++) {
|
|
|
|
pal.fadeTo(_gfx->_palette, 4);
|
|
|
|
_gfx->setPalette(pal);
|
|
|
|
waitTime( 1 );
|
|
|
|
_gfx->updateScreen();
|
|
|
|
}
|
2007-08-16 19:47:22 +00:00
|
|
|
|
2007-11-18 18:04:41 +00:00
|
|
|
_gfx->setPalette(_gfx->_palette);
|
|
|
|
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(2, kDebugExec, "doLocationEnterTransition completed");
|
2007-08-24 20:14:51 +00:00
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Zone *Parallaction::findZone(const char *name) {
|
|
|
|
|
|
|
|
for (ZoneList::iterator it = _zones.begin(); it != _zones.end(); it++) {
|
|
|
|
if (!scumm_stricmp((*it)->_label._text, name)) return *it;
|
|
|
|
}
|
|
|
|
|
|
|
|
return findAnimation(name);
|
2007-08-13 23:49:38 +00:00
|
|
|
}
|
|
|
|
|
2007-08-24 20:14:51 +00:00
|
|
|
|
|
|
|
void Parallaction::freeZones() {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(2, kDebugExec, "freeZones: kEngineQuit = %i", _engineFlags & kEngineQuit);
|
2007-08-24 20:14:51 +00:00
|
|
|
|
|
|
|
ZoneList::iterator it = _zones.begin();
|
|
|
|
|
|
|
|
while ( it != _zones.end() ) {
|
|
|
|
|
2007-10-21 15:41:21 +00:00
|
|
|
// NOTE : this condition has been relaxed compared to the original, to allow the engine
|
|
|
|
// to retain special - needed - zones that were lost across location switches.
|
2007-08-24 20:14:51 +00:00
|
|
|
Zone* z = *it;
|
2007-10-21 15:41:21 +00:00
|
|
|
if (((z->_top == -1) || (z->_left == -2)) && ((_engineFlags & kEngineQuit) == 0)) {
|
2007-09-16 08:43:34 +00:00
|
|
|
debugC(2, kDebugExec, "freeZones preserving zone '%s'", z->_label._text);
|
2007-08-24 20:14:51 +00:00
|
|
|
it++;
|
2007-10-21 15:41:21 +00:00
|
|
|
} else {
|
2007-08-24 20:14:51 +00:00
|
|
|
it = _zones.erase(it);
|
2007-10-21 15:41:21 +00:00
|
|
|
}
|
2007-08-24 20:14:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-22 18:45:43 +00:00
|
|
|
const char Character::_prefixMini[] = "mini";
|
|
|
|
const char Character::_suffixTras[] = "tras";
|
|
|
|
const char Character::_empty[] = "\0";
|
|
|
|
|
|
|
|
|
|
|
|
Character::Character(Parallaction *vm) : _vm(vm), _builder(&_ani) {
|
|
|
|
_talk = NULL;
|
|
|
|
_head = NULL;
|
|
|
|
_objs = NULL;
|
|
|
|
|
2007-10-30 19:41:55 +00:00
|
|
|
_dummy = false;
|
|
|
|
|
2007-09-22 18:45:43 +00:00
|
|
|
_ani._left = 150;
|
|
|
|
_ani._top = 100;
|
|
|
|
_ani._z = 10;
|
|
|
|
_ani._oldPos.x = -1000;
|
|
|
|
_ani._oldPos.y = -1000;
|
|
|
|
_ani._frame = 0;
|
|
|
|
_ani._flags = kFlagsActive | kFlagsNoName;
|
|
|
|
_ani._type = kZoneYou;
|
|
|
|
_ani._label._cnv.pixels = NULL;
|
|
|
|
_ani._label._text = strdup("yourself");
|
|
|
|
}
|
|
|
|
|
|
|
|
void Character::getFoot(Common::Point &foot) {
|
|
|
|
foot.x = _ani._left + _ani.width() / 2;
|
|
|
|
foot.y = _ani._top + _ani.height();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Character::setFoot(const Common::Point &foot) {
|
|
|
|
_ani._left = foot.x - _ani.width() / 2;
|
|
|
|
_ani._top = foot.y - _ani.height();
|
|
|
|
}
|
|
|
|
|
|
|
|
void Character::scheduleWalk(int16 x, int16 y) {
|
|
|
|
if ((_ani._flags & kFlagsRemove) || (_ani._flags & kFlagsActive) == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-11-19 20:23:01 +00:00
|
|
|
_walkPath = _builder.buildPath(x, y);
|
|
|
|
|
|
|
|
// WalkNodeList *list = _builder.buildPath(x, y);
|
|
|
|
// _vm->addJob(kJobWalk, list, kPriority19 );
|
2007-09-22 18:45:43 +00:00
|
|
|
|
|
|
|
_engineFlags |= kEngineWalking;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Character::free() {
|
|
|
|
|
2007-11-18 13:22:38 +00:00
|
|
|
delete _ani._cnv;
|
|
|
|
delete _talk;
|
|
|
|
delete _head;
|
|
|
|
delete _objs;
|
2007-08-24 20:14:51 +00:00
|
|
|
|
2007-09-22 18:45:43 +00:00
|
|
|
_ani._cnv = NULL;
|
|
|
|
_talk = NULL;
|
|
|
|
_head = NULL;
|
|
|
|
_objs = NULL;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2007-08-24 20:14:51 +00:00
|
|
|
|
|
|
|
|
2007-09-22 18:45:43 +00:00
|
|
|
// Various ways of detecting character modes used to exist
|
|
|
|
// inside the engine, so they have been unified in the two
|
|
|
|
// following macros.
|
|
|
|
// Mini characters are those used in far away shots, like
|
|
|
|
// the highway scenery, while Dummy characters are a mere
|
|
|
|
// workaround to keep the engine happy when showing slides.
|
|
|
|
// As a sidenote, standard sized characters' names start
|
|
|
|
// with a lowercase 'd'.
|
|
|
|
#define IS_MINI_CHARACTER(s) (((s)[0] == 'm'))
|
|
|
|
#define IS_DUMMY_CHARACTER(s) (((s)[0] == 'D'))
|
2007-08-24 20:14:51 +00:00
|
|
|
|
2007-09-22 18:45:43 +00:00
|
|
|
void Character::setName(const char *name) {
|
|
|
|
const char *begin = name;
|
|
|
|
const char *end = begin + strlen(name);
|
2007-08-24 20:14:51 +00:00
|
|
|
|
2007-09-22 18:45:43 +00:00
|
|
|
_prefix = _empty;
|
|
|
|
|
2007-10-30 19:41:55 +00:00
|
|
|
_dummy = IS_DUMMY_CHARACTER(name);
|
2007-09-22 18:45:43 +00:00
|
|
|
|
2007-10-30 19:41:55 +00:00
|
|
|
if (!_dummy) {
|
2007-11-01 17:39:58 +00:00
|
|
|
if (_engineFlags & kEngineTransformedDonna) {
|
2007-09-22 18:45:43 +00:00
|
|
|
_suffix = _suffixTras;
|
2007-11-01 17:39:58 +00:00
|
|
|
} else {
|
|
|
|
const char *s = strstr(name, "tras");
|
|
|
|
if (s) {
|
2007-11-01 23:31:28 +00:00
|
|
|
_engineFlags |= kEngineTransformedDonna;
|
2007-11-01 17:39:58 +00:00
|
|
|
_suffix = _suffixTras;
|
|
|
|
end = s;
|
|
|
|
} else {
|
|
|
|
_suffix = _empty;
|
|
|
|
}
|
2007-09-22 18:45:43 +00:00
|
|
|
}
|
|
|
|
if (IS_MINI_CHARACTER(name)) {
|
|
|
|
_prefix = _prefixMini;
|
|
|
|
begin = name+4;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(_baseName, 0, 30);
|
|
|
|
strncpy(_baseName, begin, end - begin);
|
|
|
|
sprintf(_name, "%s%s", _prefix, _baseName);
|
|
|
|
sprintf(_fullName, "%s%s%s", _prefix, _baseName, _suffix);
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Character::getName() const {
|
|
|
|
return _name;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Character::getBaseName() const {
|
|
|
|
return _baseName;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char *Character::getFullName() const {
|
|
|
|
return _fullName;
|
|
|
|
}
|
2007-08-24 20:14:51 +00:00
|
|
|
|
2007-10-30 19:41:55 +00:00
|
|
|
bool Character::dummy() const {
|
|
|
|
return _dummy;
|
|
|
|
}
|
2007-08-24 20:14:51 +00:00
|
|
|
|
2007-10-07 19:18:41 +00:00
|
|
|
void Parallaction::beep() {
|
|
|
|
_soundMan->playSfx("beep", 3, false);
|
|
|
|
}
|
2007-08-24 20:14:51 +00:00
|
|
|
|
2007-11-14 22:24:26 +00:00
|
|
|
void Parallaction::scheduleLocationSwitch(const char *location) {
|
|
|
|
strcpy(_location._name, location);
|
|
|
|
_engineFlags |= kEngineChangeLocation;
|
|
|
|
}
|
2007-08-24 20:14:51 +00:00
|
|
|
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
} // namespace Parallaction
|