diff options
-rw-r--r-- | engines/titanic/core/game_object.cpp | 70 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 168 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.cpp | 70 | ||||
-rw-r--r-- | engines/titanic/core/tree_item.h | 55 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control.cpp | 2 |
5 files changed, 183 insertions, 182 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index f386c1eb51..00a7328443 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -613,6 +613,11 @@ bool CGameObject::compareViewNameTo(const CString &name) const { return getViewFullName().compareToIgnoreCase(name); } +int CGameObject::compareRoomNameTo(const CString &name) { + CRoomItem *room = getGameManager()->getRoom(); + return room->getName().compareToIgnoreCase(name); +} + void CGameObject::petDisplayMsg(const CString &msg) const { CPetControl *pet = getPetControl(); if (pet) @@ -808,4 +813,69 @@ void CGameObject::checkPlayMovie(const CString &name, int flags) { } } +void CGameObject::clearPet() const { + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->clear(); +} + +CPetControl *CGameObject::getPetControl() const { + return static_cast<CPetControl *>(getDontSaveChild(CPetControl::_type)); +} + +CMailMan *CGameObject::getMailMan() const { + return dynamic_cast<CMailMan *>(getDontSaveChild(CMailMan::_type)); +} + +CTreeItem *CGameObject::getDontSaveChild(ClassDef *classDef) const { + CProjectItem *root = getRoot(); + if (!root) + return nullptr; + + CDontSaveFileItem *dontSave = root->getDontSaveFileItem(); + if (!dontSave) + return nullptr; + + return dontSave->findChildInstanceOf(classDef); +} + +CRoomItem *CGameObject::getRoom() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->getRoom() : nullptr; +} + +CRoomItem *CGameObject::getHiddenRoom() const { + CProjectItem *root = getRoot(); + return root ? root->findHiddenRoom() : nullptr; +} + +CMusicRoom *CGameObject::getMusicRoom() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? &gameManager->_musicRoom : nullptr; +} + +int CGameObject::getPassengerClass() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->_gameState._passengerClass : 3; +} + +int CGameObject::getPriorClass() const { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->_gameState._priorClass : 3; +} + +void CGameObject::setPassengerClass(int newClass) { + if (newClass >= 1 && newClass <= 4) { + // Change the passenger class + CGameManager *gameMan = getGameManager(); + gameMan->_gameState._priorClass = gameMan->_gameState._passengerClass; + gameMan->_gameState._passengerClass = newClass; + + // Setup the PET again, so the new class's PET background can take effect + CPetControl *petControl = getPetControl(); + if (petControl) + petControl->setup(); + } +} + } // End of namespace Titanic diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 10847c816c..f389815a99 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -103,11 +103,6 @@ protected: bool checkStartDragging(CMouseDragStartMsg *msg); /** - * Marks the area in the passed rect as dirty, and requiring re-rendering - */ - void makeDirty(const Rect &r); - - /** * Sets a new area in the PET */ void setPetArea(PetArea newArea) const; @@ -195,6 +190,11 @@ protected: bool compareViewNameTo(const CString &name) const; /** + * Compare the name of the parent room to the item to a passed string + */ + int compareRoomNameTo(const CString &name); + + /** * Display a message in the PET */ void petDisplayMsg(const CString &msg) const; @@ -258,6 +258,80 @@ protected: * Support function for drag moving */ void dragMove(const Point &pt); + + /** + * Set the position of the object + */ + void setPosition(const Point &newPos); + + void sound8(bool flag) const; + + /** + * Play an arbitrary clip + */ + void playClip(const CString &name, uint flags); + + /** + * Play a clip + */ + void playClip(uint startFrame, uint endFrame); + + /** + * Return the current view/node/room as a single string + */ + CString getViewFullName() const; + + /** + * Returns true if a clip exists in the list with a given name + * and starting frame number + */ + bool clipExistsByStart(const CString &name, int startFrame = 0) const; + + /** + * Returns true if a clip exists in the list with a given name + * and ending frame number + */ + bool clipExistsByEnd(const CString &name, int endFrame = 0) const; + + /** + * Clear the PET display + */ + void clearPet() const; + + /** + * Returns the PET control + */ + CPetControl *getPetControl() const; + + /** + * Returns the MailMan + */ + CMailMan *getMailMan() const; + + /** + * Returns a child of the Dont Save area of the project of the given class + */ + CTreeItem *getDontSaveChild(ClassDef *classDef) const; + + /** + * Return the current room + */ + CRoomItem *getRoom() const; + + /** + * Returns the special hidden room container + */ + CRoomItem *getHiddenRoom() const; + + /** + * Returns the music room instance from the game manager + */ + CMusicRoom *getMusicRoom() const; + + /** + * Set's the player's passenger class + */ + void setPassengerClass(int newClass); public: int _field60; CursorId _cursorId; @@ -292,9 +366,14 @@ public: virtual bool isPet() const; /** - * Stops any movie currently playing for the object + * Play the movie specified in _resource */ - void stopMovie(); + void playMovie(uint startFrame, uint endFrame, uint flags); + + /** + * Moves the item from it's original position to be under the hidden room + */ + void moveToHiddenRoom(); /** * Checks the passed point is validly in the object, @@ -303,52 +382,49 @@ public: bool checkPoint(const Point &pt, bool ignore40 = false, bool visibleOnly = false); /** - * Set the position of the object + * Change the object's status */ - void setPosition(const Point &newPos); - + void playMovie(uint flags); + /** - * Returns true if the object has a currently active movie + * Checks and plays a pending clip */ - bool hasActiveMovie() const; + void checkPlayMovie(const CString &name, int flags); /** - * Get the current movie frame + * Returns true if the object has a currently active movie */ - int getMovieFrame() const; - - int getSurface45() const; - void sound8(bool flag) const; + bool hasActiveMovie() const; /** - * Loads a frame + * Stops any movie currently playing for the object */ - void loadFrame(int frameNumber); + void stopMovie(); /** - * Change the object's status + * Get the current movie frame */ - void playMovie(uint flags); - + int getMovieFrame() const; + /** - * Play the movie specified in _resource + * Returns the object's frame number */ - void playMovie(uint startFrame, uint endFrame, uint flags); + int getFrameNumber() const { return _frameNumber; } /** - * Play an arbitrary clip + * Loads a frame */ - void playClip(const CString &name, uint flags); + void loadFrame(int frameNumber); /** - * Play a clip + * Marks the area occupied by the object as dirty, requiring re-rendering */ - void playClip(uint startFrame, uint endFrame); + void makeDirty(); /** - * Return the current view/node/room as a single string + * Marks the area in the passed rect as dirty, and requiring re-rendering */ - CString getViewFullName() const; + void makeDirty(const Rect &r); /** * Sets whether the object is visible @@ -356,36 +432,16 @@ public: void setVisible(bool val); /** - * Moves the item from it's original position to be under the hidden room - */ - void moveToHiddenRoom(); - - /** - * Returns the object's frame number - */ - int getFrameNumber() const { return _frameNumber; } - - /** - * Marks the area occupied by the object as dirty, requiring re-rendering + * Return the player's passenger class */ - void makeDirty(); - - /** - * Returns true if a clip exists in the list with a given name - * and starting frame number - */ - bool clipExistsByStart(const CString &name, int startFrame = 0) const; - + int getPassengerClass() const; + /** - * Returns true if a clip exists in the list with a given name - * and ending frame number + * Return the player's previous passenger class */ - bool clipExistsByEnd(const CString &name, int endFrame = 0) const; + int getPriorClass() const; - /** - * Checks and plays a pending clip - */ - void checkPlayMovie(const CString &name, int flags); + int getSurface45() const; }; } // End of namespace Titanic diff --git a/engines/titanic/core/tree_item.cpp b/engines/titanic/core/tree_item.cpp index 86a6b174a8..9b5097040c 100644 --- a/engines/titanic/core/tree_item.cpp +++ b/engines/titanic/core/tree_item.cpp @@ -268,74 +268,4 @@ CNamedItem *CTreeItem::findByName(const CString &name, int maxLen) { return nullptr; } -int CTreeItem::compareRoomNameTo(const CString &name) { - CRoomItem *room = getGameManager()->getRoom(); - return room->getName().compareToIgnoreCase(name); -} - -void CTreeItem::clearPet() const { - CPetControl *petControl = getPetControl(); - if (petControl) - petControl->clear(); -} - -CPetControl *CTreeItem::getPetControl() const { - return static_cast<CPetControl *>(getDontSaveChild(CPetControl::_type)); -} - -CMailMan *CTreeItem::getMailMan() const { - return dynamic_cast<CMailMan *>(getDontSaveChild(CMailMan::_type)); -} - -CTreeItem *CTreeItem::getDontSaveChild(ClassDef *classDef) const { - CProjectItem *root = getRoot(); - if (!root) - return nullptr; - - CDontSaveFileItem *dontSave = root->getDontSaveFileItem(); - if (!dontSave) - return nullptr; - - return dontSave->findChildInstanceOf(classDef); -} - -CRoomItem *CTreeItem::getRoom() const { - CGameManager *gameManager = getGameManager(); - return gameManager ? gameManager->getRoom() : nullptr; -} - -CRoomItem *CTreeItem::getHiddenRoom() const { - CProjectItem *root = getRoot(); - return root ? root->findHiddenRoom() : nullptr; -} - -CMusicRoom *CTreeItem::getMusicRoom() const { - CGameManager *gameManager = getGameManager(); - return gameManager ? &gameManager->_musicRoom : nullptr; -} - -int CTreeItem::getPassengerClass() const { - CGameManager *gameManager = getGameManager(); - return gameManager ? gameManager->_gameState._passengerClass : 3; -} - -int CTreeItem::getPriorClass() const { - CGameManager *gameManager = getGameManager(); - return gameManager ? gameManager->_gameState._priorClass : 3; -} - -void CTreeItem::setPassengerClass(int newClass) { - if (newClass >= 1 && newClass <= 4) { - // Change the passenger class - CGameManager *gameMan = getGameManager(); - gameMan->_gameState._priorClass = gameMan->_gameState._passengerClass; - gameMan->_gameState._passengerClass = newClass; - - // Setup the PET again, so the new class's PET background can take effect - CPetControl *petControl = getPetControl(); - if (petControl) - petControl->setup(); - } -} - } // End of namespace Titanic diff --git a/engines/titanic/core/tree_item.h b/engines/titanic/core/tree_item.h index d893d6d9ce..fd7586b819 100644 --- a/engines/titanic/core/tree_item.h +++ b/engines/titanic/core/tree_item.h @@ -238,61 +238,6 @@ public: * Finds a tree item by name */ CNamedItem *findByName(const CString &name, int maxLen = 0); - - /** - * Compare the name of the parent room to the item to a passed string - */ - int compareRoomNameTo(const CString &name); - - /** - * Clear the PET display - */ - void clearPet() const; - - /** - * Returns the PET control - */ - CPetControl *getPetControl() const; - - /** - * Returns the MailMan - */ - CMailMan *getMailMan() const; - - /** - * Returns a child of the Dont Save area of the project of the given class - */ - CTreeItem *getDontSaveChild(ClassDef *classDef) const; - - /** - * Return the current room - */ - CRoomItem *getRoom() const; - - /** - * Returns the special hidden room container - */ - CRoomItem *getHiddenRoom() const; - - /** - * Returns the music room instance from the game manager - */ - CMusicRoom *getMusicRoom() const; - - /** - * Return the player's passenger class - */ - int getPassengerClass() const; - - /** - * Return the player's previous passenger class - */ - int getPriorClass() const; - - /** - * Set's the player's passenger class - */ - void setPassengerClass(int newClass); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index 8571b5ea65..1fd6549f9b 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -225,7 +225,7 @@ void CPetControl::fn3(CTreeItem *item) { CRoomItem *CPetControl::getHiddenRoom() { if (!_hiddenRoom) - _hiddenRoom = CTreeItem::getHiddenRoom(); + _hiddenRoom = CGameObject::getHiddenRoom(); return _hiddenRoom; } |