Skip to content

Commit

Permalink
MUTATIONOFJB: Show multiple script commands in showsection debug comm…
Browse files Browse the repository at this point in the history
…and.
  • Loading branch information
LubomirR authored and sev- committed Aug 25, 2018
1 parent dae522f commit b4dad9b
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
6 changes: 4 additions & 2 deletions engines/mutationofjb/commands/saycommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion engines/mutationofjb/commands/saycommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
29 changes: 28 additions & 1 deletion engines/mutationofjb/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down
5 changes: 5 additions & 0 deletions engines/mutationofjb/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
namespace MutationOfJB {

class MutationOfJBEngine;
class Command;

class Console : public GUI::Debugger {
public:
Expand All @@ -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;
};

Expand Down
6 changes: 6 additions & 0 deletions engines/mutationofjb/script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

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

Expand Down

0 comments on commit b4dad9b

Please sign in to comment.