From c6ef39dcf20cecef3639d686fd188fc9c7118421 Mon Sep 17 00:00:00 2001 From: strangerke Date: Wed, 25 May 2011 23:36:50 +0200 Subject: HUGO: Add 3 object related functions to the console --- engines/hugo/console.cpp | 64 +++++++++++++++++++++++++++++++++++++++++++++--- engines/hugo/console.h | 3 +++ engines/hugo/parser.h | 5 ++-- 3 files changed, 66 insertions(+), 6 deletions(-) (limited to 'engines/hugo') diff --git a/engines/hugo/console.cpp b/engines/hugo/console.cpp index 5c7b5ce412..0a67b5cd0a 100644 --- a/engines/hugo/console.cpp +++ b/engines/hugo/console.cpp @@ -22,15 +22,20 @@ #include "hugo/console.h" #include "hugo/hugo.h" +#include "hugo/object.h" +#include "hugo/parser.h" #include "hugo/schedule.h" #include "hugo/text.h" namespace Hugo { HugoConsole::HugoConsole(HugoEngine *vm) : GUI::Debugger(), _vm(vm) { - DCmd_Register("listscreens", WRAP_METHOD(HugoConsole, Cmd_listScreens)); - DCmd_Register("gotoscreen", WRAP_METHOD(HugoConsole, Cmd_gotoScreen)); - DCmd_Register("Boundaries", WRAP_METHOD(HugoConsole, Cmd_boundaries)); + DCmd_Register("listscreens", WRAP_METHOD(HugoConsole, Cmd_listScreens)); + DCmd_Register("listobjects", WRAP_METHOD(HugoConsole, Cmd_listObjects)); + DCmd_Register("getobject", WRAP_METHOD(HugoConsole, Cmd_getObject)); + DCmd_Register("getallobjects", WRAP_METHOD(HugoConsole, Cmd_getAllObjects)); + DCmd_Register("gotoscreen", WRAP_METHOD(HugoConsole, Cmd_gotoScreen)); + DCmd_Register("Boundaries", WRAP_METHOD(HugoConsole, Cmd_boundaries)); } HugoConsole::~HugoConsole() { @@ -56,7 +61,7 @@ static int strToInt(const char *s) { * This command loads up the specified screen number */ bool HugoConsole::Cmd_gotoScreen(int argc, const char **argv) { - if (argc != 2) { + if ((argc != 2) || (strToInt(argv[1]) > _vm->_numScreens)){ DebugPrintf("Usage: %s \n", argv[0]); return true; } @@ -80,6 +85,57 @@ bool HugoConsole::Cmd_listScreens(int argc, const char **argv) { return true; } +/** + * This command lists all the objects available + */ +bool HugoConsole::Cmd_listObjects(int argc, const char **argv) { + if (argc != 1) { + DebugPrintf("Usage: %s\n", argv[0]); + return true; + } + + DebugPrintf("Available objects for this game are:\n"); + for (int i = 0; i < _vm->_object->_numObj; i++) { + if (_vm->_object->_objects[i].genericCmd & TAKE) + DebugPrintf("%2d - %s\n", i, _vm->_text->getNoun(_vm->_object->_objects[i].nounIndex, 2)); + } + return true; +} + +/** + * This command puts an object in the inventory + */ +bool HugoConsole::Cmd_getObject(int argc, const char **argv) { + if ((argc != 2) || (strToInt(argv[1]) > _vm->_object->_numObj)) { + DebugPrintf("Usage: %s \n", argv[0]); + return true; + } + + if (_vm->_object->_objects[strToInt(argv[1])].genericCmd & TAKE) + _vm->_parser->takeObject(&_vm->_object->_objects[strToInt(argv[1])]); + else + DebugPrintf("Object not available\n"); + + return true; +} + +/** + * This command puts all the available objects in the inventory + */ +bool HugoConsole::Cmd_getAllObjects(int argc, const char **argv) { + if (argc != 1) { + DebugPrintf("Usage: %s\n", argv[0]); + return true; + } + + for (int i = 0; i < _vm->_object->_numObj; i++) { + if (_vm->_object->_objects[i].genericCmd & TAKE) + _vm->_parser->takeObject(&_vm->_object->_objects[i]); + } + + return false; +} + /** * This command shows and hides boundaries */ diff --git a/engines/hugo/console.h b/engines/hugo/console.h index 150bc2e4be..16317e83d5 100644 --- a/engines/hugo/console.h +++ b/engines/hugo/console.h @@ -37,6 +37,9 @@ public: private: HugoEngine *_vm; bool Cmd_listScreens(int argc, const char **argv); + bool Cmd_listObjects(int argc, const char **argv); + bool Cmd_getObject(int argc, const char **argv); + bool Cmd_getAllObjects(int argc, const char **argv); bool Cmd_gotoScreen(int argc, const char **argv); bool Cmd_boundaries(int argc, const char **argv); }; diff --git a/engines/hugo/parser.h b/engines/hugo/parser.h index 6ad2b38234..faa6dc2303 100644 --- a/engines/hugo/parser.h +++ b/engines/hugo/parser.h @@ -97,6 +97,7 @@ public: virtual void lineHandler() = 0; virtual void showInventory() const = 0; + virtual void takeObject(object_t *obj) = 0; protected: HugoEngine *_vm; @@ -135,10 +136,10 @@ public: virtual void lineHandler(); virtual void showInventory() const; + virtual void takeObject(object_t *obj); protected: - virtual void dropObject(object_t *obj); - virtual void takeObject(object_t *obj); + virtual void dropObject(object_t *obj); const char *findNextNoun(const char *noun) const; bool isBackgroundWord_v1(const char *noun, const char *verb, objectList_t obj) const; -- cgit v1.2.3