diff options
author | Paul Gilbert | 2016-04-17 15:24:35 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:11:20 -0400 |
commit | a11e677494d7cb3c6b8ed2c56095873d46a00ab8 (patch) | |
tree | 04fcaf26af1bac4b7553f4ad8de2917a448294d9 /engines | |
parent | 22248ccbf20535d9c14da2e376ae7ff3c9b4081b (diff) | |
download | scummvm-rg350-a11e677494d7cb3c6b8ed2c56095873d46a00ab8.tar.gz scummvm-rg350-a11e677494d7cb3c6b8ed2c56095873d46a00ab8.tar.bz2 scummvm-rg350-a11e677494d7cb3c6b8ed2c56095873d46a00ab8.zip |
TITANIC: Added item debugger command
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/debugger.cpp | 48 | ||||
-rw-r--r-- | engines/titanic/debugger.h | 5 |
2 files changed, 53 insertions, 0 deletions
diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp index 84f961e607..f525f4f3b9 100644 --- a/engines/titanic/debugger.cpp +++ b/engines/titanic/debugger.cpp @@ -23,6 +23,7 @@ #include "titanic/debugger.h" #include "titanic/titanic.h" #include "titanic/core/tree_item.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { @@ -31,6 +32,7 @@ Debugger::Debugger(TitanicEngine *vm) : GUI::Debugger(), _vm(vm) { registerCmd("dump", WRAP_METHOD(Debugger, cmdDump)); registerCmd("room", WRAP_METHOD(Debugger, cmdRoom)); registerCmd("pet", WRAP_METHOD(Debugger, cmdPET)); + registerCmd("item", WRAP_METHOD(Debugger, cmdItem)); } int Debugger::strToInt(const char *s) { @@ -207,4 +209,50 @@ bool Debugger::cmdPET(int argc, const char **argv) { return true; } +bool Debugger::cmdItem(int argc, const char **argv) { + if (argc == 1) { + // No parameters, so list the available items + debugPrintf("item [<name> [ add ]]\n"); + for (int idx = 0; idx < 40; ++idx) + debugPrintf("%s\n", g_vm->_itemIds[idx].c_str()); + } else { + // Ensure the specified name is a valid inventory item + int itemIndex; + for (itemIndex = 0; itemIndex < 40; ++itemIndex) { + if (g_vm->_itemIds[itemIndex] == argv[1]) + break; + } + if (itemIndex == 40) { + debugPrintf("Could not find item with that name\n"); + return true; + } + + // Get the item + CCarry *item = static_cast<CCarry *>( + g_vm->_window->_project->findByName(argv[1])); + assert(item); + + if (argc == 2) { + // List it's details + CTreeItem *treeItem = item; + CString fullName; + while ((treeItem = treeItem->getParent()) != nullptr) { + if (!treeItem->getName().empty()) + fullName = treeItem->getName() + "." + fullName; + } + + debugPrintf("Current location: %s\n", fullName.c_str()); + } else if (CString(argv[2]) == "add") { + CPetControl *pet = item->getPetControl(); + pet->_visible = true; + item->addToInventory(); + return false; + } else { + debugPrintf("Unknown command\n"); + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/debugger.h b/engines/titanic/debugger.h index 29e82d699f..5edb7cb324 100644 --- a/engines/titanic/debugger.h +++ b/engines/titanic/debugger.h @@ -84,6 +84,11 @@ private: * Turn the PET on or off */ bool cmdPET(int argc, const char **argv); + + /** + * Item handling + */ + bool cmdItem(int argc, const char **argv); protected: TitanicEngine *_vm; public: |