mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 06:08:35 +00:00
HUGO: Add listscreens() and gotoscreen() to console
This commit is contained in:
parent
472d45aa2b
commit
bb4df3f115
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user