ASYLUM: add a command to show encounter commands

This commit is contained in:
alxpnv 2021-03-15 12:08:49 +03:00 committed by Eugene Sandulenko
parent 69599ccdc6
commit bba8b4f839
No known key found for this signature in database
GPG Key ID: 014D387312D34F08
2 changed files with 36 additions and 4 deletions

View File

@ -189,9 +189,11 @@ Console::Console(AsylumEngine *engine) : _vm(engine) {
registerCmd("show_script", WRAP_METHOD(Console, cmdShowScript));
registerCmd("scene", WRAP_METHOD(Console, cmdChangeScene));
registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
registerCmd("puzzle", WRAP_METHOD(Console, cmdRunPuzzle));
registerCmd("encounter", WRAP_METHOD(Console, cmdRunEncounter));
registerCmd("show_enc", WRAP_METHOD(Console, cmdShowEncounter));
registerCmd("items", WRAP_METHOD(Console, cmdListItems));
registerCmd("grab", WRAP_METHOD(Console, cmdAddToInventory));
registerCmd("throw", WRAP_METHOD(Console, cmdRemoveFromInventory));
@ -248,10 +250,12 @@ bool Console::cmdHelp(int, const char **) {
debugPrintf(" video - play a video\n");
debugPrintf(" script - run a script\n");
debugPrintf(" scene - change the scene\n");
debugPrintf(" show_script - Show script commands\n");
debugPrintf(" encounter - run an encounter\n");
debugPrintf(" show_script - show script commands\n");
debugPrintf(" puzzle - run an puzzle\n");
debugPrintf("\n");
debugPrintf(" encounter - run an encounter\n");
debugPrintf(" show_enc - show encounter commands\n");
debugPrintf("\n");
debugPrintf(" items - list all grabbable objects\n");
debugPrintf(" grab - add an item to inventory\n");
debugPrintf(" throw - remove an item from inventory\n");
@ -632,6 +636,32 @@ bool Console::cmdRunEncounter(int32 argc, const char **argv) {
return false;
}
bool Console::cmdShowEncounter(int32 argc, const char **argv) {
if (argc != 2) {
debugPrintf("Syntax: %s <encounter index>\n", argv[0]);
return true;
}
// Check index is valid
int32 index = atoi(argv[1]);
if (index < 0 || index >= (int32)getEncounter()->_items.size()) {
debugPrintf("[Error] Invalid index (was: %d - valid: [0-%d])\n", index, getEncounter()->_items.size() - 1);
return true;
}
int32 i = 0;
ResourceId resourceId = getEncounter()->_items[index].scriptResourceId;
do {
Encounter::ScriptEntry entry = getEncounter()->getScriptEntry(resourceId, i);
if (entry.opcode > 25)
break;
debugPrintf("%2d %s\n", i, entry.toString().c_str());
} while (++i);
return true;
}
bool Console::cmdRunPuzzle(int32 argc, const char **argv) {
if (argc != 2) {
debugPrintf("Syntax: %s <puzzle index>\n", argv[0]);

View File

@ -73,9 +73,11 @@ private:
bool cmdShowScript(int32 argc, const char **argv);
bool cmdRunScript(int32 argc, const char **argv);
bool cmdChangeScene(int32 argc, const char **argv);
bool cmdRunEncounter(int32 argc, const char **argv);
bool cmdRunPuzzle(int32 argc, const char **argv);
bool cmdRunEncounter(int32 argc, const char **argv);
bool cmdShowEncounter(int32 argc, const char **argv);
bool cmdListItems(int32 argc, const char **argv);
bool cmdAddToInventory(int32 argc, const char **argv);
bool cmdRemoveFromInventory(int32 argc, const char **argv);