MUTATIONOFJB: Add Game class.

This commit is contained in:
Ľubomír Remák 2018-03-20 18:58:45 +01:00 committed by Eugene Sandulenko
parent fb75e483e4
commit 1d84041508
18 changed files with 458 additions and 351 deletions

View file

@ -21,7 +21,7 @@
*/
#include "mutationofjb/commands/additemcommand.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
/*
"ADDITEM" " " <item>

View file

@ -21,7 +21,7 @@
*/
#include "mutationofjb/commands/seqcommand.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
namespace MutationOfJB {

View file

@ -22,7 +22,7 @@
#include "mutationofjb/commands/gotocommand.h"
#include "mutationofjb/commands/labelcommand.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
#include "mutationofjb/script.h"
/*

View file

@ -21,7 +21,7 @@
*/
#include "mutationofjb/commands/ifcommand.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
#include "mutationofjb/script.h"
#include "common/str.h"
#include "common/translation.h"

View file

@ -21,7 +21,7 @@
*/
#include "mutationofjb/commands/ifitemcommand.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
#include "mutationofjb/script.h"
#include "mutationofjb/util.h"
#include "common/str.h"

View file

@ -21,7 +21,7 @@
*/
#include "mutationofjb/commands/ifpiggycommand.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
#include "mutationofjb/script.h"
#include "mutationofjb/util.h"
#include "common/str.h"

View file

@ -22,7 +22,6 @@
#include "mutationofjb/commands/labelcommand.h"
#include "mutationofjb/commands/gotocommand.h"
#include "mutationofjb/game.h"
#include "mutationofjb/script.h"
/*

View file

@ -21,7 +21,7 @@
*/
#include "mutationofjb/commands/removeallitemscommand.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
/*
"DELALLITEMS"

View file

@ -21,7 +21,7 @@
*/
#include "mutationofjb/commands/removeitemcommand.h"
#include "mutationofjb/game.h"
#include "mutationofjb/gamedata.h"
/*
"DELITEM" " " <item>

View file

@ -21,6 +21,7 @@
*/
#include "mutationofjb/debug.h"
#include "mutationofjb/game.h"
#include "mutationofjb/mutationofjb.h"
#include "mutationofjb/script.h"
#include "mutationofjb/commands/command.h"
@ -61,9 +62,9 @@ bool Console::cmd_listsections(int argc, const char **argv) {
if (argc == 3) {
Script *script = nullptr;
if (strcmp(argv[1], "G") == 0) {
script = _vm->getGlobalScript();
script = _vm->getGame().getGlobalScript();
} else if (strcmp(argv[1], "L") == 0) {
script = _vm->getLocalScript();
script = _vm->getGame().getLocalScript();
}
if (!script) {
debugPrintf(_("Choose 'G' (global) or 'L' (local) script.\n"));
@ -135,9 +136,9 @@ bool Console::cmd_showsection(int argc, const char **argv) {
if (argc >= 4) {
Script *script = nullptr;
if (strcmp(argv[1], "G") == 0) {
script = _vm->getGlobalScript();
script = _vm->getGame().getGlobalScript();
} else if (strcmp(argv[1], "L") == 0) {
script = _vm->getLocalScript();
script = _vm->getGame().getLocalScript();
}
if (!script) {
debugPrintf(_("Choose 'G' (global) or 'L' (local) script.\n"));

View file

@ -21,171 +21,64 @@
*/
#include "mutationofjb/game.h"
#include "common/stream.h"
#include "mutationofjb/gamedata.h"
#include "mutationofjb/encryptedfile.h"
#include "mutationofjb/mutationofjb.h"
#include "mutationofjb/room.h"
#include "mutationofjb/script.h"
#include "mutationofjb/util.h"
#include "common/util.h"
#include "common/translation.h"
namespace MutationOfJB {
static bool readString(Common::ReadStream &stream, char *str) {
char buf[MAX_STR_LENGTH];
memset(str, 0, MAX_STR_LENGTH + 1);
Game::Game(MutationOfJBEngine* vm) : _vm(vm) {
_gameData = new GameData;
loadGameData(false);
uint8 len = stream.readByte();
stream.read(buf, MAX_STR_LENGTH);
EncryptedFile globalScriptFile;
globalScriptFile.open("global.atn");
_globalScript = new Script;
_globalScript->loadFromStream(globalScriptFile);
globalScriptFile.close();
len = MIN(len, MAX_STR_LENGTH);
memcpy(str, buf, len);
_localScript = nullptr;
_room = new Room(_vm->getScreen());
changeScene(13, false); // Initial scene.
}
GameData &Game::getGameData() {
return *_gameData;
}
Script *Game::getGlobalScript() const {
return _globalScript;
}
Script *Game::getLocalScript() const {
return _localScript;
}
bool Game::loadGameData(bool partB) {
EncryptedFile file;
const char *fileName = !partB ? "startup.dat" : "startupb.dat";
file.open(fileName);
if (!file.isOpen()) {
reportFileMissingError(fileName);
return false;
}
_gameData->loadFromStream(file);
file.close();
return true;
}
bool Door::loadFromStream(Common::ReadStream &stream) {
readString(stream, _name);
_destSceneId = stream.readByte();
_destX = stream.readUint16LE();
_destY = stream.readUint16LE();
_x = stream.readUint16LE();
_y = stream.readByte();
_width = stream.readUint16LE();
_height = stream.readByte();
_walkToX = stream.readUint16LE();
_walkToY = stream.readByte();
_SP = stream.readByte();
return true;
}
bool Object::loadFromStream(Common::ReadStream &stream) {
_AC = stream.readByte();
_FA = stream.readByte();
_FR = stream.readByte();
_NA = stream.readByte();
_FS = stream.readByte();
_unknown = stream.readByte();
_CA = stream.readByte();
_x = stream.readUint16LE();
_y = stream.readByte();
_XL = stream.readUint16LE();
_YL = stream.readByte();
_WX = stream.readUint16LE();
_WY = stream.readByte();
_SP = stream.readByte();
return true;
}
bool Static::loadFromStream(Common::ReadStream &stream) {
_active = stream.readByte();
readString(stream, _name);
_x = stream.readUint16LE();
_y = stream.readByte();
_width = stream.readUint16LE();
_height = stream.readByte();
_walkToX = stream.readUint16LE();
_walkToY = stream.readByte();
_SP = stream.readByte();
return true;
}
bool Bitmap::loadFromStream(Common::ReadStream &stream) {
_frame = stream.readByte();
_isVisible = stream.readByte();
_x1 = stream.readUint16LE();
_y1 = stream.readByte();
_x2 = stream.readUint16LE();
_y2 = stream.readByte();
return true;
}
bool Scene::loadFromStream(Common::ReadStream &stream) {
int i;
_startup = stream.readByte();
_unknown001 = stream.readByte();
_unknown002 = stream.readByte();
_unknown003 = stream.readByte();
_DL = stream.readByte();
_noDoors = stream.readByte();
_noDoors = MIN(_noDoors, (uint8) ARRAYSIZE(_doors));
for (i = 0; i < ARRAYSIZE(_doors); ++i) {
_doors[i].loadFromStream(stream);
}
_noObjects = stream.readByte();
_noObjects = MIN(_noObjects, (uint8) ARRAYSIZE(_objects));
for (i = 0; i < ARRAYSIZE(_objects); ++i) {
_objects[i].loadFromStream(stream);
}
_noStatics = stream.readByte();
_noStatics = MIN(_noStatics, (uint8) ARRAYSIZE(_statics));
for (i = 0; i < ARRAYSIZE(_statics); ++i) {
_statics[i].loadFromStream(stream);
}
for (i = 0; i < ARRAYSIZE(_bitmaps); ++i) {
_bitmaps[i].loadFromStream(stream);
}
_obstacleY1 = stream.readUint16LE();
_palRotStart = stream.readByte();
_palRotEnd = stream.readByte();
_palRotPeriod = stream.readByte();
stream.read(_unknown38A, 80);
return true;
}
Door *Scene::getDoor(uint8 doorId) {
if (doorId == 0 || doorId > _noDoors) {
warning(_("Door %d does not exist"), doorId);
return nullptr;
}
return &_doors[doorId - 1];
}
Object *Scene::getObject(uint8 objectId) {
if (objectId == 0 || objectId > _noObjects) {
warning(_("Object %d does not exist"), objectId);
return nullptr;
}
return &_objects[objectId - 1];
}
Static *Scene::getStatic(uint8 staticId) {
if (staticId == 0 || staticId > _noStatics) {
warning(_("Static %d does not exist"), staticId);
return nullptr;
}
return &_statics[staticId - 1];
}
GameData::GameData() : _currentScene(0) {}
Scene *GameData::getScene(uint8 sceneId) {
if (sceneId == 0 || sceneId > ARRAYSIZE(_scenes)) {
warning(_("Scene %d does not exist"), sceneId);
return nullptr;
}
return &_scenes[sceneId - 1];
}
bool GameData::loadFromStream(Common::ReadStream &stream) {
for (int i = 0; i < ARRAYSIZE(_scenes); ++i) {
_scenes[i].loadFromStream(stream);
}
return true;
void Game::changeScene(uint8 sceneId, bool partB) {
_gameData->_currentScene = sceneId;
_room->load(_gameData->_currentScene, partB);
}
}

View file

@ -24,139 +24,33 @@
#define MUTATIONOFJB_GAME_H
#include "common/scummsys.h"
#include "mutationofjb/inventory.h"
namespace Common {
class ReadStream;
}
namespace MutationOfJB {
static const uint8 MAX_STR_LENGTH = 0x14;
class MutationOfJBEngine;
class GameData;
class Script;
class Room;
struct Door {
/*
Door name.
Can be empty - deactivates door completely.
*/
char _name[MAX_STR_LENGTH + 1];
/*
Scene ID where the door leads.
Can be 0 - you can hover your mouse over it, but clicking it doesn't do anything (unless scripted).
*/
uint8 _destSceneId;
/* X coordinate for player's position after going through the door. */
uint16 _destX;
/* Y coordinate for player's position after going through the door. */
uint16 _destY;
/* X coordinate of the door rectangle. */
uint16 _x;
/* Y coordinate of the door rectangle. */
uint8 _y;
/* Width of the door rectangle. */
uint16 _width;
/* Height of the door rectangle. */
uint8 _height;
/* X coordinate for position towards player will walk after clicking the door. */
uint16 _walkToX;
/* Y coordinate for position towards player will walk after clicking the door. */
uint8 _walkToY;
/* Unknown for now - likely not even used. */
uint8 _SP;
bool loadFromStream(Common::ReadStream &stream);
};
struct Object {
uint8 _AC;
uint8 _FA;
uint8 _FR;
uint8 _NA;
uint8 _FS;
uint8 _unknown;
uint8 _CA;
uint16 _x;
uint8 _y;
uint16 _XL;
uint8 _YL;
uint16 _WX;
uint8 _WY;
uint8 _SP;
bool loadFromStream(Common::ReadStream &stream);
};
struct Static {
uint8 _active;
char _name[MAX_STR_LENGTH + 1];
uint16 _x;
uint8 _y;
uint16 _width;
uint8 _height;
uint16 _walkToX;
uint8 _walkToY;
uint8 _SP;
bool loadFromStream(Common::ReadStream &stream);
};
struct Bitmap {
uint8 _frame;
uint8 _isVisible;
uint16 _x1;
uint8 _y1;
uint16 _x2;
uint8 _y2;
bool loadFromStream(Common::ReadStream &stream);
};
struct Scene {
Door *getDoor(uint8 objectId);
Object *getObject(uint8 objectId);
Static *getStatic(uint8 staticId);
uint8 _startup;
uint8 _unknown001;
uint8 _unknown002;
uint8 _unknown003;
uint8 _DL;
uint8 _noDoors;
Door _doors[5];
uint8 _noObjects;
Object _objects[9];
uint8 _noStatics;
Static _statics[15];
Bitmap _bitmaps[10];
uint16 _obstacleY1;
uint8 _palRotStart;
uint8 _palRotEnd;
uint8 _palRotPeriod;
uint8 _unknown38A[80];
bool loadFromStream(Common::ReadStream &stream);
};
struct GameData {
class Game {
public:
GameData();
Scene *getScene(uint8 sceneId);
Game(MutationOfJBEngine* vm);
GameData &getGameData();
bool loadFromStream(Common::ReadStream &stream);
Script *getGlobalScript() const;
Script *getLocalScript() const;
void changeScene(uint8 sceneId, bool partB);
uint8 _currentScene;
Inventory _inventory;
Common::String _currentAPK;
private:
Scene _scenes[45];
bool loadGameData(bool partB);
MutationOfJBEngine *_vm;
GameData *_gameData;
Script *_globalScript;
Script *_localScript;
Room *_room;
};
}

View file

@ -0,0 +1,193 @@
/* 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 "mutationofjb/gamedata.h"
#include "common/stream.h"
#include "common/util.h"
#include "common/translation.h"
namespace MutationOfJB {
static bool readString(Common::ReadStream &stream, char *str) {
char buf[MAX_STR_LENGTH];
memset(str, 0, MAX_STR_LENGTH + 1);
uint8 len = stream.readByte();
stream.read(buf, MAX_STR_LENGTH);
len = MIN(len, MAX_STR_LENGTH);
memcpy(str, buf, len);
return true;
}
bool Door::loadFromStream(Common::ReadStream &stream) {
readString(stream, _name);
_destSceneId = stream.readByte();
_destX = stream.readUint16LE();
_destY = stream.readUint16LE();
_x = stream.readUint16LE();
_y = stream.readByte();
_width = stream.readUint16LE();
_height = stream.readByte();
_walkToX = stream.readUint16LE();
_walkToY = stream.readByte();
_SP = stream.readByte();
return true;
}
bool Object::loadFromStream(Common::ReadStream &stream) {
_AC = stream.readByte();
_FA = stream.readByte();
_FR = stream.readByte();
_NA = stream.readByte();
_FS = stream.readByte();
_unknown = stream.readByte();
_CA = stream.readByte();
_x = stream.readUint16LE();
_y = stream.readByte();
_XL = stream.readUint16LE();
_YL = stream.readByte();
_WX = stream.readUint16LE();
_WY = stream.readByte();
_SP = stream.readByte();
return true;
}
bool Static::loadFromStream(Common::ReadStream &stream) {
_active = stream.readByte();
readString(stream, _name);
_x = stream.readUint16LE();
_y = stream.readByte();
_width = stream.readUint16LE();
_height = stream.readByte();
_walkToX = stream.readUint16LE();
_walkToY = stream.readByte();
_SP = stream.readByte();
return true;
}
bool Bitmap::loadFromStream(Common::ReadStream &stream) {
_frame = stream.readByte();
_isVisible = stream.readByte();
_x1 = stream.readUint16LE();
_y1 = stream.readByte();
_x2 = stream.readUint16LE();
_y2 = stream.readByte();
return true;
}
bool Scene::loadFromStream(Common::ReadStream &stream) {
int i;
_startup = stream.readByte();
_unknown001 = stream.readByte();
_unknown002 = stream.readByte();
_unknown003 = stream.readByte();
_DL = stream.readByte();
_noDoors = stream.readByte();
_noDoors = MIN(_noDoors, (uint8) ARRAYSIZE(_doors));
for (i = 0; i < ARRAYSIZE(_doors); ++i) {
_doors[i].loadFromStream(stream);
}
_noObjects = stream.readByte();
_noObjects = MIN(_noObjects, (uint8) ARRAYSIZE(_objects));
for (i = 0; i < ARRAYSIZE(_objects); ++i) {
_objects[i].loadFromStream(stream);
}
_noStatics = stream.readByte();
_noStatics = MIN(_noStatics, (uint8) ARRAYSIZE(_statics));
for (i = 0; i < ARRAYSIZE(_statics); ++i) {
_statics[i].loadFromStream(stream);
}
for (i = 0; i < ARRAYSIZE(_bitmaps); ++i) {
_bitmaps[i].loadFromStream(stream);
}
_obstacleY1 = stream.readUint16LE();
_palRotStart = stream.readByte();
_palRotEnd = stream.readByte();
_palRotPeriod = stream.readByte();
stream.read(_unknown38A, 80);
return true;
}
Door *Scene::getDoor(uint8 doorId) {
if (doorId == 0 || doorId > _noDoors) {
warning(_("Door %d does not exist"), doorId);
return nullptr;
}
return &_doors[doorId - 1];
}
Object *Scene::getObject(uint8 objectId) {
if (objectId == 0 || objectId > _noObjects) {
warning(_("Object %d does not exist"), objectId);
return nullptr;
}
return &_objects[objectId - 1];
}
Static *Scene::getStatic(uint8 staticId) {
if (staticId == 0 || staticId > _noStatics) {
warning(_("Static %d does not exist"), staticId);
return nullptr;
}
return &_statics[staticId - 1];
}
GameData::GameData()
: _currentScene(0),
_partB(false) {}
Scene *GameData::getScene(uint8 sceneId) {
if (sceneId == 0 || sceneId > ARRAYSIZE(_scenes)) {
warning(_("Scene %d does not exist"), sceneId);
return nullptr;
}
return &_scenes[sceneId - 1];
}
bool GameData::loadFromStream(Common::ReadStream &stream) {
for (int i = 0; i < ARRAYSIZE(_scenes); ++i) {
_scenes[i].loadFromStream(stream);
}
return true;
}
}

View file

@ -0,0 +1,165 @@
/* 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.
*
*/
#ifndef MUTATIONOFJB_GAMEDATA_H
#define MUTATIONOFJB_GAMEDATA_H
#include "common/scummsys.h"
#include "mutationofjb/inventory.h"
namespace Common {
class ReadStream;
}
namespace MutationOfJB {
static const uint8 MAX_STR_LENGTH = 0x14;
struct Door {
/*
Door name.
Can be empty - deactivates door completely.
*/
char _name[MAX_STR_LENGTH + 1];
/*
Scene ID where the door leads.
Can be 0 - you can hover your mouse over it, but clicking it doesn't do anything (unless scripted).
*/
uint8 _destSceneId;
/* X coordinate for player's position after going through the door. */
uint16 _destX;
/* Y coordinate for player's position after going through the door. */
uint16 _destY;
/* X coordinate of the door rectangle. */
uint16 _x;
/* Y coordinate of the door rectangle. */
uint8 _y;
/* Width of the door rectangle. */
uint16 _width;
/* Height of the door rectangle. */
uint8 _height;
/* X coordinate for position towards player will walk after clicking the door. */
uint16 _walkToX;
/* Y coordinate for position towards player will walk after clicking the door. */
uint8 _walkToY;
/* Unknown for now - likely not even used. */
uint8 _SP;
bool loadFromStream(Common::ReadStream &stream);
};
struct Object {
uint8 _AC;
uint8 _FA;
uint8 _FR;
uint8 _NA;
uint8 _FS;
uint8 _unknown;
uint8 _CA;
uint16 _x;
uint8 _y;
uint16 _XL;
uint8 _YL;
uint16 _WX;
uint8 _WY;
uint8 _SP;
bool loadFromStream(Common::ReadStream &stream);
};
struct Static {
uint8 _active;
char _name[MAX_STR_LENGTH + 1];
uint16 _x;
uint8 _y;
uint16 _width;
uint8 _height;
uint16 _walkToX;
uint8 _walkToY;
uint8 _SP;
bool loadFromStream(Common::ReadStream &stream);
};
struct Bitmap {
uint8 _frame;
uint8 _isVisible;
uint16 _x1;
uint8 _y1;
uint16 _x2;
uint8 _y2;
bool loadFromStream(Common::ReadStream &stream);
};
struct Scene {
Door *getDoor(uint8 objectId);
Object *getObject(uint8 objectId);
Static *getStatic(uint8 staticId);
uint8 _startup;
uint8 _unknown001;
uint8 _unknown002;
uint8 _unknown003;
uint8 _DL;
uint8 _noDoors;
Door _doors[5];
uint8 _noObjects;
Object _objects[9];
uint8 _noStatics;
Static _statics[15];
Bitmap _bitmaps[10];
uint16 _obstacleY1;
uint8 _palRotStart;
uint8 _palRotEnd;
uint8 _palRotPeriod;
uint8 _unknown38A[80];
bool loadFromStream(Common::ReadStream &stream);
};
struct GameData {
public:
GameData();
Scene *getScene(uint8 sceneId);
bool loadFromStream(Common::ReadStream &stream);
uint8 _currentScene;
bool _partB;
Inventory _inventory;
Common::String _currentAPK;
private:
Scene _scenes[45];
};
}
#endif

View file

@ -19,6 +19,7 @@ MODULE_OBJS := \
detection.o \
encryptedfile.o \
game.o \
gamedata.o \
inventory.o \
mutationofjb.o \
room.o \

View file

@ -32,11 +32,8 @@
#include "engines/util.h"
#include "mutationofjb/mutationofjb.h"
#include "mutationofjb/room.h"
#include "mutationofjb/game.h"
#include "mutationofjb/encryptedfile.h"
#include "mutationofjb/util.h"
#include "mutationofjb/script.h"
#include "mutationofjb/gamedata.h"
#include "mutationofjb/debug.h"
namespace MutationOfJB {
@ -44,10 +41,7 @@ namespace MutationOfJB {
MutationOfJBEngine::MutationOfJBEngine(OSystem *syst)
: Engine(syst),
_console(nullptr),
_room(nullptr),
_screen(nullptr),
_globalScript(nullptr),
_localScript(nullptr) {
_screen(nullptr) {
debug("MutationOfJBEngine::MutationOfJBEngine");
}
@ -55,21 +49,6 @@ MutationOfJBEngine::~MutationOfJBEngine() {
debug("MutationOfJBEngine::~MutationOfJBEngine");
}
bool MutationOfJBEngine::loadGameData(bool partB) {
EncryptedFile file;
const char *fileName = !partB ? "startup.dat" : "startupb.dat";
file.open(fileName);
if (!file.isOpen()) {
reportFileMissingError(fileName);
return false;
}
_gameData->loadFromStream(file);
file.close();
return true;
}
void MutationOfJBEngine::setupCursor() {
const uint8 white[] = {0xFF, 0xFF, 0xFF};
@ -82,28 +61,25 @@ void MutationOfJBEngine::setupCursor() {
CursorMan.showMouse(true);
}
Graphics::Screen *MutationOfJBEngine::getScreen() const {
return _screen;
}
Game &MutationOfJBEngine::getGame() {
return *_game;
}
Common::Error MutationOfJBEngine::run() {
debug("MutationOfJBEngine::run");
initGraphics(320, 200);
_console = new Console(this);
_screen = new Graphics::Screen;
_screen = new Graphics::Screen();
_game = new Game(this);
setupCursor();
_gameData = new GameData;
_gameData->_currentScene = 13;
loadGameData(false);
_room = new Room(_screen);
_room->load(_gameData->_currentScene, false);
EncryptedFile globalScriptFile;
globalScriptFile.open("global.atn");
_globalScript = new Script;
_globalScript->loadFromStream(globalScriptFile);
globalScriptFile.close();
while(!shouldQuit()) {
Common::Event event;
while (_eventMan->pollEvent(event)) {
@ -118,13 +94,12 @@ Common::Error MutationOfJBEngine::run() {
}
case Common::EVENT_LBUTTONDOWN:
{
const Scene *const scene = _gameData->getScene(_gameData->_currentScene);
const Scene *const scene = _game->getGameData().getScene(_game->getGameData()._currentScene);
if (scene) {
for (int i = 0; i < MIN(ARRAYSIZE(scene->_doors), (int) scene->_noDoors); ++i) {
const Door &door = scene->_doors[i];
if ((event.mouse.x >= door._x) && (event.mouse.x < door._x + door._width) && (event.mouse.y >= door._y) && (event.mouse.y < door._y + door._height)) {
_gameData->_currentScene = door._destSceneId;
_room->load(_gameData->_currentScene, false);
_game->changeScene(door._destSceneId, false);
}
}
}
@ -143,12 +118,4 @@ Common::Error MutationOfJBEngine::run() {
return Common::kNoError;
}
Script *MutationOfJBEngine::getGlobalScript() {
return _globalScript;
}
Script *MutationOfJBEngine::getLocalScript() {
return _localScript;
}
}

View file

@ -32,9 +32,7 @@ namespace Graphics {
namespace MutationOfJB {
class Console;
class Room;
struct GameData;
class Script;
class Game;
class MutationOfJBEngine : public Engine {
public:
@ -42,19 +40,16 @@ public:
~MutationOfJBEngine();
virtual Common::Error run();
Script *getGlobalScript();
Script *getLocalScript();
Graphics::Screen *getScreen() const;
Game &getGame();
private:
bool loadGameData(bool partB);
void setupCursor();
Console *_console;
Room *_room;
GameData *_gameData;
Graphics::Screen *_screen;
Script *_globalScript;
Script *_localScript;
Game *_game;
};

View file

@ -59,13 +59,12 @@ struct ActionInfo {
typedef Common::Array<ActionInfo> ActionInfos;
typedef Common::Array<GotoCommand *> GotoCommands;
class ScriptParseContext
{
class ScriptParseContext {
public:
ScriptParseContext(Common::SeekableReadStream &stream);
bool readLine(Common::String &line);
void addConditionalCommand(ConditionalCommand *command, char tag);
void addLookSection(const Common::String & item, bool walkTo);
void addLookSection(const Common::String &item, bool walkTo);
Common::SeekableReadStream &_stream;
Command *_currentCommand;