[Scummvm-cvs-logs] scummvm master -> 8f8cf6eadc842f97d131437c86e17d1305c9ef56

dreammaster dreammaster at scummvm.org
Tue Aug 9 02:48:14 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
8f8cf6eadc TITANIC: Implemented room, node, and view auto sound player classes


Commit: 8f8cf6eadc842f97d131437c86e17d1305c9ef56
    https://github.com/scummvm/scummvm/commit/8f8cf6eadc842f97d131437c86e17d1305c9ef56
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-08T20:48:06-04:00

Commit Message:
TITANIC: Implemented room, node, and view auto sound player classes

Changed paths:
    engines/titanic/sound/node_auto_sound_player.cpp
    engines/titanic/sound/node_auto_sound_player.h
    engines/titanic/sound/room_auto_sound_player.cpp
    engines/titanic/sound/room_auto_sound_player.h
    engines/titanic/sound/view_auto_sound_player.cpp
    engines/titanic/sound/view_auto_sound_player.h



diff --git a/engines/titanic/sound/node_auto_sound_player.cpp b/engines/titanic/sound/node_auto_sound_player.cpp
index f74c891..40b3d2e 100644
--- a/engines/titanic/sound/node_auto_sound_player.cpp
+++ b/engines/titanic/sound/node_auto_sound_player.cpp
@@ -21,23 +21,63 @@
  */
 
 #include "titanic/sound/node_auto_sound_player.h"
+#include "titanic/sound/auto_music_player.h"
+#include "titanic/core/room_item.h"
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CNodeAutoSoundPlayer, CAutoSoundPlayer)
+	ON_MESSAGE(EnterNodeMsg)
+	ON_MESSAGE(LeaveNodeMsg)
+END_MESSAGE_MAP()
+
 void CNodeAutoSoundPlayer::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
