TITANIC: Support full view specification in debugger room command

This commit is contained in:
Paul Gilbert 2017-09-04 10:15:53 -04:00
parent 67090d3cda
commit f9bec828de
4 changed files with 49 additions and 22 deletions

@ -1205,28 +1205,11 @@ void CGameObject::loadSurface() {
}
bool CGameObject::changeView(const CString &viewName) {
return changeView(viewName, "");
return getRoot()->changeView(viewName, "");
}
bool CGameObject::changeView(const CString &viewName, const CString &clipName) {
CViewItem *newView = parseView(viewName);
CGameManager *gameManager = getGameManager();
CViewItem *oldView = gameManager->getView();
if (!oldView || !newView)
return false;
CMovieClip *clip = nullptr;
if (!clipName.empty()) {
clip = oldView->findNode()->findRoom()->findClip(clipName);
} else {
CLinkItem *link = oldView->findLink(newView);
if (link)
clip = link->getClip();
}
gameManager->_gameState.changeView(newView, clip);
return true;
return getRoot()->changeView(viewName, clipName);
}
void CGameObject::dragMove(const Point &pt) {

@ -626,4 +626,30 @@ CViewItem *CProjectItem::parseView(const CString &viewString) {
return view;
}
bool CProjectItem::changeView(const CString &viewName) {
return changeView(viewName, "");
}
bool CProjectItem::changeView(const CString &viewName, const CString &clipName) {
CViewItem *newView = parseView(viewName);
CGameManager *gameManager = getGameManager();
CViewItem *oldView = gameManager->getView();
if (!oldView || !newView)
return false;
CMovieClip *clip = nullptr;
if (!clipName.empty()) {
clip = oldView->findNode()->findRoom()->findClip(clipName);
} else {
CLinkItem *link = oldView->findLink(newView);
if (link)
clip = link->getClip();
}
gameManager->_gameState.changeView(newView, clip);
return true;
}
} // End of namespace Titanic

@ -242,6 +242,15 @@ public:
*/
CViewItem *parseView(const CString &viewString);
/**
* Change the view
*/
bool changeView(const CString &viewName, const CString &clipName);
/**
* Change the view
*/
bool changeView(const CString &viewName);
};
} // End of namespace Titanic

@ -168,9 +168,18 @@ bool Debugger::cmdRoom(int argc, const char **argv) {
} else if (argc >= 2) {
CRoomItem *roomItem = findRoom(argv[1]);
if (!roomItem)
debugPrintf("Could not find room - %s\n", argv[1]);
else if (argc == 2)
if (!roomItem && argc == 2) {
// Presume it's a full view specified
CProjectItem *project = g_vm->_window->_project;
CViewItem *view = project->parseView(argv[1]);
if (view) {
project->changeView(argv[1]);
return false;
} else {
debugPrintf("Could not find view - %s\n", argv[1]);
}
} else if (argc == 2)
listRoom(roomItem);
else {
CNodeItem *nodeItem = findNode(roomItem, argv[2]);