diff options
author | Paul Gilbert | 2016-06-27 13:43:27 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-15 19:25:27 -0400 |
commit | 3988a9eeee98efdd3b297cde76640416fc13f3ca (patch) | |
tree | 95669cf5dec9a191985b6f5f21e8aa4d4e686032 | |
parent | c87a6e212aa190a7473722dfdd34cf794105d265 (diff) | |
download | scummvm-rg350-3988a9eeee98efdd3b297cde76640416fc13f3ca.tar.gz scummvm-rg350-3988a9eeee98efdd3b297cde76640416fc13f3ca.tar.bz2 scummvm-rg350-3988a9eeee98efdd3b297cde76640416fc13f3ca.zip |
TITANIC: Adding more game object methods
-rw-r--r-- | engines/titanic/core/game_object.cpp | 35 | ||||
-rw-r--r-- | engines/titanic/core/game_object.h | 27 | ||||
-rw-r--r-- | engines/titanic/npcs/true_talk_npc.cpp | 7 | ||||
-rw-r--r-- | engines/titanic/npcs/true_talk_npc.h | 5 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control.cpp | 10 | ||||
-rw-r--r-- | engines/titanic/pet_control/pet_control.h | 11 |
6 files changed, 73 insertions, 22 deletions
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp index 15bc1ec143..72a6e9249b 100644 --- a/engines/titanic/core/game_object.cpp +++ b/engines/titanic/core/game_object.cpp @@ -678,6 +678,26 @@ int CGameObject::compareRoomNameTo(const CString &name) { return room->getName().compareToIgnoreCase(name); } +CString CGameObject::getRoomName() const { + CRoomItem *room = getRoom(); + return room ? room->getName() : CString(); +} + +CString CGameObject::getRoomNodeName() const { + CNodeItem *node = getNode(); + if (!node) + return CString(); + + CRoomItem *room = node->findRoom(); + + return CString::format("%s.%s", room->getName().c_str(), node->getName().c_str()); +} + +CString CGameObject::getFullViewName() { + CGameManager *gameManager = getGameManager(); + return gameManager ? gameManager->getFullViewName() : CString(); +} + CGameObject *CGameObject::getMailManFirstObject() const { CMailMan *mailMan = getMailMan(); return mailMan ? mailMan->getFirstObject() : nullptr; @@ -711,6 +731,11 @@ CGameObject *CGameObject::findRoomObject(const CString &name) const { return static_cast<CGameObject *>(findRoom()->findByName(name)); } +CGameObject *CGameObject::findInRoom(const CString &name) { + CRoomItem *room = getRoom(); + return room ? static_cast<CGameObject *>(room->findByName(name)) : nullptr; +} + Found CGameObject::find(const CString &name, CGameObject **item, int findAreas) { CGameObject *go; *item = nullptr; @@ -903,6 +928,16 @@ CTreeItem *CGameObject::findUnder(CTreeItem *parent, const CString &name) const return nullptr; } +CRoomItem *CGameObject::findRoomByName(const CString &name) { + CProjectItem *project = getRoot(); + for (CRoomItem *room = project->findFirstRoom(); room; room = project->findNextRoom(room)) { + if (!room->getName().compareToIgnoreCase(name)) + return room; + } + + return nullptr; +} + CMusicRoom *CGameObject::getMusicRoom() const { CGameManager *gameManager = getGameManager(); return gameManager ? &gameManager->_musicRoom : nullptr; diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h index 448b547e21..4d53bd3e6e 100644 --- a/engines/titanic/core/game_object.h +++ b/engines/titanic/core/game_object.h @@ -221,6 +221,11 @@ protected: CGameObject *findRoomObject(const CString &name) const; /** + * FInds an object under the current room + */ + CGameObject *findInRoom(const CString &name); + + /** * Moves the item from it's original position to be under the current view */ void moveToView(); @@ -305,6 +310,11 @@ protected: CTreeItem *findUnder(CTreeItem *parent, const CString &name) const; /** + * Finds a room by name + */ + CRoomItem *findRoomByName(const CString &name); + + /** * Returns the music room instance from the game manager */ CMusicRoom *getMusicRoom() const; @@ -541,6 +551,22 @@ public: */ CViewItem *getView() const; + /** + * Get the current room name + */ + CString getRoomName() const; + + /** + * Get the current node and room in the form "room.node" + */ + CString getRoomNodeName() const; + + /** + * Return the full Id of the current view in a + * room.node.view tuplet form + */ + CString getFullViewName(); + /*--- CPetControl Methods ---*/ /** @@ -655,7 +681,6 @@ public: * Start a conversation with the NPC */ void startTalking(const CString &name, uint id, CViewItem *view = nullptr); - }; } // End of namespace Titanic diff --git a/engines/titanic/npcs/true_talk_npc.cpp b/engines/titanic/npcs/true_talk_npc.cpp index 00b68c2913..0295826eb5 100644 --- a/engines/titanic/npcs/true_talk_npc.cpp +++ b/engines/titanic/npcs/true_talk_npc.cpp @@ -211,4 +211,11 @@ void CTrueTalkNPC::setView(CViewItem *view) { talkManager->start3(this, view); } +void CTrueTalkNPC::startTalker(CViewItem *view) { + CGameManager *gameManager = getGameManager(); + if (gameManager) + gameManager->getTalkManager()->start4(this, view); +} + + } // End of namespace Titanic diff --git a/engines/titanic/npcs/true_talk_npc.h b/engines/titanic/npcs/true_talk_npc.h index 1a10a0aa9b..b13841b742 100644 --- a/engines/titanic/npcs/true_talk_npc.h +++ b/engines/titanic/npcs/true_talk_npc.h @@ -85,6 +85,11 @@ public: * Set the view for the NPC */ void setView(CViewItem *view); + + /** + * Start the talker in the given view + */ + void startTalker(CViewItem *view); }; } // End of namespace Titanic diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp index 1643459963..6e30711397 100644 --- a/engines/titanic/pet_control/pet_control.cpp +++ b/engines/titanic/pet_control/pet_control.cpp @@ -513,11 +513,6 @@ void CPetControl::playSound(int soundNum) { } } -CString CPetControl::getRoomName() const { - CRoomItem *room = getRoom(); - return room ? room->getName() : CString(); -} - int CPetControl::canSummonBot(const CString &name) { // If player is the very same view as the NPC, then it's already present if (isBotInView(name)) @@ -652,11 +647,6 @@ CGameObject *CPetControl::findBot(const CString &name, CTreeItem *root) { return nullptr; } -CString CPetControl::getFullViewName() { - CGameManager *gameManager = getGameManager(); - return gameManager ? gameManager->getFullViewName() : CString(); -} - bool CPetControl::isSuccUBusActive() const { if (!_activeNPC) return false; diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h index 5601c403f4..75b92d734e 100644 --- a/engines/titanic/pet_control/pet_control.h +++ b/engines/titanic/pet_control/pet_control.h @@ -282,11 +282,6 @@ public: void playSound(int soundNum); /** - * Get the room name - */ - CString getRoomName() const; - - /** * Check whether an NPC can be summoned */ int canSummonBot(const CString &name); @@ -322,12 +317,6 @@ public: void stopPetTimer(uint timerIndex); /** - * Return the full Id of the current view in a - * room.node.view tuplet form - */ - CString getFullViewName(); - - /** * Returns true if all input is currently locked (disabled) */ bool isInputLocked() const { return _inputLockCount > 0; } |