aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/core/saveable_object.cpp6
-rw-r--r--engines/titanic/core/view_item.cpp28
-rw-r--r--engines/titanic/core/view_item.h5
-rw-r--r--engines/titanic/messages/messages.h6
4 files changed, 42 insertions, 3 deletions
diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp
index 4ad9938c9c..5fbe88878f 100644
--- a/engines/titanic/core/saveable_object.cpp
+++ b/engines/titanic/core/saveable_object.cpp
@@ -801,6 +801,9 @@ DEFFN(CIsEarBowlPuzzleDone)
DEFFN(CIsHookedOnMsg)
DEFFN(CIsParrotPresentMsg)
DEFFN(CKeyCharMsg)
+DEFFN(CLeaveNodeMsg);
+DEFFN(CLeaveRoomMsg);
+DEFFN(CLeaveViewMsg);
DEFFN(CLemonFallsFromTreeMsg)
DEFFN(CLightsMsg)
DEFFN(CLoadSuccessMsg)
@@ -1374,6 +1377,9 @@ void CSaveableObject::initClassList() {
ADDFN(CIsHookedOnMsg, CMessage);
ADDFN(CIsParrotPresentMsg, CMessage);
ADDFN(CKeyCharMsg, CMessage);
+ ADDFN(CLeaveNodeMsg, CMessage);
+ ADDFN(CLeaveRoomMsg, CMessage);
+ ADDFN(CLeaveViewMsg, CMessage);
ADDFN(CLemonFallsFromTreeMsg, CMessage);
ADDFN(CLightsMsg, CMessage);
ADDFN(CLoadSuccessMsg, CMessage);
diff --git a/engines/titanic/core/view_item.cpp b/engines/titanic/core/view_item.cpp
index 7038e94538..60463545d3 100644
--- a/engines/titanic/core/view_item.cpp
+++ b/engines/titanic/core/view_item.cpp
@@ -21,6 +21,8 @@
*/
#include "titanic/core/view_item.h"
+#include "titanic/messages/messages.h"
+#include "titanic/game_manager.h"
namespace Titanic {
@@ -73,4 +75,30 @@ bool CViewItem::getResourceKey(CResourceKey *key) {
return !filename.empty();
}
+void CViewItem::viewChange(CViewItem *newView) {
+ // Only do the processing if we've been passed a view, and it's not the same
+ if (newView && newView != this) {
+ CLeaveViewMsg viewMsg(this, newView);
+ viewMsg.execute(this, nullptr, MSGFLAG_SCAN);
+
+ CNodeItem *oldNode = findNode();
+ CNodeItem *newNode = newView->findNode();
+ if (newNode != oldNode) {
+ CLeaveNodeMsg nodeMsg(oldNode, newNode);
+ nodeMsg.execute(oldNode, nullptr, MSGFLAG_SCAN);
+
+ CRoomItem *oldRoom = oldNode->findRoom();
+ CRoomItem *newRoom = newNode->findRoom();
+ if (newRoom != oldRoom) {
+ CGameManager *gm = getGameManager();
+ if (gm)
+ gm->viewChange();
+
+ CLeaveRoomMsg roomMsg(oldRoom, newRoom);
+ roomMsg.execute(oldRoom, nullptr, MSGFLAG_SCAN);
+ }
+ }
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/view_item.h b/engines/titanic/core/view_item.h
index 106c795773..632c8e7358 100644
--- a/engines/titanic/core/view_item.h
+++ b/engines/titanic/core/view_item.h
@@ -57,6 +57,11 @@ public:
* Get the resource key for the view
*/
bool getResourceKey(CResourceKey *key);
+
+ /**
+ * Called when changing from one view to another
+ */
+ void viewChange(CViewItem *newView);
};
} // End of namespace Titanic
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index d89b0e1ae5..4e00648f1b 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -281,9 +281,9 @@ MESSAGE0(CInitializeAnimMsg);
MESSAGE1(CIsEarBowlPuzzleDone, int, value, 0);
MESSAGE1(CIsParrotPresentMsg, int, value, 0);
MESSAGE1(CKeyCharMsg, int, value, 32);
-MESSAGE1(CLeaveNodeMsg, CNodeItem *, node, nullptr);
-MESSAGE1(CLeaveRoomMsg, CRoomItem *, room, nullptr);
-MESSAGE1(CLeaveViewMsg, CViewItem *, view, nullptr);
+MESSAGE2(CLeaveNodeMsg, CNodeItem *, oldNode, nullptr, CNodeItem *, newNode, nullptr);
+MESSAGE2(CLeaveRoomMsg, CRoomItem *, oldRoom, nullptr, CRoomItem *, newRoom, nullptr);
+MESSAGE2(CLeaveViewMsg, CViewItem *, oldView, nullptr, CViewItem *, newView, nullptr);
MESSAGE2(CLemonFallsFromTreeMsg, int, value1, 0, int, value2, 0);
MESSAGE1(CLoadSuccessMsg, int, ticks, 0);
MESSAGE1(CLockPhonographMsg, int, value, 0);