[Scummvm-git-logs] scummvm master -> 850dcdbdf8252b4f5dbc6812c0108d58f101534e

dreammaster dreammaster at scummvm.org
Sun Jul 16 22:18:21 CEST 2017


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:
850dcdbdf8 TITANIC: Add a VolumeMode enum


Commit: 850dcdbdf8252b4f5dbc6812c0108d58f101534e
    https://github.com/scummvm/scummvm/commit/850dcdbdf8252b4f5dbc6812c0108d58f101534e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2017-07-16T16:18:16-04:00

Commit Message:
TITANIC: Add a VolumeMode enum

Changed paths:
    engines/titanic/core/game_object.cpp
    engines/titanic/core/game_object.h
    engines/titanic/game/credits.cpp
    engines/titanic/game/end_credit_text.cpp
    engines/titanic/game/end_credits.cpp
    engines/titanic/game/end_explode_ship.cpp
    engines/titanic/game/end_sequence_control.cpp
    engines/titanic/game/phonograph.cpp
    engines/titanic/game/transport/lift.cpp
    engines/titanic/game/transport/pellerator.cpp
    engines/titanic/sound/auto_music_player_base.cpp
    engines/titanic/sound/auto_music_player_base.h
    engines/titanic/sound/seasonal_music_player.cpp
    engines/titanic/sound/seasonal_music_player.h
    engines/titanic/sound/sound_manager.cpp
    engines/titanic/sound/sound_manager.h


diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 3d9fede..c4467c1 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -441,7 +441,7 @@ bool CGameObject::isSoundActive(int handle) const {
 	return false;
 }
 
