diff options
author | strangerke | 2011-05-25 20:03:48 +0200 |
---|---|---|
committer | strangerke | 2011-05-25 23:38:47 +0200 |
commit | bb4df3f115634ba2f719a4ef342879fc73aef246 (patch) | |
tree | b6aef434aae81314dfee452f8ba2393f9669e83b /engines | |
parent | 472d45aa2b726d05c66299cbe93c515dca79a037 (diff) | |
download | scummvm-rg350-bb4df3f115634ba2f719a4ef342879fc73aef246.tar.gz scummvm-rg350-bb4df3f115634ba2f719a4ef342879fc73aef246.tar.bz2 scummvm-rg350-bb4df3f115634ba2f719a4ef342879fc73aef246.zip |
HUGO: Add listscreens() and gotoscreen() to console
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hugo/console.cpp | 48 | ||||
-rw-r--r-- | engines/hugo/console.h | 2 |
2 files changed, 50 insertions, 0 deletions
diff --git a/engines/hugo/console.cpp b/engines/hugo/console.cpp index 3d7449e51f..0afd991728 100644 --- a/engines/hugo/console.cpp +++ b/engines/hugo/console.cpp @@ -22,13 +22,61 @@ #include "hugo/console.h" #include "hugo/hugo.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)); } HugoConsole::~HugoConsole() { } +static int strToInt(const char *s) { + if (!*s) + // No string at all + return 0; + else if (toupper(s[strlen(s) - 1]) != 'H') + // Standard decimal string + return atoi(s); + + // Hexadecimal string + uint tmp = 0; + int read = sscanf(s, "%xh", &tmp); + if (read < 1) + error("strToInt failed on string \"%s\"", s); + return (int)tmp; +} + +/** + * This command loads up the specified screen number + */ +bool HugoConsole::Cmd_gotoScreen(int argc, const char **argv) { + if (argc != 2) { + DebugPrintf("Usage: %s <screen number>\n", argv[0]); + return true; + } else { + _vm->_scheduler->newScreen(strToInt(argv[1])); + return false; + } +} + +/** + * This command lists all the screens available + */ +bool HugoConsole::Cmd_listScreens(int argc, const char **argv) { + if (argc != 1) { + DebugPrintf("Usage: %s\n", argv[0]); + return true; + } + + DebugPrintf("Available screens for this game are:\n"); + for (int i = 0; i < _vm->_numScreens; i++) + DebugPrintf("%2d - %s\n", i, _vm->_text->getScreenNames(i)); + return true; +} + } // End of namespace Hugo diff --git a/engines/hugo/console.h b/engines/hugo/console.h index 4743b791f3..1c715a046e 100644 --- a/engines/hugo/console.h +++ b/engines/hugo/console.h @@ -36,6 +36,8 @@ public: private: HugoEngine *_vm; + bool Cmd_listScreens(int argc, const char **argv); + bool Cmd_gotoScreen(int argc, const char **argv); }; } // End of namespace Hugo |