Skip to content

Commit

Permalink
HUGO: Add listscreens() and gotoscreen() to console
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed May 25, 2011
1 parent 472d45a commit bb4df3f
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
48 changes: 48 additions & 0 deletions engines/hugo/console.cpp
Expand Up @@ -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
2 changes: 2 additions & 0 deletions engines/hugo/console.h
Expand Up @@ -36,6 +36,8 @@ class HugoConsole : public GUI::Debugger {

private:
HugoEngine *_vm;
bool Cmd_listScreens(int argc, const char **argv);
bool Cmd_gotoScreen(int argc, const char **argv);
};

} // End of namespace Hugo
Expand Down

0 comments on commit bb4df3f

Please sign in to comment.