diff options
-rw-r--r-- | engines/pink/console.cpp | 72 | ||||
-rw-r--r-- | engines/pink/console.h | 9 | ||||
-rw-r--r-- | engines/pink/objects/module.h | 2 | ||||
-rw-r--r-- | engines/pink/objects/pages/game_page.h | 2 |
4 files changed, 85 insertions, 0 deletions
diff --git a/engines/pink/console.cpp b/engines/pink/console.cpp index 66413dbac1..ead4cf3832 100644 --- a/engines/pink/console.cpp +++ b/engines/pink/console.cpp @@ -22,6 +22,8 @@ #include "pink/console.h" #include "pink/pink.h" +#include "pink/objects/module.h" +#include "pink/objects/pages/game_page.h" namespace Pink { @@ -30,8 +32,17 @@ Console::Console(PinkEngine *vm) registerCmd("listModules", WRAP_METHOD(Console, Cmd_ListModules)); registerCmd("goToModule", WRAP_METHOD(Console, Cmd_GoToModule)); + registerCmd("listPages", WRAP_METHOD(Console, Cmd_ListPages)); + registerCmd("goToPage", WRAP_METHOD(Console, Cmd_GoToPage)); + registerCmd("listGameVars", WRAP_METHOD(Console, Cmd_ListGameVars)); registerCmd("setGameVar", WRAP_METHOD(Console, Cmd_SetGameVar)); + + registerCmd("listModuleVars", WRAP_METHOD(Console, Cmd_ListModuleVars)); + registerCmd("setModuleVar", WRAP_METHOD(Console, Cmd_SetModuleVar)); + + registerCmd("listPageVars", WRAP_METHOD(Console, Cmd_ListPageVars)); + registerCmd("setPageVar", WRAP_METHOD(Console, Cmd_SetPageVar)); } bool Console::Cmd_ListModules(int argc, const char **argv) { @@ -59,6 +70,33 @@ bool Console::Cmd_GoToModule(int argc, const char **argv) { return true; } +bool Console::Cmd_ListPages(int argc, const char **argv) { + const Array<GamePage*> pages = _vm->_module->_pages; + for (uint i = 0; i < pages.size(); ++i) { + debugPrintf("%d.%s\n", i, pages[i]->getName().c_str()); + } + return true; +} + +bool Console::Cmd_GoToPage(int argc, const char **argv) { + if (argc != 2) { + debugPrintf("Usage: %s pageName\n", argv[0]); + debugPrintf("Page may not work properly because of vars\n"); + return true; + } + const Array<GamePage*> pages = _vm->_module->_pages; + for (uint i = 0; i < pages.size(); ++i) { + if (pages[i]->getName() == argv[1]) { + _vm->setNextExecutors("", pages[i]->getName()); + _vm->changeScene(); + return true; + } + } + debugPrintf("Page %s doesn't exist\n", argv[1]); + return true; +} + + bool Console::Cmd_ListGameVars(int argc, const char **argv) { const StringMap &vars = _vm->_variables; for (StringMap::const_iterator it = vars.begin(); it != vars.end() ; ++it) { @@ -76,4 +114,38 @@ bool Console::Cmd_SetGameVar(int argc, const char **argv) { return true; } +bool Console::Cmd_ListModuleVars(int argc, const char **argv) { + const StringMap &vars = _vm->_module->_variables; + for (StringMap::const_iterator it = vars.begin(); it != vars.end() ; ++it) { + debugPrintf("%s %s \n", it->_key.c_str(), it->_value.c_str()); + } + return true; +} + +bool Console::Cmd_SetModuleVar(int argc, const char **argv) { + if (argc != 3) { + debugPrintf("Usage: %s varName value\n", argv[0]); + return true; + } + _vm->_module->_variables[argv[1]] = argv[2]; + return true; +} + +bool Console::Cmd_ListPageVars(int argc, const char **argv) { + const StringMap &vars = _vm->_module->_page->_variables; + for (StringMap::const_iterator it = vars.begin(); it != vars.end() ; ++it) { + debugPrintf("%s %s \n", it->_key.c_str(), it->_value.c_str()); + } + return true; +} + +bool Console::Cmd_SetPageVar(int argc, const char **argv) { + if (argc != 3) { + debugPrintf("Usage: %s varName value\n", argv[0]); + return true; + } + _vm->_module->_page->_variables[argv[1]] = argv[2]; + return true; +} + } // End of namespace Pink diff --git a/engines/pink/console.h b/engines/pink/console.h index 73041a5719..85e287fcd9 100644 --- a/engines/pink/console.h +++ b/engines/pink/console.h @@ -39,9 +39,18 @@ private: bool Cmd_ListModules(int argc, const char **argv); bool Cmd_GoToModule(int argc, const char **argv); + bool Cmd_ListPages(int argc, const char **argv); + bool Cmd_GoToPage(int argc, const char **argv); + bool Cmd_ListGameVars(int argc, const char **argv); bool Cmd_SetGameVar(int argc, const char **argv); + bool Cmd_ListModuleVars(int argc, const char **argv); + bool Cmd_SetModuleVar(int argc, const char **argv); + + bool Cmd_ListPageVars(int argc, const char **argv); + bool Cmd_SetPageVar(int argc, const char **argv); + private: PinkEngine *_vm; }; diff --git a/engines/pink/objects/module.h b/engines/pink/objects/module.h index 819c19dc3d..6c1da99dd3 100644 --- a/engines/pink/objects/module.h +++ b/engines/pink/objects/module.h @@ -65,6 +65,8 @@ public: GamePage *getPage() { return _page; } + friend class Console; + private: GamePage *findPage(const Common::String &pageName) const; diff --git a/engines/pink/objects/pages/game_page.h b/engines/pink/objects/pages/game_page.h index 81d4686d1a..6edba956d6 100644 --- a/engines/pink/objects/pages/game_page.h +++ b/engines/pink/objects/pages/game_page.h @@ -56,6 +56,8 @@ public: virtual void clear(); + friend class Console; + private: bool initHandler(); |