diff options
Diffstat (limited to 'engines/titanic/game')
-rw-r--r-- | engines/titanic/game/fan_decrease.cpp | 11 | ||||
-rw-r--r-- | engines/titanic/game/fan_decrease.h | 2 | ||||
-rw-r--r-- | engines/titanic/game/fan_increase.cpp | 11 | ||||
-rw-r--r-- | engines/titanic/game/fan_increase.h | 2 | ||||
-rw-r--r-- | engines/titanic/game/fan_noises.cpp | 179 | ||||
-rw-r--r-- | engines/titanic/game/fan_noises.h | 19 |
6 files changed, 199 insertions, 25 deletions
diff --git a/engines/titanic/game/fan_decrease.cpp b/engines/titanic/game/fan_decrease.cpp index 2049b1ebc9..b0b9cc585f 100644 --- a/engines/titanic/game/fan_decrease.cpp +++ b/engines/titanic/game/fan_decrease.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CFanDecrease, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CFanDecrease::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +38,11 @@ void CFanDecrease::load(SimpleFile *file) { CGameObject::load(file); } +bool CFanDecrease::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CStatusChangeMsg statusMsg; + statusMsg._newStatus = 2; + statusMsg.execute("FanController"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/fan_decrease.h b/engines/titanic/game/fan_decrease.h index 765c7d1560..2e90d09a3f 100644 --- a/engines/titanic/game/fan_decrease.h +++ b/engines/titanic/game/fan_decrease.h @@ -28,6 +28,8 @@ namespace Titanic { class CFanDecrease : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/fan_increase.cpp b/engines/titanic/game/fan_increase.cpp index aa23dd9275..abd2e019d3 100644 --- a/engines/titanic/game/fan_increase.cpp +++ b/engines/titanic/game/fan_increase.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CFanIncrease, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CFanIncrease::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +38,11 @@ void CFanIncrease::load(SimpleFile *file) { CGameObject::load(file); } +bool CFanIncrease::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CStatusChangeMsg statusMsg; + statusMsg._newStatus = 1; + statusMsg.execute("FanController"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/fan_increase.h b/engines/titanic/game/fan_increase.h index 08ec1322cd..7ed74e1847 100644 --- a/engines/titanic/game/fan_increase.h +++ b/engines/titanic/game/fan_increase.h @@ -28,6 +28,8 @@ namespace Titanic { class CFanIncrease : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/fan_noises.cpp b/engines/titanic/game/fan_noises.cpp index 14177ab64e..c6e6d203dd 100644 --- a/engines/titanic/game/fan_noises.cpp +++ b/engines/titanic/game/fan_noises.cpp @@ -21,42 +21,185 @@ */ #include "titanic/game/fan_noises.h" +#include "titanic/core/room_item.h" namespace Titanic { -CFanNoises::CFanNoises() : CGameObject(), _fieldBC(-1), - _fieldC0(0), _fieldC4(70), _fieldC8(-1), _fieldCC(0), - _fieldD0(0), _fieldD4(-1) { +BEGIN_MESSAGE_MAP(CFanNoises, CGameObject) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(LeaveRoomMsg) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(SetVolumeMsg) + ON_MESSAGE(LoadSuccessMsg) +END_MESSAGE_MAP() + +CFanNoises::CFanNoises() : CGameObject(), _state(-1), + _soundHandle(0), _soundPercent(70), _soundV3(-1), _soundSeconds(0), + _stopSeconds(0), _startFlag(true) { } void CFanNoises::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); - file->writeNumberLine(_fieldC0, indent); - file->writeNumberLine(_fieldC4, indent); - file->writeNumberLine(_fieldC8, indent); - file->writeNumberLine(_fieldCC, indent); - file->writeNumberLine(_fieldD0, indent); - file->writeNumberLine(_fieldD4, indent); + file->writeNumberLine(_state, indent); + file->writeNumberLine(_soundHandle, indent); + file->writeNumberLine(_soundPercent, indent); + file->writeNumberLine(_soundV3, indent); + file->writeNumberLine(_soundSeconds, indent); + file->writeNumberLine(_stopSeconds, indent); + file->writeNumberLine(_startFlag, indent); CGameObject::save(file, indent); } void CFanNoises::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); - _fieldC0 = file->readNumber(); - _fieldC4 = file->readNumber(); - _fieldC8 = file->readNumber(); - _fieldCC = file->readNumber(); - _fieldD0 = file->readNumber(); - _fieldD4 = file->readNumber(); + _state = file->readNumber(); + _soundHandle = file->readNumber(); + _soundPercent = file->readNumber(); + _soundV3 = file->readNumber(); + _soundSeconds = file->readNumber(); + _stopSeconds = file->readNumber(); + _startFlag = file->readNumber(); CGameObject::load(file); } bool CFanNoises::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CFanNoises::handleEvent"); + if (getParent() == msg->_newRoom) { + if (_soundHandle != -1) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, _stopSeconds); + _soundHandle = -1; + _startFlag = false; + } + + switch (_state) { + case 1: + _soundHandle = playSound("b#60.wav", 0, _soundV3, true); + setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); + _startFlag = true; + break; + case 2: + _soundHandle = playSound("b#58.wav", 0, _soundV3, true); + setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); + _startFlag = true; + break; + default: + break; + } + } + + return true; +} + +bool CFanNoises::LeaveRoomMsg(CLeaveRoomMsg *msg) { + if (getParent() == msg->_oldRoom && _soundHandle != -1) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, _stopSeconds); + + _soundHandle = -1; + _startFlag = false; + } + + return true; +} + +bool CFanNoises::StatusChangeMsg(CStatusChangeMsg *msg) { + if (msg->_newStatus >= -1 && msg->_newStatus <= 2) { + int oldState = _state; + _state = msg->_newStatus; + + switch (msg->_newStatus) { + case -1: + case 0: + if (_soundHandle != -1) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, 1); + _soundHandle = -1; + _startFlag = false; + } + + switch (oldState) { + case 1: + case 2: + playSound("b#59.wav", _soundPercent, _soundV3); + break; + default: + break; + } + break; + + case 1: + if (_soundHandle != -1) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, 1); + _soundHandle = -1; + _startFlag = false; + } + + switch (oldState) { + case 1: + case 2: + _soundHandle = playSound("b#60.wav", _soundPercent, _soundV3); + break; + default: + break; + } + break; + + case 2: + if (_soundHandle != -1) { + if (isSoundActive(_soundHandle)) + stopSound(_soundHandle, 1); + _soundHandle = -1; + _startFlag = false; + } + + if (oldState == 1) { + _soundHandle = playSound("b#58.wav", _soundPercent, _soundV3); + } + break; + + default: + break; + } + } + + return true; +} + +bool CFanNoises::SetVolumeMsg(CSetVolumeMsg *msg) { + _soundPercent = msg->_volume; + + if (_soundHandle != -1 && isSoundActive(_soundHandle)) + setSoundVolume(_soundHandle, _soundPercent, msg->_secondsTransition); + + return true; +} + +bool CFanNoises::LoadSuccessMsg(CLoadSuccessMsg *msg) { + if (_startFlag) { + _startFlag = false; + _soundHandle = -1; + + switch (_state) { + case 1: + playSound("b#60.wav", 0, _soundV3, true); + setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); + _startFlag = true; + break; + + case 2: + playSound("b#58.wav", 0, _soundV3, true); + setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); + _startFlag = true; + break; + + default: + break; + } + } + return true; } diff --git a/engines/titanic/game/fan_noises.h b/engines/titanic/game/fan_noises.h index bb2c35989d..56c80c0764 100644 --- a/engines/titanic/game/fan_noises.h +++ b/engines/titanic/game/fan_noises.h @@ -29,15 +29,20 @@ namespace Titanic { class CFanNoises : public CGameObject { + DECLARE_MESSAGE_MAP; bool EnterRoomMsg(CEnterRoomMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool SetVolumeMsg(CSetVolumeMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); private: - int _fieldBC; - int _fieldC0; - int _fieldC4; - int _fieldC8; - int _fieldCC; - int _fieldD0; - int _fieldD4; + int _state; + int _soundHandle; + int _soundPercent; + int _soundV3; + int _soundSeconds; + int _stopSeconds; + bool _startFlag; public: CLASSDEF; CFanNoises(); |