-void CGameObject::playGlobalSound(const CString &resName, int mode, bool initialMute, bool repeated,
+void CGameObject::playGlobalSound(const CString &resName, VolumeMode mode, bool initialMute, bool repeated,
 		int handleIndex, Audio::Mixer::SoundType soundType) {
 	if (handleIndex < 0 || handleIndex > 3)
 		return;
@@ -526,7 +526,7 @@ void CGameObject::stopGlobalSound(bool transition, int handleIndex) {
 	}
 }
 
-void CGameObject::setGlobalSoundVolume(int mode, uint seconds, int handleIndex) {
+void CGameObject::setGlobalSoundVolume(VolumeMode mode, uint seconds, int handleIndex) {
 	CGameManager *gameManager = getGameManager();
 	if (!gameManager)
 		return;
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 0c94662..0d2b8c9 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -27,6 +27,7 @@
 #include "common/stream.h"
 #include "titanic/core/named_item.h"
 #include "titanic/sound/proximity.h"
+#include "titanic/sound/sound_manager.h"
 #include "titanic/support/mouse_cursor.h"
 #include "titanic/support/credit_text.h"
 #include "titanic/support/movie_range_info.h"
@@ -261,7 +262,7 @@ protected:
 	 * @param handleIndex	Slot 0 to 3 in the shared sound handle list to store the sound's handle
 	 * @param soundType		Specifies whether the sound is a sound effect or music
 	 */
-	void playGlobalSound(const CString &resName, int mode, bool initialMute, bool repeated,
+	void playGlobalSound(const CString &resName, VolumeMode mode, bool initialMute, bool repeated,
 		int handleIndex, Audio::Mixer::SoundType soundType = Audio::Mixer::kMusicSoundType);
 
 	/**
@@ -277,7 +278,7 @@ protected:
 	 * @param seconds		Number of seconds to transition to new volume
 	 * @param handleIndex	Index of global sound to update. If -1, all global sounds are updated
 	 */
-	void setGlobalSoundVolume(int mode, uint seconds, int handleIndex);
+	void setGlobalSoundVolume(VolumeMode mode, uint seconds, int handleIndex);
 
 	/**
 	 * Stops sound channel 3 or 0
diff --git a/engines/titanic/game/credits.cpp b/engines/titanic/game/credits.cpp
index e13a2ce..02c2b08 100644
--- a/engines/titanic/game/credits.cpp
+++ b/engines/titanic/game/credits.cpp
@@ -62,7 +62,7 @@ bool CCredits::TimerMsg(CTimerMsg *msg) {
 	loadSound("a#24.wav");
 
 	playCutscene(0, 18);
-	playGlobalSound("a#16.wav", -1, false, false, 0);
+	playGlobalSound("a#16.wav", VOL_NORMAL, false, false, 0);
 	playCutscene(19, 642);
 	playSound("a#24.wav");
 	playCutscene(643, 750);
diff --git a/engines/titanic/game/end_credit_text.cpp b/engines/titanic/game/end_credit_text.cpp
index 4eee13d..9af1313 100644
--- a/engines/titanic/game/end_credit_text.cpp
+++ b/engines/titanic/game/end_credit_text.cpp
@@ -43,7 +43,7 @@ void CEndCreditText::load(SimpleFile *file) {
 }
 
 bool CEndCreditText::ActMsg(CActMsg *msg) {
-	playGlobalSound("z#41.wav", -1, false, false, 0);
+	playGlobalSound("z#41.wav", VOL_NORMAL, false, false, 0);
 	createCredits();
 	_flag = true;
 	return true;
@@ -63,7 +63,7 @@ bool CEndCreditText::FrameMsg(CFrameMsg *msg) {
 }
 
 bool CEndCreditText::TimerMsg(CTimerMsg *msg) {
-	setGlobalSoundVolume(-4, 2, -1);
+	setGlobalSoundVolume(VOL_MUTE, 2, -1);
 	sleep(1000);
 	quitGame();
 	return true;
diff --git a/engines/titanic/game/end_credits.cpp b/engines/titanic/game/end_credits.cpp
index f613e5a..77abfb0 100644
--- a/engines/titanic/game/end_credits.cpp
+++ b/engines/titanic/game/end_credits.cpp
@@ -48,7 +48,7 @@ bool CEndCredits::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
 		_flag = false;
 	} else {
 		loadSound("z#41.wav");
-		playGlobalSound("z#41.wav", -1, false, false, 0);
+		playGlobalSound("z#41.wav", VOL_NORMAL, false, false, 0);
 		_flag = true;
 	}
 
diff --git a/engines/titanic/game/end_explode_ship.cpp b/engines/titanic/game/end_explode_ship.cpp
index 05220b9..633e47e 100644
--- a/engines/titanic/game/end_explode_ship.cpp
+++ b/engines/titanic/game/end_explode_ship.cpp
@@ -55,7 +55,7 @@ bool CEndExplodeShip::ActMsg(CActMsg *msg) {
 	} else if (msg->_action == "TakeOff") {
 		loadSound("a#31.wav");
 		loadSound("a#14.wav");
-		playGlobalSound("a#13.wav", -1, true, true, 0);
+		playGlobalSound("a#13.wav", VOL_NORMAL, true, true, 0);
 		addTimer(1, 10212, 0);
 	}
 
@@ -71,7 +71,7 @@ bool CEndExplodeShip::TimerMsg(CTimerMsg *msg) {
 	}
 
 	if (msg->_actionVal == 3) {
-		setGlobalSoundVolume(-4, 2, -1);
+		setGlobalSoundVolume(VOL_MUTE, 2, -1);
 		CActMsg actMsg(_isExploding ? "ExplodeCredits" : "Credits");
 		actMsg.execute("EndGameCredits");
 	}
diff --git a/engines/titanic/game/end_sequence_control.cpp b/engines/titanic/game/end_sequence_control.cpp
index 55d3b21..52151f3 100644
--- a/engines/titanic/game/end_sequence_control.cpp
+++ b/engines/titanic/game/end_sequence_control.cpp
@@ -61,7 +61,7 @@ bool CEndSequenceControl::TimerMsg(CTimerMsg *msg) {
 }
 
 bool CEndSequenceControl::MovieEndMsg(CMovieEndMsg *msg) {
-	setGlobalSoundVolume(-4, 2, -1);
+	setGlobalSoundVolume(VOL_MUTE, 2, -1);
 	changeView("TheEnd.Node 3.N");
 	addTimer(2, 1000, 0);
 	return true;
@@ -71,7 +71,7 @@ bool CEndSequenceControl::EnterRoomMsg(CEnterRoomMsg *msg) {
 	petHide();
 	disableMouse();
 	addTimer(1, 1000, 0);
-	playGlobalSound("a#15.wav", -1, true, true, 0, Audio::Mixer::kSpeechSoundType);
+	playGlobalSound("a#15.wav", VOL_NORMAL, true, true, 0, Audio::Mixer::kSpeechSoundType);
 	return true;
 }
 
diff --git a/engines/titanic/game/phonograph.cpp b/engines/titanic/game/phonograph.cpp
index b86fa0b..71fd428 100644
--- a/engines/titanic/game/phonograph.cpp
+++ b/engines/titanic/game/phonograph.cpp
@@ -84,7 +84,7 @@ bool CPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) {
 		msg->_value = 1;
 	} else {
 		stopGlobalSound(false, -1);
-		playGlobalSound(cylinderMsg._name, -2, true, true, 0);
+		playGlobalSound(cylinderMsg._name, VOL_QUIET, true, true, 0);
 		_isPlaying = true;
 		msg->_value = 1;
 	}
diff --git a/engines/titanic/game/transport/lift.cpp b/engines/titanic/game/transport/lift.cpp
index 8dfc559..6d081f2 100644
--- a/engines/titanic/game/transport/lift.cpp
+++ b/engines/titanic/game/transport/lift.cpp
@@ -189,23 +189,23 @@ bool CLift::StatusChangeMsg(CStatusChangeMsg *msg) {
 bool CLift::MovieEndMsg(CMovieEndMsg *msg) {
 	switch (msg->_endFrame) {
 	case 108:
-		setGlobalSoundVolume(-4, 1, 2);
-		setGlobalSoundVolume(-2, 1, 1);
+		setGlobalSoundVolume(VOL_MUTE, 1, 2);
+		setGlobalSoundVolume(VOL_QUIET, 1, 1);
 		break;
 
 	case 190:
-		setGlobalSoundVolume(-4, 1, 1);
-		setGlobalSoundVolume(-2, 1, 2);
+		setGlobalSoundVolume(VOL_MUTE, 1, 1);
+		setGlobalSoundVolume(VOL_QUIET, 1, 2);
 		break;
 
 	case 407:
-		setGlobalSoundVolume(-4, 1, 0);
-		setGlobalSoundVolume(-2, 1, 1);
+		setGlobalSoundVolume(VOL_MUTE, 1, 0);
+		setGlobalSoundVolume(VOL_QUIET, 1, 1);
 		break;
 
 	case 489:
-		setGlobalSoundVolume(-4, 1, 1);
-		setGlobalSoundVolume(-2, 1, 0);
+		setGlobalSoundVolume(VOL_MUTE, 1, 1);
+		setGlobalSoundVolume(VOL_QUIET, 1, 0);
 		break;
 
 	default: {
@@ -251,17 +251,17 @@ bool CLift::EnterRoomMsg(CEnterRoomMsg *msg) {
 		}
 
 		if (floorNum < 20) {
-			playGlobalSound("z#520.wav", -2, true, true, 0);
-			playGlobalSound("z#519.wav", -4, false, true, 1);
-			playGlobalSound("z#518.wav", -4, false, true, 2);
+			playGlobalSound("z#520.wav", VOL_QUIET, true, true, 0);
+			playGlobalSound("z#519.wav", VOL_MUTE, false, true, 1);
+			playGlobalSound("z#518.wav", VOL_MUTE, false, true, 2);
 		} else if (floorNum < 28) {
-			playGlobalSound("z#520.wav", -4, false, true, 0);
-			playGlobalSound("z#519.wav", -2, true, true, 1);
-			playGlobalSound("z#518.wav", -4, false, true, 2);
+			playGlobalSound("z#520.wav", VOL_MUTE, false, true, 0);
+			playGlobalSound("z#519.wav", VOL_QUIET, true, true, 1);
+			playGlobalSound("z#518.wav", VOL_MUTE, false, true, 2);
 		} else {
-			playGlobalSound("z#520.wav", -4, false, true, 0);
-			playGlobalSound("z#519.wav", -4, false, true, 1);
-			playGlobalSound("z#518.wav", -2, true, true, 2);
+			playGlobalSound("z#520.wav", VOL_MUTE, false, true, 0);
+			playGlobalSound("z#519.wav", VOL_MUTE, false, true, 1);
+			playGlobalSound("z#518.wav", VOL_QUIET, true, true, 2);
 		}
 	}
 
diff --git a/engines/titanic/game/transport/pellerator.cpp b/engines/titanic/game/transport/pellerator.cpp
index 0228f9b..7771314 100644
--- a/engines/titanic/game/transport/pellerator.cpp
+++ b/engines/titanic/game/transport/pellerator.cpp
@@ -62,7 +62,7 @@ void CPellerator::load(SimpleFile *file) {
 
 bool CPellerator::StatusChangeMsg(CStatusChangeMsg *msg) {
 	setVisible(true);
-	playGlobalSound("z#74.wav", -2, true, true, 0);
+	playGlobalSound("z#74.wav", VOL_QUIET, true, true, 0);
 	int classNum = getPassengerClass();
 	int newDest = msg->_newStatus;
 
diff --git a/engines/titanic/sound/auto_music_player_base.cpp b/engines/titanic/sound/auto_music_player_base.cpp
index b000d8f..31522d8 100644
--- a/engines/titanic/sound/auto_music_player_base.cpp
+++ b/engines/titanic/sound/auto_music_player_base.cpp
@@ -32,7 +32,7 @@ BEGIN_MESSAGE_MAP(CAutoMusicPlayerBase, CGameObject)
 END_MESSAGE_MAP()
 
 CAutoMusicPlayerBase::CAutoMusicPlayerBase() : CGameObject(),
-	_initialMute(true), _isRepeated(false), _volumeMode(-1), _transition(1) {
+	_initialMute(true), _isRepeated(false), _volumeMode(VOL_NORMAL), _transition(1) {
 }
 void CAutoMusicPlayerBase::save(SimpleFile *file, int indent) {
 	file->writeNumberLine(1, indent);
@@ -50,7 +50,7 @@ void CAutoMusicPlayerBase::load(SimpleFile *file) {
 	_filename = file->readString();
 	_initialMute = file->readNumber();
 	_isRepeated = file->readNumber();
-	_volumeMode = file->readNumber();
+	_volumeMode = (VolumeMode)file->readNumber();
 	_transition = file->readNumber();
 
 	CGameObject::load(file);
diff --git a/engines/titanic/sound/auto_music_player_base.h b/engines/titanic/sound/auto_music_player_base.h
index 0623258..4dd0665 100644
--- a/engines/titanic/sound/auto_music_player_base.h
+++ b/engines/titanic/sound/auto_music_player_base.h
@@ -37,7 +37,7 @@ protected:
 	CString _filename;
 	bool _initialMute;
 	bool _isRepeated;
-	int _volumeMode;
+	VolumeMode _volumeMode;
 	int _transition;
 public:
 	CLASSDEF;
diff --git a/engines/titanic/sound/seasonal_music_player.cpp b/engines/titanic/sound/seasonal_music_player.cpp
index 3532311..40bf709 100644
--- a/engines/titanic/sound/seasonal_music_player.cpp
+++ b/engines/titanic/sound/seasonal_music_player.cpp
@@ -35,10 +35,10 @@ CSeasonalMusicPlayer::CSeasonalMusicPlayer() : CAutoMusicPlayerBase() {
 	_isSummer = true;
 	_isAutumn = false;
 	_isWinter = false;
-	_springMode = -4;
-	_summerMode = -2;
-	_autumnMode = -4;
-	_winterMode = -4;
+	_springMode = VOL_MUTE;
+	_summerMode = VOL_QUIET;
+	_autumnMode = VOL_MUTE;
+	_winterMode = VOL_MUTE;
 }
 
 void CSeasonalMusicPlayer::save(SimpleFile *file, int indent) {
@@ -61,10 +61,10 @@ void CSeasonalMusicPlayer::load(SimpleFile *file) {
 	_isSummer = file->readNumber();
 	_isAutumn = file->readNumber();
 	_isWinter = file->readNumber();
-	_springMode = file->readNumber();
-	_summerMode = file->readNumber();
-	_autumnMode = file->readNumber();
-	_winterMode = file->readNumber();
+	_springMode = (VolumeMode)file->readNumber();
+	_summerMode = (VolumeMode)file->readNumber();
+	_autumnMode = (VolumeMode)file->readNumber();
+	_winterMode = (VolumeMode)file->readNumber();
 
 	CAutoMusicPlayerBase::load(file);
 }
@@ -75,10 +75,10 @@ bool CSeasonalMusicPlayer::ChangeSeasonMsg(CChangeSeasonMsg *msg) {
 	_isAutumn = msg->_season == "autumn";
 	_isWinter = msg->_season == "winter";
 
-	_springMode = _isSpring ? -2 : -4;
-	_summerMode = _isSummer ? -2 : -4;
-	_autumnMode = _isAutumn ? -2 : -4;
-	_winterMode = _isWinter ? -2 : -4;
+	_springMode = _isSpring ? VOL_QUIET : VOL_MUTE;
+	_summerMode = _isSummer ? VOL_QUIET : VOL_MUTE;
+	_autumnMode = _isAutumn ? VOL_QUIET : VOL_MUTE;
+	_winterMode = _isWinter ? VOL_QUIET : VOL_MUTE;
 
 	CChangeMusicMsg changeMsg;
 	changeMsg._filename = msg->_season;
@@ -103,17 +103,17 @@ bool CSeasonalMusicPlayer::ChangeMusicMsg(CChangeMusicMsg *msg) {
 
 	if (!msg->_filename.empty()) {
 		if (_isSummer) {
-			setGlobalSoundVolume(-4, 2, 0);
-			setGlobalSoundVolume(-2, 2, 1);
+			setGlobalSoundVolume(VOL_MUTE, 2, 0);
+			setGlobalSoundVolume(VOL_QUIET, 2, 1);
 		} else if (_isAutumn) {
-			setGlobalSoundVolume(-4, 2, 1);
-			setGlobalSoundVolume(-2, 2, 2);
+			setGlobalSoundVolume(VOL_MUTE, 2, 1);
+			setGlobalSoundVolume(VOL_QUIET, 2, 2);
 		} else if (_isWinter) {
-			setGlobalSoundVolume(-4, 2, 2);
-			setGlobalSoundVolume(-2, 2, 3);
+			setGlobalSoundVolume(VOL_MUTE, 2, 2);
+			setGlobalSoundVolume(VOL_QUIET, 2, 3);
 		} else if (_isSpring) {
-			setGlobalSoundVolume(-4, 2, 3);
-			setGlobalSoundVolume(-2, 2, 0);
+			setGlobalSoundVolume(VOL_MUTE, 2, 3);
+			setGlobalSoundVolume(VOL_QUIET, 2, 0);
 		}
 	}
 
diff --git a/engines/titanic/sound/seasonal_music_player.h b/engines/titanic/sound/seasonal_music_player.h
index d6a79d7..ef15c47 100644
--- a/engines/titanic/sound/seasonal_music_player.h
+++ b/engines/titanic/sound/seasonal_music_player.h
@@ -37,10 +37,10 @@ private:
 	bool _isSummer;
 	bool _isAutumn;
 	bool _isWinter;
-	int _springMode;
-	int _summerMode;
-	int _autumnMode;
-	int _winterMode;
+	VolumeMode _springMode;
+	VolumeMode _summerMode;
+	VolumeMode _autumnMode;
+	VolumeMode _winterMode;
 public:
 	CLASSDEF;
 	CSeasonalMusicPlayer();
diff --git a/engines/titanic/sound/sound_manager.cpp b/engines/titanic/sound/sound_manager.cpp
index 09ba1ae..df9183b 100644
--- a/engines/titanic/sound/sound_manager.cpp
+++ b/engines/titanic/sound/sound_manager.cpp
@@ -33,13 +33,13 @@ CSoundManager::CSoundManager() : _musicPercent(75.0), _speechPercent(75.0),
 	_masterPercent(75.0), _parrotPercent(75.0), _handleCtr(1) {
 }
 
-uint CSoundManager::getModeVolume(int mode) {
+uint CSoundManager::getModeVolume(VolumeMode mode) {
 	switch (mode) {
-	case -1:
+	case VOL_NORMAL:
 		return (uint)_masterPercent;
-	case -2:
+	case VOL_QUIET:
 		return (uint)(_masterPercent * 30 / 100);
-	case -3:
+	case VOL_VERY_QUIET:
 		return (uint)(_masterPercent * 15 / 100);
 	default:
 		return 0;
diff --git a/engines/titanic/sound/sound_manager.h b/engines/titanic/sound/sound_manager.h
index 3c21732..59a514c 100644
--- a/engines/titanic/sound/sound_manager.h
+++ b/engines/titanic/sound/sound_manager.h
@@ -33,6 +33,10 @@
 
 namespace Titanic {
 
+enum VolumeMode {
+	VOL_NORMAL = -1, VOL_QUIET = -2, VOL_VERY_QUIET = -3, VOL_MUTE = -4
+};
+
 /**
  * Abstract interface class for a sound manager
  */
@@ -222,7 +226,7 @@ public:
 	/**
 	 * Gets the volume for a given mode? value
 	 */
-	uint getModeVolume(int mode);
+	uint getModeVolume(VolumeMode mode);
 };
 
 class QSoundManagerSound : public ListItem {





More information about the Scummvm-git-logs mailing list