From 9e920d9349a6c9fb99f41e3acedd245fbe439e93 Mon Sep 17 00:00:00 2001 From: whiterandrek Date: Thu, 21 Jun 2018 17:15:14 +0300 Subject: PINK: add commands to list and set game variables --- engines/pink/console.cpp | 24 ++++++++++++++++++++++-- engines/pink/console.h | 3 +++ 2 files changed, 25 insertions(+), 2 deletions(-) (limited to 'engines') diff --git a/engines/pink/console.cpp b/engines/pink/console.cpp index de95b9ab4b..66413dbac1 100644 --- a/engines/pink/console.cpp +++ b/engines/pink/console.cpp @@ -29,6 +29,9 @@ Console::Console(PinkEngine *vm) : _vm(vm) { registerCmd("listModules", WRAP_METHOD(Console, Cmd_ListModules)); registerCmd("goToModule", WRAP_METHOD(Console, Cmd_GoToModule)); + + registerCmd("listGameVars", WRAP_METHOD(Console, Cmd_ListGameVars)); + registerCmd("setGameVar", WRAP_METHOD(Console, Cmd_SetGameVar)); } bool Console::Cmd_ListModules(int argc, const char **argv) { @@ -42,7 +45,7 @@ bool Console::Cmd_ListModules(int argc, const char **argv) { bool Console::Cmd_GoToModule(int argc, const char **argv) { if (argc != 2) { debugPrintf("Usage: %s moduleName\n", argv[0]); - debugPrintf("Module may not work properly because of Game vars"); + debugPrintf("Module may not work properly because of Game vars\n"); return true; } const Array modules = _vm->_modules; @@ -52,7 +55,24 @@ bool Console::Cmd_GoToModule(int argc, const char **argv) { return true; } } - debugPrintf("Module %s doesn't exist", argv[1]); + debugPrintf("Module %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) { + debugPrintf("%s %s \n", it->_key.c_str(), it->_value.c_str()); + } + return true; +} + +bool Console::Cmd_SetGameVar(int argc, const char **argv) { + if (argc != 3) { + debugPrintf("Usage: %s varName value\n", argv[0]); + return true; + } + _vm->_variables[argv[1]] = argv[2]; return true; } diff --git a/engines/pink/console.h b/engines/pink/console.h index 9c438a890c..73041a5719 100644 --- a/engines/pink/console.h +++ b/engines/pink/console.h @@ -39,6 +39,9 @@ private: bool Cmd_ListModules(int argc, const char **argv); bool Cmd_GoToModule(int argc, const char **argv); + bool Cmd_ListGameVars(int argc, const char **argv); + bool Cmd_SetGameVar(int argc, const char **argv); + private: PinkEngine *_vm; }; -- cgit v1.2.3