-	file->writeNumberLine(_fieldEC, indent);
+	file->writeNumberLine(_enabled, indent);
 	CAutoSoundPlayer::save(file, indent);
 }
 
 void CNodeAutoSoundPlayer::load(SimpleFile *file) {
 	file->readNumber();
-	_fieldEC = file->readNumber();
+	_enabled = file->readNumber();
 	CAutoSoundPlayer::load(file);
 }
 
 bool CNodeAutoSoundPlayer::EnterNodeMsg(CEnterNodeMsg *msg) {
-	warning("CNodeAutoSoundPlayer::handleEvent");
+	CNodeItem *node = findNode();
+	CRoomItem *room = findRoom();
+
+	if (node == msg->_newNode) {
+		CTurnOn onMsg;
+		onMsg.execute(this);
+
+		if (_enabled) {
+			CChangeMusicMsg changeMsg;
+			changeMsg._flags = 1;
+			changeMsg.execute(room, CAutoMusicPlayer::_type,
+				MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+		}
+	}
+
+	return true;
+}
+
+bool CNodeAutoSoundPlayer::LeaveNodeMsg(CLeaveNodeMsg *msg) {
+	CNodeItem *node = findNode();
+	CRoomItem *room = findRoom();
+
+	if (node == msg->_oldNode) {
+		CTurnOff offMsg;
+		offMsg.execute(this);
+
+		if (_enabled) {
+			CChangeMusicMsg changeMsg;
+			changeMsg._flags = 2;
+			changeMsg.execute(room, CAutoMusicPlayer::_type,
+				MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+		}
+	}
+
 	return true;
 }
 
diff --git a/engines/titanic/sound/node_auto_sound_player.h b/engines/titanic/sound/node_auto_sound_player.h
index e980841..f5bdc42 100644
--- a/engines/titanic/sound/node_auto_sound_player.h
+++ b/engines/titanic/sound/node_auto_sound_player.h
@@ -29,12 +29,14 @@
 namespace Titanic {
 
 class CNodeAutoSoundPlayer : public CAutoSoundPlayer {
+	DECLARE_MESSAGE_MAP;
 	bool EnterNodeMsg(CEnterNodeMsg *msg);
+	bool LeaveNodeMsg(CLeaveNodeMsg *msg);
 private:
-	int _fieldEC;
+	bool _enabled;
 public:
 	CLASSDEF;
-	CNodeAutoSoundPlayer() : CAutoSoundPlayer(), _fieldEC(1) {}
+	CNodeAutoSoundPlayer() : CAutoSoundPlayer(), _enabled(true) {}
 
 	/**
 	 * Save the data for the class to file
diff --git a/engines/titanic/sound/room_auto_sound_player.cpp b/engines/titanic/sound/room_auto_sound_player.cpp
index da98d41..cad7c10 100644
--- a/engines/titanic/sound/room_auto_sound_player.cpp
+++ b/engines/titanic/sound/room_auto_sound_player.cpp
@@ -24,6 +24,11 @@
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CRoomAutoSoundPlayer, CAutoSoundPlayer)
+	ON_MESSAGE(EnterRoomMsg)
+	ON_MESSAGE(LeaveRoomMsg)
+END_MESSAGE_MAP()
+
 void CRoomAutoSoundPlayer::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
 	CAutoSoundPlayer::save(file, indent);
@@ -35,7 +40,22 @@ void CRoomAutoSoundPlayer::load(SimpleFile *file) {
 }
 
 bool CRoomAutoSoundPlayer::EnterRoomMsg(CEnterRoomMsg *msg) {
-	warning("CRoomAutoSoundPlayer::handleEvent");
+	CRoomItem *room = findRoom();
+	if (room == msg->_newRoom) {
+		CTurnOn onMsg;
+		onMsg.execute(this);
+	}
+
+	return true;
+}
+
+bool CRoomAutoSoundPlayer::LeaveRoomMsg(CLeaveRoomMsg *msg) {
+	CRoomItem *room = findRoom();
+	if (room == msg->_oldRoom) {
+		CTurnOff offMsg;
+		offMsg.execute(this);
+	}
+
 	return true;
 }
 
diff --git a/engines/titanic/sound/room_auto_sound_player.h b/engines/titanic/sound/room_auto_sound_player.h
index 9c3feb5..56525cc 100644
--- a/engines/titanic/sound/room_auto_sound_player.h
+++ b/engines/titanic/sound/room_auto_sound_player.h
@@ -29,7 +29,9 @@
 namespace Titanic {
 
 class CRoomAutoSoundPlayer : public CAutoSoundPlayer {
+	DECLARE_MESSAGE_MAP;
 	bool EnterRoomMsg(CEnterRoomMsg *msg);
+	bool LeaveRoomMsg(CLeaveRoomMsg *msg);
 public:
 	CLASSDEF;
 
diff --git a/engines/titanic/sound/view_auto_sound_player.cpp b/engines/titanic/sound/view_auto_sound_player.cpp
index 9150748..55501fe 100644
--- a/engines/titanic/sound/view_auto_sound_player.cpp
+++ b/engines/titanic/sound/view_auto_sound_player.cpp
@@ -21,19 +21,64 @@
  */
 
 #include "titanic/sound/view_auto_sound_player.h"
+#include "titanic/sound/auto_music_player.h"
+#include "titanic/core/room_item.h"
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CViewAutoSoundPlayer, CAutoSoundPlayer)
+	ON_MESSAGE(EnterViewMsg)
+	ON_MESSAGE(LeaveViewMsg)
+END_MESSAGE_MAP()
+
 void CViewAutoSoundPlayer::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
-	file->writeNumberLine(_fieldEC, indent);
+	file->writeNumberLine(_enabled, indent);
 	CAutoSoundPlayer::save(file, indent);
 }
 
 void CViewAutoSoundPlayer::load(SimpleFile *file) {
 	file->readNumber();
-	_fieldEC = file->readNumber();
+	_enabled = file->readNumber();
 	CAutoSoundPlayer::load(file);
 }
 
+bool CViewAutoSoundPlayer::EnterViewMsg(CEnterViewMsg *msg) {
+	CViewItem *view = findView();
+	CRoomItem *room = findRoom();
+
+	if (view == msg->_newView) {
+		CTurnOn onMsg;
+		onMsg.execute(this);
+
+		if (_enabled) {
+			CChangeMusicMsg changeMsg;
+			changeMsg._flags = 1;
+			changeMsg.execute(room, CAutoMusicPlayer::_type,
+				MSGFLAG_CLASS_DEF |MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+		}
+	}
+
+	return true;
+}
+
+bool CViewAutoSoundPlayer::LeaveViewMsg(CLeaveViewMsg *msg) {
+	CViewItem *view = findView();
+	CRoomItem *room = findRoom();
+
+	if (view == msg->_oldView) {
+		CTurnOff offMsg;
+		offMsg.execute(this);
+
+		if (_enabled) {
+			CChangeMusicMsg changeMsg;
+			changeMsg._flags = 2;
+			changeMsg.execute(room, CAutoMusicPlayer::_type,
+				MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN);
+		}
+	}
+
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/sound/view_auto_sound_player.h b/engines/titanic/sound/view_auto_sound_player.h
index 29bdee7..b62805e 100644
--- a/engines/titanic/sound/view_auto_sound_player.h
+++ b/engines/titanic/sound/view_auto_sound_player.h
@@ -28,11 +28,14 @@
 namespace Titanic {
 
 class CViewAutoSoundPlayer : public CAutoSoundPlayer {
+	DECLARE_MESSAGE_MAP;
+	bool EnterViewMsg(CEnterViewMsg *msg);
+	bool LeaveViewMsg(CLeaveViewMsg *msg);
 private:
-	int _fieldEC;
+	bool _enabled;
 public:
 	CLASSDEF;
-	CViewAutoSoundPlayer() : CAutoSoundPlayer(), _fieldEC(0) {}
+	CViewAutoSoundPlayer() : CAutoSoundPlayer(), _enabled(false) {}
 
 	/**
 	 * Save the data for the class to file






More information about the Scummvm-git-logs mailing list