Initial commit
This commit is contained in:
52
engines/mutationofjb/commands/additemcommand.cpp
Normal file
52
engines/mutationofjb/commands/additemcommand.cpp
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/additemcommand.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
/** @file
|
||||
* "ADDITEM " <item>
|
||||
*
|
||||
* Adds item to inventory.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool AddItemCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (!line.hasPrefix("ADDITEM") || line.size() < 9) {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = new AddItemCommand(line.c_str() + 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult AddItemCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
scriptExecCtx.getGameData()._inventory.addItem(_item);
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String AddItemCommand::debugString() const {
|
||||
return Common::String::format("ADDITEM '%s'", _item.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
49
engines/mutationofjb/commands/additemcommand.h
Normal file
49
engines/mutationofjb/commands/additemcommand.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_ADDITEMCOMMAND_H
|
||||
#define MUTATIONOFJB_ADDITEMCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class AddItemCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
AddItemCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class AddItemCommand : public SeqCommand {
|
||||
public:
|
||||
AddItemCommand(const Common::String &item) : _item(item) {}
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
Common::String _item;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
57
engines/mutationofjb/commands/bitmapvisibilitycommand.cpp
Normal file
57
engines/mutationofjb/commands/bitmapvisibilitycommand.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/bitmapvisibilitycommand.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
/** @file
|
||||
* "RB " <sceneId> " " <bitmapId> " " <visible>
|
||||
*
|
||||
* Changes visibility of a bitmap in the specified scene.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool BitmapVisibilityCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
|
||||
if (line.size() < 10 || !line.hasPrefix("RB "))
|
||||
return false;
|
||||
|
||||
const uint8 sceneId = (uint8) atoi(line.c_str() + 3);
|
||||
const uint8 bitmapId = (uint8) atoi(line.c_str() + 6);
|
||||
const bool visible = (line[9] == '1');
|
||||
|
||||
command = new BitmapVisibilityCommand(sceneId, bitmapId, visible);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Command::ExecuteResult BitmapVisibilityCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
scriptExecCtx.getGameData().getScene(_sceneId)->getBitmap(_bitmapId)->_isVisible = _visible;
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String BitmapVisibilityCommand::debugString() const {
|
||||
return Common::String::format("SETBITMAPVIS %u %u %s", (unsigned int) _sceneId, (unsigned int) _bitmapId, _visible ? "true" : "false");
|
||||
}
|
||||
|
||||
}
|
||||
52
engines/mutationofjb/commands/bitmapvisibilitycommand.h
Normal file
52
engines/mutationofjb/commands/bitmapvisibilitycommand.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_BITMAPVISIBILITYCOMMAND_H
|
||||
#define MUTATIONOFJB_BITMAPVISIBILITYCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class BitmapVisibilityCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
BitmapVisibilityCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class BitmapVisibilityCommand : public SeqCommand {
|
||||
public:
|
||||
BitmapVisibilityCommand(uint8 sceneId, uint8 bitmapId, bool visible) : _sceneId(sceneId), _bitmapId(bitmapId), _visible(visible) {}
|
||||
const Common::String &getName() const;
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
uint8 _sceneId;
|
||||
uint8 _bitmapId;
|
||||
bool _visible;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
82
engines/mutationofjb/commands/callmacrocommand.cpp
Normal file
82
engines/mutationofjb/commands/callmacrocommand.cpp
Normal file
@@ -0,0 +1,82 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/callmacrocommand.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/game.h"
|
||||
|
||||
/** @file
|
||||
* "_" <name>
|
||||
*
|
||||
* Calls macro with the specified name.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool CallMacroCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line.size() < 2 || line.firstChar() != '_') {
|
||||
return false;
|
||||
}
|
||||
|
||||
const Common::String macroName = line.c_str() + 1;
|
||||
command = new CallMacroCommand(macroName);
|
||||
return true;
|
||||
}
|
||||
|
||||
void CallMacroCommandParser::transition(ScriptParseContext &, Command *oldCommand, Command *newCommand, CommandParser *) {
|
||||
if (!oldCommand || !newCommand) {
|
||||
warning("Unexpected empty command in transition");
|
||||
return;
|
||||
}
|
||||
|
||||
static_cast<CallMacroCommand *>(oldCommand)->setReturnCommand(newCommand);
|
||||
}
|
||||
|
||||
|
||||
void CallMacroCommand::setReturnCommand(Command *cmd) {
|
||||
_returnCommand = cmd;
|
||||
}
|
||||
|
||||
Command *CallMacroCommand::getReturnCommand() const {
|
||||
return _returnCommand;
|
||||
}
|
||||
|
||||
Command::ExecuteResult CallMacroCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
_callCommand = scriptExecCtx.getMacro(_macroName);
|
||||
if (_callCommand) {
|
||||
scriptExecCtx.pushReturnCommand(_returnCommand);
|
||||
} else {
|
||||
warning("Macro '%s' not found.", _macroName.c_str());
|
||||
}
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Command *CallMacroCommand::next() const {
|
||||
return _callCommand;
|
||||
}
|
||||
|
||||
Common::String CallMacroCommand::debugString() const {
|
||||
return Common::String::format("CALL '%s'", _macroName.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
57
engines/mutationofjb/commands/callmacrocommand.h
Normal file
57
engines/mutationofjb/commands/callmacrocommand.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_CALLMACROCOMMAND_H
|
||||
#define MUTATIONOFJB_CALLMACROCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/command.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class CallMacroCommandParser : public CommandParser {
|
||||
public:
|
||||
CallMacroCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser) override;
|
||||
};
|
||||
|
||||
class CallMacroCommand : public Command {
|
||||
public:
|
||||
CallMacroCommand(const Common::String ¯oName) : _macroName(macroName), _returnCommand(nullptr), _callCommand(nullptr) {}
|
||||
void setReturnCommand(Command *);
|
||||
|
||||
Command *getReturnCommand() const;
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Command *next() const override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
Common::String _macroName;
|
||||
Command *_returnCommand;
|
||||
Command *_callCommand;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
58
engines/mutationofjb/commands/camefromcommand.cpp
Normal file
58
engines/mutationofjb/commands/camefromcommand.cpp
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/camefromcommand.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "common/str.h"
|
||||
|
||||
/** @file
|
||||
* "CAMEFROM " <sceneId>
|
||||
*
|
||||
* This command tests whether last scene (the scene player came from) is sceneId.
|
||||
* If true, the execution continues after this command.
|
||||
* Otherwise the execution continues after first '#' found.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool CameFromCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line.size() < 10 || !line.hasPrefix("CAMEFROM")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint8 sceneId = atoi(line.c_str() + 9);
|
||||
_tags.push(0);
|
||||
command = new CameFromCommand(sceneId);
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult CameFromCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
_cachedResult = (scriptExecCtx.getGameData()._lastScene == _sceneId);
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String CameFromCommand::debugString() const {
|
||||
return Common::String::format("CAMEFROM %d", _sceneId);
|
||||
}
|
||||
|
||||
}
|
||||
47
engines/mutationofjb/commands/camefromcommand.h
Normal file
47
engines/mutationofjb/commands/camefromcommand.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_CAMEFROMCOMMAND_H
|
||||
#define MUTATIONOFJB_CAMEFROMCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/conditionalcommand.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class CameFromCommandParser : public ConditionalCommandParser {
|
||||
public:
|
||||
CameFromCommandParser() : ConditionalCommandParser(true) {}
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class CameFromCommand : public ConditionalCommand {
|
||||
public:
|
||||
CameFromCommand(uint8 sceneId) : _sceneId(sceneId) {}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
uint8 _sceneId;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
558
engines/mutationofjb/commands/changecommand.cpp
Normal file
558
engines/mutationofjb/commands/changecommand.cpp
Normal file
@@ -0,0 +1,558 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/changecommand.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
|
||||
/** @file
|
||||
* "CHANGE" <entity> " " <register> " " <sceneId> " " <entityId> " " <value>
|
||||
*
|
||||
* Changes entity register value for specified scene.
|
||||
* <entity> 1B Entity to change register for.
|
||||
* Possible values:
|
||||
* 'D' - door
|
||||
* 'O' - object
|
||||
* 'S' - static
|
||||
* '' - scene
|
||||
* <register> 2B Register name.
|
||||
* <sceneId> 2B Scene ID.
|
||||
* <entityid> 2B Entity ID.
|
||||
* <value> *B Value (variable length).
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool ChangeCommandParser::parseValueString(const Common::String &valueString, bool changeEntity, uint8 &sceneId, uint8 &entityId, ChangeCommand::ChangeRegister ®, ChangeCommand::ChangeOperation &op, ChangeCommandValue &ccv) {
|
||||
if (changeEntity) {
|
||||
if (valueString.size() < 8) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
if (valueString.size() < 7) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
sceneId = atoi(valueString.c_str() + 3);
|
||||
if (changeEntity) {
|
||||
entityId = atoi(valueString.c_str() + 6);
|
||||
}
|
||||
const char *val = "";
|
||||
if (changeEntity) {
|
||||
if (valueString.size() >= 9) {
|
||||
val = valueString.c_str() + 9;
|
||||
}
|
||||
} else {
|
||||
if (valueString.size() >= 6) {
|
||||
val = valueString.c_str() + 6;
|
||||
}
|
||||
}
|
||||
|
||||
if (valueString.hasPrefix("NM")) {
|
||||
reg = ChangeCommand::NM;
|
||||
op = ChangeCommand::SetValue;
|
||||
Common::strlcpy(ccv._strVal, val, MAX_ENTITY_NAME_LENGTH + 1);
|
||||
} else if (valueString.hasPrefix("LT")) {
|
||||
reg = ChangeCommand::LT;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("SX")) {
|
||||
reg = ChangeCommand::SX;
|
||||
ccv._wordVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("SY")) {
|
||||
reg = ChangeCommand::SY;
|
||||
ccv._wordVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("XX")) {
|
||||
reg = ChangeCommand::XX;
|
||||
ccv._wordVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("YY")) {
|
||||
reg = ChangeCommand::YY;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("XL")) {
|
||||
reg = ChangeCommand::XL;
|
||||
ccv._wordVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("YL")) {
|
||||
reg = ChangeCommand::YL;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("WX")) {
|
||||
reg = ChangeCommand::WX;
|
||||
ccv._wordVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("WY")) {
|
||||
reg = ChangeCommand::WY;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("AC")) {
|
||||
reg = ChangeCommand::AC;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("FA")) {
|
||||
reg = ChangeCommand::FA;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("FR")) {
|
||||
reg = ChangeCommand::FR;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("NA")) {
|
||||
reg = ChangeCommand::NA;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("FS")) {
|
||||
reg = ChangeCommand::FS;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("CA")) {
|
||||
reg = ChangeCommand::CA;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("DS")) {
|
||||
reg = ChangeCommand::DS;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("DL")) {
|
||||
reg = ChangeCommand::DL;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("ND")) {
|
||||
reg = ChangeCommand::ND;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("NO")) {
|
||||
reg = ChangeCommand::NO;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("NS")) {
|
||||
reg = ChangeCommand::NS;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("PF")) {
|
||||
reg = ChangeCommand::PF;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("PL")) {
|
||||
reg = ChangeCommand::PL;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
} else if (valueString.hasPrefix("PD")) {
|
||||
reg = ChangeCommand::PD;
|
||||
ccv._byteVal = parseInteger(val, op);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ChangeDoorCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (!line.hasPrefix("CHANGED ")) {
|
||||
return false;
|
||||
}
|
||||
uint8 sceneId = 0;
|
||||
uint8 objectId = 0;
|
||||
ChangeCommand::ChangeRegister reg;
|
||||
ChangeCommand::ChangeOperation op;
|
||||
ChangeCommandValue val;
|
||||
if (!parseValueString(line.c_str() + 8, true, sceneId, objectId, reg, op, val)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = new ChangeDoorCommand(sceneId, objectId, reg, op, val);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChangeObjectCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (!line.hasPrefix("CHANGEO ")) {
|
||||
return false;
|
||||
}
|
||||
uint8 sceneId = 0;
|
||||
uint8 objectId = 0;
|
||||
ChangeCommand::ChangeRegister reg;
|
||||
ChangeCommand::ChangeOperation op;
|
||||
ChangeCommandValue val;
|
||||
if (!parseValueString(line.c_str() + 8, true, sceneId, objectId, reg, op, val)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = new ChangeObjectCommand(sceneId, objectId, reg, op, val);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChangeStaticCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (!line.hasPrefix("CHANGES ")) {
|
||||
return false;
|
||||
}
|
||||
uint8 sceneId = 0;
|
||||
uint8 objectId = 0;
|
||||
ChangeCommand::ChangeRegister reg;
|
||||
ChangeCommand::ChangeOperation op;
|
||||
ChangeCommandValue val;
|
||||
if (!parseValueString(line.c_str() + 8, true, sceneId, objectId, reg, op, val)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = new ChangeStaticCommand(sceneId, objectId, reg, op, val);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ChangeSceneCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (!line.hasPrefix("CHANGE ")) {
|
||||
return false;
|
||||
}
|
||||
uint8 sceneId = 0;
|
||||
uint8 objectId = 0;
|
||||
ChangeCommand::ChangeRegister reg;
|
||||
ChangeCommand::ChangeOperation op;
|
||||
ChangeCommandValue val;
|
||||
if (!parseValueString(line.c_str() + 7, false, sceneId, objectId, reg, op, val)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = new ChangeSceneCommand(sceneId, objectId, reg, op, val);
|
||||
return true;
|
||||
}
|
||||
|
||||
int ChangeCommandParser::parseInteger(const char *val, ChangeCommand::ChangeOperation &op) {
|
||||
op = ChangeCommand::SetValue;
|
||||
|
||||
if (!val || !(*val)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (val[0] == '\\') {
|
||||
op = ChangeCommand::SetValue;
|
||||
val++;
|
||||
} else if (val[0] == '+') {
|
||||
op = ChangeCommand::AddValue;
|
||||
val++;
|
||||
} else if (val[0] == '-') {
|
||||
op = ChangeCommand::SubtractValue;
|
||||
val++;
|
||||
}
|
||||
|
||||
return atoi(val);
|
||||
}
|
||||
|
||||
|
||||
const char *ChangeCommand::getRegisterAsString() const {
|
||||
switch (_register) {
|
||||
case NM:
|
||||
return "NM";
|
||||
case LT:
|
||||
return "LT";
|
||||
case SX:
|
||||
return "SX";
|
||||
case SY:
|
||||
return "SY";
|
||||
case XX:
|
||||
return "XX";
|
||||
case YY:
|
||||
return "YY";
|
||||
case XL:
|
||||
return "XL";
|
||||
case YL:
|
||||
return "YL";
|
||||
case WX:
|
||||
return "WX";
|
||||
case WY:
|
||||
return "WY";
|
||||
case SP:
|
||||
return "SP";
|
||||
case AC:
|
||||
return "AC";
|
||||
case FA:
|
||||
return "FA";
|
||||
case FR:
|
||||
return "FR";
|
||||
case NA:
|
||||
return "NA";
|
||||
case FS:
|
||||
return "FS";
|
||||
case CA:
|
||||
return "CA";
|
||||
case DS:
|
||||
return "DS";
|
||||
case DL:
|
||||
return "DL";
|
||||
case ND:
|
||||
return "ND";
|
||||
case NO:
|
||||
return "NO";
|
||||
case NS:
|
||||
return "NS";
|
||||
case PF:
|
||||
return "PF";
|
||||
case PL:
|
||||
return "PL";
|
||||
case PD:
|
||||
return "PD";
|
||||
default:
|
||||
return "(unknown)";
|
||||
}
|
||||
}
|
||||
|
||||
Common::String ChangeCommand::getValueAsString() const {
|
||||
switch (_register) {
|
||||
case NM:
|
||||
return Common::String::format("\"%s\"", _value._strVal);
|
||||
case LT:
|
||||
case YY:
|
||||
case YL:
|
||||
case WY:
|
||||
case SP:
|
||||
case AC:
|
||||
case FA:
|
||||
case FR:
|
||||
case NA:
|
||||
case FS:
|
||||
case CA:
|
||||
case DS:
|
||||
case DL:
|
||||
case ND:
|
||||
case NO:
|
||||
case NS:
|
||||
case PF:
|
||||
case PL:
|
||||
case PD:
|
||||
return Common::String::format("%d", static_cast<int>(_value._byteVal));
|
||||
case SX:
|
||||
case SY:
|
||||
case XX:
|
||||
case XL:
|
||||
case WX:
|
||||
return Common::String::format("%d", static_cast<int>(_value._wordVal));
|
||||
default:
|
||||
return "(unknown)";
|
||||
}
|
||||
}
|
||||
|
||||
const char *ChangeCommand::getOperationAsString() const {
|
||||
switch (_operation) {
|
||||
case SetValue:
|
||||
return "=";
|
||||
case AddValue:
|
||||
return "+=";
|
||||
case SubtractValue:
|
||||
return "-=";
|
||||
default:
|
||||
return "(unknown)";
|
||||
}
|
||||
}
|
||||
|
||||
Command::ExecuteResult ChangeDoorCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
|
||||
if (!scene) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Door *const door = scene->getDoor(_entityId);
|
||||
if (!door) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
switch (_register) {
|
||||
case NM:
|
||||
Common::strlcpy(door->_name, _value._strVal, MAX_ENTITY_NAME_LENGTH + 1);
|
||||
break;
|
||||
case LT:
|
||||
door->_destSceneId = _value._byteVal;
|
||||
break;
|
||||
case SX:
|
||||
door->_destX = _value._wordVal;
|
||||
break;
|
||||
case SY:
|
||||
door->_destY = _value._wordVal;
|
||||
break;
|
||||
case XX:
|
||||
door->_x = _value._wordVal;
|
||||
break;
|
||||
case YY:
|
||||
door->_y = _value._byteVal;
|
||||
break;
|
||||
case XL:
|
||||
door->_width = _value._wordVal;
|
||||
break;
|
||||
case YL:
|
||||
door->_height = _value._byteVal;
|
||||
break;
|
||||
case WX:
|
||||
door->_walkToX = _value._wordVal;
|
||||
break;
|
||||
case WY:
|
||||
door->_walkToY = _value._byteVal;
|
||||
break;
|
||||
case SP:
|
||||
door->_SP = _value._byteVal;
|
||||
break;
|
||||
default:
|
||||
warning("Object does not support changing this register.");
|
||||
break;
|
||||
}
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String ChangeDoorCommand::debugString() const {
|
||||
return Common::String::format("SCENE%d.DOOR%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
|
||||
}
|
||||
|
||||
Command::ExecuteResult ChangeObjectCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
|
||||
if (!scene) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Object *const object = scene->getObject(_entityId, true);
|
||||
if (!object) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
switch (_register) {
|
||||
case AC:
|
||||
object->_active = _value._byteVal;
|
||||
break;
|
||||
case FA:
|
||||
object->_firstFrame = _value._byteVal;
|
||||
break;
|
||||
case FR:
|
||||
object->_randomFrame = _value._byteVal;
|
||||
break;
|
||||
case NA:
|
||||
object->_numFrames = _value._byteVal;
|
||||
break;
|
||||
case FS:
|
||||
object->_roomFrameLSB = _value._byteVal;
|
||||
break;
|
||||
case CA:
|
||||
object->_currentFrame = _value._byteVal;
|
||||
break;
|
||||
case XX:
|
||||
object->_x = _value._wordVal;
|
||||
break;
|
||||
case YY:
|
||||
object->_y = _value._byteVal;
|
||||
break;
|
||||
case XL:
|
||||
object->_width = _value._wordVal;
|
||||
break;
|
||||
case YL:
|
||||
object->_height = _value._byteVal;
|
||||
break;
|
||||
case WX:
|
||||
object->_WX = _value._wordVal;
|
||||
break;
|
||||
case WY:
|
||||
object->_roomFrameMSB = _value._byteVal;
|
||||
break;
|
||||
case SP:
|
||||
object->_SP = _value._byteVal;
|
||||
break;
|
||||
default:
|
||||
warning("Object does not support changing this register.");
|
||||
break;
|
||||
}
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String ChangeObjectCommand::debugString() const {
|
||||
return Common::String::format("SCENE%d.OBJECT%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
|
||||
}
|
||||
|
||||
Command::ExecuteResult ChangeStaticCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
|
||||
if (!scene) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Static *const stat = scene->getStatic(_entityId);
|
||||
if (!stat) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
switch (_register) {
|
||||
case AC:
|
||||
stat->_active = _value._byteVal;
|
||||
break;
|
||||
case NM:
|
||||
Common::strlcpy(stat->_name, _value._strVal, MAX_ENTITY_NAME_LENGTH + 1);
|
||||
break;
|
||||
case XX:
|
||||
stat->_x = _value._wordVal;
|
||||
break;
|
||||
case YY:
|
||||
stat->_y = _value._byteVal;
|
||||
break;
|
||||
case XL:
|
||||
stat->_width = _value._wordVal;
|
||||
break;
|
||||
case YL:
|
||||
stat->_height = _value._byteVal;
|
||||
break;
|
||||
case WX:
|
||||
stat->_walkToX = _value._wordVal;
|
||||
break;
|
||||
case WY:
|
||||
stat->_walkToY = _value._byteVal;
|
||||
break;
|
||||
case SP:
|
||||
stat->_walkToFrame = _value._byteVal;
|
||||
break;
|
||||
default:
|
||||
warning("Object does not support changing this register.");
|
||||
break;
|
||||
}
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String ChangeStaticCommand::debugString() const {
|
||||
return Common::String::format("SCENE%d.STATIC%d.%s %s %s", _sceneId, _entityId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
|
||||
}
|
||||
|
||||
Command::ExecuteResult ChangeSceneCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
|
||||
if (!scene) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
switch (_register) {
|
||||
case DS:
|
||||
scene->_startup = _value._byteVal;
|
||||
break;
|
||||
case DL:
|
||||
scene->_delay = _value._byteVal;
|
||||
break;
|
||||
case ND:
|
||||
scene->_noDoors = _value._byteVal;
|
||||
break;
|
||||
case NO:
|
||||
scene->_noObjects = _value._byteVal;
|
||||
break;
|
||||
case NS:
|
||||
scene->_noStatics = _value._byteVal;
|
||||
break;
|
||||
case PF:
|
||||
scene->_palRotFirst = _value._byteVal;
|
||||
break;
|
||||
case PL:
|
||||
scene->_palRotLast = _value._byteVal;
|
||||
break;
|
||||
case PD:
|
||||
scene->_palRotDelay = _value._byteVal;
|
||||
break;
|
||||
default:
|
||||
warning("Scene does not support changing this register.");
|
||||
break;
|
||||
}
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String ChangeSceneCommand::debugString() const {
|
||||
return Common::String::format("SCENE%d.%s %s %s", _sceneId, getRegisterAsString(), getOperationAsString(), getValueAsString().c_str());
|
||||
}
|
||||
|
||||
}
|
||||
146
engines/mutationofjb/commands/changecommand.h
Normal file
146
engines/mutationofjb/commands/changecommand.h
Normal file
@@ -0,0 +1,146 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
union ChangeCommandValue {
|
||||
uint8 _byteVal;
|
||||
uint16 _wordVal;
|
||||
char _strVal[MAX_ENTITY_NAME_LENGTH + 1];
|
||||
};
|
||||
|
||||
class ChangeCommand : public SeqCommand {
|
||||
public:
|
||||
enum ChangeRegister {
|
||||
NM, // Name
|
||||
LT, // Destination scene ID
|
||||
SX, // Destination X
|
||||
SY, // Destination Y
|
||||
XX, // X
|
||||
YY, // Y
|
||||
XL, // Width
|
||||
YL, // Height
|
||||
WX, // Walk to X
|
||||
WY, // Walk to Y
|
||||
SP, //
|
||||
AC, // Active
|
||||
FA, // First animation
|
||||
FR,
|
||||
NA,
|
||||
FS,
|
||||
CA,
|
||||
DS, // Startup
|
||||
DL,
|
||||
ND, // Number of doors
|
||||
NO, // Number of objects
|
||||
NS, // Number of statics
|
||||
PF, // Palette rotation first
|
||||
PL, // Palette rotation last
|
||||
PD // Palette rotation delay
|
||||
};
|
||||
|
||||
enum ChangeOperation {
|
||||
SetValue,
|
||||
AddValue,
|
||||
SubtractValue
|
||||
};
|
||||
|
||||
ChangeCommand(uint8 sceneId, uint8 entityId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val) :
|
||||
_sceneId(sceneId), _entityId(entityId), _register(reg), _operation(op), _value(val)
|
||||
{}
|
||||
protected:
|
||||
const char *getRegisterAsString() const;
|
||||
Common::String getValueAsString() const;
|
||||
const char *getOperationAsString() const;
|
||||
|
||||
uint8 _sceneId;
|
||||
uint8 _entityId;
|
||||
ChangeRegister _register;
|
||||
ChangeOperation _operation;
|
||||
ChangeCommandValue _value;
|
||||
};
|
||||
|
||||
class ChangeCommandParser : public SeqCommandParser {
|
||||
protected:
|
||||
bool parseValueString(const Common::String &valueString, bool changeEntity, uint8 &sceneId, uint8 &entityId, ChangeCommand::ChangeRegister ®, ChangeCommand::ChangeOperation &op, ChangeCommandValue &ccv);
|
||||
int parseInteger(const char *val, ChangeCommand::ChangeOperation &op);
|
||||
};
|
||||
|
||||
class ChangeObjectCommandParser : public ChangeCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class ChangeDoorCommandParser : public ChangeCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class ChangeStaticCommandParser : public ChangeCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class ChangeSceneCommandParser : public ChangeCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class ChangeDoorCommand : public ChangeCommand {
|
||||
public:
|
||||
ChangeDoorCommand(uint8 sceneId, uint8 doorId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val)
|
||||
: ChangeCommand(sceneId, doorId, reg, op, val)
|
||||
{}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
};
|
||||
|
||||
class ChangeObjectCommand : public ChangeCommand {
|
||||
public:
|
||||
ChangeObjectCommand(uint8 sceneId, uint8 objectId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val)
|
||||
: ChangeCommand(sceneId, objectId, reg, op, val)
|
||||
{}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
};
|
||||
|
||||
class ChangeStaticCommand : public ChangeCommand {
|
||||
public:
|
||||
ChangeStaticCommand(uint8 sceneId, uint8 staticId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val)
|
||||
: ChangeCommand(sceneId, staticId, reg, op, val)
|
||||
{}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
};
|
||||
|
||||
class ChangeSceneCommand : public ChangeCommand {
|
||||
public:
|
||||
ChangeSceneCommand(uint8 sceneId, uint8 staticId, ChangeRegister reg, ChangeOperation op, const ChangeCommandValue &val)
|
||||
: ChangeCommand(sceneId, staticId, reg, op, val)
|
||||
{}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
};
|
||||
|
||||
}
|
||||
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/command.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
void CommandParser::transition(ScriptParseContext &, Command *, Command *, CommandParser *) {}
|
||||
void CommandParser::finish(ScriptParseContext &) {}
|
||||
CommandParser::~CommandParser() {}
|
||||
|
||||
Command::~Command() {}
|
||||
|
||||
}
|
||||
103
engines/mutationofjb/commands/command.h
Normal file
103
engines/mutationofjb/commands/command.h
Normal file
@@ -0,0 +1,103 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_COMMAND_H
|
||||
#define MUTATIONOFJB_COMMAND_H
|
||||
|
||||
namespace Common {
|
||||
class String;
|
||||
}
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class Command;
|
||||
class ScriptExecutionContext;
|
||||
class ScriptParseContext;
|
||||
|
||||
/**
|
||||
* Base class for command parsers.
|
||||
*
|
||||
* The parser's main job is to create a Command instance from input line.
|
||||
*/
|
||||
class CommandParser {
|
||||
public:
|
||||
virtual ~CommandParser();
|
||||
|
||||
/**
|
||||
* Parses the specified line and possibly returns a Command instance.
|
||||
*
|
||||
* @param line Line to parse.
|
||||
* @param parseCtx Parse context.
|
||||
* @param command Output parameter for newly created command.
|
||||
* @return True if the line has been successfully parsed by this parser, false otherwise.
|
||||
* @note You may return true and set command to nullptr.
|
||||
* That means the line has been successfully parsed, but no command is needed.
|
||||
*/
|
||||
virtual bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) = 0;
|
||||
|
||||
/**
|
||||
* Called when transitioning parsing between two commands.
|
||||
*
|
||||
* For example, cmdParserA->transition(parseCtx, cmdA, cmdB, cmdParserB) is called after command B is done parsing
|
||||
* to notify command A parser about the transition from command A to command B.
|
||||
* This is useful for sequential commands, because at the time command A is being parsed,
|
||||
* we don't have any information about command B, so we cannot set the next pointer.
|
||||
* Transition method can be used to set the next pointer after command B is available.
|
||||
*
|
||||
* @param parseCtx Parse context.
|
||||
* @param oldCommand Old command (created by this parser).
|
||||
* @param newCommand New command (created by newCommandParser).
|
||||
* @param newCommandParser Command parser which created the new command.
|
||||
*/
|
||||
virtual void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser);
|
||||
|
||||
/**
|
||||
* Called after the whole script is parsed.
|
||||
*
|
||||
* Can be used for cleanup.
|
||||
*
|
||||
* @param parseCtx Parse context.
|
||||
*/
|
||||
virtual void finish(ScriptParseContext &parseCtx);
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for script commands.
|
||||
*/
|
||||
class Command {
|
||||
public:
|
||||
enum ExecuteResult {
|
||||
None,
|
||||
Finished,
|
||||
InProgress
|
||||
};
|
||||
|
||||
virtual ~Command();
|
||||
|
||||
virtual ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) = 0;
|
||||
virtual Command *next() const = 0;
|
||||
|
||||
virtual Common::String debugString() const = 0;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
73
engines/mutationofjb/commands/conditionalcommand.cpp
Normal file
73
engines/mutationofjb/commands/conditionalcommand.cpp
Normal file
@@ -0,0 +1,73 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/conditionalcommand.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
void ConditionalCommandParser::transition(ScriptParseContext &parseContext, Command *oldCommand, Command *newCommand, CommandParser *) {
|
||||
if (!oldCommand || !newCommand) {
|
||||
warning("Unexpected empty command in transition");
|
||||
return;
|
||||
}
|
||||
|
||||
ConditionalCommand *const condCommand = static_cast<ConditionalCommand *>(oldCommand);
|
||||
parseContext.addConditionalCommand(condCommand, _tags.pop(), _firstHash);
|
||||
condCommand->setTrueCommand(newCommand);
|
||||
}
|
||||
|
||||
void ConditionalCommandParser::finish(ScriptParseContext &) {
|
||||
_tags.clear();
|
||||
}
|
||||
|
||||
|
||||
ConditionalCommand::ConditionalCommand() :
|
||||
_trueCommand(nullptr),
|
||||
_falseCommand(nullptr),
|
||||
_cachedResult(false) {}
|
||||
|
||||
Command *ConditionalCommand::getTrueCommand() const {
|
||||
return _trueCommand;
|
||||
}
|
||||
|
||||
Command *ConditionalCommand::getFalseCommand() const {
|
||||
return _falseCommand;
|
||||
}
|
||||
|
||||
void ConditionalCommand::setTrueCommand(Command *command) {
|
||||
_trueCommand = command;
|
||||
}
|
||||
|
||||
void ConditionalCommand::setFalseCommand(Command *command) {
|
||||
_falseCommand = command;
|
||||
}
|
||||
|
||||
Command *ConditionalCommand::next() const {
|
||||
if (_cachedResult) {
|
||||
return _trueCommand;
|
||||
} else {
|
||||
return _falseCommand;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
61
engines/mutationofjb/commands/conditionalcommand.h
Normal file
61
engines/mutationofjb/commands/conditionalcommand.h
Normal file
@@ -0,0 +1,61 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_CONDITIONALCOMMAND_H
|
||||
#define MUTATIONOFJB_CONDITIONALCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/command.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/queue.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ConditionalCommandParser : public CommandParser {
|
||||
public:
|
||||
ConditionalCommandParser(bool firstHash = false) : _firstHash(firstHash) {}
|
||||
void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser) override;
|
||||
void finish(ScriptParseContext &parseCtx) override;
|
||||
protected:
|
||||
Common::Queue<char> _tags;
|
||||
private:
|
||||
bool _firstHash;
|
||||
};
|
||||
|
||||
class ConditionalCommand : public Command {
|
||||
public:
|
||||
ConditionalCommand();
|
||||
|
||||
Command *getTrueCommand() const;
|
||||
Command *getFalseCommand() const;
|
||||
|
||||
void setTrueCommand(Command *command);
|
||||
void setFalseCommand(Command *command);
|
||||
|
||||
Command *next() const override;
|
||||
protected:
|
||||
Command *_trueCommand;
|
||||
Command *_falseCommand;
|
||||
bool _cachedResult;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
99
engines/mutationofjb/commands/definestructcommand.cpp
Normal file
99
engines/mutationofjb/commands/definestructcommand.cpp
Normal file
@@ -0,0 +1,99 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/definestructcommand.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/game.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
/** @file
|
||||
* "DEFINE_STRUCT " <numItemGroups> " " <context> " " <objectId> " " <colorString> <CRLF>
|
||||
* <itemGroup> { <CRLF> <itemGroup> }
|
||||
*
|
||||
* item ::= <questionIndex> " " <responseIndex> " " <nextGroup>
|
||||
* itemGroup ::= <item> " " <item> " " <item> " " <item> " " <item>
|
||||
*
|
||||
* Defines the flow of an interactive conversation.
|
||||
*
|
||||
* Every item group consists of 5 conversation items.
|
||||
* "questionIndex" and "responseIndex" specify what the player and the responder say when the conversation item is selected.
|
||||
* They refer to the line numbers of TOSAY.GER and RESPONSE.GER, respectively.
|
||||
* "nextGroup" refers to the group that follows when the conversation item is selected. A value of 0 indicates end of
|
||||
* conversation.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool DefineStructCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
|
||||
if (line.size() < 24 || !line.hasPrefix("DEFINE_STRUCT")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ConversationInfo convInfo;
|
||||
|
||||
const int numLines = atoi(line.c_str() + 14);
|
||||
convInfo._context = atoi(line.c_str() + 18);
|
||||
convInfo._objectId = atoi(line.c_str() + 20);
|
||||
convInfo._color = Game::colorFromString(line.c_str() + 23);
|
||||
|
||||
for (int i = 0; i < numLines; ++i) {
|
||||
Common::String convLineStr;
|
||||
if (!parseCtx.readLine(convLineStr)) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (convLineStr.size() != 74) {
|
||||
debug("Conversation line in DEFINE_STRUCT with wrong length");
|
||||
continue;
|
||||
}
|
||||
|
||||
const char *linePtr = convLineStr.c_str();
|
||||
|
||||
ConversationInfo::ItemGroup convGroup;
|
||||
|
||||
for (int j = 0; j < 5; ++j) {
|
||||
ConversationInfo::Item convItem;
|
||||
convItem._question = atoi(linePtr);
|
||||
linePtr += 6;
|
||||
convItem._response = atoi(linePtr);
|
||||
linePtr += 6;
|
||||
convItem._nextGroupIndex = atoi(linePtr);
|
||||
linePtr += 3;
|
||||
convGroup.push_back(convItem);
|
||||
}
|
||||
convInfo._itemGroups.push_back(convGroup);
|
||||
}
|
||||
|
||||
command = new DefineStructCommand(convInfo);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult DefineStructCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
scriptExecCtx.getGameData()._conversationInfo = _conversationInfo;
|
||||
return Command::Finished;
|
||||
}
|
||||
|
||||
Common::String DefineStructCommand::debugString() const {
|
||||
return "DEFINE_STRUCT <data omitted>";
|
||||
}
|
||||
|
||||
}
|
||||
41
engines/mutationofjb/commands/definestructcommand.h
Normal file
41
engines/mutationofjb/commands/definestructcommand.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class DefineStructCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class DefineStructCommand : public SeqCommand {
|
||||
public:
|
||||
DefineStructCommand(const ConversationInfo& convInfo) : _conversationInfo(convInfo) {}
|
||||
Command::ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
ConversationInfo _conversationInfo;
|
||||
};
|
||||
|
||||
}
|
||||
259
engines/mutationofjb/commands/endblockcommand.cpp
Normal file
259
engines/mutationofjb/commands/endblockcommand.cpp
Normal file
@@ -0,0 +1,259 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/endblockcommand.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/commands/conditionalcommand.h"
|
||||
#include "common/str.h"
|
||||
#include "common/debug.h"
|
||||
|
||||
/** @file
|
||||
* <look> | <walk> | <talk> | <pickup> | <use> | <else> | <macro> | <extra> | <endRandom>
|
||||
*
|
||||
* look ::= ("#L " | "-L ") <object>
|
||||
* walk ::= ("#W " | "-W ") <object>
|
||||
* talk ::= ("#T " | "-T ") <object>
|
||||
* pickup ::= ("#P " | "-P ") <object1>
|
||||
* use ::= ("#U " | "-U ") <object1> [<object2>]
|
||||
* else ::= ("#ELSE" | "-ELSE") [<tag>]
|
||||
* macro ::= "#MACRO " <name>
|
||||
* extra ::= "#EXTRA" <name>
|
||||
* endRandom ::= "\"
|
||||
*
|
||||
* If a line starts with '#', '=', '-', '\' it is treated as the end of a section.
|
||||
* However, at the same time it can also start a new section depending on what follows.
|
||||
*
|
||||
* #L (look), #W (walk), #T (talk), #U (use) sections are executed
|
||||
* when the user starts corresponding action on the object or in case of "use" up to two objects.
|
||||
* The difference between '#' and '-' version is whether the player walks towards the object ('#') or not ('-').
|
||||
*
|
||||
* #ELSE is used by conditional commands (see comments for IfCommand and others).
|
||||
*
|
||||
* #MACRO starts a new macro. Global script can call macros from local script and vice versa.
|
||||
*
|
||||
* #EXTRA defines an "extra" section. This is called from dialog responses ("TALK TO HIM" command).
|
||||
*
|
||||
* TODO: TIMERPROC.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool EndBlockCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
|
||||
if (line.empty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char firstChar = line.firstChar();
|
||||
if (firstChar != '#' && firstChar != '=' && firstChar != '-' && firstChar != '\\') {
|
||||
return false;
|
||||
}
|
||||
|
||||
// This is the start or end of section/block.
|
||||
command = new EndBlockCommand();
|
||||
|
||||
if (line.size() >= 4 && (line.hasPrefix("#L ") || line.hasPrefix("-L "))) {
|
||||
ActionInfo ai = {ActionInfo::Look, line.c_str() + 3, "", firstChar == '#', nullptr};
|
||||
parseCtx._actionInfos.push_back(ai);
|
||||
_pendingActionInfos.push_back(parseCtx._actionInfos.size() - 1);
|
||||
} else if (line.size() >= 4 && (line.hasPrefix("#W ") || line.hasPrefix("-W "))) {
|
||||
ActionInfo ai = {ActionInfo::Walk, line.c_str() + 3, "", firstChar == '#', nullptr};
|
||||
parseCtx._actionInfos.push_back(ai);
|
||||
_pendingActionInfos.push_back(parseCtx._actionInfos.size() - 1);
|
||||
} else if (line.size() >= 4 && (line.hasPrefix("#T ") || line.hasPrefix("-T "))) {
|
||||
ActionInfo ai = {ActionInfo::Talk, line.c_str() + 3, "", firstChar == '#', nullptr};
|
||||
parseCtx._actionInfos.push_back(ai);
|
||||
_pendingActionInfos.push_back(parseCtx._actionInfos.size() - 1);
|
||||
} else if (line.size() >= 4 && (line.hasPrefix("#P ") || line.hasPrefix("-P "))) {
|
||||
ActionInfo ai = {ActionInfo::PickUp, line.c_str() + 3, "", firstChar == '#', nullptr};
|
||||
parseCtx._actionInfos.push_back(ai);
|
||||
_pendingActionInfos.push_back(parseCtx._actionInfos.size() - 1);
|
||||
} else if (line.size() >= 4 && (line.hasPrefix("#U ") || line.hasPrefix("-U "))) {
|
||||
int secondObjPos = -1;
|
||||
for (uint i = 3; i < line.size(); ++i) {
|
||||
if (line[i] == ' ') {
|
||||
secondObjPos = i + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Common::String obj1;
|
||||
Common::String obj2;
|
||||
if (secondObjPos == -1) {
|
||||
obj1 = line.c_str() + 3;
|
||||
} else {
|
||||
obj1 = Common::String(line.c_str() + 3, secondObjPos - 4);
|
||||
obj2 = line.c_str() + secondObjPos;
|
||||
}
|
||||
|
||||
ActionInfo ai = {
|
||||
ActionInfo::Use,
|
||||
obj1,
|
||||
obj2,
|
||||
firstChar == '#',
|
||||
nullptr
|
||||
};
|
||||
parseCtx._actionInfos.push_back(ai);
|
||||
_pendingActionInfos.push_back(parseCtx._actionInfos.size() - 1);
|
||||
} else if ((line.hasPrefix("#ELSE") || line.hasPrefix("=ELSE"))) {
|
||||
_elseFound = true;
|
||||
_ifTag = 0;
|
||||
if (line.size() >= 6) {
|
||||
_ifTag = line[5];
|
||||
}
|
||||
} else if (line.size() >= 8 && line.hasPrefix("#MACRO")) {
|
||||
NameAndCommand nc = {line.c_str() + 7, command};
|
||||
_foundMacros.push_back(nc);
|
||||
} else if (line.size() >= 10 && line.hasPrefix("#STARTUP")) {
|
||||
const uint8 startupId = atoi(line.c_str() + 9);
|
||||
IdAndCommand ic = {startupId, command};
|
||||
_foundStartups.push_back(ic);
|
||||
} else if (line.size() >= 7 && line.hasPrefix("#EXTRA")) {
|
||||
NameAndCommand nc = {line.c_str() + 6, command};
|
||||
_foundExtras.push_back(nc);
|
||||
}
|
||||
|
||||
if (firstChar == '#') {
|
||||
_hashFound = true;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void EndBlockCommandParser::transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser) {
|
||||
if (_elseFound || _hashFound) {
|
||||
if (newCommand) {
|
||||
ScriptParseContext::ConditionalCommandInfos::iterator it = parseCtx._pendingCondCommands.begin();
|
||||
|
||||
while (it != parseCtx._pendingCondCommands.end()) {
|
||||
if ((it->_firstHash && _hashFound) || (!it->_firstHash && it->_tag == _ifTag)) {
|
||||
it->_command->setFalseCommand(newCommand);
|
||||
it = parseCtx._pendingCondCommands.erase(it);
|
||||
} else {
|
||||
++it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_elseFound = false;
|
||||
_hashFound = false;
|
||||
_ifTag = 0;
|
||||
}
|
||||
|
||||
if (!_foundMacros.empty()) {
|
||||
if (newCommand) {
|
||||
for (NameAndCommandArray::iterator it = _foundMacros.begin(); it != _foundMacros.end();) {
|
||||
if (it->_command != oldCommand) {
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!parseCtx._macros.contains(it->_name)) {
|
||||
parseCtx._macros[it->_name] = newCommand;
|
||||
} else {
|
||||
warning("Macro '%s' already exists", it->_name.c_str());
|
||||
}
|
||||
it = _foundMacros.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_foundStartups.empty()) {
|
||||
if (newCommand) {
|
||||
for (IdAndCommandArray::iterator it = _foundStartups.begin(); it != _foundStartups.end();) {
|
||||
if (it->_command != oldCommand) {
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!parseCtx._startups.contains(it->_id)) {
|
||||
parseCtx._startups[it->_id] = newCommand;
|
||||
} else {
|
||||
warning("Startup %u already exists", (unsigned int) it->_id);
|
||||
}
|
||||
it = _foundStartups.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!_foundExtras.empty()) {
|
||||
if (newCommand) {
|
||||
for (NameAndCommandArray::iterator it = _foundExtras.begin(); it != _foundExtras.end();) {
|
||||
if (it->_command != oldCommand) {
|
||||
it++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!parseCtx._extras.contains(it->_name)) {
|
||||
parseCtx._extras[it->_name] = newCommand;
|
||||
} else {
|
||||
warning("Extra '%s' already exists", it->_name.c_str());
|
||||
}
|
||||
it = _foundExtras.erase(it);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (newCommandParser != this) {
|
||||
if (!_pendingActionInfos.empty()) {
|
||||
for (Common::Array<uint>::iterator it = _pendingActionInfos.begin(); it != _pendingActionInfos.end(); ++it) {
|
||||
parseCtx._actionInfos[*it]._command = newCommand;
|
||||
}
|
||||
_pendingActionInfos.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EndBlockCommandParser::finish(ScriptParseContext &) {
|
||||
_elseFound = false;
|
||||
_hashFound = false;
|
||||
_ifTag = 0;
|
||||
|
||||
if (!_pendingActionInfos.empty()) {
|
||||
debug("Problem: Pending action infos from end block parser is not empty!");
|
||||
}
|
||||
if (!_foundMacros.empty()) {
|
||||
debug("Problem: Found macros from end block parser is not empty!");
|
||||
}
|
||||
if (!_foundStartups.empty()) {
|
||||
debug("Problem: Found startups from end block parser is not empty!");
|
||||
}
|
||||
if (!_foundExtras.empty()) {
|
||||
debug("Problem: Found extras from end block parser is not empty!");
|
||||
}
|
||||
_pendingActionInfos.clear();
|
||||
_foundMacros.clear();
|
||||
_foundStartups.clear();
|
||||
_foundExtras.clear();
|
||||
}
|
||||
|
||||
Command::ExecuteResult EndBlockCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
_nextCmd = scriptExecCtx.popReturnCommand();
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Command *EndBlockCommand::next() const {
|
||||
return _nextCmd;
|
||||
}
|
||||
|
||||
Common::String EndBlockCommand::debugString() const {
|
||||
return "ENDBLOCK";
|
||||
}
|
||||
|
||||
}
|
||||
77
engines/mutationofjb/commands/endblockcommand.h
Normal file
77
engines/mutationofjb/commands/endblockcommand.h
Normal file
@@ -0,0 +1,77 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_ENDBLOCKCOMMAND_H
|
||||
#define MUTATIONOFJB_ENDBLOCKCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/command.h"
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/array.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
struct ActionInfo;
|
||||
|
||||
class EndBlockCommandParser : public CommandParser {
|
||||
public:
|
||||
EndBlockCommandParser() : _elseFound(false), _hashFound(false), _ifTag(0) {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser) override;
|
||||
void finish(ScriptParseContext &parseCtx) override;
|
||||
private:
|
||||
bool _elseFound;
|
||||
bool _hashFound;
|
||||
char _ifTag;
|
||||
|
||||
Common::Array<uint> _pendingActionInfos;
|
||||
struct NameAndCommand {
|
||||
Common::String _name;
|
||||
Command *_command;
|
||||
};
|
||||
struct IdAndCommand {
|
||||
uint8 _id;
|
||||
Command *_command;
|
||||
};
|
||||
typedef Common::Array<NameAndCommand> NameAndCommandArray;
|
||||
typedef Common::Array<IdAndCommand> IdAndCommandArray;
|
||||
NameAndCommandArray _foundMacros;
|
||||
IdAndCommandArray _foundStartups;
|
||||
NameAndCommandArray _foundExtras;
|
||||
};
|
||||
|
||||
class EndBlockCommand : public Command {
|
||||
public:
|
||||
EndBlockCommand() : _nextCmd(nullptr) {}
|
||||
static bool ParseFunc(const Common::String &line, ScriptParseContext &parseContext, Command *&command);
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Command *next() const override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
Command *_nextCmd;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
79
engines/mutationofjb/commands/gotocommand.cpp
Normal file
79
engines/mutationofjb/commands/gotocommand.cpp
Normal file
@@ -0,0 +1,79 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/gotocommand.h"
|
||||
#include "mutationofjb/commands/labelcommand.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
/** @file
|
||||
* "GOTO " <label>
|
||||
*
|
||||
* Jumps to a label.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool GotoCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
|
||||
if (line.size() < 6 || !line.hasPrefix("GOTO")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Common::String label = line.c_str() + 5;
|
||||
GotoCommand *gotoCmd = new GotoCommand();
|
||||
|
||||
if (parseCtx._labels.contains(label)) {
|
||||
// We already have the label, set it.
|
||||
gotoCmd->setLabelCommand(parseCtx._labels[label]);
|
||||
} else {
|
||||
// Label is after goto, add to pending list.
|
||||
parseCtx._pendingGotos[label].push_back(gotoCmd);
|
||||
}
|
||||
|
||||
command = gotoCmd;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void GotoCommand::setLabelCommand(LabelCommand *labelCmd) {
|
||||
_labelCommand = labelCmd;
|
||||
}
|
||||
|
||||
Command::ExecuteResult GotoCommand::execute(ScriptExecutionContext &) {
|
||||
// Intentionally empty.
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Command *GotoCommand::next() const {
|
||||
return _labelCommand;
|
||||
}
|
||||
|
||||
Common::String GotoCommand::debugString() const {
|
||||
if (!_labelCommand) {
|
||||
return "GOTO (null)";
|
||||
}
|
||||
|
||||
return Common::String::format("GOTO %s", _labelCommand->getName().c_str());
|
||||
}
|
||||
|
||||
}
|
||||
54
engines/mutationofjb/commands/gotocommand.h
Normal file
54
engines/mutationofjb/commands/gotocommand.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_GOTOCOMMAND_H
|
||||
#define MUTATIONOFJB_GOTOCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/command.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class LabelCommand;
|
||||
|
||||
class GotoCommandParser : public CommandParser {
|
||||
public:
|
||||
GotoCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class GotoCommand : public Command {
|
||||
public:
|
||||
GotoCommand() : _labelCommand(nullptr) {}
|
||||
|
||||
void setLabelCommand(LabelCommand *labelCmd);
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Command *next() const override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
LabelCommand *_labelCommand;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
108
engines/mutationofjb/commands/ifcommand.cpp
Normal file
108
engines/mutationofjb/commands/ifcommand.cpp
Normal file
@@ -0,0 +1,108 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/ifcommand.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "common/str.h"
|
||||
|
||||
/** @file
|
||||
* "IF" <tag> <sceneId> <objectId> <value> ["!"]
|
||||
*
|
||||
* IF command compares the value of the WX pseudo-register of the object in the specified scene.
|
||||
* If the values match, execution continues to the next line.
|
||||
* Otherwise execution continues after first "#ELSE" or "=ELSE" with the same <tag>.
|
||||
* The logic can be reversed with exclamation mark at the end.
|
||||
*
|
||||
* <tag> is always 1 character long, <sceneId> and <objectId> 2 characters long.
|
||||
*
|
||||
* Please note that this does not work like you are used to from saner languages.
|
||||
* IF does not have any blocks. It only searches for first #ELSE, so you can have stuff like:
|
||||
* IF something
|
||||
* IF something else
|
||||
* #ELSE
|
||||
* ...
|
||||
* This is effectively logical AND.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool IfCommandParser::parse(const Common::String &line, ScriptParseContext &, 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 (!line.hasPrefix("IF")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *const cstr = line.c_str();
|
||||
const char tag = cstr[2] == ' ' ? 0 : 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() == '!');
|
||||
|
||||
_tags.push(tag);
|
||||
|
||||
command = new IfCommand(sceneId, objectId, value, negative);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
IfCommand::IfCommand(uint8 sceneId, uint8 objectId, uint16 value, bool negative) :
|
||||
_sceneId(sceneId),
|
||||
_objectId(objectId),
|
||||
_value(value),
|
||||
_negative(negative) {}
|
||||
|
||||
Command::ExecuteResult IfCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
Scene *const scene = scriptExecCtx.getGameData().getScene(_sceneId);
|
||||
if (!scene) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Object *const object = scene->getObject(_objectId, true);
|
||||
if (!object) {
|
||||
return Finished;
|
||||
}
|
||||
|
||||
_cachedResult = (object->_WX == _value);
|
||||
if (_negative) {
|
||||
_cachedResult = !_cachedResult;
|
||||
}
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String IfCommand::debugString() const {
|
||||
return Common::String::format("IF scene%d.object%d.WX %s %d", _sceneId, _objectId, _negative ? "!=" : "==", _value);
|
||||
}
|
||||
|
||||
}
|
||||
54
engines/mutationofjb/commands/ifcommand.h
Normal file
54
engines/mutationofjb/commands/ifcommand.h
Normal file
@@ -0,0 +1,54 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_IFCOMMAND_H
|
||||
#define MUTATIONOFJB_IFCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/conditionalcommand.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ScriptParseContext;
|
||||
|
||||
class IfCommandParser : public ConditionalCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
private:
|
||||
};
|
||||
|
||||
class IfCommand : public ConditionalCommand {
|
||||
public:
|
||||
IfCommand(uint8 sceneId, uint8 objectId, uint16 value, bool negative);
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
|
||||
private:
|
||||
uint8 _sceneId;
|
||||
uint8 _objectId;
|
||||
uint16 _value;
|
||||
bool _negative;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
86
engines/mutationofjb/commands/ifitemcommand.cpp
Normal file
86
engines/mutationofjb/commands/ifitemcommand.cpp
Normal file
@@ -0,0 +1,86 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/ifitemcommand.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/util.h"
|
||||
#include "common/str.h"
|
||||
|
||||
/** @file
|
||||
* "IFITEM " <item> [ "!" ]
|
||||
*
|
||||
* IFITEM command tests whether an item is in the inventory.
|
||||
* If it is, execution continues to the next line.
|
||||
* Otherwise execution continues after first "#ELSE" or "=ELSE".
|
||||
* The logic can be reversed with exclamation mark at the end.
|
||||
*
|
||||
* Please note that this does not work like you are used to from saner languages.
|
||||
* IFITEM does not have any blocks. It only searches for first #ELSE, so you can have stuff like:
|
||||
* IFITEM item1
|
||||
* IFITEM item2
|
||||
* #ELSE
|
||||
* ...
|
||||
* This is effectively logical AND.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool IfItemCommandParser::parse(const Common::String &line, ScriptParseContext &parseContext, Command *&command) {
|
||||
if (line.size() < 8) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!line.hasPrefix("IFITEM")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const bool negative = (line.lastChar() == '!');
|
||||
Common::String item(line.c_str() + 7);
|
||||
if (negative) {
|
||||
item.deleteLastChar(); // Remove '!'.
|
||||
}
|
||||
|
||||
_tags.push(0);
|
||||
command = new IfItemCommand(item, negative);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
IfItemCommand::IfItemCommand(const Common::String &item, bool negative) :
|
||||
_item(item),
|
||||
_negative(negative) {}
|
||||
|
||||
Command::ExecuteResult IfItemCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
_cachedResult = scriptExecCtx.getGameData()._inventory.hasItem(_item);
|
||||
if (_negative) {
|
||||
_cachedResult = !_cachedResult;
|
||||
}
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String IfItemCommand::debugString() const {
|
||||
return Common::String::format("IFITEM %s%s", _negative ? "NOT " : "", _item.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
52
engines/mutationofjb/commands/ifitemcommand.h
Normal file
52
engines/mutationofjb/commands/ifitemcommand.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_IFITEMCOMMAND_H
|
||||
#define MUTATIONOFJB_IFITEMCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/conditionalcommand.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ScriptParseContext;
|
||||
|
||||
class IfItemCommandParser : public ConditionalCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class IfItemCommand : public ConditionalCommand {
|
||||
public:
|
||||
IfItemCommand(const Common::String &item, bool negative);
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
|
||||
private:
|
||||
Common::String _item;
|
||||
bool _negative;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
68
engines/mutationofjb/commands/ifpiggycommand.cpp
Normal file
68
engines/mutationofjb/commands/ifpiggycommand.cpp
Normal file
@@ -0,0 +1,68 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/ifpiggycommand.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/util.h"
|
||||
#include "common/str.h"
|
||||
|
||||
/** @file
|
||||
* "IFPIGGY"
|
||||
*
|
||||
* IFPIGGY command tests whether current loaded APK file (character animation) is "piggy.apk".
|
||||
* If it is, execution continues to the next line.
|
||||
* Otherwise execution continues after first "#ELSE" or "=ELSE".
|
||||
*
|
||||
* Please note that this does not work like you are used to from saner languages.
|
||||
* IFPIGGY does not have any blocks. It only searches for first #ELSE, so you can have stuff like:
|
||||
* IFPIGGY
|
||||
* IFITEM someitem
|
||||
* #ELSE
|
||||
* ...
|
||||
* This is effectively logical AND.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool IfPiggyCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line != "IFPIGGY") {
|
||||
return false;
|
||||
}
|
||||
|
||||
_tags.push(0);
|
||||
command = new IfPiggyCommand();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Command::ExecuteResult IfPiggyCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
_cachedResult = scriptExecCtx.getGameData()._currentAPK == "piggy.apk";
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String IfPiggyCommand::debugString() const {
|
||||
return "IFPIGGY";
|
||||
}
|
||||
|
||||
}
|
||||
48
engines/mutationofjb/commands/ifpiggycommand.h
Normal file
48
engines/mutationofjb/commands/ifpiggycommand.h
Normal file
@@ -0,0 +1,48 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_IFPIGGYCOMMAND_H
|
||||
#define MUTATIONOFJB_IFPIGGYCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/conditionalcommand.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ScriptParseContext;
|
||||
|
||||
class IfPiggyCommandParser : public ConditionalCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class IfPiggyCommand : public ConditionalCommand {
|
||||
public:
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
76
engines/mutationofjb/commands/labelcommand.cpp
Normal file
76
engines/mutationofjb/commands/labelcommand.cpp
Normal file
@@ -0,0 +1,76 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/labelcommand.h"
|
||||
#include "mutationofjb/commands/gotocommand.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
/** @file
|
||||
* <label> ":"
|
||||
*
|
||||
* Creates a label.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool LabelCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
|
||||
if (line.lastChar() != ':') {
|
||||
return false;
|
||||
}
|
||||
|
||||
Common::String label = line;
|
||||
label.deleteLastChar();
|
||||
|
||||
LabelCommand *labelCmd = new LabelCommand(label);
|
||||
if (!parseCtx._labels.contains(label)) {
|
||||
parseCtx._labels[label] = labelCmd;
|
||||
} else {
|
||||
warning("Label '%s' already exists", label.c_str());
|
||||
}
|
||||
|
||||
if (parseCtx._pendingGotos.contains(label)) {
|
||||
GotoCommands &gotos = parseCtx._pendingGotos[label];
|
||||
for (GotoCommands::const_iterator it = gotos.begin(); it != gotos.end(); ++it) {
|
||||
(*it)->setLabelCommand(labelCmd);
|
||||
}
|
||||
gotos.clear();
|
||||
}
|
||||
|
||||
command = labelCmd;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
const Common::String &LabelCommand::getName() const {
|
||||
return _name;
|
||||
}
|
||||
|
||||
Command::ExecuteResult LabelCommand::execute(ScriptExecutionContext &) {
|
||||
// Intentionally empty.
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String LabelCommand::debugString() const {
|
||||
return Common::String::format("LABEL %s", _name.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
50
engines/mutationofjb/commands/labelcommand.h
Normal file
50
engines/mutationofjb/commands/labelcommand.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_LABELCOMMAND_H
|
||||
#define MUTATIONOFJB_LABELCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class LabelCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
LabelCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class LabelCommand : public SeqCommand {
|
||||
public:
|
||||
LabelCommand(const Common::String &name) : _name(name) {}
|
||||
const Common::String &getName() const;
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
Common::String _name;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
63
engines/mutationofjb/commands/loadplayercommand.cpp
Normal file
63
engines/mutationofjb/commands/loadplayercommand.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/loadplayercommand.h"
|
||||
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
/** @file
|
||||
* "RABLOAD " <apkFrameFirst> " " <apkFrameLast> " " <playerFrameFirst> " " <palIndexFirst> " " <apkFilename>
|
||||
*
|
||||
* Load player frames from APK file specified by apkFileName.
|
||||
* Only frames between apkFrameFirst and apkFrameLast are loaded onto position defined by playerFrameFirst.
|
||||
* Player's palette is loaded at index defined by palIndexFirst.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool LoadPlayerCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line.size() < 25 || !line.hasPrefix("RABLOAD ")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint8 apkFrameFirst = atoi(line.c_str() + 8);
|
||||
const uint8 apkFrameLast = atoi(line.c_str() + 12);
|
||||
const uint8 playerFrameFirst = atoi(line.c_str() + 16);
|
||||
const uint8 palIndexFirst = atoi(line.c_str() + 20);
|
||||
const Common::String apkFileName = line.c_str() + 24;
|
||||
|
||||
command = new LoadPlayerCommand(apkFrameFirst, apkFrameLast, playerFrameFirst, palIndexFirst, apkFileName);
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult LoadPlayerCommand::execute(ScriptExecutionContext &scriptExeCtx) {
|
||||
scriptExeCtx.getGameData()._currentAPK = _apkFileName;
|
||||
|
||||
return Command::Finished;
|
||||
}
|
||||
|
||||
Common::String LoadPlayerCommand::debugString() const {
|
||||
return Common::String::format("LOADPLAYER %u %u %u %u %s", (unsigned int) _apkFrameFirst, (unsigned int) _apkFrameLast, (unsigned int) _playerFrameFirst, (unsigned int) _palIndexFirst, _apkFileName.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
56
engines/mutationofjb/commands/loadplayercommand.h
Normal file
56
engines/mutationofjb/commands/loadplayercommand.h
Normal file
@@ -0,0 +1,56 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_LOADPLAYERCOMMAND_H
|
||||
#define MUTATIONOFJB_LOADPLAYERCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "mutationofjb/tasks/task.h"
|
||||
|
||||
#include "common/scummsys.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ConversationTask;
|
||||
|
||||
class LoadPlayerCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class LoadPlayerCommand : public SeqCommand {
|
||||
public:
|
||||
LoadPlayerCommand(uint8 apkFrameFirst, uint8 apkFrameLast, uint8 playerFrameFirst, uint8 palIndexFirst, const Common::String &apkFileName) : _apkFrameFirst(apkFrameFirst), _apkFrameLast(apkFrameLast), _playerFrameFirst(playerFrameFirst), _palIndexFirst(palIndexFirst), _apkFileName(apkFileName) {}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
|
||||
private:
|
||||
uint8 _apkFrameFirst;
|
||||
uint8 _apkFrameLast;
|
||||
uint8 _playerFrameFirst;
|
||||
uint8 _palIndexFirst;
|
||||
Common::String _apkFileName;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
83
engines/mutationofjb/commands/newroomcommand.cpp
Normal file
83
engines/mutationofjb/commands/newroomcommand.cpp
Normal file
@@ -0,0 +1,83 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/newroomcommand.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "common/str.h"
|
||||
|
||||
/** @file
|
||||
* "NEWROOM " <sceneId> " " <x> " " <y> [ " " <frame> ]
|
||||
*
|
||||
* NEWROOM changes the current scene. While doing that, it also executes STARTUP section for the new room.
|
||||
* However, after that, the execution goes back to the old script to finish commands after NEWROOM.
|
||||
*
|
||||
* All parameters are supposed to be 3 characters long.
|
||||
* SceneId is the scene to load, x and y are the player's new position and frame is the player's new frame (orientation).
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool NewRoomCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line.size() < 19 || !line.hasPrefix("NEWROOM")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const uint8 sceneId = atoi(line.c_str() + 8);
|
||||
const uint16 x = atoi(line.c_str() + 12);
|
||||
const uint16 y = atoi(line.c_str() + 16);
|
||||
uint8 frame = 0;
|
||||
if (line.size() >= 21)
|
||||
frame = atoi(line.c_str() + 20);
|
||||
command = new NewRoomCommand(sceneId, x, y, frame);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
NewRoomCommand::NewRoomCommand(uint8 sceneId, uint16 x, uint16 y, uint8 frame) : _sceneId(sceneId), _x(x), _y(y), _frame(frame), _innerExecCtx(nullptr) {}
|
||||
|
||||
Command::ExecuteResult NewRoomCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
Game &game = scriptExecCtx.getGame();
|
||||
|
||||
// Execute new startup section.
|
||||
ExecuteResult res;
|
||||
if (!_innerExecCtx) {
|
||||
Script *newScript = game.changeSceneDelayScript(_sceneId, game.getGameData()._partB);
|
||||
_innerExecCtx = new ScriptExecutionContext(scriptExecCtx.getGame(), newScript);
|
||||
res = _innerExecCtx->startStartupSection();
|
||||
} else {
|
||||
res = _innerExecCtx->runActiveCommand();
|
||||
}
|
||||
|
||||
if (res == Finished) {
|
||||
delete _innerExecCtx;
|
||||
_innerExecCtx = nullptr;
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
Common::String NewRoomCommand::debugString() const {
|
||||
return Common::String::format("NEWROOM %u %u %u %u", (unsigned int) _sceneId, (unsigned int) _x, (unsigned int) _y, (unsigned int) _frame);
|
||||
}
|
||||
|
||||
}
|
||||
55
engines/mutationofjb/commands/newroomcommand.h
Normal file
55
engines/mutationofjb/commands/newroomcommand.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_NEWROOMCOMMAND_H
|
||||
#define MUTATIONOFJB_NEWROOMCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ScriptExecutionContext;
|
||||
|
||||
class NewRoomCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
NewRoomCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class NewRoomCommand : public SeqCommand {
|
||||
public:
|
||||
NewRoomCommand(uint8 sceneId, uint16 x, uint16 y, uint8 frame);
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
uint8 _sceneId;
|
||||
uint16 _x;
|
||||
uint16 _y;
|
||||
uint8 _frame;
|
||||
|
||||
ScriptExecutionContext *_innerExecCtx;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
60
engines/mutationofjb/commands/playanimationcommand.cpp
Normal file
60
engines/mutationofjb/commands/playanimationcommand.cpp
Normal file
@@ -0,0 +1,60 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/playanimationcommand.h"
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/room.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
/** @file
|
||||
* ( "FLB " | "FLX" ) <fromFrame> " " <toFrame>
|
||||
*
|
||||
* Plays the specified frames from room animation.
|
||||
*
|
||||
* TODO: Parse all arguments of this command.
|
||||
* TODO: Actually play the animation instead of just showing last frame.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool PlayAnimationCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
|
||||
if (line.size() < 11 || (!line.hasPrefix("FLB ") && !line.hasPrefix("FLX ")))
|
||||
return false;
|
||||
|
||||
const int fromFrame = atoi(line.c_str() + 4);
|
||||
const int toFrame = atoi(line.c_str() + 8);
|
||||
|
||||
command = new PlayAnimationCommand(fromFrame, toFrame);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Command::ExecuteResult PlayAnimationCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
scriptExecCtx.getGame().getRoom().drawFrames(_fromFrame - 1, _toFrame - 1);
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String PlayAnimationCommand::debugString() const {
|
||||
return Common::String::format("PLAYROOMANIM %u %u", (unsigned int) _fromFrame, (unsigned int) _toFrame);
|
||||
}
|
||||
|
||||
}
|
||||
51
engines/mutationofjb/commands/playanimationcommand.h
Normal file
51
engines/mutationofjb/commands/playanimationcommand.h
Normal file
@@ -0,0 +1,51 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_PLAYANIMATIONCOMMAND_H
|
||||
#define MUTATIONOFJB_PLAYANIMATIONCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class PlayAnimationCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
PlayAnimationCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class PlayAnimationCommand : public SeqCommand {
|
||||
public:
|
||||
PlayAnimationCommand(int fromFrame, int toFrame) : _fromFrame(fromFrame), _toFrame(toFrame) {}
|
||||
const Common::String &getName() const;
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
int _fromFrame;
|
||||
int _toFrame;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
114
engines/mutationofjb/commands/randomcommand.cpp
Normal file
114
engines/mutationofjb/commands/randomcommand.cpp
Normal file
@@ -0,0 +1,114 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/randomcommand.h"
|
||||
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/random.h"
|
||||
|
||||
/** @file
|
||||
* "RANDOM " <numChoices>
|
||||
*
|
||||
* RANDOM command randomly picks one of the command blocks that
|
||||
* follow it and jumps to its start.
|
||||
*
|
||||
* These blocks start with "/" and end with "\". The end of a random
|
||||
* block also ends the current section. The number of blocks must
|
||||
* match numChoices.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool RandomCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
|
||||
if (line.size() < 8 || !line.hasPrefix("RANDOM")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int numChoices = atoi(line.c_str() + 7);
|
||||
if (parseCtx._pendingRandomCommand) {
|
||||
// Nested RANDOM commands are unused and not properly supported by the original game.
|
||||
warning("Ignoring nested RANDOM command.");
|
||||
} else if (numChoices >= 1) {
|
||||
RandomCommand *randomCommand = new RandomCommand(static_cast<uint>(numChoices));
|
||||
parseCtx._pendingRandomCommand = randomCommand;
|
||||
command = randomCommand;
|
||||
} else {
|
||||
warning("Ignoring malformed RANDOM command with %d choices.", numChoices);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool RandomBlockStartParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&) {
|
||||
if (line != "/") {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!parseCtx._pendingRandomCommand) {
|
||||
warning("Unexpected start of RANDOM block");
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void RandomBlockStartParser::transition(ScriptParseContext &parseCtx, Command *, Command *newCommand, CommandParser *) {
|
||||
RandomCommand *randomCommand = parseCtx._pendingRandomCommand;
|
||||
if (newCommand && randomCommand) {
|
||||
randomCommand->_choices.push_back(newCommand);
|
||||
|
||||
if (randomCommand->_choices.size() == randomCommand->_numChoices) {
|
||||
parseCtx._pendingRandomCommand = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
RandomCommand::RandomCommand(uint numChoices)
|
||||
: _numChoices(numChoices),
|
||||
_chosenNext(nullptr) {
|
||||
_choices.reserve(numChoices);
|
||||
}
|
||||
|
||||
Command::ExecuteResult RandomCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
assert(!_choices.empty());
|
||||
|
||||
Common::RandomSource &rng = scriptExecCtx.getGame().getRandomSource();
|
||||
uint choice = rng.getRandomNumber(_choices.size() - 1);
|
||||
_chosenNext = _choices[choice];
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Command *RandomCommand::next() const {
|
||||
return _chosenNext;
|
||||
}
|
||||
|
||||
Common::String RandomCommand::debugString() const {
|
||||
return Common::String::format("RANDOM %u", _numChoices);
|
||||
}
|
||||
|
||||
const RandomCommand::Choices &RandomCommand::getChoices() const {
|
||||
return _choices;
|
||||
}
|
||||
|
||||
}
|
||||
69
engines/mutationofjb/commands/randomcommand.h
Normal file
69
engines/mutationofjb/commands/randomcommand.h
Normal file
@@ -0,0 +1,69 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_RANDOMCOMMAND_H
|
||||
#define MUTATIONOFJB_RANDOMCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/command.h"
|
||||
#include "common/array.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class RandomCommandParser : public CommandParser {
|
||||
public:
|
||||
RandomCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class RandomBlockStartParser : public CommandParser {
|
||||
public:
|
||||
RandomBlockStartParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser) override;
|
||||
};
|
||||
|
||||
class RandomCommand : public Command {
|
||||
friend class RandomBlockStartParser;
|
||||
|
||||
public:
|
||||
typedef Common::Array<Command *> Choices;
|
||||
|
||||
RandomCommand(uint numChoices);
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Command *next() const override;
|
||||
|
||||
Common::String debugString() const override;
|
||||
|
||||
const Choices &getChoices() const;
|
||||
|
||||
private:
|
||||
uint _numChoices;
|
||||
Choices _choices;
|
||||
Command *_chosenNext;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
52
engines/mutationofjb/commands/removeallitemscommand.cpp
Normal file
52
engines/mutationofjb/commands/removeallitemscommand.cpp
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/removeallitemscommand.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
|
||||
/** @file
|
||||
* "DELALLITEMS"
|
||||
*
|
||||
* Removes all items from inventory.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool RemoveAllItemsCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line != "DELALLITEMS") {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = new RemoveAllItemsCommand();
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult RemoveAllItemsCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
scriptExecCtx.getGameData()._inventory.removeAllItems();
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String RemoveAllItemsCommand::debugString() const {
|
||||
return "DELALLITEM";
|
||||
}
|
||||
|
||||
}
|
||||
47
engines/mutationofjb/commands/removeallitemscommand.h
Normal file
47
engines/mutationofjb/commands/removeallitemscommand.h
Normal file
@@ -0,0 +1,47 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_REMOVEALLITEMSCOMMAND_H
|
||||
#define MUTATIONOFJB_REMOVEALLITEMSCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class RemoveAllItemsCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
RemoveAllItemsCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class RemoveAllItemsCommand : public SeqCommand {
|
||||
public:
|
||||
RemoveAllItemsCommand() {}
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
52
engines/mutationofjb/commands/removeitemcommand.cpp
Normal file
52
engines/mutationofjb/commands/removeitemcommand.cpp
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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/removeitemcommand.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
|
||||
/** @file
|
||||
* "DELITEM " <item>
|
||||
*
|
||||
* Removes item from inventory.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool RemoveItemCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (!line.hasPrefix("DELITEM") || line.size() < 9) {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = new RemoveItemCommand(line.c_str() + 8);
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult RemoveItemCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
scriptExecCtx.getGameData()._inventory.removeItem(_item);
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String RemoveItemCommand::debugString() const {
|
||||
return Common::String::format("DELITEM '%s'", _item.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
49
engines/mutationofjb/commands/removeitemcommand.h
Normal file
49
engines/mutationofjb/commands/removeitemcommand.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_REMOVEITEMCOMMAND_H
|
||||
#define MUTATIONOFJB_REMOVEITEMCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class RemoveItemCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
RemoveItemCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class RemoveItemCommand : public SeqCommand {
|
||||
public:
|
||||
RemoveItemCommand(const Common::String &item) : _item(item) {}
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
Common::String _item;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
78
engines/mutationofjb/commands/renamecommand.cpp
Normal file
78
engines/mutationofjb/commands/renamecommand.cpp
Normal file
@@ -0,0 +1,78 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/renamecommand.h"
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "common/algorithm.h"
|
||||
|
||||
/** @file
|
||||
* "REN " <oldName> " " <newName>
|
||||
*
|
||||
* Renames every door, static (in the current scene) and inventory item
|
||||
* with the name oldName to newName.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool RenameCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line.size() < 7 || !line.hasPrefix("REN")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Common::String::const_iterator sep = Common::find(line.begin() + 4, line.end(), ' ');
|
||||
if (sep == line.end() || sep + 1 == line.end()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const Common::String oldName(line.begin() + 4, sep);
|
||||
const Common::String newName(sep + 1, line.end());
|
||||
command = new RenameCommand(oldName, newName);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Command::ExecuteResult RenameCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
Scene *const scene = scriptExecCtx.getGameData().getCurrentScene();
|
||||
|
||||
for (int i = 1; i <= scene->getNoDoors(); ++i) {
|
||||
Door *const door = scene->getDoor(i);
|
||||
if (strcmp(door->_name, _oldName.c_str()) == 0) {
|
||||
strncpy(door->_name, _newName.c_str(), MAX_ENTITY_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
for (int i = 1; i <= scene->getNoStatics(); ++i) {
|
||||
Static *const stat = scene->getStatic(i);
|
||||
if (strcmp(stat->_name, _oldName.c_str()) == 0) {
|
||||
strncpy(stat->_name, _newName.c_str(), MAX_ENTITY_NAME_LENGTH);
|
||||
}
|
||||
}
|
||||
|
||||
scriptExecCtx.getGameData().getInventory().renameItem(_oldName, _newName);
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String RenameCommand::debugString() const {
|
||||
return Common::String::format("RENAME '%s' '%s'", _oldName.c_str(), _newName.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
49
engines/mutationofjb/commands/renamecommand.h
Normal file
49
engines/mutationofjb/commands/renamecommand.h
Normal file
@@ -0,0 +1,49 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_RENAMECOMMAND_H
|
||||
#define MUTATIONOFJB_RENAMECOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class RenameCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class RenameCommand : public SeqCommand {
|
||||
public:
|
||||
RenameCommand(const Common::String &oldName, const Common::String &newName) : _oldName(oldName), _newName(newName) {}
|
||||
|
||||
Command::ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
|
||||
private:
|
||||
Common::String _oldName;
|
||||
Common::String _newName;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
169
engines/mutationofjb/commands/saycommand.cpp
Normal file
169
engines/mutationofjb/commands/saycommand.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/saycommand.h"
|
||||
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/tasks/saytask.h"
|
||||
#include "mutationofjb/tasks/taskmanager.h"
|
||||
|
||||
#include "common/str.h"
|
||||
#include "common/debug.h"
|
||||
#include "common/debug-channels.h"
|
||||
|
||||
/** @file
|
||||
* <firstLine> { <CRLF> <additionalLine> }
|
||||
*
|
||||
* firstLine ::= ("SM" | "SLM" | "NM" | "NLM") " " <lineToSay> [ "<" <voiceFile> | "<!" ]
|
||||
* additionalLine ::= <skipped> " " <lineToSay> ( "<" <voiceFile> | "<!" )
|
||||
*
|
||||
* Say command comes in four variants: SM, SLM, NM and NLM.
|
||||
* Note: In script files, they are usually written as *SM.
|
||||
* The asterisk is ignored by the readLine function.
|
||||
*
|
||||
* Each of them plays a voice file (if present) and/or shows a message
|
||||
* (if voice file not present or subtitles are enabled).
|
||||
*
|
||||
* The difference between versions starting with "S" and "N" is that
|
||||
* the "N" version does not show talking animation.
|
||||
*
|
||||
* The "L" versions are "blocking", i.e. they wait for the previous say command to finish.
|
||||
*
|
||||
* If the line ends with "<!", it means the message continues to the next line.
|
||||
* Next line usually has "SM" (or other variant) repeated, but it does not have to.
|
||||
* Then we have the rest of the string to say (which is concatenated with the previous line)
|
||||
* and possibly the voice file or "<!" again.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool SayCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
|
||||
bool waitForPrevious = false;
|
||||
bool talkingAnimation = false;
|
||||
|
||||
if (line.hasPrefix("SM")) {
|
||||
waitForPrevious = false;
|
||||
talkingAnimation = true;
|
||||
} else if (line.hasPrefix("SLM")) {
|
||||
waitForPrevious = true;
|
||||
talkingAnimation = true;
|
||||
} else if (line.hasPrefix("NM")) {
|
||||
waitForPrevious = false;
|
||||
talkingAnimation = false;
|
||||
} else if (line.hasPrefix("NLM")) {
|
||||
waitForPrevious = true;
|
||||
talkingAnimation = false;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
||||
Common::String currentLine = line;
|
||||
|
||||
Common::String lineToSay;
|
||||
Common::String voiceFile;
|
||||
|
||||
bool cont = false;
|
||||
bool firstPass = true;
|
||||
|
||||
do {
|
||||
cont = false;
|
||||
|
||||
uint startPos;
|
||||
for (startPos = 0; startPos < currentLine.size(); ++startPos) {
|
||||
if (currentLine[startPos] == ' ') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (startPos == currentLine.size()) {
|
||||
if (!firstPass) {
|
||||
warning("Unable to parse line '%s'", currentLine.c_str());
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (startPos != currentLine.size()) {
|
||||
startPos++;
|
||||
}
|
||||
|
||||
uint endPos;
|
||||
for (endPos = startPos; endPos < currentLine.size(); ++endPos) {
|
||||
if (currentLine[endPos] == '<') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Common::String talkStr(currentLine.c_str() + startPos, endPos - startPos);
|
||||
|
||||
if (endPos != currentLine.size()) {
|
||||
const char *end = currentLine.c_str() + endPos + 1;
|
||||
if (end[0] == '!') {
|
||||
cont = true;
|
||||
} else {
|
||||
voiceFile = end;
|
||||
}
|
||||
}
|
||||
|
||||
if (talkStr.lastChar() == '~') {
|
||||
debug("Found say command ending with '~'. Please take a look.");
|
||||
}
|
||||
|
||||
if (lineToSay.empty()) {
|
||||
lineToSay = talkStr;
|
||||
} else {
|
||||
lineToSay += " " + talkStr;
|
||||
}
|
||||
|
||||
if (cont) {
|
||||
if (!parseCtx.readLine(currentLine)) {
|
||||
cont = false;
|
||||
}
|
||||
}
|
||||
|
||||
firstPass = false;
|
||||
} while (cont);
|
||||
|
||||
command = new SayCommand(lineToSay, voiceFile, waitForPrevious, talkingAnimation);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Command::ExecuteResult SayCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
Game &game = scriptExecCtx.getGame();
|
||||
|
||||
if (_waitForPrevious) {
|
||||
if (game.getActiveSayTask()) {
|
||||
return InProgress;
|
||||
}
|
||||
}
|
||||
|
||||
TaskPtr task(new SayTask(_lineToSay, game.getGameData()._color));
|
||||
game.getTaskManager().startTask(task);
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String SayCommand::debugString() const {
|
||||
return Common::String::format("SHOWMSG%s%s '%s' '%s'", _waitForPrevious ? "+WAIT" : "", _talkingAnimation ? "+TALKANIM" : "", _lineToSay.c_str(), _voiceFile.c_str());
|
||||
}
|
||||
|
||||
}
|
||||
55
engines/mutationofjb/commands/saycommand.h
Normal file
55
engines/mutationofjb/commands/saycommand.h
Normal file
@@ -0,0 +1,55 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_SAYCOMMAND_H
|
||||
#define MUTATIONOFJB_SAYCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class SayCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
SayCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class SayCommand : public SeqCommand {
|
||||
public:
|
||||
SayCommand(const Common::String &lineToSay, const Common::String &voiceFile, bool waitForPrevious, bool talkingAnimation) :
|
||||
_lineToSay(lineToSay),
|
||||
_voiceFile(voiceFile),
|
||||
_waitForPrevious(waitForPrevious),
|
||||
_talkingAnimation(talkingAnimation) {}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
Common::String _lineToSay;
|
||||
Common::String _voiceFile;
|
||||
bool _waitForPrevious;
|
||||
bool _talkingAnimation;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
45
engines/mutationofjb/commands/seqcommand.cpp
Normal file
45
engines/mutationofjb/commands/seqcommand.cpp
Normal file
@@ -0,0 +1,45 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
|
||||
#include "common/textconsole.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
void SeqCommandParser::transition(ScriptParseContext &, Command *oldCommand, Command *newCommand, CommandParser *) {
|
||||
if (!oldCommand || !newCommand) {
|
||||
warning("Unexpected empty command in transition");
|
||||
return;
|
||||
}
|
||||
|
||||
static_cast<SeqCommand *>(oldCommand)->setNextCommand(newCommand);
|
||||
}
|
||||
|
||||
void SeqCommand::setNextCommand(Command *nextCommand) {
|
||||
_nextCommand = nextCommand;
|
||||
}
|
||||
|
||||
Command *SeqCommand::next() const {
|
||||
return _nextCommand;
|
||||
}
|
||||
|
||||
}
|
||||
50
engines/mutationofjb/commands/seqcommand.h
Normal file
50
engines/mutationofjb/commands/seqcommand.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_SEQCOMMAND_H
|
||||
#define MUTATIONOFJB_SEQCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/command.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class SeqCommandParser : public CommandParser {
|
||||
public:
|
||||
void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser) override;
|
||||
};
|
||||
|
||||
/**
|
||||
* Base class for sequential commands.
|
||||
*/
|
||||
class SeqCommand : public Command {
|
||||
public:
|
||||
SeqCommand() : _nextCommand(nullptr) {}
|
||||
void setNextCommand(Command *nextCommand);
|
||||
Command *next() const override;
|
||||
|
||||
private:
|
||||
Command *_nextCommand;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
59
engines/mutationofjb/commands/setcolorcommand.cpp
Normal file
59
engines/mutationofjb/commands/setcolorcommand.cpp
Normal file
@@ -0,0 +1,59 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/setcolorcommand.h"
|
||||
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
#include "common/str.h"
|
||||
|
||||
/** @file
|
||||
* "SETCOL " <colorString>
|
||||
*
|
||||
* Sets subtitle color used by SayCommand.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool SetColorCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line.size() < 8 || !line.hasPrefix("SETCOL")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *const colorStr = line.c_str() + 7;
|
||||
const uint8 color = Game::colorFromString(colorStr);
|
||||
|
||||
command = new SetColorCommand(color);
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult SetColorCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
scriptExecCtx.getGameData()._color = _color;
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String SetColorCommand::debugString() const {
|
||||
return Common::String::format("SETCOL %u", _color);
|
||||
}
|
||||
|
||||
}
|
||||
50
engines/mutationofjb/commands/setcolorcommand.h
Normal file
50
engines/mutationofjb/commands/setcolorcommand.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_SETCOLORCOMMAND_H
|
||||
#define MUTATIONOFJB_SETCOLORCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class SetColorCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
|
||||
class SetColorCommand : public SeqCommand {
|
||||
public:
|
||||
SetColorCommand(uint8 color) : _color(color) {}
|
||||
|
||||
Command::ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
|
||||
private:
|
||||
uint8 _color;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
63
engines/mutationofjb/commands/setobjectframecommand.cpp
Normal file
63
engines/mutationofjb/commands/setobjectframecommand.cpp
Normal file
@@ -0,0 +1,63 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/setobjectframecommand.h"
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/room.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
/** @file
|
||||
* "SETANIM " <objectId> " " <frame>
|
||||
*
|
||||
* Draws the frame for the specified object without changing the object's current frame.
|
||||
* If the object is active, it is deactivated.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool SetObjectFrameCommandParser::parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) {
|
||||
if (line.size() < 13 || !line.hasPrefix("SETANIM "))
|
||||
return false;
|
||||
|
||||
const uint8 objectId = (uint8) atoi(line.c_str() + 8);
|
||||
const unsigned int frame = atoi(line.c_str() + 11);
|
||||
|
||||
command = new SetObjectFrameCommand(objectId, frame);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Command::ExecuteResult SetObjectFrameCommand::execute(ScriptExecutionContext &scriptExecCtx) {
|
||||
Object *const object = scriptExecCtx.getGameData().getCurrentScene()->getObject(_objectId);
|
||||
|
||||
object->_active = 0;
|
||||
// The object's current frame is not changed, so use frame override instead.
|
||||
scriptExecCtx.getGame().getRoom().drawObject(_objectId, _frame);
|
||||
|
||||
return Finished;
|
||||
}
|
||||
|
||||
Common::String SetObjectFrameCommand::debugString() const {
|
||||
return Common::String::format("SETOBJECTFRAME %u %u", (unsigned int) _objectId, (unsigned int) _frame);
|
||||
}
|
||||
|
||||
}
|
||||
50
engines/mutationofjb/commands/setobjectframecommand.h
Normal file
50
engines/mutationofjb/commands/setobjectframecommand.h
Normal file
@@ -0,0 +1,50 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_SETOBJECTFRAMECOMMAND_H
|
||||
#define MUTATIONOFJB_SETOBJECTFRAMECOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/str.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class SetObjectFrameCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
SetObjectFrameCommandParser() {}
|
||||
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class SetObjectFrameCommand : public SeqCommand {
|
||||
public:
|
||||
SetObjectFrameCommand(uint8 objectId, uint8 frame) : _objectId(objectId), _frame(frame) {}
|
||||
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
private:
|
||||
uint8 _objectId;
|
||||
uint8 _frame;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
77
engines/mutationofjb/commands/specialshowcommand.cpp
Normal file
77
engines/mutationofjb/commands/specialshowcommand.cpp
Normal file
@@ -0,0 +1,77 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/specialshowcommand.h"
|
||||
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
#include "common/str.h"
|
||||
|
||||
/** @file
|
||||
* "SPECIALSHOW " <mode>
|
||||
*
|
||||
* Shows special screen.
|
||||
* The command supports multiple modes:
|
||||
* 1 - show puzzle hint,
|
||||
* 2 - show computer puzzle.
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool SpecialShowCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line.size() < 13 || !line.hasPrefix("SPECIALSHOW ")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
const int modeInt = atoi(line.c_str() + 12);
|
||||
|
||||
SpecialShowCommand::Mode mode = SpecialShowCommand::PUZZLE_HINT;
|
||||
|
||||
if (modeInt == 1) {
|
||||
mode = SpecialShowCommand::PUZZLE_HINT;
|
||||
} else if (modeInt == 2) {
|
||||
mode = SpecialShowCommand::COMPUTER_PUZZLE;
|
||||
} else {
|
||||
warning("Invalid special show mode %d", modeInt);
|
||||
return false;
|
||||
}
|
||||
|
||||
command = new SpecialShowCommand(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult SpecialShowCommand::execute(ScriptExecutionContext &scriptExeCtx) {
|
||||
// TODO: Show UI.
|
||||
if (_mode == COMPUTER_PUZZLE) {
|
||||
scriptExeCtx.getGameData().getScene(32)->getObject(2, true)->_WX = 255;
|
||||
scriptExeCtx.getGameData().getScene(32)->getObject(1, true)->_active = 0;
|
||||
}
|
||||
return Command::Finished;
|
||||
}
|
||||
|
||||
Common::String SpecialShowCommand::debugString() const {
|
||||
const char *modes[] = {"PUZZLE_HINT", "COMPUTER_PUZZLE"};
|
||||
return Common::String::format("SPECIALSHOW %s", modes[static_cast<int>(_mode)]);
|
||||
}
|
||||
|
||||
}
|
||||
52
engines/mutationofjb/commands/specialshowcommand.h
Normal file
52
engines/mutationofjb/commands/specialshowcommand.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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_SPECIALSHOWCOMMAND_H
|
||||
#define MUTATIONOFJB_SPECIALSHOWCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class SpecialShowCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class SpecialShowCommand : public SeqCommand {
|
||||
public:
|
||||
enum Mode {
|
||||
PUZZLE_HINT,
|
||||
COMPUTER_PUZZLE
|
||||
};
|
||||
|
||||
SpecialShowCommand(Mode mode) : _mode(mode) {}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
|
||||
private:
|
||||
Mode _mode;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
57
engines/mutationofjb/commands/switchpartcommand.cpp
Normal file
57
engines/mutationofjb/commands/switchpartcommand.cpp
Normal file
@@ -0,0 +1,57 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/switchpartcommand.h"
|
||||
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/gamedata.h"
|
||||
#include "mutationofjb/script.h"
|
||||
|
||||
#include "common/str.h"
|
||||
|
||||
/** @file
|
||||
* "SWITCHPART"
|
||||
*
|
||||
* Switches to the second part of the game (part B).
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool SwitchPartCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line != "SWITCHPART") {
|
||||
return false;
|
||||
}
|
||||
|
||||
command = new SwitchPartCommand();
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult SwitchPartCommand::execute(ScriptExecutionContext &scriptExeCtx) {
|
||||
scriptExeCtx.getGame().switchToPartB();
|
||||
|
||||
return Command::Finished;
|
||||
}
|
||||
|
||||
Common::String SwitchPartCommand::debugString() const {
|
||||
return "SWITCHPART";
|
||||
}
|
||||
|
||||
}
|
||||
46
engines/mutationofjb/commands/switchpartcommand.h
Normal file
46
engines/mutationofjb/commands/switchpartcommand.h
Normal file
@@ -0,0 +1,46 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_SWITCHPARTCOMMAND_H
|
||||
#define MUTATIONOFJB_SWITCHPARTCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/scummsys.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ConversationTask;
|
||||
|
||||
class SwitchPartCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class SwitchPartCommand : public SeqCommand {
|
||||
public:
|
||||
SwitchPartCommand() {}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
87
engines/mutationofjb/commands/talkcommand.cpp
Normal file
87
engines/mutationofjb/commands/talkcommand.cpp
Normal file
@@ -0,0 +1,87 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "mutationofjb/commands/talkcommand.h"
|
||||
|
||||
#include "mutationofjb/game.h"
|
||||
#include "mutationofjb/script.h"
|
||||
#include "mutationofjb/tasks/conversationtask.h"
|
||||
#include "mutationofjb/tasks/taskmanager.h"
|
||||
|
||||
#include "common/str.h"
|
||||
|
||||
/** @file
|
||||
* "TALK TO HIM" [ " " <mode> ]
|
||||
*
|
||||
* Begins interactive conversation defined by DefineStructCommand.
|
||||
* The command supports multiple modes:
|
||||
* 0 - normal mode,
|
||||
* 1 - Ray and Buttleg mode (two responders),
|
||||
* 2 - unknown (unused) mode,
|
||||
* 3 - carnival ticket seller mode (special animation).
|
||||
*/
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
bool TalkCommandParser::parse(const Common::String &line, ScriptParseContext &, Command *&command) {
|
||||
if (line.size() < 11 || !line.hasPrefix("TALK TO HIM")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int modeInt = 0;
|
||||
|
||||
if (line.size() >= 13) {
|
||||
modeInt = atoi(line.c_str() + 12);
|
||||
}
|
||||
|
||||
TalkCommand::Mode mode = TalkCommand::NORMAL_MODE;
|
||||
|
||||
if (modeInt == 1) {
|
||||
mode = TalkCommand::RAY_AND_BUTTLEG_MODE;
|
||||
} else if (modeInt == 3) {
|
||||
mode = TalkCommand::CARNIVAL_TICKET_SELLER_MODE;
|
||||
}
|
||||
|
||||
command = new TalkCommand(mode);
|
||||
return true;
|
||||
}
|
||||
|
||||
Command::ExecuteResult TalkCommand::execute(ScriptExecutionContext &scriptExeCtx) {
|
||||
if (!_task) {
|
||||
_task = TaskPtr(new ConversationTask(scriptExeCtx.getGameData()._currentScene, scriptExeCtx.getGame().getGameData()._conversationInfo, _mode));
|
||||
scriptExeCtx.getGame().getTaskManager().startTask(_task);
|
||||
}
|
||||
|
||||
if (_task->getState() == Task::FINISHED) {
|
||||
_task.reset();
|
||||
|
||||
return Command::Finished;
|
||||
}
|
||||
|
||||
return Command::InProgress;
|
||||
}
|
||||
|
||||
Common::String TalkCommand::debugString() const {
|
||||
const char *modes[] = {"NORMAL", "RAY_AND_BUTTLEG", "CARNIVAL_TICKET_SELLER"};
|
||||
return Common::String::format("TALK %s", modes[static_cast<int>(_mode)]);
|
||||
}
|
||||
|
||||
}
|
||||
57
engines/mutationofjb/commands/talkcommand.h
Normal file
57
engines/mutationofjb/commands/talkcommand.h
Normal file
@@ -0,0 +1,57 @@
|
||||
/* 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 3 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, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef MUTATIONOFJB_TALKCOMMAND_H
|
||||
#define MUTATIONOFJB_TALKCOMMAND_H
|
||||
|
||||
#include "mutationofjb/commands/seqcommand.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "mutationofjb/tasks/task.h"
|
||||
|
||||
namespace MutationOfJB {
|
||||
|
||||
class ConversationTask;
|
||||
|
||||
class TalkCommandParser : public SeqCommandParser {
|
||||
public:
|
||||
bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
|
||||
};
|
||||
|
||||
class TalkCommand : public SeqCommand {
|
||||
public:
|
||||
enum Mode {
|
||||
NORMAL_MODE,
|
||||
RAY_AND_BUTTLEG_MODE,
|
||||
CARNIVAL_TICKET_SELLER_MODE
|
||||
};
|
||||
|
||||
TalkCommand(Mode mode) : _mode(mode) {}
|
||||
ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
|
||||
Common::String debugString() const override;
|
||||
|
||||
private:
|
||||
Mode _mode;
|
||||
TaskPtr _task;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user