Permalink
Browse files

MUTATIONOFJB: Show multiple script commands in showsection debug comm…

…and.
  • Loading branch information...
LubomirR committed Mar 8, 2018
1 parent 8a25e49 commit b0ed1789293c3fd10ea08c868641ed1747fd9258
@@ -93,7 +93,9 @@ bool SayCommandParser::parse(const Common::String &line, ScriptParseContext &par
break;
}
}
startPos++;
if (startPos != currentLine.size()) {
startPos++;
}

uint endPos;
for (endPos = startPos; endPos < currentLine.size(); ++endPos) {
@@ -120,7 +122,7 @@ bool SayCommandParser::parse(const Common::String &line, ScriptParseContext &par
if (lineToSay.empty()) {
lineToSay = talkStr;
} else {
lineToSay = " " + talkStr;
lineToSay += " " + talkStr;
}

if (cont) {
@@ -37,7 +37,7 @@ class SayCommandParser : public SeqCommandParser {

class SayCommand : public SeqCommand {
public:
SayCommand(Common::String &lineToSay, Common::String &voiceFile, bool waitForPrevious, bool talkingAnimation) :
SayCommand(const Common::String &lineToSay, const Common::String &voiceFile, bool waitForPrevious, bool talkingAnimation) :
_lineToSay(lineToSay),
_voiceFile(voiceFile),
_waitForPrevious(waitForPrevious),
@@ -24,6 +24,8 @@
#include "mutationofjb/mutationofjb.h"
#include "mutationofjb/script.h"
#include "mutationofjb/commands/command.h"
#include "mutationofjb/commands/seqcommand.h"
#include "mutationofjb/commands/conditionalcommand.h"
#include "common/debug-channels.h"
#include "common/translation.h"
#include "common/scummsys.h"
@@ -87,6 +89,31 @@ bool Console::cmd_listsections(int argc, const char **argv) {
return true;
}

void Console::showIndent(int indentLevel) {
for (int i = 0; i < indentLevel; ++i) {
debugPrintf(" ");
}
}

void Console::showCommands(Command *command, int indentLevel) {
while (command) {
showIndent(indentLevel);
debugPrintf("%s\n", command->debugString().c_str());

if (SeqCommand *const seqCmd = dynamic_cast<SeqCommand *>(command)) {
command = seqCmd->next();
} else if (ConditionalCommand *const condCmd = dynamic_cast<ConditionalCommand *>(command)) {
showCommands(condCmd->getTrueCommand(), indentLevel + 1);
showIndent(indentLevel);
debugPrintf("ELSE\n");
showCommands(condCmd->getFalseCommand(), indentLevel + 1);
command = nullptr;
} else {
command = nullptr;
}
}
}

bool Console::cmd_showsection(int argc, const char **argv) {
if (argc == 4) {
Script *script = nullptr;
@@ -146,7 +173,7 @@ bool Console::cmd_showsection(int argc, const char **argv) {

if (found) {
if (command) {
debugPrintf("%s\n", command->debugString().c_str());
showCommands(command);
}
} else {
debugPrintf("Section not found.\n");
@@ -28,6 +28,7 @@
namespace MutationOfJB {

class MutationOfJBEngine;
class Command;

class Console : public GUI::Debugger {
public:
@@ -36,6 +37,10 @@ class Console : public GUI::Debugger {
private:
bool cmd_listsections(int argc, const char **argv);
bool cmd_showsection(int argc, const char **argv);

void showIndent(int indentLevel);
void showCommands(Command *command, int indentLevel = 0);

MutationOfJBEngine *_vm;
};

@@ -31,6 +31,9 @@
#include "mutationofjb/commands/endblockcommand.h"
#include "mutationofjb/commands/changecommand.h"
#include "mutationofjb/commands/saycommand.h"
#include "mutationofjb/commands/additemcommand.h"
#include "mutationofjb/commands/removeitemcommand.h"
#include "mutationofjb/commands/removeallitemscommand.h"

namespace MutationOfJB {

@@ -43,6 +46,9 @@ static CommandParser** getParsers() {
new ChangeStaticCommandParser,
new ChangeSceneCommandParser,
new SayCommandParser,
new AddItemCommandParser,
new RemoveItemCommandParser,
new RemoveAllItemsCommandParser,
nullptr
};

0 comments on commit b0ed178

Please sign in to comment.