aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-10 12:54:17 -0400
committerPaul Gilbert2016-08-10 12:54:17 -0400
commit223aaaa185489fb39c3e163840efd7d2160c24aa (patch)
treedfc4d37ca0c46ba2662d8f44c2c95e460fb9bc89 /engines/titanic
parent708bf81589dece72f1ee506fd719ba798febf10b (diff)
downloadscummvm-rg350-223aaaa185489fb39c3e163840efd7d2160c24aa.tar.gz
scummvm-rg350-223aaaa185489fb39c3e163840efd7d2160c24aa.tar.bz2
scummvm-rg350-223aaaa185489fb39c3e163840efd7d2160c24aa.zip
TITANIC: Implemented CGondolierSong class
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/sound/gondolier_song.cpp59
-rw-r--r--engines/titanic/sound/gondolier_song.h8
2 files changed, 64 insertions, 3 deletions
diff --git a/engines/titanic/sound/gondolier_song.cpp b/engines/titanic/sound/gondolier_song.cpp
index b44400b2db..5c96718723 100644
--- a/engines/titanic/sound/gondolier_song.cpp
+++ b/engines/titanic/sound/gondolier_song.cpp
@@ -24,16 +24,71 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CGondolierSong, CRoomAutoSoundPlayer)
+ ON_MESSAGE(TurnOn)
+ ON_MESSAGE(SignalObject)
+ ON_MESSAGE(SetVolumeMsg)
+ ON_MESSAGE(StatusChangeMsg)
+END_MESSAGE_MAP()
+
void CGondolierSong::save(SimpleFile *file, int indent) {
- file->writeNumberLine(1, indent);
+ file->writeNumberLine(_enabled, indent);
file->writeNumberLine(_value, indent);
CRoomAutoSoundPlayer::save(file, indent);
}
void CGondolierSong::load(SimpleFile *file) {
- file->readNumber();
+ _enabled = file->readNumber();
_value = file->readNumber();
CRoomAutoSoundPlayer::load(file);
}
+bool CGondolierSong::TurnOn(CTurnOn *msg) {
+ if (_enabled) {
+ if (_soundHandle != -1) {
+ int volume = _value * _volume / 100;
+
+ if (_startSeconds == -1) {
+ _soundHandle = playSound(_filename, volume, _fieldD0, _repeated);
+ } else {
+ _soundHandle = playSound(_filename, 0, _fieldD0, _repeated);
+ setSoundVolume(_soundHandle, _volume, _startSeconds);
+ }
+
+ _active = true;
+ }
+ }
+
+ return true;
+}
+
+bool CGondolierSong::SignalObject(CSignalObject *msg) {
+ _enabled = false;
+ CAutoSoundPlayer::SignalObject(msg);
+ return true;
+}
+
+bool CGondolierSong::SetVolumeMsg(CSetVolumeMsg *msg) {
+ if (_enabled) {
+ _volume = msg->_volume;
+
+ if (_soundHandle != -1 && isSoundActive(_soundHandle)) {
+ int newVolume = _value * _volume / 100;
+ setSoundVolume(_soundHandle, newVolume, msg->_secondsTransition);
+ }
+ }
+
+ return true;
+}
+
+bool CGondolierSong::StatusChangeMsg(CStatusChangeMsg *msg) {
+ if (_enabled) {
+ _value = CLIP(msg->_newStatus, 0, 100);
+ CSetVolumeMsg volumeMsg(_volume, _stopSeconds);
+ volumeMsg.execute(this);
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/sound/gondolier_song.h b/engines/titanic/sound/gondolier_song.h
index 0a7120c0fc..d586711de9 100644
--- a/engines/titanic/sound/gondolier_song.h
+++ b/engines/titanic/sound/gondolier_song.h
@@ -28,11 +28,17 @@
namespace Titanic {
class CGondolierSong : public CRoomAutoSoundPlayer {
+ DECLARE_MESSAGE_MAP;
+ bool TurnOn(CTurnOn *msg);
+ bool SignalObject(CSignalObject *msg);
+ bool SetVolumeMsg(CSetVolumeMsg *msg);
+ bool StatusChangeMsg(CStatusChangeMsg *msg);
public:
+ bool _enabled;
int _value;
public:
CLASSDEF;
- CGondolierSong() : CRoomAutoSoundPlayer(), _value(0) {}
+ CGondolierSong() : CRoomAutoSoundPlayer(), _enabled(true), _value(0) {}
/**
* Save the data for the class to file