2007-01-14 21:29:12 +00:00
|
|
|
/* ScummVM - Scumm Interpreter
|
|
|
|
* Copyright (C) 2006 The ScummVM project
|
|
|
|
*
|
|
|
|
* 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$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef PARALLACTION_H
|
|
|
|
#define PARALLACTION_H
|
|
|
|
|
|
|
|
#include "engines/engine.h"
|
|
|
|
#include "parallaction/defs.h"
|
|
|
|
#include "parallaction/inventory.h"
|
2007-02-19 22:34:00 +00:00
|
|
|
#include "parallaction/parser.h"
|
2007-02-25 20:35:47 +00:00
|
|
|
#include "parallaction/disk.h"
|
2007-03-17 07:52:47 +00:00
|
|
|
#include "parallaction/zone.h"
|
2007-02-11 21:17:37 +00:00
|
|
|
#include "common/str.h"
|
|
|
|
#include "gui/dialog.h"
|
|
|
|
#include "gui/widget.h"
|
|
|
|
|
|
|
|
namespace GUI {
|
|
|
|
class ListWidget;
|
|
|
|
class CommandSender;
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
namespace Parallaction {
|
|
|
|
|
|
|
|
// high values mean high priority
|
|
|
|
|
2007-02-04 08:12:33 +00:00
|
|
|
enum {
|
2007-02-17 15:37:49 +00:00
|
|
|
kPriority0 = 0,
|
|
|
|
kPriority1 = 1,
|
|
|
|
kPriority2 = 2,
|
|
|
|
kPriority3 = 3,
|
|
|
|
kPriority4 = 4,
|
|
|
|
kPriority5 = 5,
|
|
|
|
kPriority6 = 6,
|
|
|
|
kPriority7 = 7,
|
|
|
|
kPriority8 = 8,
|
|
|
|
kPriority9 = 9,
|
|
|
|
kPriority10 = 10,
|
|
|
|
kPriority11 = 11,
|
|
|
|
kPriority12 = 12,
|
|
|
|
kPriority13 = 13,
|
|
|
|
kPriority14 = 14,
|
|
|
|
kPriority15 = 15,
|
|
|
|
kPriority16 = 16,
|
|
|
|
kPriority17 = 17,
|
|
|
|
kPriority18 = 18,
|
|
|
|
kPriority19 = 19,
|
|
|
|
kPriority20 = 20,
|
|
|
|
kPriority21 = 21
|
2007-02-04 08:12:33 +00:00
|
|
|
};
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
enum {
|
|
|
|
kMouseNone = 0,
|
|
|
|
kMouseLeftUp = 1,
|
|
|
|
kMouseLeftDown = 2,
|
|
|
|
kMouseRightUp = 3,
|
|
|
|
kMouseRightDown = 4
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum ParallactionGameType {
|
|
|
|
GType_Nippon = 1,
|
|
|
|
GType_BRA
|
|
|
|
};
|
|
|
|
|
2007-01-21 20:24:38 +00:00
|
|
|
struct PARALLACTIONGameDescription;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
struct Job;
|
|
|
|
typedef void (*JobFn)(void*, Job*);
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
struct Job : public Node {
|
2007-01-14 21:29:12 +00:00
|
|
|
uint16 _count; // # of executions left
|
|
|
|
uint16 _tag; // used for ordering
|
|
|
|
uint16 _finished;
|
|
|
|
void * _parm;
|
|
|
|
JobFn _fn;
|
2007-03-17 13:14:50 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
Job() : _count(0), _tag(0), _finished(0), _parm(NULL), _fn(NULL) {
|
|
|
|
}
|
2007-01-14 21:29:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
extern uint16 _mouseButtons;
|
|
|
|
|
|
|
|
extern uint16 _score;
|
|
|
|
extern uint16 _language;
|
|
|
|
extern Zone *_activeZone;
|
|
|
|
extern uint32 _engineFlags;
|
|
|
|
extern callable _callables[];
|
2007-03-17 07:52:47 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
extern Node _zones;
|
|
|
|
extern Node _animations;
|
|
|
|
extern uint32 _localFlags[];
|
|
|
|
extern Command *_forwardedCommands[];
|
|
|
|
extern char _forwardedAnimationNames[][20];
|
|
|
|
extern uint16 _numForwards;
|
|
|
|
extern char _soundFile[];
|
|
|
|
extern char _slideText[][40];
|
|
|
|
extern uint16 _introSarcData3; // sarcophagus stuff to be saved
|
|
|
|
extern uint16 _introSarcData2; // sarcophagus stuff to be saved
|
2007-03-11 13:01:11 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
extern char *_globalTable[];
|
|
|
|
extern char _saveData1[];
|
|
|
|
extern byte _mouseHidden;
|
|
|
|
extern uint32 _commandFlags;
|
2007-03-11 00:04:50 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
extern char *_objectsNames[];
|
2007-01-15 21:14:34 +00:00
|
|
|
extern const char *_zoneTypeNames[];
|
|
|
|
extern const char *_zoneFlagNames[];
|
2007-01-14 21:29:12 +00:00
|
|
|
extern char *_localFlagNames[];
|
2007-01-15 21:14:34 +00:00
|
|
|
extern const char *commands_names[];
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-01-15 21:14:34 +00:00
|
|
|
extern const char *_instructionNames[];
|
|
|
|
extern const char *_callableNames[];
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-10 22:13:47 +00:00
|
|
|
extern const char *_dinoName;
|
|
|
|
extern const char *_donnaName;
|
|
|
|
extern const char *_doughName;
|
|
|
|
extern const char *_drkiName;
|
|
|
|
extern const char *_minidinoName;
|
|
|
|
extern const char *_minidonnaName;
|
|
|
|
extern const char *_minidoughName;
|
|
|
|
extern const char *_minidrkiName;
|
|
|
|
|
2007-03-10 22:55:09 +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-01-14 21:29:12 +00:00
|
|
|
void waitUntilLeftClick();
|
|
|
|
|
|
|
|
void addNode(Node *list, Node *n);
|
|
|
|
void removeNode(Node *n);
|
|
|
|
void freeNodeList(Node *list);
|
|
|
|
|
2007-02-20 16:54:55 +00:00
|
|
|
Command *parseCommands(Script &script);
|
2007-01-14 21:29:12 +00:00
|
|
|
void runCommands(Command *list, Zone *z = NULL);
|
|
|
|
void freeCommands(Command*);
|
|
|
|
|
|
|
|
void freeZones(Node *list);
|
|
|
|
|
|
|
|
void runDialogue(SpeakData*);
|
|
|
|
|
|
|
|
WalkNode *buildWalkPath(uint16 x, uint16 y);
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
void jobRemovePickedItem(void*, Job *j);
|
|
|
|
void jobDisplayDroppedItem(void*, Job *j);
|
|
|
|
void jobToggleDoor(void*, Job *j);
|
|
|
|
void jobEraseAnimations(void *arg_0, Job *j);
|
|
|
|
void jobWalk(void*, Job *j);
|
|
|
|
void jobRunScripts(void*, Job *j);
|
|
|
|
void jobDisplayAnimations(void*, Job *j);
|
|
|
|
void jobDisplayLabel(void *parm, Job *j);
|
|
|
|
void jobWaitRemoveJob(void *parm, Job *j);
|
|
|
|
void jobShowInventory(void *parm, Job *j);
|
|
|
|
void jobHideInventory(void *parm, Job *j);
|
|
|
|
void jobEraseLabel(void *parm, Job *j);
|
|
|
|
|
|
|
|
|
|
|
|
enum EngineFlags {
|
|
|
|
kEngineQuit = (1 << 0),
|
|
|
|
kEnginePauseJobs = (1 << 1),
|
|
|
|
kEngineInventory = (1 << 2),
|
|
|
|
kEngineWalking = (1 << 3),
|
|
|
|
kEngineChangeLocation = (1 << 4),
|
|
|
|
kEngineMouse = (1 << 5),
|
|
|
|
kEngineDragging = (1 << 6),
|
2007-03-10 22:56:32 +00:00
|
|
|
kEngineTransformedDonna = (1 << 7)
|
2007-01-14 21:29:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kEvNone = 0,
|
|
|
|
kEvEnterZone = 1,
|
|
|
|
kEvExitZone = 2,
|
|
|
|
kEvAction = 3,
|
|
|
|
kEvOpenInventory = 4,
|
|
|
|
kEvCloseInventory = 5,
|
|
|
|
kEvHoverInventory = 6,
|
|
|
|
kEvWalk = 7,
|
|
|
|
kEvQuitGame = 1000,
|
|
|
|
kEvSaveGame = 2000,
|
|
|
|
kEvLoadGame = 4000
|
|
|
|
};
|
|
|
|
|
|
|
|
enum {
|
|
|
|
kCursorArrow = -1
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
class Gfx;
|
2007-01-14 21:29:12 +00:00
|
|
|
class Menu;
|
2007-02-21 21:42:37 +00:00
|
|
|
class MidiPlayer;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-11 14:14:08 +00:00
|
|
|
struct Location {
|
|
|
|
|
2007-03-18 17:17:21 +00:00
|
|
|
Common::Point _startPosition;
|
2007-03-11 14:14:08 +00:00
|
|
|
uint16 _startFrame;
|
|
|
|
Node _walkNodes;
|
|
|
|
char _name[100];
|
|
|
|
|
|
|
|
Command *_aCommands;
|
|
|
|
Command *_commands;
|
|
|
|
char *_comment;
|
|
|
|
char *_endComment;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2007-03-17 07:52:47 +00:00
|
|
|
struct Character {
|
2007-03-17 07:55:16 +00:00
|
|
|
Animation _ani;
|
2007-03-18 10:25:46 +00:00
|
|
|
StaticCnv *_head;
|
2007-03-18 10:20:38 +00:00
|
|
|
Cnv *_talk;
|
2007-03-17 07:55:16 +00:00
|
|
|
Cnv _normalFrames;
|
|
|
|
Cnv _miniFrames;
|
2007-03-18 10:34:41 +00:00
|
|
|
Cnv *_objs;
|
2007-03-17 17:52:30 +00:00
|
|
|
|
|
|
|
Character() {
|
2007-03-18 10:20:38 +00:00
|
|
|
_talk = NULL;
|
|
|
|
// ._width = 0;
|
|
|
|
// _talk._height = 0;
|
|
|
|
// _talk._count = 0;
|
|
|
|
// _talk._array = NULL;
|
2007-03-17 17:52:30 +00:00
|
|
|
|
2007-03-18 10:25:46 +00:00
|
|
|
_head = NULL;
|
|
|
|
// _head._width = 0;
|
|
|
|
// _head._height = 0;
|
|
|
|
// _head._data0 = NULL;
|
|
|
|
// _head._data1 = NULL;
|
2007-03-17 17:52:30 +00:00
|
|
|
|
2007-03-18 10:34:41 +00:00
|
|
|
_objs = NULL;
|
|
|
|
// _objs._count = 0;
|
2007-03-17 17:52:30 +00:00
|
|
|
|
2007-03-17 19:48:48 +00:00
|
|
|
_ani._zone._left = 150;
|
|
|
|
_ani._zone._top = 100;
|
2007-03-17 17:52:30 +00:00
|
|
|
_ani._z = 10;
|
2007-03-17 20:19:16 +00:00
|
|
|
_ani._zone._oldLeft = -1000;
|
|
|
|
_ani._zone._oldTop = -1000;
|
2007-03-17 17:52:30 +00:00
|
|
|
_ani._frame = 0;
|
|
|
|
_ani._zone._flags = kFlagsActive | kFlagsNoName;
|
|
|
|
_ani._zone._type = kZoneYou;
|
|
|
|
_ani._zone._label._cnv._data0 = NULL;
|
|
|
|
_ani._zone._label._text = strdup("yourself");
|
|
|
|
}
|
|
|
|
|
2007-03-17 07:52:47 +00:00
|
|
|
};
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
class Parallaction : public Engine {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
Parallaction(OSystem *syst);
|
|
|
|
~Parallaction();
|
|
|
|
|
|
|
|
int init();
|
|
|
|
|
|
|
|
int go();
|
|
|
|
|
|
|
|
|
|
|
|
void loadGame();
|
|
|
|
void saveGame();
|
|
|
|
|
|
|
|
uint16 updateInput();
|
|
|
|
|
|
|
|
void waitTime(uint32 t);
|
|
|
|
|
2007-01-15 21:14:34 +00:00
|
|
|
static void initTable(const char *path, char **table);
|
|
|
|
static void freeTable(char** table);
|
|
|
|
static int16 searchTable(const char *s, const char **table);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
void parseLocation(const char *filename);
|
|
|
|
void changeCursor(int32 index);
|
|
|
|
void changeCharacter(const char *name);
|
|
|
|
|
2007-02-20 09:52:07 +00:00
|
|
|
char *parseComment(Script &script);
|
2007-02-20 16:54:55 +00:00
|
|
|
char *parseDialogueString(Script &script);
|
|
|
|
Dialogue *parseDialogue(Script &script);
|
2007-02-19 22:34:00 +00:00
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
Job *addJob(JobFn fn, void *parm, uint16 tag);
|
|
|
|
void removeJob(Job *j);
|
|
|
|
void pauseJobs();
|
|
|
|
void resumeJobs();
|
|
|
|
void runJobs();
|
2007-02-19 22:34:00 +00:00
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
public:
|
2007-01-21 20:24:38 +00:00
|
|
|
int getGameType() const;
|
|
|
|
uint32 getFeatures() const;
|
|
|
|
Common::Language getLanguage() const;
|
|
|
|
Common::Platform getPlatform() const;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
const PARALLACTIONGameDescription *_gameDescription;
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2007-02-21 21:42:37 +00:00
|
|
|
MidiPlayer *_midiPlayer;
|
|
|
|
|
2007-03-12 20:41:25 +00:00
|
|
|
Gfx* _gfx;
|
2007-01-14 21:29:12 +00:00
|
|
|
Menu* _menu;
|
|
|
|
char _characterName[30];
|
2007-03-04 13:27:29 +00:00
|
|
|
Disk* _disk;
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
char _locationNames[120][32];
|
|
|
|
int16 _currentLocationIndex;
|
|
|
|
uint16 _numLocations;
|
|
|
|
|
2007-03-17 07:52:47 +00:00
|
|
|
Character _char;
|
2007-03-11 14:14:08 +00:00
|
|
|
Location _location;
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
InventoryItem _activeItem;
|
|
|
|
|
2007-02-20 09:17:28 +00:00
|
|
|
Script *_locationScript;
|
2007-02-19 22:34:00 +00:00
|
|
|
|
2007-03-18 17:22:07 +00:00
|
|
|
Common::Point _mousePos;
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
protected: // data
|
|
|
|
|
|
|
|
struct InputData {
|
|
|
|
uint16 _event;
|
2007-03-18 17:12:48 +00:00
|
|
|
Common::Point _mousePos;
|
2007-01-15 20:11:49 +00:00
|
|
|
|
|
|
|
int16 _inventoryIndex;
|
|
|
|
Zone* _zone;
|
2007-03-17 20:51:13 +00:00
|
|
|
Label* _label;
|
2007-01-14 21:29:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool _skipMenu;
|
|
|
|
|
|
|
|
// input-only
|
|
|
|
InputData _input;
|
|
|
|
bool _actionAfterWalk; // actived when the character needs to move before taking an action
|
|
|
|
|
|
|
|
// these two could/should be merged as they carry on the same duty in two member functions,
|
|
|
|
// respectively processInput and translateInput
|
|
|
|
int16 _procCurrentHoverItem;
|
|
|
|
int16 _transCurrentHoverItem;
|
|
|
|
|
|
|
|
uint32 _baseTime;
|
|
|
|
|
|
|
|
uint16 _musicData1; // only used in changeLocation
|
|
|
|
char _characterName1[50]; // only used in changeCharacter
|
|
|
|
|
|
|
|
int16 _keyDown;
|
|
|
|
|
2007-03-17 13:14:50 +00:00
|
|
|
Job _jobs;
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
protected: // members
|
|
|
|
bool detectGame(void);
|
|
|
|
|
|
|
|
void initGame();
|
|
|
|
void initGlobals();
|
|
|
|
|
2007-02-17 15:37:49 +00:00
|
|
|
Common::String _saveFileName;
|
|
|
|
int buildSaveFileList(Common::StringList& l);
|
|
|
|
int selectSaveFile(uint16 arg_0, const char* caption, const char* button);
|
2007-02-11 21:17:37 +00:00
|
|
|
void doLoadGame(uint16 slot);
|
|
|
|
void doSaveGame(uint16 slot, const char* name);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
void runGame();
|
|
|
|
InputData * translateInput();
|
|
|
|
void processInput(InputData*);
|
|
|
|
|
|
|
|
int16 getHoverInventoryItem(int16 x, int16 y);
|
|
|
|
|
|
|
|
uint32 getElapsedTime();
|
|
|
|
void resetTimer();
|
|
|
|
|
|
|
|
void doLocationEnterTransition();
|
2007-02-20 16:54:55 +00:00
|
|
|
void parseZone(Script &script, Node *list, char *name);
|
|
|
|
Animation * parseAnimation(Script &script, Node *list, char *name);
|
2007-01-14 21:29:12 +00:00
|
|
|
void parseScriptLine(Instruction *inst, Animation *a, LocalVariable *locals);
|
2007-02-20 16:54:55 +00:00
|
|
|
void parseZoneTypeBlock(Script &script, Zone *z);
|
2007-01-14 21:29:12 +00:00
|
|
|
void loadProgram(Animation *a, char *filename);
|
|
|
|
void changeLocation(char *location);
|
2007-03-11 13:01:11 +00:00
|
|
|
void showSlide(const char *name);
|
2007-01-14 21:29:12 +00:00
|
|
|
|
2007-03-11 10:50:52 +00:00
|
|
|
void pickMusic(const char *location);
|
2007-03-10 22:13:47 +00:00
|
|
|
void selectCharacterMusic(const char *name);
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
// FIXME: remove global
|
|
|
|
extern Parallaction *_vm;
|
|
|
|
|
2007-02-11 21:17:37 +00:00
|
|
|
class SaveLoadChooser : public GUI::Dialog {
|
|
|
|
typedef Common::String String;
|
|
|
|
typedef Common::StringList StringList;
|
|
|
|
protected:
|
|
|
|
GUI::ListWidget *_list;
|
|
|
|
GUI::ButtonWidget *_chooseButton;
|
|
|
|
GUI::GraphicsWidget *_gfxWidget;
|
|
|
|
GUI::StaticTextWidget *_date;
|
|
|
|
GUI::StaticTextWidget *_time;
|
|
|
|
GUI::StaticTextWidget *_playtime;
|
|
|
|
GUI::ContainerWidget *_container;
|
|
|
|
Parallaction *_vm;
|
|
|
|
|
|
|
|
uint8 _fillR, _fillG, _fillB;
|
|
|
|
|
|
|
|
public:
|
|
|
|
SaveLoadChooser(const String &title, const String &buttonLabel, Parallaction *engine);
|
|
|
|
~SaveLoadChooser();
|
|
|
|
|
|
|
|
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
|
|
|
|
const String &getResultString() const;
|
|
|
|
void setList(const StringList& list);
|
|
|
|
int runModal();
|
|
|
|
|
|
|
|
virtual void reflowLayout();
|
|
|
|
};
|
|
|
|
|
2007-01-14 21:29:12 +00:00
|
|
|
|
|
|
|
} // namespace Parallaction
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|