[Scummvm-cvs-logs] scummvm master -> 0b952c3ceded860f2051c77fefb17593dfb5ff05
dreammaster
dreammaster at scummvm.org
Tue Aug 9 03:21:25 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:
0b952c3ced TITANIC: Implemented CAutoSoundPlayerADSR & CBackgroundSoundMaker
Commit: 0b952c3ceded860f2051c77fefb17593dfb5ff05
https://github.com/scummvm/scummvm/commit/0b952c3ceded860f2051c77fefb17593dfb5ff05
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-08-08T21:21:18-04:00
Commit Message:
TITANIC: Implemented CAutoSoundPlayerADSR & CBackgroundSoundMaker
Changed paths:
engines/titanic/core/game_object.cpp
engines/titanic/core/game_object.h
engines/titanic/sound/auto_sound_player_adsr.cpp
engines/titanic/sound/auto_sound_player_adsr.h
engines/titanic/sound/background_sound_maker.cpp
engines/titanic/sound/background_sound_maker.h
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index ecaa415..c7742cb 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -743,6 +743,16 @@ int CGameObject::playSound(const CString &name, CProximity &prox) {
return 0;
}
+int CGameObject::queueSound(const CString &name, uint priorHandle, uint volume, int val3, bool repeated) {
+ CProximity prox;
+ prox._fieldC = val3;
+ prox._repeated = repeated;
+ prox._channelVolume = volume;
+ prox._soundHandle = priorHandle;
+
+ return playSound(name, prox);
+}
+
void CGameObject::stopSound(int handle, uint seconds) {
if (handle != 0 && handle != -1) {
CGameManager *gameManager = getGameManager();
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 799cbcc..bcfc989 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -196,6 +196,13 @@ protected:
int playSound(const CString &name, CProximity &prox);
/**
+ * Queues a sound to play after a specified one finishes
+ * @param resName Filename of sound to play
+ * @param volume Volume level
+ */
+ int queueSound(const CString &name, uint priorHandle, uint volume = 100, int val3 = 0, bool repeated = false);
+
+ /**
* Stop a sound
* @param handle Sound handle
* @param seconds Optional number of seconds to transition sound off
diff --git a/engines/titanic/sound/auto_sound_player_adsr.cpp b/engines/titanic/sound/auto_sound_player_adsr.cpp
index 4bfd557..f9f0457 100644
--- a/engines/titanic/sound/auto_sound_player_adsr.cpp
+++ b/engines/titanic/sound/auto_sound_player_adsr.cpp
@@ -24,20 +24,56 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CAutoSoundPlayerADSR, CAutoSoundPlayer)
+ ON_MESSAGE(TurnOn)
+ ON_MESSAGE(TurnOff)
+END_MESSAGE_MAP()
+
void CAutoSoundPlayerADSR::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeQuotedLine(_string2, indent);
- file->writeQuotedLine(_string3, indent);
- file->writeQuotedLine(_string4, indent);
+ file->writeQuotedLine(_soundName1, indent);
+ file->writeQuotedLine(_soundName2, indent);
+ file->writeQuotedLine(_soundName3, indent);
CAutoSoundPlayer::save(file, indent);
}
void CAutoSoundPlayerADSR::load(SimpleFile *file) {
file->readNumber();
- _string2 = file->readString();
- _string3 = file->readString();
- _string4 = file->readString();
+ _soundName1 = file->readString();
+ _soundName2 = file->readString();
+ _soundName3 = file->readString();
CAutoSoundPlayer::load(file);
}
+bool CAutoSoundPlayerADSR::TurnOn(CTurnOn *msg) {
+ if (_soundHandle == -1) {
+ if (!_soundName1.empty()) {
+ _soundHandle = playSound(_soundName1, _volume, _fieldD0);
+
+ if (!_soundName2.empty())
+ _soundHandle = queueSound(_soundName2, _soundHandle, _volume, _fieldD0);
+
+ _soundHandle = queueSound(_filename, _soundHandle, _volume, _fieldD0);
+ _active = true;
+ }
+ }
+
+ return true;
+}
+
+bool CAutoSoundPlayerADSR::TurnOff(CTurnOff *msg) {
+ if (_soundHandle != -1) {
+ if (!_soundName3.empty())
+ queueSound(_soundName3, _soundHandle, _volume, _fieldD0);
+
+ if (isSoundActive(_soundHandle))
+ stopSound(_soundHandle);
+
+ _soundHandle = -1;
+ _active = false;
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/sound/auto_sound_player_adsr.h b/engines/titanic/sound/auto_sound_player_adsr.h
index 6dc2853..9f09636 100644
--- a/engines/titanic/sound/auto_sound_player_adsr.h
+++ b/engines/titanic/sound/auto_sound_player_adsr.h
@@ -28,10 +28,13 @@
namespace Titanic {
class CAutoSoundPlayerADSR : public CAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool TurnOn(CTurnOn *msg);
+ bool TurnOff(CTurnOff *msg);
private:
- CString _string2;
- CString _string3;
- CString _string4;
+ CString _soundName1;
+ CString _soundName2;
+ CString _soundName3;
public:
CLASSDEF;
diff --git a/engines/titanic/sound/background_sound_maker.cpp b/engines/titanic/sound/background_sound_maker.cpp
index 0abab89..58dde02 100644
--- a/engines/titanic/sound/background_sound_maker.cpp
+++ b/engines/titanic/sound/background_sound_maker.cpp
@@ -24,6 +24,10 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CBackgroundSoundMaker, CGameObject)
+ ON_MESSAGE(FrameMsg)
+END_MESSAGE_MAP()
+
void CBackgroundSoundMaker::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_value, indent);
@@ -36,4 +40,8 @@ void CBackgroundSoundMaker::load(SimpleFile *file) {
CGameObject::load(file);
}
+bool CBackgroundSoundMaker::FrameMsg(CFrameMsg *msg) {
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/sound/background_sound_maker.h b/engines/titanic/sound/background_sound_maker.h
index 022d8f4..94f3b79 100644
--- a/engines/titanic/sound/background_sound_maker.h
+++ b/engines/titanic/sound/background_sound_maker.h
@@ -28,6 +28,8 @@
namespace Titanic {
class CBackgroundSoundMaker : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool FrameMsg(CFrameMsg *msg);
public:
int _value;
public:
More information about the Scummvm-git-logs
mailing list