diff options
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/game_object.cpp | 52 | ||||
-rw-r--r-- | engines/titanic/core/project_item.cpp | 56 | ||||
-rw-r--r-- | engines/titanic/core/project_item.h | 7 | ||||
-rw-r--r-- | engines/titanic/debugger.cpp | 10 | ||||
-rw-r--r-- | engines/titanic/debugger.h | 5 | ||||
-rw-r--r-- | engines/titanic/main_game_window.cpp | 9 |
6 files changed, 86 insertions, 53 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 27af509618..ab91a6decc 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -883,57 +883,7 @@ void CGameObject::gotoView(const CString &viewName, const CString &clipName) { } CViewItem *CGameObject::parseView(const CString &viewString) { - int firstIndex = viewString.indexOf('.'); - int lastIndex = viewString.lastIndexOf('.'); - CString roomName, nodeName, viewName; - - if (firstIndex == -1) { - roomName = viewString; - } else { - roomName = viewString.left(firstIndex); - - if (lastIndex > firstIndex) { - nodeName = viewString.mid(firstIndex + 1, lastIndex - firstIndex - 1); - viewName = viewString.mid(lastIndex + 1); - } else { - nodeName = viewString.mid(firstIndex + 1); - } - } - - CGameManager *gameManager = getGameManager(); - if (!gameManager) - return nullptr; - - CRoomItem *room = gameManager->getRoom(); - CProjectItem *project = room->getRoot(); - - // Ensure we have the specified room - if (project) { - if (room->getName().compareToIgnoreCase(roomName)) { - // Scan for the correct room - for (room = project->findFirstRoom(); - room && room->getName().compareToIgnoreCase(roomName); - room = project->findNextRoom(room)) ; - } - } - if (!room) - return nullptr; - - // Find the designated node within the room - CNodeItem *node = dynamic_cast<CNodeItem *>(room->findChildInstanceOf(CNodeItem::_type)); - while (node && node->getName().compareToIgnoreCase(nodeName)) - node = dynamic_cast<CNodeItem *>(room->findNextInstanceOf(CNodeItem::_type, node)); - if (!node) - return nullptr; - - CViewItem *view = dynamic_cast<CViewItem *>(node->findChildInstanceOf(CViewItem::_type)); - while (view && view->getName().compareToIgnoreCase(viewName)) - view = dynamic_cast<CViewItem *>(node->findNextInstanceOf(CViewItem::_type, view)); - if (!view) - return nullptr; - - // Find the view, so return it - return view; + return getRoot()->parseView(viewString); } CString CGameObject::getViewFullName() const { diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp index fa902e6ab7..13bcdfc4b4 100644 --- a/engines/titanic/core/project_item.cpp +++ b/engines/titanic/core/project_item.cpp @@ -569,4 +569,60 @@ Graphics::Surface *CProjectItem::createThumbnail() { return thumb; } +CViewItem *CProjectItem::parseView(const CString &viewString) { + int firstIndex = viewString.indexOf('.'); + int lastIndex = viewString.lastIndexOf('.'); + CString roomName, nodeName, viewName; + + if (firstIndex == -1) { + roomName = viewString; + } + else { + roomName = viewString.left(firstIndex); + + if (lastIndex > firstIndex) { + nodeName = viewString.mid(firstIndex + 1, lastIndex - firstIndex - 1); + viewName = viewString.mid(lastIndex + 1); + } + else { + nodeName = viewString.mid(firstIndex + 1); + } + } + + CGameManager *gameManager = getGameManager(); + if (!gameManager) + return nullptr; + + CRoomItem *room = gameManager->getRoom(); + CProjectItem *project = room->getRoot(); + + // Ensure we have the specified room + if (project) { + if (room->getName().compareToIgnoreCase(roomName)) { + // Scan for the correct room + for (room = project->findFirstRoom(); + room && room->getName().compareToIgnoreCase(roomName); + room = project->findNextRoom(room)); + } + } + if (!room) + return nullptr; + + // Find the designated node within the room + CNodeItem *node = dynamic_cast<CNodeItem *>(room->findChildInstanceOf(CNodeItem::_type)); + while (node && node->getName().compareToIgnoreCase(nodeName)) + node = dynamic_cast<CNodeItem *>(room->findNextInstanceOf(CNodeItem::_type, node)); + if (!node) + return nullptr; + + CViewItem *view = dynamic_cast<CViewItem *>(node->findChildInstanceOf(CViewItem::_type)); + while (view && view->getName().compareToIgnoreCase(viewName)) + view = dynamic_cast<CViewItem *>(node->findNextInstanceOf(CViewItem::_type, view)); + if (!view) + return nullptr; + + // Find the view, so return it + return view; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h index 71a84f7e00..4a87e64e2e 100644 --- a/engines/titanic/core/project_item.h +++ b/engines/titanic/core/project_item.h @@ -235,6 +235,13 @@ public: * Finds a view */ CViewItem *findView(int roomNumber, int nodeNumber, int viewNumber); + + /** + * Parses a view into it's components of room, node, and view, + * and locates the designated view + */ + CViewItem *parseView(const CString &viewString); + }; } // End of namespace Titanic diff --git a/engines/titanic/debugger.cpp b/engines/titanic/debugger.cpp index 5f28aedeb7..ec38291c65 100644 --- a/engines/titanic/debugger.cpp +++ b/engines/titanic/debugger.cpp @@ -37,6 +37,7 @@ Debugger::Debugger(TitanicEngine *vm) : GUI::Debugger(), _vm(vm) { registerCmd("item", WRAP_METHOD(Debugger, cmdItem)); registerCmd("movie", WRAP_METHOD(Debugger, cmdMovie)); registerCmd("sound", WRAP_METHOD(Debugger, cmdSound)); + registerCmd("cheat", WRAP_METHOD(Debugger, cmdCheat)); } int Debugger::strToInt(const char *s) { @@ -330,4 +331,13 @@ bool Debugger::cmdSound(int argc, const char **argv) { } } +bool Debugger::cmdCheat(int argc, const char **argv) { + CGameManager *gameManager = g_vm->_window->_gameManager; + CProjectItem *project = g_vm->_window->_project; + + CViewItem *newView = project->parseView("Cheat Room.Node 1.Cheat Rooms View"); + gameManager->_gameState.changeView(newView, nullptr); + return false; +} + } // End of namespace Titanic diff --git a/engines/titanic/debugger.h b/engines/titanic/debugger.h index a9610d1555..36da1d33f4 100644 --- a/engines/titanic/debugger.h +++ b/engines/titanic/debugger.h @@ -99,6 +99,11 @@ private: * Play a sound */ bool cmdSound(int argc, const char **argv); + + /** + * Change to the cheat room + */ + bool cmdCheat(int argc, const char **argv); protected: TitanicEngine *_vm; public: diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp index 559e186f70..53539d84a5 100644 --- a/engines/titanic/main_game_window.cpp +++ b/engines/titanic/main_game_window.cpp @@ -333,10 +333,15 @@ void CMainGameWindow::keyDown(Common::KeyState keyState) { // Attach to the debugger _vm->_debugger->attach(); _vm->_debugger->onFrame(); - } - if (_inputAllowed) + } else if (keyState.keycode == Common::KEYCODE_c && (keyState.flags & Common::KBD_CTRL)) { + // Cheat action + CViewItem *newView = _project->parseView("Cheat Room.Node 1.Cheat Rooms View"); + _gameManager->_gameState.changeView(newView, nullptr); + + } else if (_inputAllowed) { _gameManager->_inputTranslator.keyDown(keyState); + } } bool CMainGameWindow::isMouseControlEnabled() const { |