aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFilippos Karapetis2013-06-09 16:07:45 +0300
committerFilippos Karapetis2013-06-09 16:07:45 +0300
commita14cb193a9d0cde8b6eb84c5193ba6944de1e6c4 (patch)
tree728c7a1a6d1ad11a1370bafa135584df31fc277a
parent3dfe25504a5e288af9721229b8311483a6cf1fd2 (diff)
downloadscummvm-rg350-a14cb193a9d0cde8b6eb84c5193ba6944de1e6c4.tar.gz
scummvm-rg350-a14cb193a9d0cde8b6eb84c5193ba6944de1e6c4.tar.bz2
scummvm-rg350-a14cb193a9d0cde8b6eb84c5193ba6944de1e6c4.zip
NEVERHOOD: Add a debug console, together with a command to change rooms
-rw-r--r--engines/neverhood/console.cpp58
-rw-r--r--engines/neverhood/console.h44
-rw-r--r--engines/neverhood/gamemodule.h5
-rw-r--r--engines/neverhood/module.mk1
-rw-r--r--engines/neverhood/neverhood.cpp16
-rw-r--r--engines/neverhood/neverhood.h4
6 files changed, 125 insertions, 3 deletions
diff --git a/engines/neverhood/console.cpp b/engines/neverhood/console.cpp
new file mode 100644
index 0000000000..c82f3a5f38
--- /dev/null
+++ b/engines/neverhood/console.cpp
@@ -0,0 +1,58 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "neverhood/console.h"
+#include "gui/debugger.h"
+#include "neverhood/neverhood.h"
+#include "neverhood/gamemodule.h"
+
+namespace Neverhood {
+
+Console::Console(NeverhoodEngine *vm) : GUI::Debugger(), _vm(vm) {
+ DCmd_Register("room", WRAP_METHOD(Console, Cmd_Room));
+}
+
+Console::~Console() {
+}
+
+bool Console::Cmd_Room(int argc, const char **argv) {
+ int currentModule = _vm->_gameModule->getCurrentModuleNum();
+ int previousModule = _vm->_gameModule->getPreviousModuleNum();
+ int scene = _vm->gameState().sceneNum;
+
+ DebugPrintf("Current module: %d, previous module: %d, scene %d\n", currentModule, previousModule, scene);
+
+ if (argc != 3) {
+ DebugPrintf("Use room <module> <scene> to change rooms\n");
+ DebugPrintf("Modules are incremental by 100, from 1000 to 3000\n");
+ } else {
+ int module = atoi(argv[1]);
+ int scene = atoi(argv[2]);
+
+ _vm->gameState().sceneNum = scene;
+ _vm->_gameModule->createModule(module, -1);
+ }
+
+ return true;
+}
+
+} // End of namespace Neverhood
diff --git a/engines/neverhood/console.h b/engines/neverhood/console.h
new file mode 100644
index 0000000000..78a7338dc5
--- /dev/null
+++ b/engines/neverhood/console.h
@@ -0,0 +1,44 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef NEVERHOOD_CONSOLE_H
+#define NEVERHOOD_CONSOLE_H
+
+#include "gui/debugger.h"
+
+namespace Neverhood {
+
+class NeverhoodEngine;
+
+class Console : public GUI::Debugger {
+public:
+ Console(NeverhoodEngine *vm);
+ virtual ~Console(void);
+
+private:
+ NeverhoodEngine *_vm;
+
+ bool Cmd_Room(int argc, const char **argv);
+};
+
+} // End of namespace Neverhood
+#endif
diff --git a/engines/neverhood/gamemodule.h b/engines/neverhood/gamemodule.h
index 8101d38009..1fb3557b81 100644
--- a/engines/neverhood/gamemodule.h
+++ b/engines/neverhood/gamemodule.h
@@ -55,6 +55,10 @@ public:
void initCubeSymbolsPuzzle();
void initCrystalColorsPuzzle();
uint32 getCurrRadioMusicFileHash();
+ int getCurrentModuleNum() { return _moduleNum; }
+ int getPreviousModuleNum() { return _moduleNum; }
+
+ void createModule(int moduleNum, int which);
protected:
int _moduleNum;
Entity *_prevChildObject;
@@ -64,7 +68,6 @@ protected:
bool _canRequestMainMenu;
bool _mainMenuRequested;
uint32 handleMessage(int messageNum, const MessageParam &param, Entity *sender);
- void createModule(int moduleNum, int which);
void createModuleByHash(uint32 nameHash);
void updateModule();
void openMainMenu();
diff --git a/engines/neverhood/module.mk b/engines/neverhood/module.mk
index 714fc3079b..030c78a407 100644
--- a/engines/neverhood/module.mk
+++ b/engines/neverhood/module.mk
@@ -3,6 +3,7 @@ MODULE := engines/neverhood
MODULE_OBJS = \
background.o \
blbarchive.o \
+ console.o \
detection.o \
diskplayerscene.o \
entity.o \
diff --git a/engines/neverhood/neverhood.cpp b/engines/neverhood/neverhood.cpp
index 6b27343d03..57fce58b94 100644
--- a/engines/neverhood/neverhood.cpp
+++ b/engines/neverhood/neverhood.cpp
@@ -22,12 +22,18 @@
#include "common/file.h"
#include "common/config-manager.h"
+#include "common/textconsole.h"
+
#include "base/plugins.h"
#include "base/version.h"
+
#include "graphics/cursorman.h"
+
#include "engines/util.h"
+
#include "neverhood/neverhood.h"
#include "neverhood/blbarchive.h"
+#include "neverhood/console.h"
#include "neverhood/gamemodule.h"
#include "neverhood/gamevars.h"
#include "neverhood/graphics.h"
@@ -76,7 +82,8 @@ Common::Error NeverhoodEngine::run() {
_gameVars = new GameVars();
_screen = new Screen(this);
_res = new ResourceMan();
-
+ _console = new Console(this);
+
if (isDemo()) {
_res->addArchive("a.blb");
_res->addArchive("nevdemo.blb");
@@ -123,6 +130,7 @@ Common::Error NeverhoodEngine::run() {
delete _soundMan;
delete _audioResourceMan;
+ delete _console;
delete _res;
delete _screen;
@@ -140,6 +148,11 @@ void NeverhoodEngine::mainLoop() {
while (eventMan->pollEvent(event)) {
switch (event.type) {
case Common::EVENT_KEYDOWN:
+ if (event.kbd.hasFlags(Common::KBD_CTRL) && event.kbd.keycode == Common::KEYCODE_d) {
+ // Open debugger console
+ _console->attach();
+ continue;
+ }
_gameModule->handleKeyDown(event.kbd.keycode);
_gameModule->handleAsciiKey(event.kbd.ascii);
break;
@@ -169,6 +182,7 @@ void NeverhoodEngine::mainLoop() {
_gameModule->checkRequests();
_gameModule->handleUpdate();
_gameModule->draw();
+ _console->onFrame();
_screen->update();
nextFrameTime = _screen->getNextFrameTime();
};
diff --git a/engines/neverhood/neverhood.h b/engines/neverhood/neverhood.h
index 577fbd7a66..18f2cc9f64 100644
--- a/engines/neverhood/neverhood.h
+++ b/engines/neverhood/neverhood.h
@@ -48,6 +48,7 @@ class Screen;
class SoundMan;
class AudioResourceMan;
class StaticData;
+class Console;
struct NPoint;
struct GameState {
@@ -86,7 +87,8 @@ public:
ResourceMan *_res;
GameModule *_gameModule;
StaticData *_staticData;
-
+ Console *_console;
+
SoundMan *_soundMan;
AudioResourceMan *_audioResourceMan;