diff options
Diffstat (limited to 'engines/titanic/core')
-rw-r--r-- | engines/titanic/core/background.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/core/game_object.cpp | 56 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 28 | ||||
-rw-r--r-- | engines/titanic/core/project_item.cpp | 17 | ||||
-rw-r--r-- | engines/titanic/core/project_item.h | 2 | ||||
-rw-r--r-- | engines/titanic/core/saveable_object.cpp | 14 | ||||
-rw-r--r-- | engines/titanic/core/saveable_object.h | 6 | ||||
-rw-r--r-- | engines/titanic/core/view_item.cpp | 2 |
8 files changed, 75 insertions, 52 deletions
diff --git a/engines/titanic/core/background.cpp b/engines/titanic/core/background.cpp index 733dfc1cf3..792cd28346 100644 --- a/engines/titanic/core/background.cpp +++ b/engines/titanic/core/background.cpp @@ -58,7 +58,7 @@ void CBackground::load(SimpleFile *file) { bool CBackground::StatusChangeMsg(CStatusChangeMsg *msg) { setVisible(true); if (_fieldDC) { - playMovie(_startFrame, _endFrame, 16); + playMovie(_startFrame, _endFrame, MOVIE_GAMESTATE); } else { playMovie(_startFrame, _endFrame, 0); } diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 8f71b3d995..76a2f2d5c0 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -403,8 +403,11 @@ void CGameObject::loadImage(const CString &name, bool pendingFlag) { void CGameObject::loadFrame(int frameNumber) { _frameNumber = -1; - if (!_resource.empty()) + + if (!_surface && !_resource.empty()) { loadResource(_resource); + _resource.clear(); + } if (_surface) _surface->setMovieFrame(frameNumber); @@ -612,9 +615,8 @@ void CGameObject::playMovie(uint flags) { void CGameObject::playMovie(int startFrame, int endFrame, uint flags) { _frameNumber = -1; - if (!_surface) { - if (!_resource.empty()) - loadResource(_resource); + if (!_surface && !_resource.empty()) { + loadResource(_resource); _resource.clear(); } @@ -630,9 +632,8 @@ void CGameObject::playMovie(int startFrame, int endFrame, uint flags) { void CGameObject::playMovie(int startFrame, int endFrame, int initialFrame, uint flags) { _frameNumber = -1; - if (!_surface) { - if (!_resource.empty()) - loadResource(_resource); + if (!_surface && !_resource.empty()) { + loadResource(_resource); _resource.clear(); } @@ -645,6 +646,8 @@ void CGameObject::playMovie(int startFrame, int endFrame, int initialFrame, uint } void CGameObject::playClip(const CString &name, uint flags) { + debugC(ERROR_DETAILED, kDebugScripts, "playClip - %s", name.c_str()); + _frameNumber = -1; CMovieClip *clip = _movieClips.findByName(name); if (clip) @@ -652,6 +655,8 @@ void CGameObject::playClip(const CString &name, uint flags) { } void CGameObject::playClip(uint startFrame, uint endFrame) { + debugC(ERROR_DETAILED, kDebugScripts, "playClip - %d to %d", startFrame, endFrame); + CMovieClip *clip = new CMovieClip("", startFrame, endFrame); CGameManager *gameManager = getGameManager(); CRoomItem *room = gameManager->getRoom(); @@ -753,7 +758,7 @@ int CGameObject::playSound(const CString &name, CProximity &prox) { if (gameManager && !name.empty()) { g_vm->_filesManager->preload(name); - gameManager->_sound.playSound(name, prox); + return gameManager->_sound.playSound(name, prox); } return -1; @@ -864,7 +869,8 @@ CViewItem *CGameObject::parseView(const CString &viewString) { if (project) { if (room->getName() != roomName) { // Scan for the correct room - for (room = project->findFirstRoom(); room && room->getName() != roomName; + for (room = project->findFirstRoom(); + room && room->getName() != roomName; room = project->findNextRoom(room)) ; } } @@ -912,12 +918,12 @@ Point CGameObject::getMousePos() const { } bool CGameObject::compareViewNameTo(const CString &name) const { - return getViewFullName().compareToIgnoreCase(name); + return !getViewFullName().compareToIgnoreCase(name); } int CGameObject::compareRoomNameTo(const CString &name) { CRoomItem *room = getGameManager()->getRoom(); - return room->getName().compareToIgnoreCase(name); + return !room->getName().compareToIgnoreCase(name); } CString CGameObject::getRoomName() const { @@ -1142,11 +1148,11 @@ void CGameObject::lockMouse() { } void CGameObject::hideMouse() { - CScreenManager::_screenManagerPtr->_mouseCursor->hide(); + CScreenManager::_screenManagerPtr->_mouseCursor->incHideCounter(); } void CGameObject::showMouse() { - CScreenManager::_screenManagerPtr->_mouseCursor->show(); + CScreenManager::_screenManagerPtr->_mouseCursor->decHideCounter(); } void CGameObject::disableMouse() { @@ -1159,12 +1165,12 @@ void CGameObject::enableMouse() { showMouse(); } -void CGameObject::mouseLockE4() { - CScreenManager::_screenManagerPtr->_mouseCursor->lockE4(); +void CGameObject::mouseDisableControl() { + CScreenManager::_screenManagerPtr->_mouseCursor->disableControl(); } -void CGameObject::mouseUnlockE4() { - CScreenManager::_screenManagerPtr->_mouseCursor->unlockE4(); +void CGameObject::mouseEnableControl() { + CScreenManager::_screenManagerPtr->_mouseCursor->enableControl(); } void CGameObject::mouseSetPosition(const Point &pt, double rate) { @@ -1330,17 +1336,17 @@ CMusicRoom *CGameObject::getMusicRoom() const { return gameManager ? &gameManager->_musicRoom : nullptr; } -int CGameObject::getPassengerClass() const { +PassengerClass CGameObject::getPassengerClass() const { CGameManager *gameManager = getGameManager(); - return gameManager ? gameManager->_gameState._passengerClass : 3; + return gameManager ? gameManager->_gameState._passengerClass : THIRD_CLASS; } -int CGameObject::getPriorClass() const { +PassengerClass CGameObject::getPriorClass() const { CGameManager *gameManager = getGameManager(); - return gameManager ? gameManager->_gameState._priorClass : 3; + return gameManager ? gameManager->_gameState._priorClass : THIRD_CLASS; } -void CGameObject::setPassengerClass(int newClass) { +void CGameObject::setPassengerClass(PassengerClass newClass) { if (newClass >= 1 && newClass <= 4) { // Change the passenger class CGameManager *gameMan = getGameManager(); @@ -1575,7 +1581,7 @@ void CGameObject::petMoveToHiddenRoom() { } } -void CGameObject::petReassignRoom(int passClassNum) { +void CGameObject::petReassignRoom(PassengerClass passClassNum) { CPetControl *petControl = getPetControl(); if (petControl) petControl->reassignRoom(passClassNum); @@ -1607,7 +1613,7 @@ void CGameObject::petSetRooms1D4(int v) { void CGameObject::petOnSummonBot(const CString &name, int val) { CPetControl *pet = getPetControl(); if (pet) - pet->summonBot(name, val); + pet->onSummonBot(name, val); } void CGameObject::petUnlockInput() { @@ -1654,7 +1660,7 @@ void CGameObject::startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view) { } } -void CGameObject::endTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view) { +void CGameObject::setTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view) { CPetControl *pet = getPetControl(); if (pet) pet->setActiveNPC(npc); diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index b50278cf21..ae35e2ba5b 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -165,8 +165,15 @@ protected: */ void enableMouse(); - void mouseLockE4(); - void mouseUnlockE4(); + /** + * Disables user control of the mouse + */ + void mouseDisableControl(); + + /** + * Re-enables user control of the mouse + */ + void mouseEnableControl(); /** * Sets the mouse to a new position @@ -445,7 +452,7 @@ protected: /** * Set's the player's passenger class */ - void setPassengerClass(int newClass); + void setPassengerClass(PassengerClass newClass); /** * Overrides whether the object's movie has audio timing @@ -705,12 +712,12 @@ public: /** * Return the player's passenger class */ - int getPassengerClass() const; + PassengerClass getPassengerClass() const; /** * Return the player's previous passenger class */ - int getPriorClass() const; + PassengerClass getPriorClass() const; /** * Sets the mail identifier for an object @@ -877,7 +884,7 @@ public: /** * Gives the player a new assigned room in the specified passenger class */ - void petReassignRoom(int passClassNum); + void petReassignRoom(PassengerClass passClassNum); /** * Sets a new area in the PET @@ -925,19 +932,20 @@ public: /*--- CTrueTalkManager Methods ---*/ /** - * Stop a conversation with the NPC + * Start a conversation with the NPC */ - void endTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view = nullptr); + void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr); /** * Start a conversation with the NPC */ - void startTalking(CTrueTalkNPC *npc, uint id, CViewItem *view = nullptr); + void startTalking(const CString &name, uint id, CViewItem *view = nullptr); /** * Start a conversation with the NPC */ - void startTalking(const CString &name, uint id, CViewItem *view = nullptr); + void setTalking(CTrueTalkNPC *npc, bool viewFlag, CViewItem *view = nullptr); + /** * Sets a dial region for a given NPC diff --git a/engines/titanic/core/project_item.cpp b/engines/titanic/core/project_item.cpp index 65e8645baa..af67f69580 100644 --- a/engines/titanic/core/project_item.cpp +++ b/engines/titanic/core/project_item.cpp @@ -372,15 +372,20 @@ CTreeItem *CProjectItem::findChildInstance(ClassDef *classDef) const { } CRoomItem *CProjectItem::findNextRoom(CRoomItem *priorRoom) const { - return dynamic_cast<CRoomItem *>(findSiblingInstanceOf(CRoomItem::_type, priorRoom)); + return dynamic_cast<CRoomItem *>(findSiblingChildInstanceOf(CRoomItem::_type, priorRoom)); } -CTreeItem *CProjectItem::findSiblingInstanceOf(ClassDef *classDef, CTreeItem *startItem) const { - CTreeItem *treeItem = startItem->getParent()->getNextSibling(); - if (treeItem == nullptr) - return nullptr; +CTreeItem *CProjectItem::findSiblingChildInstanceOf(ClassDef *classDef, CTreeItem *startItem) const { + for (CTreeItem *treeItem = startItem->getParent()->getNextSibling(); + treeItem; treeItem = treeItem->getNextSibling()) { + for (CTreeItem *childItem = treeItem->getFirstChild(); + childItem; childItem = childItem->getNextSibling()) { + if (childItem->isInstanceOf(classDef)) + return childItem; + } + } - return findChildInstance(classDef); + return nullptr; } CDontSaveFileItem *CProjectItem::getDontSaveFileItem() const { diff --git a/engines/titanic/core/project_item.h b/engines/titanic/core/project_item.h index 4d009dd50b..20c4a4377a 100644 --- a/engines/titanic/core/project_item.h +++ b/engines/titanic/core/project_item.h @@ -118,7 +118,7 @@ private: /** * Finds the next sibling occurance of a given class type */ - CTreeItem *findSiblingInstanceOf(ClassDef *classDef, CTreeItem *startItem) const; + CTreeItem *findSiblingChildInstanceOf(ClassDef *classDef, CTreeItem *startItem) const; private: /** * Load project data from the passed file diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index 7522a34737..73b4bf861f 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -421,14 +421,14 @@ CSaveableObject *ClassDef::create() { /*------------------------------------------------------------------------*/ -Common::HashMap<Common::String, CSaveableObject::CreateFunction> * - CSaveableObject::_classList = nullptr; -Common::List<ClassDef *> *CSaveableObject::_classDefs; +CSaveableObject::ClassListMap *CSaveableObject::_classList; +CSaveableObject::ClassDefList *CSaveableObject::_classDefs; #define DEFFN(T) CSaveableObject *Function##T() { return new T(); } \ ClassDef *T::_type #define ADDFN(CHILD, PARENT) \ CHILD::_type = new TypeTemplate<CHILD>(#CHILD, PARENT::_type); \ + _classDefs->push_back(CHILD::_type); \ (*_classList)[#CHILD] = Function##CHILD DEFFN(CArm); @@ -835,6 +835,7 @@ DEFFN(CMouseDragMsg); DEFFN(CMouseDragStartMsg); DEFFN(CMouseDragMoveMsg); DEFFN(CMouseDragEndMsg); +DEFFN(CMouseWheelMsg); DEFFN(CMoveToStartPosMsg); DEFFN(CMovieEndMsg); DEFFN(CMovieFrameMsg); @@ -1019,8 +1020,8 @@ DEFFN(CStarControl); DEFFN(CTimeEventInfo); void CSaveableObject::initClassList() { - _classDefs = new Common::List<ClassDef *>(); - _classList = new Common::HashMap<Common::String, CreateFunction>(); + _classDefs = new ClassDefList(); + _classList = new ClassListMap(); ADDFN(CArm, CCarry); ADDFN(CAuditoryCentre, CBrain); ADDFN(CBowlEar, CEar); @@ -1426,6 +1427,7 @@ void CSaveableObject::initClassList() { ADDFN(CMouseDragStartMsg, CMouseDragMsg); ADDFN(CMouseDragMoveMsg, CMouseDragMsg); ADDFN(CMouseDragEndMsg, CMouseDragMsg); + ADDFN(CMouseWheelMsg, CMouseMsg); ADDFN(CMoveToStartPosMsg, CMessage); ADDFN(CMovieEndMsg, CMessage); ADDFN(CMovieFrameMsg, CMessage); @@ -1615,7 +1617,7 @@ void CSaveableObject::initClassList() { } void CSaveableObject::freeClassList() { - Common::List<ClassDef *>::iterator i; + ClassDefList::iterator i; for (i = _classDefs->begin(); i != _classDefs->end(); ++i) delete *i; diff --git a/engines/titanic/core/saveable_object.h b/engines/titanic/core/saveable_object.h index 4c7c1a7737..80525f1156 100644 --- a/engines/titanic/core/saveable_object.h +++ b/engines/titanic/core/saveable_object.h @@ -59,8 +59,10 @@ public: class CSaveableObject { typedef CSaveableObject *(*CreateFunction)(); private: - static Common::List<ClassDef *> *_classDefs; - static Common::HashMap<Common::String, CreateFunction> *_classList; + typedef Common::List<ClassDef *> ClassDefList; + typedef Common::HashMap<Common::String, CreateFunction> ClassListMap; + static ClassDefList *_classDefs; + static ClassListMap *_classList; public: /** * Sets up the list of saveable object classes diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp index 9b20860a46..aa1ff7108e 100644 --- a/engines/titanic/core/view_item.cpp +++ b/engines/titanic/core/view_item.cpp @@ -270,7 +270,7 @@ bool CViewItem::handleMouseMsg(CMouseMsg *msg, bool flag) { if (gameObjects.size() == 0) return false; - for (int idx = (int)gameObjects.size() - 1; idx >= 0; ++idx) { + for (int idx = (int)gameObjects.size() - 1; idx >= 0; --idx) { if (gameObjects[idx]->_cursorId != CURSOR_IGNORE) { CScreenManager::_screenManagerPtr->_mouseCursor->setCursor(gameObjects[idx]->_cursorId); break; |