2009-06-21 12:09:44 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2010-11-03 04:27:47 +00:00
|
|
|
#include "asylum/console.h"
|
|
|
|
|
2010-11-04 22:19:02 +00:00
|
|
|
#include "asylum/resources/actionlist.h"
|
2010-11-05 04:14:46 +00:00
|
|
|
#include "asylum/resources/actor.h"
|
|
|
|
#include "asylum/resources/object.h"
|
|
|
|
#include "asylum/resources/worldstats.h"
|
|
|
|
|
|
|
|
#include "asylum/system/screen.h"
|
2010-11-03 04:27:47 +00:00
|
|
|
|
|
|
|
#include "asylum/views/scene.h"
|
2009-06-21 12:09:44 +00:00
|
|
|
|
|
|
|
#include "asylum/asylum.h"
|
2010-11-03 04:27:47 +00:00
|
|
|
|
|
|
|
#include "common/debug-channels.h"
|
2009-06-21 12:09:44 +00:00
|
|
|
|
|
|
|
namespace Asylum {
|
|
|
|
|
2009-12-04 03:14:07 +00:00
|
|
|
extern int32 g_debugPolygons;
|
2010-11-04 22:14:44 +00:00
|
|
|
extern int32 g_debugObjects;
|
2009-12-05 20:51:46 +00:00
|
|
|
extern int32 g_debugScrolling;
|
2009-06-22 11:54:06 +00:00
|
|
|
|
2010-11-04 22:14:37 +00:00
|
|
|
Console::Console(AsylumEngine *engine) : _vm(engine) {
|
|
|
|
// Commands
|
|
|
|
DCmd_Register("help", WRAP_METHOD(Console, cmdHelp));
|
|
|
|
|
|
|
|
DCmd_Register("ls", WRAP_METHOD(Console, cmdListFiles));
|
|
|
|
|
|
|
|
DCmd_Register("actions", WRAP_METHOD(Console, cmdListActions));
|
|
|
|
DCmd_Register("actors", WRAP_METHOD(Console, cmdListActors));
|
|
|
|
DCmd_Register("flags", WRAP_METHOD(Console, cmdListFlags));
|
|
|
|
DCmd_Register("objects", WRAP_METHOD(Console, cmdListObjects));
|
|
|
|
|
|
|
|
DCmd_Register("video", WRAP_METHOD(Console, cmdPlayVideo));
|
|
|
|
DCmd_Register("script", WRAP_METHOD(Console, cmdRunScript));
|
|
|
|
DCmd_Register("scene", WRAP_METHOD(Console, cmdChangeScene));
|
|
|
|
|
|
|
|
DCmd_Register("toggle_flag", WRAP_METHOD(Console, cmdToggleFlag));
|
|
|
|
|
|
|
|
// Variables
|
|
|
|
DVar_Register("show_polygons", &g_debugPolygons, DVAR_INT, 0);
|
2010-11-04 22:14:44 +00:00
|
|
|
DVar_Register("show_objects", &g_debugObjects, DVAR_INT, 0);
|
2009-12-05 20:51:46 +00:00
|
|
|
DVar_Register("use_scrolling", &g_debugScrolling, DVAR_INT, 0);
|
2009-06-21 12:09:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Console::~Console() {
|
2010-11-03 04:27:47 +00:00
|
|
|
DebugMan.clearAllDebugChannels();
|
2010-11-04 22:14:37 +00:00
|
|
|
|
|
|
|
// Zero passed pointers
|
|
|
|
_vm = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Help
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
bool Console::cmdHelp(int, const char **) {
|
|
|
|
DebugPrintf("Debug flags\n");
|
|
|
|
DebugPrintf("-----------\n");
|
|
|
|
DebugPrintf(" debugflag_list - Lists the available debug flags and their status\n");
|
|
|
|
DebugPrintf(" debugflag_enable - Enables a debug flag\n");
|
|
|
|
DebugPrintf(" debugflag_disable - Disables a debug flag\n");
|
|
|
|
DebugPrintf(" show_polygons - Show polygons\n");
|
2010-11-04 22:14:44 +00:00
|
|
|
DebugPrintf(" show_objects - Show objects\n");
|
2010-11-04 22:14:37 +00:00
|
|
|
DebugPrintf(" use_scrolling - Use scrolling\n");
|
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf("Commands\n");
|
|
|
|
DebugPrintf("--------\n");
|
|
|
|
DebugPrintf(" ls - list engine files\n");
|
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf(" actors - show actors information\n");
|
|
|
|
DebugPrintf(" action - show action information\n");
|
|
|
|
DebugPrintf(" flags - show flags\n");
|
|
|
|
DebugPrintf(" objects - show objects information\n");
|
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf(" video - play a video\n");
|
|
|
|
DebugPrintf(" script - run a script\n");
|
|
|
|
DebugPrintf(" scene - change the scene\n");
|
|
|
|
DebugPrintf("\n");
|
|
|
|
DebugPrintf(" toggle_flag - toggle a flag\n");
|
|
|
|
DebugPrintf("\n");
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// List commands
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
bool Console::cmdListFiles(int argc, const char **argv) {
|
|
|
|
if (argc != 2) {
|
|
|
|
DebugPrintf("Syntax: %s <filter> (use * for all)\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
Common::String filter(const_cast<char *>(argv[1]));
|
|
|
|
|
|
|
|
Common::ArchiveMemberList list;
|
|
|
|
int count = SearchMan.listMatchingMembers(list, filter);
|
|
|
|
|
|
|
|
DebugPrintf("Number of matches: %d\n", count);
|
|
|
|
for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it)
|
|
|
|
DebugPrintf(" %s\n", (*it)->getName().c_str());
|
|
|
|
|
|
|
|
return true;
|
2009-06-21 12:09:44 +00:00
|
|
|
}
|
|
|
|
|
2010-11-04 22:14:37 +00:00
|
|
|
bool Console::cmdListActions(int32 argc, const char **argv) {
|
|
|
|
if (argc != 1 && argc != 2) {
|
|
|
|
DebugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc == 1) {
|
|
|
|
for (uint32 i = 0; i < getWorld()->actions.size(); i++)
|
|
|
|
DebugPrintf("%s\n", getWorld()->actions[i]->toString().c_str());
|
2009-08-13 13:57:52 +00:00
|
|
|
|
|
|
|
} else {
|
2010-11-04 22:14:37 +00:00
|
|
|
int index = atoi(argv[1]);
|
|
|
|
int maxIndex = getWorld()->actions.size() - 1;
|
|
|
|
|
|
|
|
if (index < 0 || index > maxIndex) {
|
|
|
|
DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
|
|
|
|
return true;
|
2009-08-13 13:57:52 +00:00
|
|
|
}
|
2010-11-04 22:14:37 +00:00
|
|
|
|
|
|
|
DebugPrintf("%s\n", getWorld()->actions[index]->toString().c_str());
|
2009-08-13 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-04 22:14:37 +00:00
|
|
|
bool Console::cmdListActors(int32 argc, const char **argv) {
|
|
|
|
if (argc != 1 && argc != 2) {
|
|
|
|
DebugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (argc == 1) {
|
|
|
|
for (uint32 i = 0; i < getWorld()->actors.size(); i++)
|
|
|
|
DebugPrintf("%s\n", getWorld()->actors[i]->toString().c_str());
|
|
|
|
|
|
|
|
} else {
|
|
|
|
int index = atoi(argv[1]);
|
|
|
|
int maxIndex = getWorld()->actors.size() - 1;
|
|
|
|
|
|
|
|
if (index < 0 || index > maxIndex) {
|
|
|
|
DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
DebugPrintf("%s\n", getWorld()->actors[index]->toString().c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2009-08-13 13:57:52 +00:00
|
|
|
}
|
|
|
|
|
2010-11-04 22:14:37 +00:00
|
|
|
bool Console::cmdListFlags(int32 argc, const char **argv) {
|
|
|
|
if (argc != 1 && argc != 2) {
|
|
|
|
DebugPrintf("Syntax: %s <type> (nothing: all - 1: show set flags - 0: show unset flags)\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show all flags
|
|
|
|
if (argc == 1) {
|
|
|
|
for (int32 i = 0; i < 1512; i++) {
|
|
|
|
DebugPrintf("%04d: %d ", i, _vm->isGameFlagSet((GameFlag)i));
|
|
|
|
|
|
|
|
if ((i + 1) % 10 == 0)
|
|
|
|
DebugPrintf("\n");
|
|
|
|
}
|
|
|
|
DebugPrintf("\n");
|
|
|
|
} else {
|
|
|
|
bool type = atoi(argv[1]);
|
|
|
|
|
|
|
|
if (type != 0 && type != 1) {
|
|
|
|
DebugPrintf("Syntax: %s <type> (nothing: all - 1: show set flags - 0: show unset flags)\n", argv[0]);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Show only set/unset flags
|
|
|
|
int count = 0;
|
|
|
|
for (int32 i = 0; i < 1512; i++) {
|
|
|
|
if (_vm->isGameFlagSet((GameFlag)i) == type) {
|
|
|
|
DebugPrintf("%04d: %d ", i, _vm->isGameFlagSet((GameFlag)i));
|
|
|
|
++count;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((count + 1) % 10 == 0)
|
|
|
|
DebugPrintf("\n");
|
2009-08-10 11:53:45 +00:00
|
|
|
}
|
2010-11-04 22:14:37 +00:00
|
|
|
DebugPrintf("\n\n%s flags: %d\n", (type ? "Set" : "Unset"), count);
|
2009-08-10 11:53:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-04 22:14:37 +00:00
|
|
|
bool Console::cmdListObjects(int32 argc, const char **argv) {
|
|
|
|
if (argc != 1 && argc != 2) {
|
|
|
|
DebugPrintf("Syntax: %s <index> (use nothing for all)\n", argv[0]);
|
2009-08-13 10:32:23 +00:00
|
|
|
return true;
|
|
|
|
}
|
2010-11-04 22:14:37 +00:00
|
|
|
|
|
|
|
if (argc == 1) {
|
2010-11-04 22:14:44 +00:00
|
|
|
for (uint32 i = 0; i < getWorld()->objects.size(); i++)
|
|
|
|
DebugPrintf("%s\n", getWorld()->objects[i]->toString().c_str());
|
2010-11-04 22:14:37 +00:00
|
|
|
|
|
|
|
} else {
|
|
|
|
int index = atoi(argv[1]);
|
2010-11-04 22:14:44 +00:00
|
|
|
int maxIndex = getWorld()->objects.size() - 1;
|
2010-11-04 22:14:37 +00:00
|
|
|
|
|
|
|
if (index < 0 || index > maxIndex) {
|
|
|
|
DebugPrintf("[error] index should be between 0 and %d\n", maxIndex);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-04 22:14:44 +00:00
|
|
|
DebugPrintf("%s\n", getWorld()->objects[index]->toString().c_str());
|
2010-11-04 22:14:37 +00:00
|
|
|
}
|
2009-08-13 10:32:23 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-04 22:14:37 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Video / Scene / Script commands
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2009-12-04 03:14:07 +00:00
|
|
|
bool Console::cmdPlayVideo(int32 argc, const char **argv) {
|
2009-06-21 12:09:44 +00:00
|
|
|
if (argc != 2) {
|
2010-11-04 22:14:37 +00:00
|
|
|
DebugPrintf("Syntax: %s <video number>\n", argv[0]);
|
2009-06-21 12:09:44 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-09-21 19:11:49 +00:00
|
|
|
|
2010-11-04 22:14:37 +00:00
|
|
|
int index = atoi(argv[1]);
|
|
|
|
|
|
|
|
// Check if the video exists
|
|
|
|
char filename[20];
|
|
|
|
sprintf(filename, "mov%03d.smk", index);
|
|
|
|
if (!SearchMan.hasFile(filename)) {
|
|
|
|
DebugPrintf("[Error] Movie %d does not exists\n", index);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
getScreen()->clearScreen();
|
|
|
|
getScene()->actions()->setDelayedVideoIndex(index);
|
2009-06-21 12:09:44 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-04 03:14:07 +00:00
|
|
|
bool Console::cmdRunScript(int32 argc, const char **argv) {
|
2009-07-07 13:59:11 +00:00
|
|
|
if (argc != 2) {
|
2010-11-04 22:14:37 +00:00
|
|
|
DebugPrintf("Syntax: %s <script number>\n", argv[0]);
|
2009-07-07 13:59:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-11-27 14:36:27 +00:00
|
|
|
// FIXME push the script index into the script queue
|
|
|
|
//_vm->scene()->actions()->setScriptByIndex(atoi(argv[1]));
|
2009-07-07 13:59:11 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-12-04 03:14:07 +00:00
|
|
|
bool Console::cmdChangeScene(int32 argc, const char **argv) {
|
2009-07-07 13:59:11 +00:00
|
|
|
if (argc != 2) {
|
2010-11-04 22:14:37 +00:00
|
|
|
DebugPrintf("Syntax: %s <scene number>\n", argv[0]);
|
2009-07-07 13:59:11 +00:00
|
|
|
return true;
|
|
|
|
}
|
2009-09-21 19:11:49 +00:00
|
|
|
|
2010-11-05 00:35:45 +00:00
|
|
|
int index = atoi(argv[1]);
|
|
|
|
|
|
|
|
// Check if the scene exists
|
|
|
|
char filename[20];
|
|
|
|
sprintf(filename, "scn.%03d", index);
|
|
|
|
if (!SearchMan.hasFile(filename)) {
|
|
|
|
DebugPrintf("[Error] Scene %d does not exists\n", index);
|
2009-07-09 11:11:30 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-11-05 00:35:45 +00:00
|
|
|
_vm->scene()->actions()->setDelayedSceneIndex(index);
|
2009-11-27 14:36:27 +00:00
|
|
|
// FIXME push the script index into the script queue
|
|
|
|
// XXX is this right or should it be ws->actionListIdx???
|
|
|
|
//_vm->scene()->actions()->setScriptByIndex(0);
|
2009-07-07 13:59:11 +00:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-11-04 22:14:37 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
// Flags commands
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
bool Console::cmdToggleFlag(int32 argc, const char **argv) {
|
|
|
|
if (argc != 2 || atoi(argv[1]) > 1512 || atoi(argv[1]) < 0) {
|
|
|
|
DebugPrintf("Syntax: <value> between 0 and 1512\n");
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
_vm->toggleGameFlag((GameFlag)atoi(argv[1]));
|
|
|
|
DebugPrintf("Flag %d == %d\n", atoi(argv[1]), _vm->isGameFlagSet((GameFlag)atoi(argv[1])));
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
2009-06-21 12:09:44 +00:00
|
|
|
|
|
|
|
} // End of namespace Asulym
|