[Scummvm-cvs-logs] scummvm master -> 3bece5f4788779b2c0af3a2bb422e05a183b6d6b

dreammaster dreammaster at scummvm.org
Mon Aug 8 14:13:13 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:
3bece5f478 TITANIC: Implemented CSeasonalMusicPlayer class


Commit: 3bece5f4788779b2c0af3a2bb422e05a183b6d6b
    https://github.com/scummvm/scummvm/commit/3bece5f4788779b2c0af3a2bb422e05a183b6d6b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-08T08:13:05-04:00

Commit Message:
TITANIC: Implemented CSeasonalMusicPlayer class

Changed paths:
    engines/titanic/core/game_object.cpp
    engines/titanic/core/game_object.h
    engines/titanic/sound/seasonal_music_player.cpp
    engines/titanic/sound/seasonal_music_player.h



diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 897eab8..ecaa415 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -38,11 +38,12 @@ namespace Titanic {
 EMPTY_MESSAGE_MAP(CGameObject, CNamedItem);
 
 CCreditText *CGameObject::_credits;
-int CGameObject::_soundHandles[3];
+int CGameObject::_soundHandles[4];
 
 void CGameObject::init() {
 	_credits = nullptr;
-	_soundHandles[0] = _soundHandles[1] = _soundHandles[2] = -1;
+	_soundHandles[0] = _soundHandles[1] = 0;
+	_soundHandles[2] = _soundHandles[3] = -1;
 }
 
 void CGameObject::deinit() {
@@ -501,7 +502,7 @@ void CGameObject::stopGlobalSound(bool transition, int handleIndex) {
 	CSound &sound = gameManager->_sound;
 
 	if (handleIndex == -1) {
-		for (int idx = 0; idx < 3; ++idx) {
+		for (int idx = 0; idx < 4; ++idx) {
 			if (_soundHandles[idx] != -1) {
 				sound.setVolume(_soundHandles[idx], 0, transition ? 1 : 0);
 				sound.setCanFree(_soundHandles[idx]);
@@ -531,7 +532,7 @@ void CGameObject::setGlobalSoundVolume(int mode, uint seconds, int handleIndex)
 		// Iterate through calling the method for each handle
 		for (int idx = 0; idx < 3; ++idx)
 			setGlobalSoundVolume(mode, seconds, idx);
-	} else if (handleIndex >= 0 && handleIndex <= 2 && _soundHandles[handleIndex] != -1) {
+	} else if (handleIndex >= 0 && handleIndex <= 3 && _soundHandles[handleIndex] != -1) {
 		uint newVolume = sound._soundManager.getModeVolume(mode);
 		sound.setVolume(_soundHandles[handleIndex], newVolume, seconds);
 	}
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index e446cc3..799cbcc 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -53,7 +53,7 @@ class CGameObject : public CNamedItem {
 	DECLARE_MESSAGE_MAP;
 private:
 	static CCreditText *_credits;
-	static int _soundHandles[3];
+	static int _soundHandles[4];
 private:
 	/**
 	 * Load a visual resource for the object
diff --git a/engines/titanic/sound/seasonal_music_player.cpp b/engines/titanic/sound/seasonal_music_player.cpp
index 8ac6eb6..3532311 100644
--- a/engines/titanic/sound/seasonal_music_player.cpp
+++ b/engines/titanic/sound/seasonal_music_player.cpp
@@ -24,43 +24,112 @@
 
 namespace Titanic {
 
+BEGIN_MESSAGE_MAP(CSeasonalMusicPlayer, CAutoMusicPlayerBase)
+	ON_MESSAGE(ChangeSeasonMsg)
+	ON_MESSAGE(ArboretumGateMsg)
+	ON_MESSAGE(ChangeMusicMsg)
+END_MESSAGE_MAP()
+
 CSeasonalMusicPlayer::CSeasonalMusicPlayer() : CAutoMusicPlayerBase() {
-	_fieldD8 = 0;
-	_fieldDC = 1;
-	_fieldE0 = 0;
-	_fieldE4 = 0;
-	_fieldE8 = -4;
-	_fieldEC = -2;
-	_fieldF0 = -4;
-	_fieldF4 = -4;
+	_isSpring = false;
+	_isSummer = true;
+	_isAutumn = false;
+	_isWinter = false;
+	_springMode = -4;
+	_summerMode = -2;
+	_autumnMode = -4;
+	_winterMode = -4;
 }
 
 void CSeasonalMusicPlayer::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
-	file->writeNumberLine(_fieldD8, indent);
-	file->writeNumberLine(_fieldDC, indent);
-	file->writeNumberLine(_fieldE0, indent);
-	file->writeNumberLine(_fieldE4, indent);
-	file->writeNumberLine(_fieldE8, indent);
-	file->writeNumberLine(_fieldEC, indent);
-	file->writeNumberLine(_fieldF0, indent);
-	file->writeNumberLine(_fieldF4, indent);
+	file->writeNumberLine(_isSpring, indent);
+	file->writeNumberLine(_isSummer, indent);
+	file->writeNumberLine(_isAutumn, indent);
+	file->writeNumberLine(_isWinter, indent);
+	file->writeNumberLine(_springMode, indent);
+	file->writeNumberLine(_summerMode, indent);
+	file->writeNumberLine(_autumnMode, indent);
+	file->writeNumberLine(_winterMode, indent);
 
 	CAutoMusicPlayerBase::save(file, indent);
 }
 
 void CSeasonalMusicPlayer::load(SimpleFile *file) {
 	file->readNumber();
-	_fieldD8 = file->readNumber();
-	_fieldDC = file->readNumber();
-	_fieldE0 = file->readNumber();
-	_fieldE4 = file->readNumber();
-	_fieldE8 = file->readNumber();
-	_fieldEC = file->readNumber();
-	_fieldF0 = file->readNumber();
-	_fieldF4 = file->readNumber();
+	_isSpring = file->readNumber();
+	_isSummer = file->readNumber();
+	_isAutumn = file->readNumber();
+	_isWinter = file->readNumber();
+	_springMode = file->readNumber();
+	_summerMode = file->readNumber();
+	_autumnMode = file->readNumber();
+	_winterMode = file->readNumber();
 
 	CAutoMusicPlayerBase::load(file);
 }
 
+bool CSeasonalMusicPlayer::ChangeSeasonMsg(CChangeSeasonMsg *msg) {
+	_isSpring = msg->_season == "spring";
+	_isSummer = msg->_season == "summer";
+	_isAutumn = msg->_season == "autumn";
+	_isWinter = msg->_season == "winter";
+
+	_springMode = _isSpring ? -2 : -4;
+	_summerMode = _isSummer ? -2 : -4;
+	_autumnMode = _isAutumn ? -2 : -4;
+	_winterMode = _isWinter ? -2 : -4;
+
+	CChangeMusicMsg changeMsg;
+	changeMsg._filename = msg->_season;
+	changeMsg.execute(this);
+
+	return true;
+}
+
+bool CSeasonalMusicPlayer::ArboretumGateMsg(CArboretumGateMsg *msg) {
+	CChangeMusicMsg changeMsg;
+	changeMsg._flags = msg->_value ? 2 : 1;
+	changeMsg.execute(this);
+
+	return true;
+}
+
+bool CSeasonalMusicPlayer::ChangeMusicMsg(CChangeMusicMsg *msg) {
+	if (_isRepeated && msg->_flags == 1) {
+		_isRepeated = false;
+		stopGlobalSound(_transition, -1);
+	}
+
+	if (!msg->_filename.empty()) {
+		if (_isSummer) {
+			setGlobalSoundVolume(-4, 2, 0);
+			setGlobalSoundVolume(-2, 2, 1);
+		} else if (_isAutumn) {
+			setGlobalSoundVolume(-4, 2, 1);
+			setGlobalSoundVolume(-2, 2, 2);
+		} else if (_isWinter) {
+			setGlobalSoundVolume(-4, 2, 2);
+			setGlobalSoundVolume(-2, 2, 3);
+		} else if (_isSpring) {
+			setGlobalSoundVolume(-4, 2, 3);
+			setGlobalSoundVolume(-2, 2, 0);
+		}
+	}
+
+	if (!_isRepeated && msg->_flags == 2) {
+		_isRepeated = true;
+		loadSound("c#64.wav");
+		loadSound("c#63.wav");
+		loadSound("c#65.wav");
+		loadSound("c#62.wav");
+		playGlobalSound("c#64.wav", _springMode, _isSpring, true, 0);
+		playGlobalSound("c#63.wav", _summerMode, _isSummer, true, 1);
+		playGlobalSound("c#65.wav", _autumnMode, _isAutumn, true, 2);
+		playGlobalSound("c#62.wav", _winterMode, _isWinter, true, 3);
+	}
+
+	return true;
+}
+
 } // End of namespace Titanic
diff --git a/engines/titanic/sound/seasonal_music_player.h b/engines/titanic/sound/seasonal_music_player.h
index 30c296d..c5259e2 100644
--- a/engines/titanic/sound/seasonal_music_player.h
+++ b/engines/titanic/sound/seasonal_music_player.h
@@ -28,15 +28,19 @@
 namespace Titanic {
 
 class CSeasonalMusicPlayer : public CAutoMusicPlayerBase {
+	DECLARE_MESSAGE_MAP;
+	bool ChangeSeasonMsg(CChangeSeasonMsg *msg);
+	bool ArboretumGateMsg(CArboretumGateMsg *msg);
+	bool ChangeMusicMsg(CChangeMusicMsg *msg);
 private:
-	int _fieldD8;
-	int _fieldDC;
-	int _fieldE0;
-	int _fieldE4;
-	int _fieldE8;
-	int _fieldEC;
-	int _fieldF0;
-	int _fieldF4;
+	bool _isSpring;
+	bool _isSummer;
+	bool _isAutumn;
+	bool _isWinter;
+	int _springMode;
+	int _summerMode;
+	int _autumnMode;
+	int _winterMode;
 public:
 	CLASSDEF;
 	CSeasonalMusicPlayer();






More information about the Scummvm-git-logs mailing list