mirror of
https://github.com/libretro/scummvm.git
synced 2025-03-05 01:38:36 +00:00
MUTATIONOFJB: Start implementation of ATN scripts (IF command).
This commit is contained in:
parent
356a6809c3
commit
f7d5a825a0
33
engines/mutationofjb/commands/command.cpp
Normal file
33
engines/mutationofjb/commands/command.cpp
Normal file
@ -0,0 +1,33 @@
|
||||
/* 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/commands/command.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
Command::~Command() {}
|
||||
|
||||
SeqCommand *Command::asSeqCommand() {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
}
|
58
engines/mutationofjb/commands/command.h
Normal file
58
engines/mutationofjb/commands/command.h
Normal file
@ -0,0 +1,58 @@
|
||||
/* 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_COMMAND_H
|
||||
#define MUTATIONOFJB_COMMAND_H
|
||||
|
||||
namespace Common {
|
||||
class String;
|
||||
}
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class GameData;
|
||||
class SeqCommand;
|
||||
class IfCommand;
|
||||
class CallMacroCommand;
|
||||
class ScriptParseContext;
|
||||
class Command;
|
||||
|
||||
typedef bool (*CommandParseFunc)(const Common::String &line, ScriptParseContext &parseContext, Command *&command);
|
||||
|
||||
class Command {
|
||||
public:
|
||||
enum ExecuteResult {
|
||||
None,
|
||||
Finished,
|
||||
InProgress
|
||||
};
|
||||
|
||||
virtual ~Command();
|
||||
|
||||
virtual ExecuteResult execute(GameData &gameData) = 0;
|
||||
virtual Command *next() const = 0;
|
||||
|
||||
virtual SeqCommand *asSeqCommand();
|
||||
};
|
||||
}
|
||||
|
||||
#endif
|
41
engines/mutationofjb/commands/conditionalcommand.cpp
Normal file
41
engines/mutationofjb/commands/conditionalcommand.cpp
Normal file
@ -0,0 +1,41 @@
|
||||
/* 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/commands/conditionalcommand.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
ConditionalCommand::ConditionalCommand() :
|
||||
_trueCommand(nullptr),
|
||||
_falseCommand(nullptr),
|
||||
_cachedResult(false)
|
||||
{}
|
||||
|
||||
Command *ConditionalCommand::next() const {
|
||||
if (_cachedResult) {
|
||||
return _trueCommand;
|
||||
} else {
|
||||
return _falseCommand;
|
||||
}
|
||||
}
|
||||
};
|
41
engines/mutationofjb/commands/conditionalcommand.h
Normal file
41
engines/mutationofjb/commands/conditionalcommand.h
Normal file
@ -0,0 +1,41 @@
|
||||
/* 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/commands/command.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ConditionalCommand : public Command {
|
||||
public:
|
||||
ConditionalCommand();
|
||||
void setTrueCommand(Command *command);
|
||||
void setFalseCommand(Command *command);
|
||||
|
||||
virtual Command *next() const override;
|
||||
protected:
|
||||
Command *_trueCommand;
|
||||
Command *_falseCommand;
|
||||
bool _cachedResult;
|
||||
};
|
||||
|
||||
}
|
88
engines/mutationofjb/commands/ifcommand.cpp
Normal file
88
engines/mutationofjb/commands/ifcommand.cpp
Normal file
@ -0,0 +1,88 @@
|
||||
/* 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/commands/ifcommand.h"
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "common/str.h"
|
||||
#include "common/translation.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool IfCommand::ParseFunc(const Common::String &line, ScriptParseContext &parseContext, Command *&command)
|
||||
{
|
||||
// IFtss oo val!
|
||||
// <t> 1B Tag.
|
||||
// <ss> 2B Scene.
|
||||
// <oo> 2B Object ID.
|
||||
// <val> VL Value.
|
||||
// ! 1B Negation (optional).
|
||||
|
||||
if (line.size() < 10) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (strncmp(line.c_str(), "IF", 2) != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *const cstr = line.c_str();
|
||||
const char tag = cstr[2];
|
||||
const uint8 sceneId = atoi(cstr + 3);
|
||||
const uint8 objectId = atoi(cstr + 6);
|
||||
const uint8 value = atoi(cstr + 9);
|
||||
const bool negative = (line.lastChar() == '!');
|
||||
|
||||
IfCommand *ifCommand = new IfCommand(sceneId, objectId, value, negative);
|
||||
|
||||
command = ifCommand;
|
||||
parseContext.addConditionalCommand(ifCommand, tag);
|
||||
return true;
|
||||
}
|
||||
|
||||
IfCommand::IfCommand(uint8 sceneId, uint8 objectId, uint16 value, bool negative) :
|
||||
_sceneId(sceneId),
|
||||
_objectId(objectId),
|
||||
_value(value),
|
||||
_negative(negative)
|
||||
{}
|
||||
|
||||
Command::ExecuteResult IfCommand::execute(GameData &gameData) {
|
||||
Scene* const scene = gameData.getScene(_sceneId);
|
||||
if (!scene) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Object* const object = scene->getObject(_objectId);
|
||||
if (!object) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
_cachedResult = (object->_WX == _value);
|
||||
if (_negative) {
|
||||
_cachedResult = !_cachedResult;
|
||||
}
|
||||
|
||||
return Finished;
|
||||
}
|
||||
}
|
||||
|
52
engines/mutationofjb/commands/ifcommand.h
Normal file
52
engines/mutationofjb/commands/ifcommand.h
Normal file
@ -0,0 +1,52 @@
|
||||
/* 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_IFCOMMAND_H
|
||||
#define MUTATIONOFJB_IFCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/conditionalcommand.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ScriptParseContext;
|
||||
|
||||
class IfCommand : public ConditionalCommand {
|
||||
public:
|
||||
static bool ParseFunc(const Common::String &line, ScriptParseContext &parseContext, Command *&command);
|
||||
|
||||
IfCommand(uint8 sceneId, uint8 objectId, uint16 value, bool negative);
|
||||
|
||||
virtual ExecuteResult execute(GameData &gameData) override;
|
||||
|
||||
private:
|
||||
uint8 _sceneId;
|
||||
uint8 _objectId;
|
||||
uint16 _value;
|
||||
bool _negative;
|
||||
|
||||
bool _cachedResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
40
engines/mutationofjb/commands/seqcommand.cpp
Normal file
40
engines/mutationofjb/commands/seqcommand.cpp
Normal file
@ -0,0 +1,40 @@
|
||||
/* 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 "seqcommand.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
void SeqCommand::setNextCommand(Command *nextCommand)
|
||||
{
|
||||
_nextCommand = nextCommand;
|
||||
}
|
||||
|
||||
Command *SeqCommand::next() const {
|
||||
return _nextCommand;
|
||||
}
|
||||
|
||||
SeqCommand *SeqCommand::asSeqCommand() {
|
||||
return this;
|
||||
}
|
||||
|
||||
}
|
44
engines/mutationofjb/commands/seqcommand.h
Normal file
44
engines/mutationofjb/commands/seqcommand.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* 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_SEQCOMMAND_H
|
||||
#define MUTATIONOFJB_SEQCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/command.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class SeqCommand : public Command {
|
||||
public:
|
||||
void setNextCommand(Command *nextCommand);
|
||||
virtual Command *next() const override;
|
||||
virtual SeqCommand *asSeqCommand();
|
||||
|
||||
private:
|
||||
Command *_nextCommand;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "mutationofjb/game.h"
|
||||
#include "common/stream.h"
|
||||
#include "common/util.h"
|
||||
#include "common/translation.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
@ -101,7 +102,7 @@ bool Bitmap::loadFromStream(Common::ReadStream &stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool SceneInfo::loadFromStream(Common::ReadStream &stream) {
|
||||
bool Scene::loadFromStream(Common::ReadStream &stream) {
|
||||
int i;
|
||||
|
||||
_startup = stream.readByte();
|
||||
@ -111,16 +112,19 @@ bool SceneInfo::loadFromStream(Common::ReadStream &stream) {
|
||||
_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);
|
||||
}
|
||||
@ -139,8 +143,27 @@ bool SceneInfo::loadFromStream(Common::ReadStream &stream) {
|
||||
return true;
|
||||
}
|
||||
|
||||
Object *Scene::getObject(uint8 objectId) {
|
||||
if (objectId == 0 || objectId > _noObjects) {
|
||||
warning(_("Object %d does not exist"), objectId);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
return &_objects[objectId - 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);
|
||||
|
@ -22,13 +22,11 @@
|
||||
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace Common
|
||||
{
|
||||
namespace Common {
|
||||
class ReadStream;
|
||||
}
|
||||
|
||||
namespace MutationOfJB
|
||||
{
|
||||
namespace MutationOfJB {
|
||||
|
||||
static const uint8 MAX_STR_LENGTH = 0x14;
|
||||
|
||||
@ -93,7 +91,10 @@ struct Bitmap {
|
||||
};
|
||||
|
||||
|
||||
struct SceneInfo {
|
||||
struct Scene {
|
||||
|
||||
Object *getObject(uint8 objectId);
|
||||
|
||||
uint8 _startup;
|
||||
uint8 _unknown001;
|
||||
uint8 _unknown002;
|
||||
@ -123,12 +124,16 @@ struct SceneInfo {
|
||||
|
||||
struct GameData
|
||||
{
|
||||
public:
|
||||
GameData();
|
||||
|
||||
SceneInfo _scenes[45];
|
||||
uint8 _currentScene;
|
||||
Scene *getScene(uint8 sceneId);
|
||||
|
||||
bool loadFromStream(Common::ReadStream &stream);
|
||||
|
||||
uint8 _currentScene;
|
||||
private:
|
||||
Scene _scenes[45];
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,11 +1,16 @@
|
||||
MODULE := engines/mutationofjb
|
||||
|
||||
MODULE_OBJS := \
|
||||
commands/command.o \
|
||||
commands/conditionalcommand.o \
|
||||
commands/ifcommand.o \
|
||||
commands/seqcommand.o \
|
||||
detection.o \
|
||||
encryptedfile.o \
|
||||
game.o \
|
||||
mutationofjb.o \
|
||||
room.o \
|
||||
script.o \
|
||||
util.o
|
||||
|
||||
# This module can be built as a plugin
|
||||
|
@ -102,12 +102,14 @@ Common::Error MutationOfJBEngine::run() {
|
||||
switch (event.type) {
|
||||
case Common::EVENT_LBUTTONDOWN:
|
||||
{
|
||||
const SceneInfo &sceneInfo = _gameData->_scenes[_gameData->_currentScene - 1];
|
||||
for (int i = 0; i < MIN(ARRAYSIZE(sceneInfo._doors), (int) sceneInfo._noDoors); ++i) {
|
||||
const Door &door = sceneInfo._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);
|
||||
const Scene* const scene = _gameData->getScene(_gameData->_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);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -132,6 +132,9 @@ void Room::loadBackground(EncryptedFile &file, uint32 size) {
|
||||
}
|
||||
lines++;
|
||||
}
|
||||
if (readBytes < size) {
|
||||
file.seek(size - readBytes, SEEK_CUR);
|
||||
}
|
||||
|
||||
_screen->update();
|
||||
}
|
||||
|
75
engines/mutationofjb/script.cpp
Normal file
75
engines/mutationofjb/script.cpp
Normal file
@ -0,0 +1,75 @@
|
||||
/* 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 "script.h"
|
||||
|
||||
#include "common/hashmap.h"
|
||||
#include "common/hash-str.h"
|
||||
#include "common/stream.h"
|
||||
#include "mutationofjb/commands/command.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
static CommandParseFunc* getParseFuncs() {
|
||||
static CommandParseFunc funcs[] = {
|
||||
nullptr
|
||||
};
|
||||
|
||||
return funcs;
|
||||
}
|
||||
|
||||
|
||||
ScriptParseContext::ScriptParseContext(Common::SeekableReadStream &stream) : _stream(stream) {}
|
||||
|
||||
bool ScriptParseContext::readLine(Common::String &line) {
|
||||
do {
|
||||
Common::String str = _stream.readLine();
|
||||
if (str.empty() || str[0] != '.') {
|
||||
line = str;
|
||||
if (line[0] == '*') {
|
||||
line.deleteChar(0);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
} while(_stream.eos());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void ScriptParseContext::addConditionalCommand(ConditionalCommand *command, char tag) {
|
||||
ConditionalCommandInfo cmi = {command, tag};
|
||||
_pendingCondCommands.push_back(cmi);
|
||||
}
|
||||
|
||||
bool Script::loadFromStream(Common::SeekableReadStream &stream) {
|
||||
|
||||
CommandParseFunc * const parseFuncs = getParseFuncs();
|
||||
|
||||
ScriptParseContext parseCtx(stream);
|
||||
|
||||
Common::HashMap<Common::String, Command *> macros;
|
||||
Common::HashMap<Common::String, Command *> labels;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
64
engines/mutationofjb/script.h
Normal file
64
engines/mutationofjb/script.h
Normal file
@ -0,0 +1,64 @@
|
||||
/* 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_SCRIPT_H
|
||||
#define MUTATIONOFJB_SCRIPT_H
|
||||
|
||||
#include "common/array.h"
|
||||
|
||||
namespace Common {
|
||||
class SeekableReadStream;
|
||||
class String;
|
||||
}
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ConditionalCommand;
|
||||
|
||||
class ScriptParseContext
|
||||
{
|
||||
public:
|
||||
ScriptParseContext(Common::SeekableReadStream &stream);
|
||||
bool readLine(Common::String &line);
|
||||
void addConditionalCommand(ConditionalCommand *command, char tag);
|
||||
//void setLastIfCommand(IfCommand *command);
|
||||
|
||||
private:
|
||||
Common::SeekableReadStream &_stream;
|
||||
|
||||
struct ConditionalCommandInfo {
|
||||
ConditionalCommand *command;
|
||||
char tag;
|
||||
};
|
||||
Common::Array<ConditionalCommandInfo> _pendingCondCommands;
|
||||
};
|
||||
|
||||
class Script {
|
||||
public:
|
||||
bool loadFromStream(Common::SeekableReadStream &stream);
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user