aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorWalter van Niftrik2016-03-27 14:36:14 +0200
committerWalter van Niftrik2016-06-06 20:35:49 +0200
commit73dfe71b1beaca362463104ed90cdab8a04ea968 (patch)
treecb87864a8c2839079b9ee9410a725b74a5deb855 /engines
parent367cb511d153c6d4733a65b153506b7f0e8b01b3 (diff)
downloadscummvm-rg350-73dfe71b1beaca362463104ed90cdab8a04ea968.tar.gz
scummvm-rg350-73dfe71b1beaca362463104ed90cdab8a04ea968.tar.bz2
scummvm-rg350-73dfe71b1beaca362463104ed90cdab8a04ea968.zip
ADL: Add verbs and nouns debug commands
Diffstat (limited to 'engines')
-rw-r--r--engines/adl/adl.h1
-rw-r--r--engines/adl/console.cpp57
-rw-r--r--engines/adl/console.h12
3 files changed, 70 insertions, 0 deletions
diff --git a/engines/adl/adl.h b/engines/adl/adl.h
index d9fc5908b4..4367e8b917 100644
--- a/engines/adl/adl.h
+++ b/engines/adl/adl.h
@@ -171,6 +171,7 @@ struct RoomData {
};
class AdlEngine : public Engine {
+friend class Console;
public:
virtual ~AdlEngine();
diff --git a/engines/adl/console.cpp b/engines/adl/console.cpp
index e051716a6c..5fe7f08a18 100644
--- a/engines/adl/console.cpp
+++ b/engines/adl/console.cpp
@@ -21,11 +21,68 @@
*/
#include "adl/console.h"
+#include "adl/adl.h"
namespace Adl {
Console::Console(AdlEngine *engine) : GUI::Debugger() {
_engine = engine;
+
+ registerCmd("help", WRAP_METHOD(Console, Cmd_Help));
+ registerCmd("nouns", WRAP_METHOD(Console, Cmd_Nouns));
+ registerCmd("verbs", WRAP_METHOD(Console, Cmd_Verbs));
+}
+
+static Common::String toAscii(const Common::String &str) {
+ Common::String ascii(str);
+
+ for (uint i = 0; i < ascii.size(); ++i)
+ ascii.setChar(ascii[i] & 0x7f, i);
+
+ return ascii;
+}
+
+bool Console::Cmd_Help(int argc, const char **argv) {
+ debugPrintf("Parser:\n");
+ debugPrintf(" verbs - Lists the vocabulary verbs\n");
+ debugPrintf(" nouns - Lists the vocabulary nouns\n");
+ return true;
+}
+
+bool Console::Cmd_Verbs(int argc, const char **argv) {
+ if (argc != 1) {
+ debugPrintf("Usage: %s\n", argv[0]);
+ return true;
+ }
+
+ debugPrintf("Verbs in alphabetical order:\n");
+ printWordMap(_engine->_verbs);
+ return true;
+}
+
+bool Console::Cmd_Nouns(int argc, const char **argv) {
+ if (argc != 1) {
+ debugPrintf("Usage: %s\n", argv[0]);
+ return true;
+ }
+
+ debugPrintf("Nouns in alphabetical order:\n");
+ printWordMap(_engine->_nouns);
+ return true;
+}
+
+void Console::printWordMap(const WordMap &wordMap) {
+ Common::StringArray words;
+ WordMap::const_iterator verb;
+
+ for (verb = wordMap.begin(); verb != wordMap.end(); ++verb)
+ words.push_back(verb->_key);
+
+ Common::sort(words.begin(), words.end());
+
+ Common::StringArray::const_iterator word;
+ for (word = words.begin(); word != words.end(); ++word)
+ debugPrintf("%s: %d\n", toAscii(*word).c_str(), wordMap[*word]);
}
} // End of namespace Adl
diff --git a/engines/adl/console.h b/engines/adl/console.h
index 56c84f08fa..d8a6525541 100644
--- a/engines/adl/console.h
+++ b/engines/adl/console.h
@@ -25,6 +25,12 @@
#include "gui/debugger.h"
+#include "common/hashmap.h"
+
+namespace Common {
+class String;
+}
+
namespace Adl {
class AdlEngine;
@@ -34,6 +40,12 @@ public:
Console(AdlEngine *engine);
private:
+ bool Cmd_Help(int argc, const char **argv);
+ bool Cmd_Nouns(int argc, const char **argv);
+ bool Cmd_Verbs(int argc, const char **argv);
+
+ void printWordMap(const Common::HashMap<Common::String, uint> &wordMap);
+
AdlEngine *_engine;
};