2011-09-03 17:33:14 +02:00
|
|
|
/* Residual - A 3D game interpreter
|
|
|
|
*
|
|
|
|
* Residual is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the AUTHORS
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
2012-01-05 10:07:48 +01:00
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2012-01-05 10:07:48 +01:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
2011-09-03 17:33:14 +02:00
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
2012-01-05 10:07:48 +01:00
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2012-01-05 10:07:48 +01:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2011-09-03 17:33:14 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "engines/myst3/console.h"
|
2011-09-04 11:16:27 +02:00
|
|
|
#include "engines/myst3/variables.h"
|
2011-09-03 17:33:14 +02:00
|
|
|
|
|
|
|
namespace Myst3 {
|
|
|
|
|
|
|
|
Console::Console(Myst3Engine *vm) : GUI::Debugger(), _vm(vm) {
|
|
|
|
DCmd_Register("infos", WRAP_METHOD(Console, Cmd_Infos));
|
|
|
|
DCmd_Register("lookAt", WRAP_METHOD(Console, Cmd_LookAt));
|
2011-09-04 09:24:06 +02:00
|
|
|
DCmd_Register("initScript", WRAP_METHOD(Console, Cmd_InitScript));
|
2011-09-04 11:16:27 +02:00
|
|
|
DCmd_Register("var", WRAP_METHOD(Console, Cmd_Var));
|
2011-09-04 20:08:37 +02:00
|
|
|
DCmd_Register("listNodes", WRAP_METHOD(Console, Cmd_ListNodes));
|
2011-09-04 20:57:57 +02:00
|
|
|
DCmd_Register("run", WRAP_METHOD(Console, Cmd_Run));
|
2011-09-09 07:40:18 +02:00
|
|
|
DCmd_Register("go", WRAP_METHOD(Console, Cmd_Go));
|
2011-09-03 17:33:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
Console::~Console() {
|
|
|
|
}
|
|
|
|
|
2011-09-04 20:08:37 +02:00
|
|
|
void Console::describeScript(const Common::Array<Opcode> &script) {
|
2011-09-04 09:24:06 +02:00
|
|
|
for(uint j = 0; j < script.size(); j++) {
|
2011-10-15 10:02:30 +02:00
|
|
|
DebugPrintf("%s", _vm->_scriptEngine->describeOpcode(script[j]).c_str());
|
2011-09-04 09:24:06 +02:00
|
|
|
}
|
2011-09-04 20:08:37 +02:00
|
|
|
}
|
|
|
|
|
2011-09-03 17:33:14 +02:00
|
|
|
bool Console::Cmd_Infos(int argc, const char **argv) {
|
|
|
|
|
2011-09-21 19:28:57 +02:00
|
|
|
uint16 nodeId = _vm->_vars->getLocationNode();
|
2012-01-06 14:32:01 +01:00
|
|
|
uint32 roomId = _vm->_vars->getLocationRoom();
|
2011-09-04 11:16:27 +02:00
|
|
|
|
|
|
|
if (argc >= 2) {
|
|
|
|
nodeId = atoi(argv[1]);
|
|
|
|
}
|
|
|
|
|
2011-09-04 20:08:37 +02:00
|
|
|
if (argc >= 3) {
|
2011-09-09 07:40:18 +02:00
|
|
|
roomId = _vm->_db->getRoomId(argv[2]);
|
|
|
|
|
|
|
|
if (roomId == 0) {
|
|
|
|
DebugPrintf("Unknown room name %s\n", argv[2]);
|
|
|
|
return true;
|
|
|
|
}
|
2011-09-04 20:08:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
NodePtr nodeData = _vm->_db->getNodeData(nodeId, roomId);
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2011-09-21 19:28:57 +02:00
|
|
|
if (!nodeData) {
|
|
|
|
DebugPrintf("No node with id %d\n", nodeId);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-03 17:33:14 +02:00
|
|
|
char roomName[8];
|
2011-09-04 20:08:37 +02:00
|
|
|
_vm->_db->getRoomName(roomName, roomId);
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2011-09-09 07:40:18 +02:00
|
|
|
DebugPrintf("node: %s %d ", roomName, nodeId);
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2011-09-04 09:24:06 +02:00
|
|
|
for (uint i = 0; i < nodeData->hotspots.size(); i++) {
|
2011-10-15 10:02:30 +02:00
|
|
|
DebugPrintf("\nhotspot %d > %s (%s)\n", i,
|
|
|
|
_vm->_vars->describeCondition(nodeData->hotspots[i].condition).c_str(),
|
|
|
|
_vm->_vars->evaluate(nodeData->hotspots[i].condition) ? "true" : "false");
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2011-09-04 09:24:06 +02:00
|
|
|
for(uint j = 0; j < nodeData->hotspots[i].rects.size(); j++) {
|
|
|
|
PolarRect &rect = nodeData->hotspots[i].rects[j];
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2011-09-04 09:24:06 +02:00
|
|
|
DebugPrintf(" rect > pitch: %d heading: %d height: %d width: %d\n",
|
|
|
|
rect.centerPitch, rect.centerHeading, rect.width, rect.height);
|
|
|
|
}
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2011-09-04 20:08:37 +02:00
|
|
|
describeScript(nodeData->hotspots[i].script);
|
2011-09-04 09:24:06 +02:00
|
|
|
}
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2011-09-04 09:24:06 +02:00
|
|
|
for (uint i = 0; i < nodeData->scripts.size(); i++) {
|
2011-10-15 10:02:30 +02:00
|
|
|
DebugPrintf("\nscript %d > %s (%s)\n", i,
|
|
|
|
_vm->_vars->describeCondition(nodeData->scripts[i].condition).c_str(),
|
|
|
|
_vm->_vars->evaluate(nodeData->scripts[i].condition) ? "true" : "false");
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2011-09-04 20:08:37 +02:00
|
|
|
describeScript(nodeData->scripts[i].script);
|
2011-09-04 09:24:06 +02:00
|
|
|
}
|
2011-09-03 17:33:14 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Console::Cmd_LookAt(int argc, const char **argv) {
|
|
|
|
|
2011-09-09 07:40:18 +02:00
|
|
|
if (argc != 1 && argc != 3) {
|
2011-09-03 17:33:14 +02:00
|
|
|
DebugPrintf("Usage :\n");
|
|
|
|
DebugPrintf("lookAt pitch heading\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-09 07:40:18 +02:00
|
|
|
Common::Point lookAt = _vm->_scene->getMousePos();
|
|
|
|
DebugPrintf("pitch: %d heading: %d\n", lookAt.y, lookAt.x);
|
2011-09-03 17:33:14 +02:00
|
|
|
|
2011-09-09 07:40:18 +02:00
|
|
|
if (argc >= 3){
|
|
|
|
_vm->_scene->lookAt(atof(argv[1]), atof(argv[2]));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2011-09-03 17:33:14 +02:00
|
|
|
}
|
|
|
|
|
2011-09-04 09:24:06 +02:00
|
|
|
bool Console::Cmd_InitScript(int argc, const char **argv) {
|
2011-09-04 20:08:37 +02:00
|
|
|
describeScript(_vm->_db->getNodeInitScript());
|
2011-09-04 09:24:06 +02:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-04 11:16:27 +02:00
|
|
|
|
|
|
|
bool Console::Cmd_Var(int argc, const char **argv) {
|
|
|
|
|
|
|
|
if (argc != 2 && argc != 3) {
|
|
|
|
DebugPrintf("Usage :\n");
|
|
|
|
DebugPrintf("var variable : Display var value\n");
|
|
|
|
DebugPrintf("var variable value : Change var value\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
uint16 var = atoi(argv[1]);
|
2011-09-04 20:08:37 +02:00
|
|
|
uint32 value = _vm->_vars->get(var);
|
2011-09-04 11:16:27 +02:00
|
|
|
|
|
|
|
if (argc == 3) {
|
|
|
|
value = atoi(argv[2]);
|
|
|
|
_vm->_vars->set(var, value);
|
|
|
|
}
|
|
|
|
|
2011-10-15 10:02:30 +02:00
|
|
|
DebugPrintf("%s: %d\n", _vm->_vars->describeVar(var).c_str(), value);
|
|
|
|
|
2011-09-04 11:16:27 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-04 20:08:37 +02:00
|
|
|
bool Console::Cmd_ListNodes(int argc, const char **argv) {
|
|
|
|
|
2012-01-06 14:32:01 +01:00
|
|
|
uint32 roomID = 0;
|
2011-09-04 20:08:37 +02:00
|
|
|
|
|
|
|
if (argc == 2) {
|
2011-09-09 07:40:18 +02:00
|
|
|
roomID = _vm->_db->getRoomId(argv[1]);
|
|
|
|
|
|
|
|
if (roomID == 0) {
|
|
|
|
DebugPrintf("Unknown room name %s\n", argv[1]);
|
|
|
|
return true;
|
|
|
|
}
|
2011-09-04 20:08:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("Nodes:\n");
|
|
|
|
|
|
|
|
Common::Array<uint16> list = _vm->_db->listRoomNodes(roomID);
|
|
|
|
for (uint i = 0; i < list.size(); i++) {
|
|
|
|
DebugPrintf("%d\n", list[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-04 20:57:57 +02:00
|
|
|
bool Console::Cmd_Run(int argc, const char **argv) {
|
2011-09-21 19:28:57 +02:00
|
|
|
uint16 nodeId = _vm->_vars->getLocationNode();
|
2012-01-06 14:32:01 +01:00
|
|
|
uint32 roomId = 0;
|
2011-09-04 20:57:57 +02:00
|
|
|
|
|
|
|
if (argc >= 2) {
|
|
|
|
nodeId = atoi(argv[1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc >= 3) {
|
2011-09-09 07:40:18 +02:00
|
|
|
roomId = _vm->_db->getRoomId(argv[2]);
|
|
|
|
|
|
|
|
if (roomId == 0) {
|
|
|
|
DebugPrintf("Unknown room name %s\n", argv[2]);
|
|
|
|
return true;
|
|
|
|
}
|
2011-09-04 20:57:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
_vm->runScriptsFromNode(nodeId, roomId);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-09 07:40:18 +02:00
|
|
|
|
|
|
|
bool Console::Cmd_Go(int argc, const char **argv) {
|
|
|
|
if (argc != 3) {
|
|
|
|
DebugPrintf("Usage :\n");
|
|
|
|
DebugPrintf("go [room name] [node id] : Go to node\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2012-01-06 14:32:01 +01:00
|
|
|
uint32 roomID = _vm->_db->getRoomId(argv[1]);
|
2011-09-09 07:40:18 +02:00
|
|
|
uint16 nodeId = atoi(argv[2]);
|
|
|
|
|
|
|
|
if (roomID == 0) {
|
|
|
|
DebugPrintf("Unknown room name %s\n", argv[1]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->goToNode(nodeId, roomID);
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-09-03 17:33:14 +02:00
|
|
|
} /* namespace Myst3 */
|