From 17762761fe01b467bf2df2e33b3d7293eb40c26c Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Tue, 2 Aug 2016 18:31:37 -0400 Subject: TITANIC: Added CPETPosition leaveViewMsg --- engines/titanic/game/pet/pet_position.cpp | 108 +++++++++++++++++++++++++++++- engines/titanic/game/pet/pet_position.h | 2 + 2 files changed, 109 insertions(+), 1 deletion(-) (limited to 'engines/titanic/game/pet') diff --git a/engines/titanic/game/pet/pet_position.cpp b/engines/titanic/game/pet/pet_position.cpp index 9f58093ccc..3573cdeeae 100644 --- a/engines/titanic/game/pet/pet_position.cpp +++ b/engines/titanic/game/pet/pet_position.cpp @@ -21,11 +21,15 @@ */ #include "titanic/game/pet/pet_position.h" +#include "titanic/core/view_item.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { BEGIN_MESSAGE_MAP(CPETPosition, CGameObject) ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) END_MESSAGE_MAP() void CPETPosition::save(SimpleFile *file, int indent) { @@ -39,8 +43,110 @@ void CPETPosition::load(SimpleFile *file) { } bool CPETPosition::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CPETPosition::handleEvent"); + if (msg->_newRoom->getName() == "EmbLobby") { + CPetControl *pet = getPetControl(); + if (pet) + pet->setRoomsFloorNum(1); + } + + return true; +} + +bool CPETPosition::EnterViewMsg(CEnterViewMsg *msg) { + // TODO + return true; +} + +bool CPETPosition::LeaveViewMsg(CLeaveViewMsg *msg) { + CPetControl *pet = getPetControl(); + CString oldView = msg->_oldView->getName(); + CString newView = msg->_newView->getName(); + + if (pet && newView == "Lift.Node 1.N") { + int elevatorNum = pet->getRoomsElevatorNum(); + + if (oldView == "TopOfWell.Node 25.N") { + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(1); + return true; + } else if (oldView == "TopOfWell.Node 24.SE") { + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(2); + return true; + } else if (oldView == "TopOfWell.Node 26.N") { + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(3); + return true; + } else if (oldView == "TopOfWell.Node 27.N") { + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(4); + return true; + } else if (oldView == "1stClassLobby.Node 10.S") { + switch (elevatorNum) { + case 1: + pet->setRoomsFloorNum(1); + pet->setRoomsElevatorNum(1); + break; + case 2: + pet->setRoomsElevatorNum(1); + break; + default: + pet->setRoomsElevatorNum(3); + break; + } + return true; + } else if (oldView == "1stClassLobby.Node 9.S") { + switch (elevatorNum) { + case 1: + case 2: + pet->setRoomsElevatorNum(2); + break; + default: + pet->setRoomsElevatorNum(4); + break; + } + return true; + } else if (oldView == "2ndClassLobby.Node 8.S") { + switch (elevatorNum) { + case 1: + case 2: + pet->setRoomsElevatorNum(1); + break; + default: + pet->setRoomsElevatorNum(3); + break; + } + return true; + } else if (oldView == "2ndClassLobby.Node 1.S") { + switch (elevatorNum) { + case 1: + case 2: + pet->setRoomsElevatorNum(2); + break; + default: + pet->setRoomsElevatorNum(4); + break; + } + return true; + } else if (oldView == "SgtLobby.Node 1.S") { + return true; + } else if (oldView == "BottomOfWell.Node 10.E" || oldView == "BottomOfWell.Node 11.W") { + pet->setRoomsElevatorNum(1); + return true; + } + } + + CRoomItem *newRoom = msg->_newView->findRoom(); + if (newRoom) { + CString roomName = newRoom->getName(); + if (roomName == "1stClassLobby" || roomName == "2ndClassLobby" || roomName == "SgtLobby") { + if (pet) + pet->resetRoomsHighlight(); + } + } + return true; } + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_position.h b/engines/titanic/game/pet/pet_position.h index d1ac0507f4..0cf835f23f 100644 --- a/engines/titanic/game/pet/pet_position.h +++ b/engines/titanic/game/pet/pet_position.h @@ -31,6 +31,8 @@ namespace Titanic { class CPETPosition : public CGameObject { DECLARE_MESSAGE_MAP; bool EnterRoomMsg(CEnterRoomMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: CLASSDEF; -- cgit v1.2.3