From b4dad9bca7593029ab368bc99f7bd96c71cbf4d8 Mon Sep 17 00:00:00 2001 From: Ľubomír Remák Date: Thu, 8 Mar 2018 23:05:44 +0100 Subject: MUTATIONOFJB: Show multiple script commands in showsection debug command. --- engines/mutationofjb/commands/saycommand.cpp | 6 ++++-- engines/mutationofjb/commands/saycommand.h | 2 +- engines/mutationofjb/debug.cpp | 29 +++++++++++++++++++++++++++- engines/mutationofjb/debug.h | 5 +++++ engines/mutationofjb/script.cpp | 6 ++++++ 5 files changed, 44 insertions(+), 4 deletions(-) (limited to 'engines/mutationofjb') diff --git a/engines/mutationofjb/commands/saycommand.cpp b/engines/mutationofjb/commands/saycommand.cpp index 9448203911..a0c9c79bd6 100644 --- a/engines/mutationofjb/commands/saycommand.cpp +++ b/engines/mutationofjb/commands/saycommand.cpp @@ -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) { diff --git a/engines/mutationofjb/commands/saycommand.h b/engines/mutationofjb/commands/saycommand.h index 16303de467..e2a1207afc 100644 --- a/engines/mutationofjb/commands/saycommand.h +++ b/engines/mutationofjb/commands/saycommand.h @@ -37,7 +37,7 @@ public: 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), diff --git a/engines/mutationofjb/debug.cpp b/engines/mutationofjb/debug.cpp index 4861ab1f52..cf96fc62ac 100644 --- a/engines/mutationofjb/debug.cpp +++ b/engines/mutationofjb/debug.cpp @@ -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(command)) { + command = seqCmd->next(); + } else if (ConditionalCommand *const condCmd = dynamic_cast(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"); diff --git a/engines/mutationofjb/debug.h b/engines/mutationofjb/debug.h index a41bacaaf3..ee187cb605 100644 --- a/engines/mutationofjb/debug.h +++ b/engines/mutationofjb/debug.h @@ -28,6 +28,7 @@ namespace MutationOfJB { class MutationOfJBEngine; +class Command; class Console : public GUI::Debugger { public: @@ -36,6 +37,10 @@ public: 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; }; diff --git a/engines/mutationofjb/script.cpp b/engines/mutationofjb/script.cpp index 98b1727935..1b11545741 100644 --- a/engines/mutationofjb/script.cpp +++ b/engines/mutationofjb/script.cpp @@ -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 }; -- cgit v1.2.3