diff options
Diffstat (limited to 'engines/titanic/game')
162 files changed, 3753 insertions, 530 deletions
diff --git a/engines/titanic/game/arboretum_gate.cpp b/engines/titanic/game/arboretum_gate.cpp index 4c3ca03b7a..1435e3e204 100644 --- a/engines/titanic/game/arboretum_gate.cpp +++ b/engines/titanic/game/arboretum_gate.cpp @@ -21,7 +21,6 @@ */ #include "titanic/game/arboretum_gate.h" -#include "titanic/game/seasonal_adjustment.h" namespace Titanic { @@ -45,30 +44,30 @@ CArboretumGate::CArboretumGate() : CBackground() { _viewName2 = "NULL"; _seasonNum = 0; _fieldF0 = 0; - _winterOffStartFrame = 244; - _winterOffEndFrame = 304; - _springOffStartFrame = 122; - _springOffEndFrame = 182; - _summerOffStartFrame1 = 183; - _summerOffEndFrame1 = 243; - _summerOffStartFrame2 = 665; - _summerOffEndFrame2 = 724; - _autumnOffStartFrame1 = 61; - _autumnOffEndFrame1 = 121; - _autumnOffStartFrame2 = 0; - _autumnOffEndFrame2 = 60; - _winterOnStartFrame = 485; - _winterOnEndFrame = 544; - _springOnStartFrame = 425; - _springOnEndFrame = 484; - _summerOnStartFrame1 = 545; - _summerOnEndFrame1 = 604; - _summerOnStartFrame2 = 605; - _summerOnEndFrame2 = 664; - _autumnOnStartFrame1 = 305; - _autumnOnEndFrame1 = 364; - _autumnOnStartFrame2 = 365; - _autumnOnEndFrame2 = 424; + _startFrameSpringOff = 244; + _endFrameSpringOff = 304; + _startFrameSummerOff = 122; + _endFrameSummerOff = 182; + _startFrameAutumnOff1 = 183; + _endFrameAutumnOff1 = 243; + _startFrameAutumnOff2 = 665; + _endFrameAutumnOff2 = 724; + _startFrameWinterOff1 = 61; + _endFrameWinterOff1 = 121; + _startFrameWinterOff2 = 0; + _endFrameWinterOff2 = 60; + _startFrameSpringOn = 485; + _endFrameSpringOn = 544; + _startFrameSummerOn = 425; + _endFrameSummerOn = 484; + _startFrameAutumnOn1 = 545; + _endFrameAutumnOn1 = 604; + _startFrameAutumnOn2 = 605; + _endFrameAutumnOn2 = 664; + _startFrameWinterOn1 = 305; + _endFrameWinterOn1 = 364; + _startFrameWinterOn2 = 365; + _endFrameWinterOn2 = 424; } void CArboretumGate::save(SimpleFile *file, int indent) { @@ -79,30 +78,30 @@ void CArboretumGate::save(SimpleFile *file, int indent) { file->writeNumberLine(_v3, indent); file->writeQuotedLine(_viewName1, indent); file->writeNumberLine(_fieldF0, indent); - file->writeNumberLine(_winterOffStartFrame, indent); - file->writeNumberLine(_winterOffEndFrame, indent); - file->writeNumberLine(_springOffStartFrame, indent); - file->writeNumberLine(_springOffEndFrame, indent); - file->writeNumberLine(_summerOffStartFrame1, indent); - file->writeNumberLine(_summerOffEndFrame1, indent); - file->writeNumberLine(_summerOffStartFrame2, indent); - file->writeNumberLine(_summerOffEndFrame2, indent); - file->writeNumberLine(_autumnOffStartFrame1, indent); - file->writeNumberLine(_autumnOffEndFrame1, indent); - file->writeNumberLine(_autumnOffStartFrame2, indent); - file->writeNumberLine(_autumnOffEndFrame2, indent); - file->writeNumberLine(_winterOnStartFrame, indent); - file->writeNumberLine(_winterOnEndFrame, indent); - file->writeNumberLine(_springOnStartFrame, indent); - file->writeNumberLine(_springOnEndFrame, indent); - file->writeNumberLine(_summerOnStartFrame1, indent); - file->writeNumberLine(_summerOnEndFrame1, indent); - file->writeNumberLine(_summerOnStartFrame2, indent); - file->writeNumberLine(_summerOnEndFrame2, indent); - file->writeNumberLine(_autumnOnStartFrame1, indent); - file->writeNumberLine(_autumnOnEndFrame1, indent); - file->writeNumberLine(_autumnOnStartFrame2, indent); - file->writeNumberLine(_autumnOnEndFrame2, indent); + file->writeNumberLine(_startFrameSpringOff, indent); + file->writeNumberLine(_endFrameSpringOff, indent); + file->writeNumberLine(_startFrameSummerOff, indent); + file->writeNumberLine(_endFrameSummerOff, indent); + file->writeNumberLine(_startFrameAutumnOff1, indent); + file->writeNumberLine(_endFrameAutumnOff1, indent); + file->writeNumberLine(_startFrameAutumnOff2, indent); + file->writeNumberLine(_endFrameAutumnOff2, indent); + file->writeNumberLine(_startFrameWinterOff1, indent); + file->writeNumberLine(_endFrameWinterOff1, indent); + file->writeNumberLine(_startFrameWinterOff2, indent); + file->writeNumberLine(_endFrameWinterOff2, indent); + file->writeNumberLine(_startFrameSpringOn, indent); + file->writeNumberLine(_endFrameSpringOn, indent); + file->writeNumberLine(_startFrameSummerOn, indent); + file->writeNumberLine(_endFrameSummerOn, indent); + file->writeNumberLine(_startFrameAutumnOn1, indent); + file->writeNumberLine(_endFrameAutumnOn1, indent); + file->writeNumberLine(_startFrameAutumnOn2, indent); + file->writeNumberLine(_endFrameAutumnOn2, indent); + file->writeNumberLine(_startFrameWinterOn1, indent); + file->writeNumberLine(_endFrameWinterOn1, indent); + file->writeNumberLine(_startFrameWinterOn2, indent); + file->writeNumberLine(_endFrameWinterOn2, indent); file->writeQuotedLine(_viewName2, indent); CBackground::save(file, indent); @@ -116,30 +115,30 @@ void CArboretumGate::load(SimpleFile *file) { _v3 = file->readNumber(); _viewName1 = file->readString(); _fieldF0 = file->readNumber(); - _winterOffStartFrame = file->readNumber(); - _winterOffEndFrame = file->readNumber(); - _springOffStartFrame = file->readNumber(); - _springOffEndFrame = file->readNumber(); - _summerOffStartFrame1 = file->readNumber(); - _summerOffEndFrame1 = file->readNumber(); - _summerOffStartFrame2 = file->readNumber(); - _summerOffEndFrame2 = file->readNumber(); - _autumnOffStartFrame1 = file->readNumber(); - _autumnOffEndFrame1 = file->readNumber(); - _autumnOffStartFrame2 = file->readNumber(); - _autumnOffEndFrame2 = file->readNumber(); - _winterOnStartFrame = file->readNumber(); - _winterOnEndFrame = file->readNumber(); - _springOnStartFrame = file->readNumber(); - _springOnEndFrame = file->readNumber(); - _summerOnStartFrame1 = file->readNumber(); - _summerOnEndFrame1 = file->readNumber(); - _summerOnStartFrame2 = file->readNumber(); - _summerOnEndFrame2 = file->readNumber(); - _autumnOnStartFrame1 = file->readNumber(); - _autumnOnEndFrame1 = file->readNumber(); - _autumnOnStartFrame2 = file->readNumber(); - _autumnOnEndFrame2 = file->readNumber(); + _startFrameSpringOff = file->readNumber(); + _endFrameSpringOff = file->readNumber(); + _startFrameSummerOff = file->readNumber(); + _endFrameSummerOff = file->readNumber(); + _startFrameAutumnOff1 = file->readNumber(); + _endFrameAutumnOff1 = file->readNumber(); + _startFrameAutumnOff2 = file->readNumber(); + _endFrameAutumnOff2 = file->readNumber(); + _startFrameWinterOff1 = file->readNumber(); + _endFrameWinterOff1 = file->readNumber(); + _startFrameWinterOff2 = file->readNumber(); + _endFrameWinterOff2 = file->readNumber(); + _startFrameSpringOn = file->readNumber(); + _endFrameSpringOn = file->readNumber(); + _startFrameSummerOn = file->readNumber(); + _endFrameSummerOn = file->readNumber(); + _startFrameAutumnOn1 = file->readNumber(); + _endFrameAutumnOn1 = file->readNumber(); + _startFrameAutumnOn2 = file->readNumber(); + _endFrameAutumnOn2 = file->readNumber(); + _startFrameWinterOn1 = file->readNumber(); + _endFrameWinterOn1 = file->readNumber(); + _startFrameWinterOn2 = file->readNumber(); + _endFrameWinterOn2 = file->readNumber(); _viewName2 = file->readString(); CBackground::load(file); @@ -213,28 +212,28 @@ bool CArboretumGate::LeaveViewMsg(CLeaveViewMsg *msg) { bool CArboretumGate::TurnOff(CTurnOff *msg) { if (!_v3) { switch (_seasonNum) { - case SPRING: - playMovie(_springOffStartFrame, _springOffEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + case SEASON_SUMMER: + playMovie(_startFrameSummerOff, _endFrameSummerOff, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); break; - case SUMMER: + case SEASON_AUTUMN: if (_v1) { - playMovie(_summerOffStartFrame2, _summerOffEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOff2, _endFrameAutumnOff2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_summerOffStartFrame1, _summerOffEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOff1, _endFrameAutumnOff1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } break; - case AUTUMN: + case SEASON_WINTER: if (_v1) { - playMovie(_autumnOffStartFrame2, _autumnOffEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOff2, _endFrameWinterOff2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_autumnOffStartFrame1, _autumnOffEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOff1, _endFrameWinterOff1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } break; - case WINTER: - playMovie(_winterOffStartFrame, _winterOffEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + case SEASON_SPRING: + playMovie(_startFrameSpringOff, _endFrameSpringOff, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); break; default: @@ -256,28 +255,28 @@ bool CArboretumGate::TurnOn(CTurnOn *msg) { setVisible(true); switch (_seasonNum) { - case SPRING: - playMovie(_springOnStartFrame, _springOnEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + case SEASON_SUMMER: + playMovie(_startFrameSummerOn, _endFrameSummerOn, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); break; - case SUMMER: + case SEASON_AUTUMN: if (_v1) { - playMovie(_summerOnStartFrame2, _summerOnEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOn2, _endFrameAutumnOn2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_summerOnStartFrame1, _summerOnEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameAutumnOn1, _endFrameAutumnOn1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } break; - case AUTUMN: + case SEASON_WINTER: if (_v1) { - playMovie(_autumnOnStartFrame2, _autumnOnEndFrame2, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOn2, _endFrameWinterOn2, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } else { - playMovie(_autumnOnStartFrame1, _autumnOnEndFrame1, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + playMovie(_startFrameWinterOn1, _endFrameWinterOn1, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); } break; - case WINTER: - playMovie(_winterOnStartFrame, _winterOnEndFrame, MOVIE_GAMESTATE || MOVIE_NOTIFY_OBJECT); + case SEASON_SPRING: + playMovie(_startFrameSpringOn, _endFrameSpringOn, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); break; default: @@ -302,20 +301,20 @@ bool CArboretumGate::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { bool CArboretumGate::EnterViewMsg(CEnterViewMsg *msg) { if (!_v3) { switch (_seasonNum) { - case SPRING: - _initialFrame = _springOffStartFrame; + case SEASON_SUMMER: + _initialFrame = _startFrameSummerOff; break; - case SUMMER: - _initialFrame = _v1 ? _summerOffStartFrame2 : _summerOffStartFrame1; + case SEASON_AUTUMN: + _initialFrame = _v1 ? _startFrameAutumnOff2 : _startFrameAutumnOff1; break; - case AUTUMN: - _initialFrame = _v1 ? _autumnOffStartFrame1 : _autumnOffStartFrame2; + case SEASON_WINTER: + _initialFrame = _v1 ? _startFrameWinterOff1 : _startFrameWinterOff2; break; - case WINTER: - _initialFrame = _winterOffStartFrame; + case SEASON_SPRING: + _initialFrame = _startFrameSpringOff; break; default: diff --git a/engines/titanic/game/arboretum_gate.h b/engines/titanic/game/arboretum_gate.h index 62c9200a64..b1c06cf773 100644 --- a/engines/titanic/game/arboretum_gate.h +++ b/engines/titanic/game/arboretum_gate.h @@ -47,30 +47,30 @@ private: int _seasonNum; CString _viewName1; int _fieldF0; - int _winterOffStartFrame; - int _winterOffEndFrame; - int _springOffStartFrame; - int _springOffEndFrame; - int _summerOffStartFrame2; - int _summerOffEndFrame2; - int _summerOffStartFrame1; - int _summerOffEndFrame1; - int _autumnOffStartFrame2; - int _autumnOffEndFrame2; - int _autumnOffStartFrame1; - int _autumnOffEndFrame1; - int _winterOnStartFrame; - int _winterOnEndFrame; - int _springOnStartFrame; - int _springOnEndFrame; - int _summerOnStartFrame1; - int _summerOnEndFrame1; - int _summerOnStartFrame2; - int _summerOnEndFrame2; - int _autumnOnStartFrame1; - int _autumnOnEndFrame1; - int _autumnOnStartFrame2; - int _autumnOnEndFrame2; + int _startFrameSpringOff; + int _endFrameSpringOff; + int _startFrameSummerOff; + int _endFrameSummerOff; + int _startFrameAutumnOff2; + int _endFrameAutumnOff2; + int _startFrameAutumnOff1; + int _endFrameAutumnOff1; + int _startFrameWinterOff2; + int _endFrameWinterOff2; + int _startFrameWinterOff1; + int _endFrameWinterOff1; + int _startFrameSpringOn; + int _endFrameSpringOn; + int _startFrameSummerOn; + int _endFrameSummerOn; + int _startFrameAutumnOn1; + int _endFrameAutumnOn1; + int _startFrameAutumnOn2; + int _endFrameAutumnOn2; + int _startFrameWinterOn1; + int _endFrameWinterOn1; + int _startFrameWinterOn2; + int _endFrameWinterOn2; CString _viewName2; public: CLASSDEF; diff --git a/engines/titanic/game/bar_bell.cpp b/engines/titanic/game/bar_bell.cpp index 207644a00e..5f17dffda1 100644 --- a/engines/titanic/game/bar_bell.cpp +++ b/engines/titanic/game/bar_bell.cpp @@ -116,7 +116,7 @@ bool CBarBell::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { } ++_fieldBC; - return 2; + return true; } bool CBarBell::ActMsg(CActMsg *msg) { diff --git a/engines/titanic/game/computer.cpp b/engines/titanic/game/computer.cpp index 90574997b1..3077b46178 100644 --- a/engines/titanic/game/computer.cpp +++ b/engines/titanic/game/computer.cpp @@ -46,7 +46,7 @@ void CComputer::load(SimpleFile *file) { bool CComputer::ActMsg(CActMsg *msg) { if (_state) { - playSound("a#35.wav", 100, 0, 0); + playSound("a#35.wav"); playMovie(32, 42, 0); if (msg->_action == "CD1") @@ -66,11 +66,11 @@ bool CComputer::ActMsg(CActMsg *msg) { bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { if (_currentCD == "None") { if (_state) { - playSound("a#35.wav", 100, 0, 0); + playSound("a#35.wav"); playMovie(11, 21, 0); _state = 0; } else { - playSound("a#34.wav", 100, 0, 0); + playSound("a#34.wav"); playMovie(0, 10, 0); _state = 1; } @@ -81,7 +81,7 @@ bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { actMsg.execute(_currentCD); _currentCD = "None"; } else { - playSound("a#34.wav", 100, 0, 0); + playSound("a#34.wav"); playMovie(21, 31, 0); _state = 1; } @@ -92,10 +92,10 @@ bool CComputer::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { bool CComputer::MovieEndMsg(CMovieEndMsg *msg) { if (msg->_endFrame == 90) { - playSound("a#32.wav", 100, 0, 0); - playSound("a#33.wav", 100, 0, 0); - playSound("a#31.wav", 100, 0, 0); - playSound("a#0.wav", 100, 0, 0); + playSound("a#32.wav"); + playSound("a#33.wav"); + playSound("a#31.wav"); + playSound("a#0.wav"); gotoView("Home.Node 4.E", "_TRACK,3,e-cu,4,E"); } diff --git a/engines/titanic/game/computer_screen.cpp b/engines/titanic/game/computer_screen.cpp index 3e5172219d..9a7ac4b34e 100644 --- a/engines/titanic/game/computer_screen.cpp +++ b/engines/titanic/game/computer_screen.cpp @@ -57,7 +57,7 @@ bool CComputerScreen::ActMsg(CActMsg *msg) { } bool CComputerScreen::MovieEndMsg(CMovieEndMsg *msg) { - playSound("z#47.wav", 100, 0, 0); + playSound("z#47.wav"); addTimer(0, 3000, 0); for (int idx = 0; idx < 10; ++idx) @@ -111,7 +111,7 @@ bool CComputerScreen::TimerMsg(CTimerMsg *msg) { playSound("a#29.wav"); stopSound(handle); - playSound("y#662.wav"); + handle = playSound("y#662.wav"); setSoundVolume(handle, 10, 2); playClip(392, 450); startTalking("Doorbot", 0x3611A); diff --git a/engines/titanic/game/fan_noises.cpp b/engines/titanic/game/fan_noises.cpp index c6e6d203dd..9144f523f4 100644 --- a/engines/titanic/game/fan_noises.cpp +++ b/engines/titanic/game/fan_noises.cpp @@ -34,7 +34,7 @@ BEGIN_MESSAGE_MAP(CFanNoises, CGameObject) END_MESSAGE_MAP() CFanNoises::CFanNoises() : CGameObject(), _state(-1), - _soundHandle(0), _soundPercent(70), _soundV3(-1), _soundSeconds(0), + _soundHandle(0), _soundPercent(70), _soundBalance(0), _soundSeconds(0), _stopSeconds(0), _startFlag(true) { } @@ -43,7 +43,7 @@ void CFanNoises::save(SimpleFile *file, int indent) { file->writeNumberLine(_state, indent); file->writeNumberLine(_soundHandle, indent); file->writeNumberLine(_soundPercent, indent); - file->writeNumberLine(_soundV3, indent); + file->writeNumberLine(_soundBalance, indent); file->writeNumberLine(_soundSeconds, indent); file->writeNumberLine(_stopSeconds, indent); file->writeNumberLine(_startFlag, indent); @@ -56,7 +56,7 @@ void CFanNoises::load(SimpleFile *file) { _state = file->readNumber(); _soundHandle = file->readNumber(); _soundPercent = file->readNumber(); - _soundV3 = file->readNumber(); + _soundBalance = file->readNumber(); _soundSeconds = file->readNumber(); _stopSeconds = file->readNumber(); _startFlag = file->readNumber(); @@ -75,12 +75,12 @@ bool CFanNoises::EnterRoomMsg(CEnterRoomMsg *msg) { switch (_state) { case 1: - _soundHandle = playSound("b#60.wav", 0, _soundV3, true); + _soundHandle = playSound("b#60.wav", 0, _soundBalance, true); setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); _startFlag = true; break; case 2: - _soundHandle = playSound("b#58.wav", 0, _soundV3, true); + _soundHandle = playSound("b#58.wav", 0, _soundBalance, true); setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); _startFlag = true; break; @@ -122,7 +122,7 @@ bool CFanNoises::StatusChangeMsg(CStatusChangeMsg *msg) { switch (oldState) { case 1: case 2: - playSound("b#59.wav", _soundPercent, _soundV3); + playSound("b#59.wav", _soundPercent, _soundBalance); break; default: break; @@ -140,7 +140,7 @@ bool CFanNoises::StatusChangeMsg(CStatusChangeMsg *msg) { switch (oldState) { case 1: case 2: - _soundHandle = playSound("b#60.wav", _soundPercent, _soundV3); + _soundHandle = playSound("b#60.wav", _soundPercent, _soundBalance); break; default: break; @@ -156,7 +156,7 @@ bool CFanNoises::StatusChangeMsg(CStatusChangeMsg *msg) { } if (oldState == 1) { - _soundHandle = playSound("b#58.wav", _soundPercent, _soundV3); + _soundHandle = playSound("b#58.wav", _soundPercent, _soundBalance); } break; @@ -184,13 +184,13 @@ bool CFanNoises::LoadSuccessMsg(CLoadSuccessMsg *msg) { switch (_state) { case 1: - playSound("b#60.wav", 0, _soundV3, true); + playSound("b#60.wav", 0, _soundBalance, true); setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); _startFlag = true; break; case 2: - playSound("b#58.wav", 0, _soundV3, true); + playSound("b#58.wav", 0, _soundBalance, true); setSoundVolume(_soundHandle, _soundPercent, _soundSeconds); _startFlag = true; break; diff --git a/engines/titanic/game/fan_noises.h b/engines/titanic/game/fan_noises.h index 56c80c0764..488d42e79e 100644 --- a/engines/titanic/game/fan_noises.h +++ b/engines/titanic/game/fan_noises.h @@ -39,7 +39,7 @@ private: int _state; int _soundHandle; int _soundPercent; - int _soundV3; + int _soundBalance; int _soundSeconds; int _stopSeconds; bool _startFlag; diff --git a/engines/titanic/game/head_smash_lever.cpp b/engines/titanic/game/head_smash_lever.cpp index d5c2eaf8c4..dabed26478 100644 --- a/engines/titanic/game/head_smash_lever.cpp +++ b/engines/titanic/game/head_smash_lever.cpp @@ -32,13 +32,13 @@ BEGIN_MESSAGE_MAP(CHeadSmashLever, CBackground) END_MESSAGE_MAP() CHeadSmashLever::CHeadSmashLever() : CBackground(), - _enabled(false), _fieldE4(false), _ticksCount(0) {} + _enabled(false), _fieldE4(false), _ticks(0) {} void CHeadSmashLever::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_enabled, indent); file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_ticksCount, indent); + file->writeNumberLine(_ticks, indent); CBackground::save(file, indent); } @@ -47,7 +47,7 @@ void CHeadSmashLever::load(SimpleFile *file) { file->readNumber(); _enabled = file->readNumber(); _fieldE4 = file->readNumber(); - _ticksCount = file->readNumber(); + _ticks = file->readNumber(); CBackground::load(file); } @@ -58,7 +58,7 @@ bool CHeadSmashLever::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { playSound("z#54.wav"); int soundHandle = playSound("z#45.wav"); queueSound("z#49.wav", soundHandle); - _ticksCount = getTicksCount(); + _ticks = getTicksCount(); _fieldE4 = true; } else { playMovie(0); @@ -78,7 +78,7 @@ bool CHeadSmashLever::ActMsg(CActMsg *msg) { } bool CHeadSmashLever::FrameMsg(CFrameMsg *msg) { - if (_fieldE4 && msg->_ticks > (_ticksCount + 750)) { + if (_fieldE4 && msg->_ticks > (_ticks + 750)) { CActMsg actMsg1("CreatorsChamber.Node 1.S"); actMsg1.execute("MoveToCreators"); CActMsg actMsg2("PlayToEnd"); @@ -93,7 +93,7 @@ bool CHeadSmashLever::FrameMsg(CFrameMsg *msg) { bool CHeadSmashLever::LoadSuccessMsg(CLoadSuccessMsg *msg) { if (_fieldE4) - _ticksCount = getTicksCount(); + _ticks = getTicksCount(); return true; } diff --git a/engines/titanic/game/head_smash_lever.h b/engines/titanic/game/head_smash_lever.h index e2426b68da..19de07922a 100644 --- a/engines/titanic/game/head_smash_lever.h +++ b/engines/titanic/game/head_smash_lever.h @@ -36,7 +36,7 @@ class CHeadSmashLever : public CBackground { public: bool _enabled; bool _fieldE4; - int _ticksCount; + uint _ticks; public: CLASSDEF; CHeadSmashLever(); diff --git a/engines/titanic/game/maitred/maitred_prod_receptor.cpp b/engines/titanic/game/maitred/maitred_prod_receptor.cpp index 66533a542f..95e029af44 100644 --- a/engines/titanic/game/maitred/maitred_prod_receptor.cpp +++ b/engines/titanic/game/maitred/maitred_prod_receptor.cpp @@ -80,8 +80,8 @@ bool CMaitreDProdReceptor::MouseMoveMsg(CMouseMoveMsg *msg) { else if (isEquals("Perch")) prodMsg._value = 125; - CMaitreD *maitreD = static_cast<CMaitreD *>(findRoomObject("MaitreD")); - if (maitreD->_field100 <= 0) + CMaitreD *maitreD = dynamic_cast<CMaitreD *>(findRoomObject("MaitreD")); + if (maitreD && maitreD->_field100 <= 0) prodMsg.execute(this); return true; diff --git a/engines/titanic/game/music_console_button.cpp b/engines/titanic/game/music_console_button.cpp index 9cf385e3a7..dc86765476 100644 --- a/engines/titanic/game/music_console_button.cpp +++ b/engines/titanic/game/music_console_button.cpp @@ -22,7 +22,7 @@ #include "titanic/game/music_console_button.h" #include "titanic/core/room_item.h" -#include "titanic/sound/music_handler.h" +#include "titanic/sound/music_room_handler.h" #include "titanic/titanic.h" namespace Titanic { @@ -84,48 +84,48 @@ bool CMusicConsoleButton::SetMusicControlsMsg(CSetMusicControlsMsg *msg) { CQueryMusicControlSettingMsg queryMsg; queryMsg.execute("Bells Mute Control"); - musicRoom->setItem5(BELLS, queryMsg._value == 1 ? 1 : 0); + musicRoom->setMuteControl(BELLS, queryMsg._value == 1 ? 1 : 0); queryMsg.execute("Bells Pitch Control"); - musicRoom->setItem2(BELLS, queryMsg._value); + musicRoom->setPitchControl(BELLS, queryMsg._value); queryMsg.execute("Bells Speed Control"); - musicRoom->setItem1(BELLS, queryMsg._value); + musicRoom->setSpeedControl(BELLS, queryMsg._value); queryMsg.execute("Bells Inversion Control"); - musicRoom->setItem4(BELLS, queryMsg._value == 0 ? 1 : 0); + musicRoom->setInversionControl(BELLS, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Bells Direction Control"); - musicRoom->setItem3(BELLS, queryMsg._value == 0 ? 1 : 0); + musicRoom->setDirectionControl(BELLS, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Snake Mute Control"); - musicRoom->setItem5(SNAKE, queryMsg._value == 1 ? 1 : 0); + musicRoom->setMuteControl(SNAKE, queryMsg._value == 1 ? 1 : 0); queryMsg.execute("Snake Pitch Control"); - musicRoom->setItem2(SNAKE, queryMsg._value); + musicRoom->setPitchControl(SNAKE, queryMsg._value); queryMsg.execute("Snake Speed Control"); - musicRoom->setItem1(SNAKE, queryMsg._value); + musicRoom->setSpeedControl(SNAKE, queryMsg._value); queryMsg.execute("Snake Inversion Control"); - musicRoom->setItem4(SNAKE, queryMsg._value == 0 ? 1 : 0); + musicRoom->setInversionControl(SNAKE, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Snake Direction Control"); - musicRoom->setItem3(SNAKE, queryMsg._value == 0 ? 1 : 0); + musicRoom->setDirectionControl(SNAKE, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Piano Mute Control"); - musicRoom->setItem5(PIANO, queryMsg._value == 1 ? 1 : 0); + musicRoom->setMuteControl(PIANO, queryMsg._value == 1 ? 1 : 0); queryMsg.execute("Piano Pitch Control"); - musicRoom->setItem2(PIANO, queryMsg._value); + musicRoom->setPitchControl(PIANO, queryMsg._value); queryMsg.execute("Piano Speed Control"); - musicRoom->setItem1(PIANO, queryMsg._value); + musicRoom->setSpeedControl(PIANO, queryMsg._value); queryMsg.execute("Piano Inversion Control"); - musicRoom->setItem4(PIANO, queryMsg._value == 0 ? 1 : 0); + musicRoom->setInversionControl(PIANO, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Piano Direction Control"); - musicRoom->setItem3(PIANO, queryMsg._value == 0 ? 1 : 0); + musicRoom->setDirectionControl(PIANO, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Bass Mute Control"); - musicRoom->setItem5(BASS, queryMsg._value == 1 ? 1 : 0); + musicRoom->setMuteControl(BASS, queryMsg._value == 1 ? 1 : 0); queryMsg.execute("Bass Pitch Control"); - musicRoom->setItem2(BASS, queryMsg._value); + musicRoom->setPitchControl(BASS, queryMsg._value); queryMsg.execute("Bass Speed Control"); - musicRoom->setItem1(BASS, queryMsg._value); + musicRoom->setSpeedControl(BASS, queryMsg._value); queryMsg.execute("Bass Inversion Control"); - musicRoom->setItem4(BASS, queryMsg._value == 0 ? 1 : 0); + musicRoom->setInversionControl(BASS, queryMsg._value == 0 ? 1 : 0); queryMsg.execute("Bass Direction Control"); - musicRoom->setItem3(BASS, queryMsg._value == 0 ? 1 : 0); + musicRoom->setDirectionControl(BASS, queryMsg._value == 0 ? 1 : 0); return true; } diff --git a/engines/titanic/game/parrot/parrot_lobby_controller.cpp b/engines/titanic/game/parrot/parrot_lobby_controller.cpp index f1e054a8dd..907e7519b8 100644 --- a/engines/titanic/game/parrot/parrot_lobby_controller.cpp +++ b/engines/titanic/game/parrot/parrot_lobby_controller.cpp @@ -21,9 +21,14 @@ */ #include "titanic/game/parrot/parrot_lobby_controller.h" +#include "titanic/core/room_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CParrotLobbyController, CParrotLobbyObject) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + void CParrotLobbyController::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CParrotLobbyObject::save(file, indent); @@ -34,4 +39,34 @@ void CParrotLobbyController::load(SimpleFile *file) { CParrotLobbyObject::load(file); } +bool CParrotLobbyController::ActMsg(CActMsg *msg) { + if (msg->_action == "Refresh") + return false; + else if (msg->_action == "GainParrot") + _haveParrot = true; + else if (msg->_action == "LoseParrot") + _haveParrot = false; + else if (msg->_action == "GainPerch") + _havePerch = true; + else if (msg->_action == "LosePerch") + _havePerch = false; + else if (msg->_action == "GainStick") + _haveStick = true; + else if (msg->_action == "LoseStick") + _haveStick = false; + + _flags = 0; + if (_haveParrot) + _flags = 4; + if (_havePerch) + _flags |= 2; + if (_haveStick) + _flags |= 1; + + CActMsg actMsg("Refresh"); + actMsg.execute(findRoom(), CParrotLobbyObject::_type, MSGFLAG_CLASS_DEF | MSGFLAG_SCAN); + actMsg.execute("ParrotLobbyUpdater_TOW"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_lobby_controller.h b/engines/titanic/game/parrot/parrot_lobby_controller.h index d2fa4a1801..896a4e19d2 100644 --- a/engines/titanic/game/parrot/parrot_lobby_controller.h +++ b/engines/titanic/game/parrot/parrot_lobby_controller.h @@ -28,6 +28,8 @@ namespace Titanic { class CParrotLobbyController : public CParrotLobbyObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/parrot/parrot_lobby_link_updater.cpp b/engines/titanic/game/parrot/parrot_lobby_link_updater.cpp index 25d5ec724b..47311c31f5 100644 --- a/engines/titanic/game/parrot/parrot_lobby_link_updater.cpp +++ b/engines/titanic/game/parrot/parrot_lobby_link_updater.cpp @@ -21,9 +21,46 @@ */ #include "titanic/game/parrot/parrot_lobby_link_updater.h" +#include "titanic/titanic.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CParrotLobbyLinkUpdater, CParrotLobbyObject) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + +/*------------------------------------------------------------------------*/ + +LinkUpdatorEntry::LinkUpdatorEntry() { + Common::fill(&_vals[0], &_vals[8], 0); +} + +void LinkUpdatorEntry::load(Common::SeekableReadStream *s) { + _linkStr = readStringFromStream(s); + for (int idx = 0; idx < 8; ++idx) + _vals[idx] = s->readByte(); +} + +/*------------------------------------------------------------------------*/ + +void LinkUpdatorEntries::load(Common::SeekableReadStream *s, int count) { + resize(count); + for (int idx = 0; idx < count; ++idx) + (*this)[idx].load(s); +} + +/*------------------------------------------------------------------------*/ + +CParrotLobbyLinkUpdater::CParrotLobbyLinkUpdater() : CParrotLobbyObject(), _fieldBC(1) { + Common::SeekableReadStream *s = g_vm->_filesManager->getResource("DATA/PARROT_LOBBY_LINK_UPDATOR"); + _entries[0].load(s, 7); + _entries[1].load(s, 5); + _entries[2].load(s, 6); + _entries[3].load(s, 9); + _entries[4].load(s, 1); + delete s; +} + void CParrotLobbyLinkUpdater::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CParrotLobbyObject::save(file, indent); @@ -34,4 +71,45 @@ void CParrotLobbyLinkUpdater::load(SimpleFile *file) { CParrotLobbyObject::load(file); } +bool CParrotLobbyLinkUpdater::ActMsg(CActMsg *msg) { + if (msg->_action != "Refresh") + return false; + + CNodeItem *node = findNode(); + LinkUpdatorEntries *entriesP; + if (isEquals("ParrotLobbyUpdater_TOW")) { + entriesP = &_entries[4]; + } else { + if (node->_nodeNumber > 3) + return true; + entriesP = &_entries[node->_nodeNumber]; + } + int count = entriesP->size(); + + for (CTreeItem *item = node->getFirstChild(); item; item = item->scan(node)) { + CLinkItem *link = dynamic_cast<CLinkItem *>(item); + if (!link || count == 0) + continue; + + CString linkName = link->getName(); + char c = linkName.lastChar(); + if (c >= 'a' && c <= 'd') + linkName.deleteLastChar(); + + for (uint idx = 0; idx < entriesP->size(); ++idx) { + const LinkUpdatorEntry &entry = (*entriesP)[idx]; + if (entry._linkStr == linkName) { + int val = entry._vals[CParrotLobbyObject::_flags]; + if (val) + linkName += (char)(0x60 + val); + + link->_name = linkName; + break; + } + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_lobby_link_updater.h b/engines/titanic/game/parrot/parrot_lobby_link_updater.h index 0470a62dee..93db931a53 100644 --- a/engines/titanic/game/parrot/parrot_lobby_link_updater.h +++ b/engines/titanic/game/parrot/parrot_lobby_link_updater.h @@ -23,16 +23,34 @@ #ifndef TITANIC_PARROT_LOBBY_LINK_UPDATER_H #define TITANIC_PARROT_LOBBY_LINK_UPDATER_H +#include "common/stream.h" #include "titanic/game/parrot/parrot_lobby_object.h" namespace Titanic { +struct LinkUpdatorEntry { + CString _linkStr; + int _vals[8]; + + LinkUpdatorEntry(); + void load(Common::SeekableReadStream *s); +}; + +class LinkUpdatorEntries : public Common::Array<LinkUpdatorEntry> { +public: + void load(Common::SeekableReadStream *s, int count); +}; + class CParrotLobbyLinkUpdater : public CParrotLobbyObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); +private: + LinkUpdatorEntries _entries[5]; public: int _fieldBC; public: CLASSDEF; - CParrotLobbyLinkUpdater() : CParrotLobbyObject(), _fieldBC(1) {} + CParrotLobbyLinkUpdater(); /** * Save the data for the class to file diff --git a/engines/titanic/game/parrot/parrot_lobby_object.cpp b/engines/titanic/game/parrot/parrot_lobby_object.cpp index a78ab2b6d9..06222fd063 100644 --- a/engines/titanic/game/parrot/parrot_lobby_object.cpp +++ b/engines/titanic/game/parrot/parrot_lobby_object.cpp @@ -26,34 +26,34 @@ namespace Titanic { EMPTY_MESSAGE_MAP(CParrotLobbyObject, CGameObject); -int CParrotLobbyObject::_v1; -int CParrotLobbyObject::_v2; -int CParrotLobbyObject::_v3; -int CParrotLobbyObject::_v4; +bool CParrotLobbyObject::_haveParrot; +bool CParrotLobbyObject::_havePerch; +bool CParrotLobbyObject::_haveStick; +int CParrotLobbyObject::_flags; void CParrotLobbyObject::init() { - _v1 = 1; - _v2 = 1; - _v3 = 1; - _v4 = 7; + _haveParrot = true; + _havePerch = true; + _haveStick = true; + _flags = 7; } void CParrotLobbyObject::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_v1, indent); - file->writeNumberLine(_v2, indent); - file->writeNumberLine(_v3, indent); - file->writeNumberLine(_v4, indent); + file->writeNumberLine(_haveParrot, indent); + file->writeNumberLine(_havePerch, indent); + file->writeNumberLine(_haveStick, indent); + file->writeNumberLine(_flags, indent); CGameObject::save(file, indent); } void CParrotLobbyObject::load(SimpleFile *file) { file->readNumber(); - _v1 = file->readNumber(); - _v2 = file->readNumber(); - _v3 = file->readNumber(); - _v4 = file->readNumber(); + _haveParrot = file->readNumber(); + _havePerch = file->readNumber(); + _haveStick = file->readNumber(); + _flags = file->readNumber(); CGameObject::load(file); } diff --git a/engines/titanic/game/parrot/parrot_lobby_object.h b/engines/titanic/game/parrot/parrot_lobby_object.h index 5272303888..a210331399 100644 --- a/engines/titanic/game/parrot/parrot_lobby_object.h +++ b/engines/titanic/game/parrot/parrot_lobby_object.h @@ -30,10 +30,10 @@ namespace Titanic { class CParrotLobbyObject : public CGameObject { DECLARE_MESSAGE_MAP; public: - static int _v1; - static int _v2; - static int _v3; - static int _v4; + static bool _haveParrot; + static bool _havePerch; + static bool _haveStick; + static int _flags; static void init(); public: diff --git a/engines/titanic/game/parrot/parrot_lobby_view_object.cpp b/engines/titanic/game/parrot/parrot_lobby_view_object.cpp index ae398036a8..1151325676 100644 --- a/engines/titanic/game/parrot/parrot_lobby_view_object.cpp +++ b/engines/titanic/game/parrot/parrot_lobby_view_object.cpp @@ -24,16 +24,28 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CParrotLobbyViewObject, CParrotLobbyObject) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + void CParrotLobbyViewObject::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_flag, indent); CParrotLobbyObject::save(file, indent); } void CParrotLobbyViewObject::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); + _flag = file->readNumber(); CParrotLobbyObject::load(file); } +bool CParrotLobbyViewObject::ActMsg(CActMsg *msg) { + if (msg->_action != "Refresh") + return false; + + setVisible(_flag ? _haveParrot : _haveStick); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_lobby_view_object.h b/engines/titanic/game/parrot/parrot_lobby_view_object.h index 3179bb962d..484d70908e 100644 --- a/engines/titanic/game/parrot/parrot_lobby_view_object.h +++ b/engines/titanic/game/parrot/parrot_lobby_view_object.h @@ -28,11 +28,13 @@ namespace Titanic { class CParrotLobbyViewObject : public CParrotLobbyObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); public: - int _fieldBC; + bool _flag; public: CLASSDEF; - CParrotLobbyViewObject() : CParrotLobbyObject(), _fieldBC(1) {} + CParrotLobbyViewObject() : CParrotLobbyObject(), _flag(true) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/parrot/parrot_loser.cpp b/engines/titanic/game/parrot/parrot_loser.cpp index 6e23ef8314..dc854ee9bd 100644 --- a/engines/titanic/game/parrot/parrot_loser.cpp +++ b/engines/titanic/game/parrot/parrot_loser.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CParrotLoser, CGameObject) + ON_MESSAGE(LeaveRoomMsg) +END_MESSAGE_MAP() + void CParrotLoser::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +38,10 @@ void CParrotLoser::load(SimpleFile *file) { CGameObject::load(file); } +bool CParrotLoser::LeaveRoomMsg(CLeaveRoomMsg *msg) { + CActMsg actMsg("FreeParrot"); + actMsg.execute("CarryParrot"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_loser.h b/engines/titanic/game/parrot/parrot_loser.h index 819fd6614c..e03bfb0727 100644 --- a/engines/titanic/game/parrot/parrot_loser.h +++ b/engines/titanic/game/parrot/parrot_loser.h @@ -28,6 +28,8 @@ namespace Titanic { class CParrotLoser : public CGameObject { + DECLARE_MESSAGE_MAP; + bool LeaveRoomMsg(CLeaveRoomMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp b/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp index c83d66cbdf..2654042967 100644 --- a/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp +++ b/engines/titanic/game/parrot/parrot_nut_bowl_actor.cpp @@ -21,27 +21,95 @@ */ #include "titanic/game/parrot/parrot_nut_bowl_actor.h" +#include "titanic/core/room_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CParrotNutBowlActor, CGameObject) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(BowlStateChangeMsg) + ON_MESSAGE(IsEarBowlPuzzleDone) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(ReplaceBowlAndNutsMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(NutPuzzleMsg) +END_MESSAGE_MAP() + CParrotNutBowlActor::CParrotNutBowlActor() : CGameObject(), - _value1(0), _value2(0) { + _puzzleDone(0), _state(0) { } void CParrotNutBowlActor::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value1, indent); - file->writeNumberLine(_value2, indent); + file->writeNumberLine(_puzzleDone, indent); + file->writeNumberLine(_state, indent); CGameObject::save(file, indent); } void CParrotNutBowlActor::load(SimpleFile *file) { file->readNumber(); - _value1 = file->readNumber(); - _value2 = file->readNumber(); + _puzzleDone = file->readNumber(); + _state = file->readNumber(); CGameObject::load(file); } +bool CParrotNutBowlActor::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (!_state) { + CActMsg actMsg("Jiggle"); + actMsg.execute("BowlNutsRustler"); + } + + return true; +} + +bool CParrotNutBowlActor::BowlStateChangeMsg(CBowlStateChangeMsg *msg) { + _state = msg->_state; + if (msg->_state == 3) { + if (!_puzzleDone) { + CReplaceBowlAndNutsMsg replaceMsg; + replaceMsg.execute(findRoom(), nullptr, MSGFLAG_SCAN); + playSound("z#47.wav"); + } + + _puzzleDone = true; + } + + return true; +} + +bool CParrotNutBowlActor::IsEarBowlPuzzleDone(CIsEarBowlPuzzleDone *msg) { + msg->_value = _puzzleDone; + return true; +} + +bool CParrotNutBowlActor::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CParrotNutBowlActor::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) { + if (!_puzzleDone) + _state = 0; + return true; +} + +bool CParrotNutBowlActor::LeaveViewMsg(CLeaveViewMsg *msg) { + if (!_puzzleDone && _state) { + CReplaceBowlAndNutsMsg replaceMsg; + replaceMsg.execute(findRoom(), nullptr, MSGFLAG_SCAN); + } + + return true; +} + +bool CParrotNutBowlActor::NutPuzzleMsg(CNutPuzzleMsg *msg) { + if (msg->_value == "NutsGone") + _state = 1; + else if (msg->_value == "BowlUnlocked") + _state = 2; + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_nut_bowl_actor.h b/engines/titanic/game/parrot/parrot_nut_bowl_actor.h index d8395bb65a..b228c0ea9e 100644 --- a/engines/titanic/game/parrot/parrot_nut_bowl_actor.h +++ b/engines/titanic/game/parrot/parrot_nut_bowl_actor.h @@ -28,8 +28,17 @@ namespace Titanic { class CParrotNutBowlActor : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool BowlStateChangeMsg(CBowlStateChangeMsg *msg); + bool IsEarBowlPuzzleDone(CIsEarBowlPuzzleDone *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool NutPuzzleMsg(CNutPuzzleMsg *msg); public: - int _value1, _value2; + bool _puzzleDone; + int _state; public: CLASSDEF; CParrotNutBowlActor(); diff --git a/engines/titanic/game/parrot/parrot_nut_eater.cpp b/engines/titanic/game/parrot/parrot_nut_eater.cpp index 309b379ab8..751da931ac 100644 --- a/engines/titanic/game/parrot/parrot_nut_eater.cpp +++ b/engines/titanic/game/parrot/parrot_nut_eater.cpp @@ -21,9 +21,17 @@ */ #include "titanic/game/parrot/parrot_nut_eater.h" +#include "titanic/core/room_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CParrotNutEater, CGameObject) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(ReplaceBowlAndNutsMsg) + ON_MESSAGE(NutPuzzleMsg) + ON_MESSAGE(MovieFrameMsg) +END_MESSAGE_MAP() + CParrotNutEater::CParrotNutEater() : CGameObject(), _fieldBC(0), _fieldC0(69), _fieldC4(132), _fieldC8(0), _fieldCC(68) { } @@ -42,4 +50,48 @@ void CParrotNutEater::load(SimpleFile *file) { CGameObject::load(file); } +bool CParrotNutEater::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(false); + CNutPuzzleMsg nutMsg("NutsGone"); + nutMsg.execute(getRoom(), nullptr, MSGFLAG_SCAN); + + playSound("z#47.wav"); + return true; +} + +bool CParrotNutEater::ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg) { + setVisible(false); + return true; +} + +bool CParrotNutEater::NutPuzzleMsg(CNutPuzzleMsg *msg) { + if (msg->_value == "Jiggle") { + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + movieEvent(68); + movieEvent(132); + playSound("z#215.wav"); + + CTrueTalkTriggerActionMsg triggerMsg; + triggerMsg._param1 = triggerMsg._param2 = 0; + triggerMsg.execute("PerchedParrot"); + } + + return true; +} + +bool CParrotNutEater::MovieFrameMsg(CMovieFrameMsg *msg) { + switch (msg->_frameNumber) { + case 68: + playSound("z#214.wav"); + break; + case 132: + playSound("z#216.wav"); + break; + default: + break; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_nut_eater.h b/engines/titanic/game/parrot/parrot_nut_eater.h index 5dcb01ca11..e09ad63947 100644 --- a/engines/titanic/game/parrot/parrot_nut_eater.h +++ b/engines/titanic/game/parrot/parrot_nut_eater.h @@ -28,6 +28,11 @@ namespace Titanic { class CParrotNutEater : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MovieEndMsg(CMovieEndMsg *msg); + bool ReplaceBowlAndNutsMsg(CReplaceBowlAndNutsMsg *msg); + bool NutPuzzleMsg(CNutPuzzleMsg *msg); + bool MovieFrameMsg(CMovieFrameMsg *msg); public: int _fieldBC; int _fieldC0; diff --git a/engines/titanic/game/parrot/parrot_perch_holder.cpp b/engines/titanic/game/parrot/parrot_perch_holder.cpp index dd8523990b..d594446219 100644 --- a/engines/titanic/game/parrot/parrot_perch_holder.cpp +++ b/engines/titanic/game/parrot/parrot_perch_holder.cpp @@ -21,9 +21,19 @@ */ #include "titanic/game/parrot/parrot_perch_holder.h" +#include "titanic/game/cage.h" +#include "titanic/core/project_item.h" +#include "titanic/npcs/parrot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CParrotPerchHolder, CMultiDropTarget) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(DropObjectMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + void CParrotPerchHolder::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CMultiDropTarget::save(file, indent); @@ -34,4 +44,39 @@ void CParrotPerchHolder::load(SimpleFile *file) { CMultiDropTarget::load(file); } +bool CParrotPerchHolder::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (CParrot::_v1) { + if (CCage::_open) { + petDisplayMessage("You cannot take this because the cage is locked shut."); + } else if (!CParrot::_v4) { + CTrueTalkTriggerActionMsg triggerMsg(280252, 0, 0); + triggerMsg.execute(getRoot(), CParrot::_type, + MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + } + } + + return true; +} + +bool CParrotPerchHolder::StatusChangeMsg(CStatusChangeMsg *msg) { + _fieldF4 = msg->_newStatus; + return true; +} + +bool CParrotPerchHolder::DropObjectMsg(CDropObjectMsg *msg) { + if (CCage::_open) + return false; + else + return CMultiDropTarget::DropObjectMsg(msg); +} + +bool CParrotPerchHolder::ActMsg(CActMsg *msg) { + if (msg->_action == "FlashCore") { + playMovie(2, 2, 0); + playMovie(1, 1, 0); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_perch_holder.h b/engines/titanic/game/parrot/parrot_perch_holder.h index ff618f09dc..c1fe243476 100644 --- a/engines/titanic/game/parrot/parrot_perch_holder.h +++ b/engines/titanic/game/parrot/parrot_perch_holder.h @@ -28,6 +28,11 @@ namespace Titanic { class CParrotPerchHolder : public CMultiDropTarget { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool DropObjectMsg(CDropObjectMsg *msg); + bool ActMsg(CActMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/parrot/parrot_trigger.cpp b/engines/titanic/game/parrot/parrot_trigger.cpp index 36e99ada33..b7287ebb6a 100644 --- a/engines/titanic/game/parrot/parrot_trigger.cpp +++ b/engines/titanic/game/parrot/parrot_trigger.cpp @@ -21,9 +21,15 @@ */ #include "titanic/game/parrot/parrot_trigger.h" +#include "titanic/npcs/parrot.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CParrotTrigger, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CParrotTrigger::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value, indent); @@ -36,4 +42,11 @@ void CParrotTrigger::load(SimpleFile *file) { CGameObject::load(file); } +bool CParrotTrigger::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CTrueTalkTriggerActionMsg triggerMsg(_value, 0, 0); + triggerMsg.execute(getRoot(), CParrot::_type, + MSGFLAG_CLASS_DEF | MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_SCAN); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/parrot/parrot_trigger.h b/engines/titanic/game/parrot/parrot_trigger.h index 28a1663fa8..6fba77b56d 100644 --- a/engines/titanic/game/parrot/parrot_trigger.h +++ b/engines/titanic/game/parrot/parrot_trigger.h @@ -28,6 +28,8 @@ namespace Titanic { class CParrotTrigger : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: int _value; public: diff --git a/engines/titanic/game/parrot/player_meets_parrot.cpp b/engines/titanic/game/parrot/player_meets_parrot.cpp index 6db9345bc0..cdb14516bf 100644 --- a/engines/titanic/game/parrot/player_meets_parrot.cpp +++ b/engines/titanic/game/parrot/player_meets_parrot.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPlayerMeetsParrot, CGameObject) + ON_MESSAGE(EnterRoomMsg) +END_MESSAGE_MAP() + void CPlayerMeetsParrot::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -35,7 +39,7 @@ void CPlayerMeetsParrot::load(SimpleFile *file) { } bool CPlayerMeetsParrot::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CPlayerMeetsParrot::handleEvent"); + stateSet24(); return true; } diff --git a/engines/titanic/game/parrot/player_meets_parrot.h b/engines/titanic/game/parrot/player_meets_parrot.h index 9cee9ee322..edae18801f 100644 --- a/engines/titanic/game/parrot/player_meets_parrot.h +++ b/engines/titanic/game/parrot/player_meets_parrot.h @@ -29,6 +29,7 @@ namespace Titanic { class CPlayerMeetsParrot : public CGameObject { + DECLARE_MESSAGE_MAP; protected: bool EnterRoomMsg(CEnterRoomMsg *msg); public: diff --git a/engines/titanic/game/pet/pet.cpp b/engines/titanic/game/pet/pet.cpp index cd4e16d38c..99c9e01eb3 100644 --- a/engines/titanic/game/pet/pet.cpp +++ b/engines/titanic/game/pet/pet.cpp @@ -21,9 +21,14 @@ */ #include "titanic/game/pet/pet.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPET, CGameObject) + ON_MESSAGE(ShowTextMsg) +END_MESSAGE_MAP() + CPET::CPET() : CGameObject(), _fieldBC(0), _fieldC0(3), _fieldC4(0), _fieldC8(0), _fieldD8(0), _fieldDC(0) { } @@ -54,4 +59,11 @@ void CPET::load(SimpleFile *file) { CGameObject::load(file); } +bool CPET::ShowTextMsg(CShowTextMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet) + pet->petDisplayMessage(1, msg->_value); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet.h b/engines/titanic/game/pet/pet.h index cdad649401..de31a423d0 100644 --- a/engines/titanic/game/pet/pet.h +++ b/engines/titanic/game/pet/pet.h @@ -28,6 +28,8 @@ namespace Titanic { class CPET : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ShowTextMsg(CShowTextMsg *msg); public: int _fieldBC; int _fieldC0; diff --git a/engines/titanic/game/pet/pet_lift.cpp b/engines/titanic/game/pet/pet_lift.cpp index 39b0d01540..afa9dd04cd 100644 --- a/engines/titanic/game/pet/pet_lift.cpp +++ b/engines/titanic/game/pet/pet_lift.cpp @@ -21,9 +21,14 @@ */ #include "titanic/game/pet/pet_lift.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPETLift, CPETTransport) + ON_MESSAGE(TransportMsg) +END_MESSAGE_MAP() + void CPETLift::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CPETTransport::save(file, indent); @@ -34,4 +39,36 @@ void CPETLift::load(SimpleFile *file) { CPETTransport::load(file); } +bool CPETLift::TransportMsg(CTransportMsg *msg) { + CPetControl *pet = getPetControl(); + if (msg->_value1 != 1) + return false; + + int floorNum = -1; + if (msg->_roomName == "TopOfWell") { + floorNum = 1; + } else if (msg->_roomName == "BottomOfWell") { + floorNum = 39; + } else if (msg->_roomName == "PlayersRoom" && pet) { + int assignedFloor = pet->getAssignedFloorNum(); + if (assignedFloor < 1 || assignedFloor > 39) { + pet->petDisplayMessage("You have not assigned a room to go to."); + floorNum = -1; + } + } + + if (floorNum != -1) { + int elevatorNum = pet ? pet->getRoomsElevatorNum() : 0; + + if ((elevatorNum == 2 || elevatorNum == 4) && floorNum > 27) { + petDisplayMessage("Sorry, this elevator does not go below floor 27."); + } else { + CTrueTalkTriggerActionMsg triggerMsg(2, floorNum, 0); + triggerMsg.execute("Liftbot"); + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_lift.h b/engines/titanic/game/pet/pet_lift.h index 88b4e1c029..ce3aace1a6 100644 --- a/engines/titanic/game/pet/pet_lift.h +++ b/engines/titanic/game/pet/pet_lift.h @@ -28,6 +28,8 @@ namespace Titanic { class CPETLift : public CPETTransport { + DECLARE_MESSAGE_MAP; + bool TransportMsg(CTransportMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/pet/pet_monitor.cpp b/engines/titanic/game/pet/pet_monitor.cpp index 6a0d207a55..2716a81fa8 100644 --- a/engines/titanic/game/pet/pet_monitor.cpp +++ b/engines/titanic/game/pet/pet_monitor.cpp @@ -21,6 +21,8 @@ */ #include "titanic/game/pet/pet_monitor.h" +#include "titanic/core/room_item.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { @@ -39,7 +41,23 @@ void CPETMonitor::load(SimpleFile *file) { } bool CPETMonitor::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CPETMonitor::handleEvent"); + bool flag = true; + if (msg->_newRoom && msg->_oldRoom) { + CString oldRoomName = msg->_oldRoom->getName(); + CString newRoomName = msg->_newRoom->getName(); + + if (newRoomName == "SgtLobby" && oldRoomName == "SGTState") + flag = false; + } + + if (flag) { + CPetControl *pet = getPetControl(); + if (pet) { + pet->setRoomsRoomNum(0); + pet->resetRoomsHighlight(); + } + } + return true; } diff --git a/engines/titanic/game/pet/pet_pellerator.cpp b/engines/titanic/game/pet/pet_pellerator.cpp index a29942ca59..59516ebcde 100644 --- a/engines/titanic/game/pet/pet_pellerator.cpp +++ b/engines/titanic/game/pet/pet_pellerator.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPETPellerator, CPETTransport) + ON_MESSAGE(PETActivateMsg) +END_MESSAGE_MAP() + void CPETPellerator::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CPETTransport::save(file, indent); @@ -34,4 +38,24 @@ void CPETPellerator::load(SimpleFile *file) { CPETTransport::load(file); } +bool CPETPellerator::PETActivateMsg(CPETActivateMsg *msg) { + CStatusChangeMsg statusMsg; + + if (msg->_name == "PromenadeDeck") + statusMsg._newStatus = 0; + else if (msg->_name == "MusicRoom") + statusMsg._newStatus = 1; + else if (msg->_name == "Bar") + statusMsg._newStatus = 2; + else if (msg->_name == "TopOfWell") + statusMsg._newStatus = 4; + else if (msg->_name == "1stClassRestaurant") + statusMsg._newStatus = 5; + else if (msg->_name == "Arboretum") + statusMsg._newStatus = 6; + + statusMsg.execute("PelleratorObject"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_pellerator.h b/engines/titanic/game/pet/pet_pellerator.h index 9b90c9af28..51af6f1bcd 100644 --- a/engines/titanic/game/pet/pet_pellerator.h +++ b/engines/titanic/game/pet/pet_pellerator.h @@ -24,10 +24,13 @@ #define TITANIC_PET_PELLERATOR_H #include "titanic/game/pet/pet_transport.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CPETPellerator : public CPETTransport { + DECLARE_MESSAGE_MAP; + bool PETActivateMsg(CPETActivateMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/pet/pet_sentinal.cpp b/engines/titanic/game/pet/pet_sentinal.cpp index 1b647d7c62..ac4cbc8418 100644 --- a/engines/titanic/game/pet/pet_sentinal.cpp +++ b/engines/titanic/game/pet/pet_sentinal.cpp @@ -21,17 +21,46 @@ */ #include "titanic/game/pet/pet_sentinal.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPETSentinal, CGameObject) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +CPETSentinal::CPETSentinal() : CGameObject(), _elevatorNum(0), + _wellEntry(0), _resetHighlight(0) { +} + void CPETSentinal::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); + file->writeNumberLine(_elevatorNum, indent); + file->writeNumberLine(_wellEntry, indent); + file->writeNumberLine(_resetHighlight, indent); CGameObject::save(file, indent); } void CPETSentinal::load(SimpleFile *file) { file->readNumber(); + _elevatorNum = file->readNumber(); + _wellEntry = file->readNumber(); + _resetHighlight = file->readNumber(); CGameObject::load(file); } +bool CPETSentinal::EnterViewMsg(CEnterViewMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet) { + if (_elevatorNum != -1) + pet->setRoomsElevatorNum(_elevatorNum); + if (_wellEntry) + pet->setRoomsWellEntry(_wellEntry); + if (_resetHighlight) + pet->resetRoomsHighlight(); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_sentinal.h b/engines/titanic/game/pet/pet_sentinal.h index f7f9fef0ba..150fe4a87e 100644 --- a/engines/titanic/game/pet/pet_sentinal.h +++ b/engines/titanic/game/pet/pet_sentinal.h @@ -28,8 +28,15 @@ namespace Titanic { class CPETSentinal : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); +private: + int _elevatorNum; + int _wellEntry; + bool _resetHighlight; public: CLASSDEF; + CPETSentinal(); /** * Save the data for the class to file diff --git a/engines/titanic/game/pet/pet_sounds.cpp b/engines/titanic/game/pet/pet_sounds.cpp index d612c745bb..c7f3cd3bf8 100644 --- a/engines/titanic/game/pet/pet_sounds.cpp +++ b/engines/titanic/game/pet/pet_sounds.cpp @@ -24,16 +24,40 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPETSounds, CGameObject) + ON_MESSAGE(PETPlaySoundMsg) + ON_MESSAGE(LoadSuccessMsg) +END_MESSAGE_MAP() + void CPETSounds::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_ticks, indent); CGameObject::save(file, indent); } void CPETSounds::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _ticks = file->readNumber(); CGameObject::load(file); } +bool CPETSounds::PETPlaySoundMsg(CPETPlaySoundMsg *msg) { + if (msg->_soundNum == 1) { + playSound("z#65.wav"); + } else if (msg->_soundNum == 2 && stateGet24()) { + uint ticks = getTicksCount(); + if (!_ticks || ticks > (_ticks + 12000)) { + playSound("z#36.wav"); + _ticks = ticks; + } + } + + return true; +} + +bool CPETSounds::LoadSuccessMsg(CLoadSuccessMsg *msg) { + _ticks = 0; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_sounds.h b/engines/titanic/game/pet/pet_sounds.h index 1d3acdb5f3..2262fde916 100644 --- a/engines/titanic/game/pet/pet_sounds.h +++ b/engines/titanic/game/pet/pet_sounds.h @@ -24,15 +24,19 @@ #define TITANIC_PET_SOUNDS_H #include "titanic/core/game_object.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CPETSounds : public CGameObject { + DECLARE_MESSAGE_MAP; + bool PETPlaySoundMsg(CPETPlaySoundMsg *msg); + bool LoadSuccessMsg(CLoadSuccessMsg *msg); public: - int _value; + uint _ticks; public: CLASSDEF; - CPETSounds() : CGameObject(), _value(0) {} + CPETSounds() : CGameObject(), _ticks(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/pet/pet_transition.cpp b/engines/titanic/game/pet/pet_transition.cpp index 33cc36ca11..ec10569236 100644 --- a/engines/titanic/game/pet/pet_transition.cpp +++ b/engines/titanic/game/pet/pet_transition.cpp @@ -21,9 +21,15 @@ */ #include "titanic/game/pet/pet_transition.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/core/view_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPETTransition, CGameObject) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + void CPETTransition::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +40,21 @@ void CPETTransition::load(SimpleFile *file) { CGameObject::load(file); } +bool CPETTransition::EnterViewMsg(CEnterViewMsg *msg) { + CPetControl *pet = getPetControl(); + + if (compareRoomNameTo("1stClassLobby") && pet) { + int elevatorNum = pet->getRoomsElevatorNum(); + CString nodeView = msg->_newView->getNodeViewName(); + + if (nodeView == "Node 1.E") { + pet->setRoomsElevatorNum((elevatorNum == 1 || elevatorNum == 2) ? 1 : 3); + } else if (nodeView == "Node 1.W") { + pet->setRoomsElevatorNum((elevatorNum == 1 || elevatorNum == 2) ? 2 : 4); + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet/pet_transition.h b/engines/titanic/game/pet/pet_transition.h index 4abf16d509..d0fa20ccc5 100644 --- a/engines/titanic/game/pet/pet_transition.h +++ b/engines/titanic/game/pet/pet_transition.h @@ -28,6 +28,8 @@ namespace Titanic { class CPETTransition : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/pet/pet_transport.cpp b/engines/titanic/game/pet/pet_transport.cpp index 9661cace2c..a48e70ed01 100644 --- a/engines/titanic/game/pet/pet_transport.cpp +++ b/engines/titanic/game/pet/pet_transport.cpp @@ -39,7 +39,7 @@ void CPETTransport::load(SimpleFile *file) { } bool CPETTransport::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CPETTransport::handleEvent"); + petClear(); return true; } diff --git a/engines/titanic/game/pet_disabler.cpp b/engines/titanic/game/pet_disabler.cpp index 2275156503..c4946fe39f 100644 --- a/engines/titanic/game/pet_disabler.cpp +++ b/engines/titanic/game/pet_disabler.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPetDisabler, CGameObject) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + void CPetDisabler::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeQuotedLine(_value, indent); @@ -36,4 +41,14 @@ void CPetDisabler::load(SimpleFile *file) { CGameObject::load(file); } +bool CPetDisabler::EnterViewMsg(CEnterViewMsg *msg) { + petLockInput(); + return true; +} + +bool CPetDisabler::LeaveViewMsg(CLeaveViewMsg *msg) { + petUnlockInput(); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pet_disabler.h b/engines/titanic/game/pet_disabler.h index 92b4dff0a8..06e99be49e 100644 --- a/engines/titanic/game/pet_disabler.h +++ b/engines/titanic/game/pet_disabler.h @@ -28,6 +28,9 @@ namespace Titanic { class CPetDisabler : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: CString _value; public: diff --git a/engines/titanic/game/phonograph.cpp b/engines/titanic/game/phonograph.cpp index 9740e29273..408cfa3413 100644 --- a/engines/titanic/game/phonograph.cpp +++ b/engines/titanic/game/phonograph.cpp @@ -24,9 +24,18 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPhonograph, CMusicPlayer) + ON_MESSAGE(PhonographPlayMsg) + ON_MESSAGE(PhonographStopMsg) + ON_MESSAGE(PhonographRecordMsg) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(LeaveRoomMsg) + ON_MESSAGE(MusicHasStartedMsg) +END_MESSAGE_MAP() + CPhonograph::CPhonograph() : CMusicPlayer(), - _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0), - _fieldF0(0), _fieldF4(0) { + _fieldE0(false), _fieldE4(0), _fieldE8(0), _fieldEC(0), + _fieldF0(0), _fieldF4(0) { } void CPhonograph::save(SimpleFile *file, int indent) { @@ -55,8 +64,113 @@ void CPhonograph::load(SimpleFile *file) { CMusicPlayer::load(file); } +bool CPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) { + CQueryCylinderHolderMsg holderMsg; + holderMsg.execute(this); + if (!holderMsg._value2) { + _fieldE0 = false; + return true; + } + + CQueryCylinderMsg cylinderMsg; + cylinderMsg.execute(holderMsg._target); + + if (cylinderMsg._name.empty()) { + _fieldE0 = false; + } else if (cylinderMsg._name.hasPrefix("STMusic")) { + CStartMusicMsg startMsg(this); + startMsg.execute(this); + _fieldE0 = true; + msg->_value = 1; + } else { + stopGlobalSound(0, -1); + playGlobalSound(cylinderMsg._name, -2, true, true, 0); + _fieldE0 = true; + msg->_value = 1; + } + + return true; +} + +bool CPhonograph::PhonographStopMsg(CPhonographStopMsg *msg) { + CQueryCylinderHolderMsg holderMsg; + holderMsg.execute(this); + if (!holderMsg._value2) + return true; + + _fieldE0 = false; + CQueryCylinderMsg cylinderMsg; + cylinderMsg.execute(holderMsg._target); + + if (_fieldE0) { + if (!cylinderMsg._name.empty()) { + if (cylinderMsg._name.hasPrefix("STMusic")) { + CStopMusicMsg stopMsg; + stopMsg.execute(this); + } else { + stopGlobalSound(msg->_value1, -1); + } + msg->_value2 = 1; + } + + if (!msg->_value3) + _fieldE0 = false; + } else if (_fieldE4) { + _fieldE4 = false; + msg->_value2 = 1; + } + + return true; +} + +bool CPhonograph::PhonographRecordMsg(CPhonographRecordMsg *msg) { + if (!_fieldE0 && !_fieldE4 && !_fieldE8) { + CQueryCylinderHolderMsg holderMsg; + holderMsg.execute(this); + + if (holderMsg._value2) { + _fieldE4 = true; + CErasePhonographCylinderMsg eraseMsg; + eraseMsg.execute(holderMsg._target); + } else { + _fieldE4 = false; + } + } + + return true; +} + bool CPhonograph::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CPhonograph::handleEvent"); + if (_fieldE0) { + CPhonographPlayMsg playMsg; + playMsg.execute(this); + } + + return true; +} + +bool CPhonograph::LeaveRoomMsg(CLeaveRoomMsg *msg) { + if (_fieldE0) { + CPhonographStopMsg stopMsg; + stopMsg._value1 = 1; + stopMsg.execute(this); + } + + return true; +} + +bool CPhonograph::MusicHasStartedMsg(CMusicHasStartedMsg *msg) { + if (_fieldE4) { + CQueryCylinderHolderMsg holderMsg; + holderMsg.execute(this); + if (holderMsg._value2) { + CRecordOntoCylinderMsg recordMsg; + recordMsg.execute(holderMsg._target); + } else { + _fieldE4 = false; + } + } + return true; } diff --git a/engines/titanic/game/phonograph.h b/engines/titanic/game/phonograph.h index 274d4ba367..b13a5ea910 100644 --- a/engines/titanic/game/phonograph.h +++ b/engines/titanic/game/phonograph.h @@ -29,10 +29,16 @@ namespace Titanic { class CPhonograph : public CMusicPlayer { + DECLARE_MESSAGE_MAP; + bool PhonographPlayMsg(CPhonographPlayMsg *msg); + bool PhonographStopMsg(CPhonographStopMsg *msg); + bool PhonographRecordMsg(CPhonographRecordMsg *msg); bool EnterRoomMsg(CEnterRoomMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); + bool MusicHasStartedMsg(CMusicHasStartedMsg *msg); protected: CString _string2; - int _fieldE0; + bool _fieldE0; int _fieldE4; int _fieldE8; int _fieldEC; diff --git a/engines/titanic/game/phonograph_lid.cpp b/engines/titanic/game/phonograph_lid.cpp index a0518420f7..3741749fbf 100644 --- a/engines/titanic/game/phonograph_lid.cpp +++ b/engines/titanic/game/phonograph_lid.cpp @@ -24,16 +24,63 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPhonographLid, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(LockPhonographMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + void CPhonographLid::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_open, indent); CGameObject::save(file, indent); } void CPhonographLid::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _open = file->readNumber(); CGameObject::load(file); } +bool CPhonographLid::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CQueryPhonographState stateMsg; + stateMsg.execute(getParent(), nullptr, MSGFLAG_SCAN); + if (stateMsg._value) { + if (_open) { + CGameObject *lock = dynamic_cast<CGameObject *>(findByName("Music System Lock")); + if (lock) + lock->setVisible(false); + playMovie(0, 27, 0); + } else { + playMovie(27, 55, 0); + } + + _open = !_open; + } else { + petDisplayMessage(0, "This is the restaurant music system. It appears to be locked."); + } + + return true; +} + +bool CPhonographLid::MovieEndMsg(CMovieEndMsg *msg) { + // WORKAROUND: Redundant code in original not included + return true; +} + +bool CPhonographLid::LockPhonographMsg(CLockPhonographMsg *msg) { + _cursorId = msg->_value ? CURSOR_INVALID : CURSOR_ARROW; + return true; +} + +bool CPhonographLid::LeaveViewMsg(CLeaveViewMsg *msg) { + if (_open) { + playMovie(27, 55, MOVIE_GAMESTATE); + _open = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/phonograph_lid.h b/engines/titanic/game/phonograph_lid.h index ab32be268b..4e71d70ec2 100644 --- a/engines/titanic/game/phonograph_lid.h +++ b/engines/titanic/game/phonograph_lid.h @@ -28,11 +28,16 @@ namespace Titanic { class CPhonographLid : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool LockPhonographMsg(CLockPhonographMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); private: - int _value; + bool _open; public: CLASSDEF; - CPhonographLid() : CGameObject(), _value(0) {} + CPhonographLid() : CGameObject(), _open(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/pickup/pick_up.cpp b/engines/titanic/game/pickup/pick_up.cpp index c660a36a32..64d2d1d0d2 100644 --- a/engines/titanic/game/pickup/pick_up.cpp +++ b/engines/titanic/game/pickup/pick_up.cpp @@ -24,16 +24,26 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPickUp, CGameObject) + ON_MESSAGE(StatusChangeMsg) +END_MESSAGE_MAP() + void CPickUp::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); + file->writeNumberLine(_enabled, indent); CGameObject::save(file, indent); } void CPickUp::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); + _enabled = file->readNumber(); CGameObject::load(file); } +bool CPickUp::StatusChangeMsg(CStatusChangeMsg *msg) { + _enabled = msg->_newStatus == 1; + setVisible(_enabled); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up.h b/engines/titanic/game/pickup/pick_up.h index f0b6794442..f5ee06fd32 100644 --- a/engines/titanic/game/pickup/pick_up.h +++ b/engines/titanic/game/pickup/pick_up.h @@ -28,11 +28,13 @@ namespace Titanic { class CPickUp : public CGameObject { -private: - int _fieldBC; + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); +protected: + bool _enabled; public: CLASSDEF; - CPickUp() : CGameObject(), _fieldBC(0) {} + CPickUp() : CGameObject(), _enabled(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/pickup/pick_up_bar_glass.cpp b/engines/titanic/game/pickup/pick_up_bar_glass.cpp index 85b883281e..9da17b139e 100644 --- a/engines/titanic/game/pickup/pick_up_bar_glass.cpp +++ b/engines/titanic/game/pickup/pick_up_bar_glass.cpp @@ -21,9 +21,16 @@ */ #include "titanic/game/pickup/pick_up_bar_glass.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPickUpBarGlass, CPickUp) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CPickUpBarGlass::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CPickUp::save(file, indent); @@ -34,4 +41,48 @@ void CPickUpBarGlass::load(SimpleFile *file) { CPickUp::load(file); } +bool CPickUpBarGlass::StatusChangeMsg(CStatusChangeMsg *msg) { + switch (msg->_newStatus) { + case 0: + setVisible(false); + _enabled = false; + break; + case 1: + setVisible(true); + _enabled = true; + break; + case 2: + setVisible(true); + _enabled = false; + break; + default: + break; + } + + return true; +} + +bool CPickUpBarGlass::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (checkStartDragging(msg) && _enabled) { + CTurnOn onMsg; + onMsg.execute("BeerGlass"); + CVisibleMsg visibleMsg; + visibleMsg.execute("BeerGlass"); + CPassOnDragStartMsg passMsg(msg->_mousePos, 1, 3); + passMsg.execute("BeerGlass"); + + msg->_dragItem = getRoot()->findByName("BeerGlass"); + + CActMsg actMsg("PlayerTakesGlass"); + actMsg.execute("Barbot"); + return true; + } else { + return false; + } +} + +bool CPickUpBarGlass::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_bar_glass.h b/engines/titanic/game/pickup/pick_up_bar_glass.h index b5ef6f5a47..d273d96170 100644 --- a/engines/titanic/game/pickup/pick_up_bar_glass.h +++ b/engines/titanic/game/pickup/pick_up_bar_glass.h @@ -28,6 +28,10 @@ namespace Titanic { class CPickUpBarGlass : public CPickUp { + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/pickup/pick_up_hose.cpp b/engines/titanic/game/pickup/pick_up_hose.cpp index 7375ddaa63..d07088cefd 100644 --- a/engines/titanic/game/pickup/pick_up_hose.cpp +++ b/engines/titanic/game/pickup/pick_up_hose.cpp @@ -21,14 +21,24 @@ */ #include "titanic/game/pickup/pick_up_hose.h" +#include "titanic/core/project_item.h" +#include "titanic/core/room_item.h" +#include "titanic/core/view_item.h" namespace Titanic { -int CPickUpHose::_v1; +BEGIN_MESSAGE_MAP(CPickUpHose, CPickUp) + ON_MESSAGE(MouseDragStartMsg) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + +bool CPickUpHose::_v1; void CPickUpHose::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_target, indent); file->writeNumberLine(_v1, indent); CPickUp::save(file, indent); @@ -36,10 +46,61 @@ void CPickUpHose::save(SimpleFile *file, int indent) { void CPickUpHose::load(SimpleFile *file) { file->readNumber(); - _string1 = file->readString(); + _target = file->readString(); _v1 = file->readNumber(); CPickUp::load(file); } +bool CPickUpHose::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkStartDragging(msg)) + return true; + if (_v1 || !_enabled) + return false; + + CViewItem *view = getView(); + if (view) { + _v1 = true; + CRoomItem *room = locateRoom("Arboretum"); + CTreeItem *hose = room ? room->findByName("Hose") : nullptr; + + if (!hose) { + room = locateRoom("FrozenArboretum"); + if (room) + hose = room->findByName("Hose"); + } + + if (hose) { + CVisibleMsg visibleMsg; + visibleMsg.execute(this); + moveUnder(view); + + CPassOnDragStartMsg passMsg(msg->_mousePos, 1); + passMsg.execute("Hose"); + + msg->_dragItem = getRoot()->findByName("Hose"); + _cursorId = CURSOR_IGNORE; + + CActMsg actMsg("PlayerGetsHose"); + actMsg.execute(_target); + } + } + + return true; +} + +bool CPickUpHose::StatusChangeMsg(CStatusChangeMsg *msg) { + _cursorId = msg->_newStatus == 1 ? CURSOR_HAND : CURSOR_IGNORE; + return true; +} + +bool CPickUpHose::EnterViewMsg(CEnterViewMsg *msg) { + _cursorId = CURSOR_IGNORE; + return true; +} + +bool CPickUpHose::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return _enabled; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_hose.h b/engines/titanic/game/pickup/pick_up_hose.h index 80ccedc845..2ad7c2a583 100644 --- a/engines/titanic/game/pickup/pick_up_hose.h +++ b/engines/titanic/game/pickup/pick_up_hose.h @@ -28,10 +28,15 @@ namespace Titanic { class CPickUpHose : public CPickUp { + DECLARE_MESSAGE_MAP; + bool MouseDragStartMsg(CMouseDragStartMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); private: - static int _v1; + static bool _v1; - CString _string1; + CString _target; public: CLASSDEF; diff --git a/engines/titanic/game/pickup/pick_up_lemon.cpp b/engines/titanic/game/pickup/pick_up_lemon.cpp index 772114f76c..5109c36304 100644 --- a/engines/titanic/game/pickup/pick_up_lemon.cpp +++ b/engines/titanic/game/pickup/pick_up_lemon.cpp @@ -21,9 +21,15 @@ */ #include "titanic/game/pickup/pick_up_lemon.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPickUpLemon, CPickUp) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + void CPickUpLemon::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CPickUp::save(file, indent); @@ -34,4 +40,23 @@ void CPickUpLemon::load(SimpleFile *file) { CPickUp::load(file); } +bool CPickUpLemon::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CPickUpLemon::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkStartDragging(msg)) + return true; + if (!_enabled) + return false; + + CVisibleMsg visibleMsg; + visibleMsg.execute("Lemon"); + CPassOnDragStartMsg passMsg(msg->_mousePos, 1); + passMsg.execute("Lemon"); + + msg->_dragItem = getRoot()->findByName("Lemon"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_lemon.h b/engines/titanic/game/pickup/pick_up_lemon.h index 0312c71012..c196acdeaf 100644 --- a/engines/titanic/game/pickup/pick_up_lemon.h +++ b/engines/titanic/game/pickup/pick_up_lemon.h @@ -28,6 +28,9 @@ namespace Titanic { class CPickUpLemon : public CPickUp { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/pickup/pick_up_speech_centre.cpp b/engines/titanic/game/pickup/pick_up_speech_centre.cpp index 0b9a8d2c48..5e99c0a3b7 100644 --- a/engines/titanic/game/pickup/pick_up_speech_centre.cpp +++ b/engines/titanic/game/pickup/pick_up_speech_centre.cpp @@ -21,9 +21,16 @@ */ #include "titanic/game/pickup/pick_up_speech_centre.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPickUpSpeechCentre, CPickUp) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + void CPickUpSpeechCentre::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CPickUp::save(file, indent); @@ -34,4 +41,33 @@ void CPickUpSpeechCentre::load(SimpleFile *file) { CPickUp::load(file); } +bool CPickUpSpeechCentre::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CPickUpSpeechCentre::StatusChangeMsg(CStatusChangeMsg *msg) { + _enabled = msg->_newStatus == 1; + return true; +} + +bool CPickUpSpeechCentre::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (checkStartDragging(msg)) { + if (_enabled) { + CVisibleMsg visibleMsg; + visibleMsg.execute("SpeechCentre"); + CPassOnDragStartMsg passMsg(msg->_mousePos, 1); + passMsg.execute("SpeechCentre"); + + msg->_dragItem = getRoot()->findByName("SpeechCentre"); + + CActMsg actMsg("PlayerGetsSpeechCentre"); + actMsg.execute("SeasonalAdjust"); + } else { + petDisplayMessage("You can't pick this up on account of it being stuck to the branch."); + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_speech_centre.h b/engines/titanic/game/pickup/pick_up_speech_centre.h index 29dce04fb3..81ee0b5d77 100644 --- a/engines/titanic/game/pickup/pick_up_speech_centre.h +++ b/engines/titanic/game/pickup/pick_up_speech_centre.h @@ -28,6 +28,10 @@ namespace Titanic { class CPickUpSpeechCentre : public CPickUp { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/pickup/pick_up_vis_centre.cpp b/engines/titanic/game/pickup/pick_up_vis_centre.cpp index 796e46778c..baf1763d09 100644 --- a/engines/titanic/game/pickup/pick_up_vis_centre.cpp +++ b/engines/titanic/game/pickup/pick_up_vis_centre.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPickUpVisCentre, CPickUp) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + void CPickUpVisCentre::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CPickUp::save(file, indent); @@ -34,4 +39,22 @@ void CPickUpVisCentre::load(SimpleFile *file) { CPickUp::load(file); } + +bool CPickUpVisCentre::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CPickUpVisCentre::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkStartDragging(msg) || !_enabled) + return false; + + setVisible(false); + CVisibleMsg visibleMsg; + visibleMsg.execute("VisionCentre"); + msg->execute("VisionCentre"); + CActMsg actMsg("PlayerTakesVisCentre"); + actMsg.execute("Barbot"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/pickup/pick_up_vis_centre.h b/engines/titanic/game/pickup/pick_up_vis_centre.h index 4f808f73c5..a5f59211d3 100644 --- a/engines/titanic/game/pickup/pick_up_vis_centre.h +++ b/engines/titanic/game/pickup/pick_up_vis_centre.h @@ -28,6 +28,9 @@ namespace Titanic { class CPickUpVisCentre : public CPickUp { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/placeholder/bar_shelf_vis_centre.cpp b/engines/titanic/game/placeholder/bar_shelf_vis_centre.cpp index fc5d680f0c..6e5037f237 100644 --- a/engines/titanic/game/placeholder/bar_shelf_vis_centre.cpp +++ b/engines/titanic/game/placeholder/bar_shelf_vis_centre.cpp @@ -24,7 +24,7 @@ namespace Titanic { -BEGIN_MESSAGE_MAP(CBarShelfVisCentre, CPlaceHolderItem) +BEGIN_MESSAGE_MAP(CBarShelfVisCentre, CPlaceHolder) ON_MESSAGE(MouseButtonDownMsg) ON_MESSAGE(TimerMsg) ON_MESSAGE(EnterViewMsg) @@ -33,13 +33,13 @@ END_MESSAGE_MAP() void CBarShelfVisCentre::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_flag, indent); - CPlaceHolderItem::save(file, indent); + CPlaceHolder::save(file, indent); } void CBarShelfVisCentre::load(SimpleFile *file) { file->readNumber(); _flag = file->readNumber(); - CPlaceHolderItem::load(file); + CPlaceHolder::load(file); } bool CBarShelfVisCentre::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { diff --git a/engines/titanic/game/placeholder/bar_shelf_vis_centre.h b/engines/titanic/game/placeholder/bar_shelf_vis_centre.h index 672655d368..8ad3dcb8d1 100644 --- a/engines/titanic/game/placeholder/bar_shelf_vis_centre.h +++ b/engines/titanic/game/placeholder/bar_shelf_vis_centre.h @@ -23,11 +23,11 @@ #ifndef TITANIC_BAR_SHELF_VIS_CENTRE_H #define TITANIC_BAR_SHELF_VIS_CENTRE_H -#include "titanic/game/placeholder/place_holder_item.h" +#include "titanic/game/placeholder/place_holder.h" namespace Titanic { -class CBarShelfVisCentre : public CPlaceHolderItem { +class CBarShelfVisCentre : public CPlaceHolder { DECLARE_MESSAGE_MAP; bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); bool TimerMsg(CTimerMsg *msg); @@ -36,7 +36,7 @@ private: bool _flag; public: CLASSDEF; - CBarShelfVisCentre() : CPlaceHolderItem(), _flag(false) {} + CBarShelfVisCentre() : CPlaceHolder(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/placeholder/lemon_on_bar.cpp b/engines/titanic/game/placeholder/lemon_on_bar.cpp index 917c751e67..e9cf6a309a 100644 --- a/engines/titanic/game/placeholder/lemon_on_bar.cpp +++ b/engines/titanic/game/placeholder/lemon_on_bar.cpp @@ -24,20 +24,20 @@ namespace Titanic { -BEGIN_MESSAGE_MAP(CLemonOnBar, CPlaceHolderItem) +BEGIN_MESSAGE_MAP(CLemonOnBar, CPlaceHolder) ON_MESSAGE(VisibleMsg) END_MESSAGE_MAP() void CLemonOnBar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writePoint(_lemonPos, indent); - CPlaceHolderItem::save(file, indent); + CPlaceHolder::save(file, indent); } void CLemonOnBar::load(SimpleFile *file) { file->readNumber(); _lemonPos = file->readPoint(); - CPlaceHolderItem::load(file); + CPlaceHolder::load(file); } bool CLemonOnBar::VisibleMsg(CVisibleMsg *msg) { diff --git a/engines/titanic/game/placeholder/lemon_on_bar.h b/engines/titanic/game/placeholder/lemon_on_bar.h index af5d5e67c8..c6512ced67 100644 --- a/engines/titanic/game/placeholder/lemon_on_bar.h +++ b/engines/titanic/game/placeholder/lemon_on_bar.h @@ -23,11 +23,11 @@ #ifndef TITANIC_LEMON_ON_BAR_H #define TITANIC_LEMON_ON_BAR_H -#include "titanic/game/placeholder/place_holder_item.h" +#include "titanic/game/placeholder/place_holder.h" namespace Titanic { -class CLemonOnBar : public CPlaceHolderItem { +class CLemonOnBar : public CPlaceHolder { DECLARE_MESSAGE_MAP; bool VisibleMsg(CVisibleMsg *msg); private: diff --git a/engines/titanic/game/placeholder/place_holder_item.cpp b/engines/titanic/game/placeholder/place_holder.cpp index 365e8cbe50..ae42cabc29 100644 --- a/engines/titanic/game/placeholder/place_holder_item.cpp +++ b/engines/titanic/game/placeholder/place_holder.cpp @@ -20,18 +20,27 @@ * */ -#include "titanic/game/placeholder/place_holder_item.h" +#include "titanic/game/placeholder/place_holder.h" namespace Titanic { -void CPlaceHolderItem::save(SimpleFile *file, int indent) { +BEGIN_MESSAGE_MAP(CPlaceHolder, CGameObject) + ON_MESSAGE(VisibleMsg) +END_MESSAGE_MAP() + +void CPlaceHolder::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); } -void CPlaceHolderItem::load(SimpleFile *file) { +void CPlaceHolder::load(SimpleFile *file) { file->readNumber(); CGameObject::load(file); } +bool CPlaceHolder::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/placeholder/place_holder_item.h b/engines/titanic/game/placeholder/place_holder.h index de04a64bf7..b1aa041710 100644 --- a/engines/titanic/game/placeholder/place_holder_item.h +++ b/engines/titanic/game/placeholder/place_holder.h @@ -27,7 +27,9 @@ namespace Titanic { -class CPlaceHolderItem : public CGameObject { +class CPlaceHolder : public CGameObject { + DECLARE_MESSAGE_MAP; + bool VisibleMsg(CVisibleMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/placeholder/tv_on_bar.cpp b/engines/titanic/game/placeholder/tv_on_bar.cpp index efbbe50461..710b5a346e 100644 --- a/engines/titanic/game/placeholder/tv_on_bar.cpp +++ b/engines/titanic/game/placeholder/tv_on_bar.cpp @@ -24,16 +24,30 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CTVOnBar, CPlaceHolder) + ON_MESSAGE(VisibleMsg) +END_MESSAGE_MAP() + void CTVOnBar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writePoint(_pos1, indent); - CPlaceHolderItem::save(file, indent); + file->writePoint(_tvPos, indent); + CPlaceHolder::save(file, indent); } void CTVOnBar::load(SimpleFile *file) { file->readNumber(); - _pos1 = file->readPoint(); - CPlaceHolderItem::load(file); + _tvPos = file->readPoint(); + CPlaceHolder::load(file); +} + +bool CTVOnBar::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + if (msg->_visible) + setPosition(_tvPos); + else + setPosition(Point(0, 0)); + + return true; } } // End of namespace Titanic diff --git a/engines/titanic/game/placeholder/tv_on_bar.h b/engines/titanic/game/placeholder/tv_on_bar.h index d41d972e73..0157bc8764 100644 --- a/engines/titanic/game/placeholder/tv_on_bar.h +++ b/engines/titanic/game/placeholder/tv_on_bar.h @@ -23,13 +23,15 @@ #ifndef TITANIC_TV_ON_BAR_H #define TITANIC_TV_ON_BAR_H -#include "titanic/game/placeholder/place_holder_item.h" +#include "titanic/game/placeholder/place_holder.h" namespace Titanic { -class CTVOnBar : public CPlaceHolderItem { +class CTVOnBar : public CPlaceHolder { + DECLARE_MESSAGE_MAP; + bool VisibleMsg(CVisibleMsg *msg); private: - Point _pos1; + Point _tvPos; public: CLASSDEF; diff --git a/engines/titanic/game/play_music_button.cpp b/engines/titanic/game/play_music_button.cpp index 8066739f10..21fd3c336a 100644 --- a/engines/titanic/game/play_music_button.cpp +++ b/engines/titanic/game/play_music_button.cpp @@ -21,23 +21,58 @@ */ #include "titanic/game/play_music_button.h" +#include "titanic/sound/music_room.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CPlayMusicButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(FrameMsg) +END_MESSAGE_MAP() + void CPlayMusicButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_flag, indent); + file->writeNumberLine(_ticks, indent); CBackground::save(file, indent); } void CPlayMusicButton::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _flag = file->readNumber(); + _ticks = file->readNumber(); CBackground::load(file); } +bool CPlayMusicButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CMusicRoom *musicRoom = getMusicRoom(); + if (_flag) { + musicRoom->stopMusic(); + stopMovie(); + loadFrame(0); + _flag = false; + } else { + musicRoom->startMusic(100); + playMovie(MOVIE_REPEAT); + _ticks = getTicksCount(); + _flag = true; + } + + return true; +} + +bool CPlayMusicButton::FrameMsg(CFrameMsg *msg) { + if (_flag && !CMusicRoom::_musicHandler->poll()) { + CMusicRoom *musicRoom = getMusicRoom(); + musicRoom->stopMusic(); + stopMovie(); + loadFrame(0); + _flag = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/play_music_button.h b/engines/titanic/game/play_music_button.h index 4e3474181c..824b372bf9 100644 --- a/engines/titanic/game/play_music_button.h +++ b/engines/titanic/game/play_music_button.h @@ -28,12 +28,15 @@ namespace Titanic { class CPlayMusicButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool FrameMsg(CFrameMsg *msg); public: - int _fieldE0; - int _fieldE4; + bool _flag; + uint _ticks; public: CLASSDEF; - CPlayMusicButton() : CBackground(), _fieldE0(0), _fieldE4(0) {} + CPlayMusicButton() : CBackground(), _flag(false), _ticks(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/play_on_act.cpp b/engines/titanic/game/play_on_act.cpp index e1ef1201c6..9c368c335d 100644 --- a/engines/titanic/game/play_on_act.cpp +++ b/engines/titanic/game/play_on_act.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CPlayOnAct, CBackground) + ON_MESSAGE(ActMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + void CPlayOnAct::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBackground::save(file, indent); @@ -34,4 +39,20 @@ void CPlayOnAct::load(SimpleFile *file) { CBackground::load(file); } +bool CPlayOnAct::ActMsg(CActMsg *msg) { + if (msg->_action == "PlayMovie") { + setVisible(true); + playMovie(0); + } else if (msg->_action == "PlayToEnd") { + setVisible(true); + playMovie(MOVIE_GAMESTATE); + } + + return true; +} + +bool CPlayOnAct::LeaveViewMsg(CLeaveViewMsg *msg) { + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/play_on_act.h b/engines/titanic/game/play_on_act.h index 197e647943..72615f2fc4 100644 --- a/engines/titanic/game/play_on_act.h +++ b/engines/titanic/game/play_on_act.h @@ -28,6 +28,9 @@ namespace Titanic { class CPlayOnAct : public CBackground { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/port_hole.cpp b/engines/titanic/game/port_hole.cpp index f3c447f443..25807b1b1d 100644 --- a/engines/titanic/game/port_hole.cpp +++ b/engines/titanic/game/port_hole.cpp @@ -24,26 +24,72 @@ namespace Titanic { -CPortHole::CPortHole() : CGameObject(), _fieldBC(0), - _string1("b#47.wav"), _string2("b#46.wav") { +BEGIN_MESSAGE_MAP(CPortHole, CGameObject) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +CPortHole::CPortHole() : CGameObject(), _open(false), + _closeSoundName("b#47.wav"), _openSoundName("b#46.wav") { } void CPortHole::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldBC, indent); - file->writeQuotedLine(_string1, indent); - file->writeQuotedLine(_string2, indent); + file->writeNumberLine(_open, indent); + file->writeQuotedLine(_closeSoundName, indent); + file->writeQuotedLine(_openSoundName, indent); CGameObject::save(file, indent); } void CPortHole::load(SimpleFile *file) { file->readNumber(); - _fieldBC = file->readNumber(); - _string1 = file->readString(); - _string2 = file->readString(); + _open = file->readNumber(); + _closeSoundName = file->readString(); + _openSoundName = file->readString(); CGameObject::load(file); } +bool CPortHole::ActMsg(CActMsg *msg) { + if (msg->_action == "TogglePortHole") { + if (_open) { + playMovie(14, 26, MOVIE_NOTIFY_OBJECT); + playSound(_closeSoundName); + _open = false; + } else { + setVisible(true); + playMovie(1, 13, 0); + playSound(_openSoundName); + _open = true; + } + } + + return true; +} + +bool CPortHole::MovieEndMsg(CMovieEndMsg *msg) { + _open = false; + setVisible(false); + return true; +} + +bool CPortHole::LeaveViewMsg(CLeaveViewMsg *msg) { + if (_open) { + playSound(_closeSoundName); + playMovie(14, 26, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _open = false; + } + + return true; +} + +bool CPortHole::EnterViewMsg(CEnterViewMsg *msg) { + setVisible(false); + _open = false; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/port_hole.h b/engines/titanic/game/port_hole.h index 7bba18d12a..9f1997a517 100644 --- a/engines/titanic/game/port_hole.h +++ b/engines/titanic/game/port_hole.h @@ -28,9 +28,14 @@ namespace Titanic { class CPortHole : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); private: - int _fieldBC; - CString _string1, _string2; + bool _open; + CString _closeSoundName, _openSoundName; public: CLASSDEF; CPortHole(); diff --git a/engines/titanic/game/record_phonograph_button.cpp b/engines/titanic/game/record_phonograph_button.cpp index f022957dbb..1ffaec4228 100644 --- a/engines/titanic/game/record_phonograph_button.cpp +++ b/engines/titanic/game/record_phonograph_button.cpp @@ -24,16 +24,44 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CRecordPhonographButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(PhonographStopMsg) +END_MESSAGE_MAP() + void CRecordPhonographButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_active, indent); CBackground::save(file, indent); } void CRecordPhonographButton::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _active = file->readNumber(); CBackground::load(file); } +bool CRecordPhonographButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CPhonographRecordMsg recordMsg; + recordMsg.execute(getParent()); + + if (recordMsg._value) { + playSound("z#58.wav"); + loadFrame(1); + _active = true; + } + + return true; +} + +bool CRecordPhonographButton::PhonographStopMsg(CPhonographStopMsg *msg) { + if (_active) { + playSound("z#57.wav"); + loadFrame(0); + _active = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/record_phonograph_button.h b/engines/titanic/game/record_phonograph_button.h index 3383c01e31..985a4c4576 100644 --- a/engines/titanic/game/record_phonograph_button.h +++ b/engines/titanic/game/record_phonograph_button.h @@ -28,11 +28,14 @@ namespace Titanic { class CRecordPhonographButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool PhonographStopMsg(CPhonographStopMsg *msg); public: - int _value; + bool _active; public: CLASSDEF; - CRecordPhonographButton() : CBackground(), _value(0) {} + CRecordPhonographButton() : CBackground(), _active(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/replacement_ear.cpp b/engines/titanic/game/replacement_ear.cpp index 1f9960365d..e8bd384207 100644 --- a/engines/titanic/game/replacement_ear.cpp +++ b/engines/titanic/game/replacement_ear.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CReplacementEar, CBackground) + ON_MESSAGE(VisibleMsg) +END_MESSAGE_MAP() + void CReplacementEar::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBackground::save(file, indent); @@ -34,4 +38,11 @@ void CReplacementEar::load(SimpleFile *file) { CBackground::load(file); } +bool CReplacementEar::VisibleMsg(CVisibleMsg *msg) { + setVisible(true); + playMovie(MOVIE_GAMESTATE); + playSound("z#64.wav"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/replacement_ear.h b/engines/titanic/game/replacement_ear.h index 0d282b7fb4..7775a9631a 100644 --- a/engines/titanic/game/replacement_ear.h +++ b/engines/titanic/game/replacement_ear.h @@ -28,6 +28,8 @@ namespace Titanic { class CReplacementEar : public CBackground { + DECLARE_MESSAGE_MAP; + bool VisibleMsg(CVisibleMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/reserved_table.cpp b/engines/titanic/game/reserved_table.cpp index a600190709..734d53af45 100644 --- a/engines/titanic/game/reserved_table.cpp +++ b/engines/titanic/game/reserved_table.cpp @@ -21,22 +21,55 @@ */ #include "titanic/game/reserved_table.h" +#include "titanic/core/room_item.h" +#include "titanic/core/view_item.h" +#include "titanic/npcs/maitre_d.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CReservedTable, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(PlayerTriesRestaurantTableMsg) +END_MESSAGE_MAP() + void CReservedTable::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value1, indent); - file->writeNumberLine(_value2, indent); + file->writeNumberLine(_flag, indent); + file->writeNumberLine(_tableId, indent); CGameObject::save(file, indent); } void CReservedTable::load(SimpleFile *file) { file->readNumber(); - _value1 = file->readNumber(); - _value2 = file->readNumber(); + _flag = file->readNumber(); + _tableId = file->readNumber(); CGameObject::load(file); } +bool CReservedTable::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (!_flag) { + CPlayerTriesRestaurantTableMsg tryMsg(_tableId, 0); + tryMsg.execute(findRoom(), CReservedTable::_type, MSGFLAG_CLASS_DEF | MSGFLAG_SCAN); + } + + return true; +} + +bool CReservedTable::PlayerTriesRestaurantTableMsg(CPlayerTriesRestaurantTableMsg *msg) { + if (msg->_tableId == _tableId) { + if (!msg->_result) { + CMaitreD *maitreD = dynamic_cast<CMaitreD *>(findRoomObject("MaitreD")); + startTalking(maitreD, 118, maitreD->findView()); + msg->_result = true; + } + + _cursorId = CURSOR_INVALID; + _flag = true; + return true; + } else { + return false; + } +} + } // End of namespace Titanic diff --git a/engines/titanic/game/reserved_table.h b/engines/titanic/game/reserved_table.h index a3532c7d14..bc037ae3d9 100644 --- a/engines/titanic/game/reserved_table.h +++ b/engines/titanic/game/reserved_table.h @@ -28,11 +28,15 @@ namespace Titanic { class CReservedTable : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool PlayerTriesRestaurantTableMsg(CPlayerTriesRestaurantTableMsg *msg); public: - int _value1, _value2; + bool _flag; + int _tableId; public: CLASSDEF; - CReservedTable() : CGameObject(), _value1(0), _value2(0) {} + CReservedTable() : CGameObject(), _flag(false), _tableId(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/restaurant_cylinder_holder.cpp b/engines/titanic/game/restaurant_cylinder_holder.cpp index d70009f151..8726d1a925 100644 --- a/engines/titanic/game/restaurant_cylinder_holder.cpp +++ b/engines/titanic/game/restaurant_cylinder_holder.cpp @@ -24,20 +24,29 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CRestaurantCylinderHolder, CDropTarget) + ON_MESSAGE(EjectCylinderMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(QueryCylinderHolderMsg) + ON_MESSAGE(QueryCylinderNameMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + CRestaurantCylinderHolder::CRestaurantCylinderHolder() : CDropTarget(), _field118(0), _field11C(0), _field12C(0), _field130(0), - _string6("z#61.wav"), _field140(1) { + _ejectSoundName("z#61.wav"), _defaultCursorId(CURSOR_ARROW) { } void CRestaurantCylinderHolder::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_field118, indent); file->writeNumberLine(_field11C, indent); - file->writeQuotedLine(_string5, indent); + file->writeQuotedLine(_target, indent); file->writeNumberLine(_field12C, indent); file->writeNumberLine(_field130, indent); - file->writeQuotedLine(_string6, indent); - file->writeNumberLine(_field140, indent); + file->writeQuotedLine(_ejectSoundName, indent); + file->writeNumberLine(_defaultCursorId, indent); CDropTarget::save(file, indent); } @@ -46,13 +55,98 @@ void CRestaurantCylinderHolder::load(SimpleFile *file) { file->readNumber(); _field118 = file->readNumber(); _field11C = file->readNumber(); - _string5 = file->readString(); + _target = file->readString(); _field12C = file->readNumber(); _field130 = file->readNumber(); - _string6 = file->readString(); - _field140 = file->readNumber(); + _ejectSoundName = file->readString(); + _defaultCursorId = (CursorId)file->readNumber(); CDropTarget::load(file); } +bool CRestaurantCylinderHolder::EjectCylinderMsg(CEjectCylinderMsg *msg) { + _field11C = true; + bool hasCylinder = findByName("Phonograph Cylinder") != nullptr; + + if (_field118) { + playClip(hasCylinder ? "CloseHolder_Full" : "CloseHolder_Empty", + MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _fieldF4 = 1; + } else { + playClip(hasCylinder ? "OpenHolder_Full" : "OpenHolder_Empty", + MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + playSound(_ejectSoundName, 50); + return true; +} + +bool CRestaurantCylinderHolder::EnterViewMsg(CEnterViewMsg *msg) { + if (_field118) { + CTreeItem *cylinder = findByName("Phonograph Cylinder", true); + if (cylinder) { + loadFrame(_dropFrame); + _cursorId = _dropCursorId; + } else { + loadFrame(_dragFrame); + _cursorId = _dragCursorId; + } + } else { + loadFrame(_field130); + _cursorId = _defaultCursorId; + } + + return true; +} + +bool CRestaurantCylinderHolder::MovieEndMsg(CMovieEndMsg *msg) { + _field11C = false; + if (_field118) { + _field118 = false; + _cursorId = _defaultCursorId; + + CPhonographReadyToPlayMsg readyMsg; + readyMsg.execute(_target); + } else { + _field118 = true; + _fieldF4 = false; + _cursorId = findByName("Phonograph Cylinder") ? _dropCursorId : _dragCursorId; + } + + CCylinderHolderReadyMsg holderMsg; + holderMsg.execute(_target); + return true; +} + +bool CRestaurantCylinderHolder::QueryCylinderHolderMsg(CQueryCylinderHolderMsg *msg) { + CNamedItem *cylinder = findByName("Phonograph Cylinder", true); + + msg->_value1 = _field118; + if (cylinder) { + msg->_value2 = 1; + msg->_target = cylinder; + } + + return true; +} + +bool CRestaurantCylinderHolder::QueryCylinderNameMsg(CQueryCylinderNameMsg *msg) { + CNamedItem *cylinder = findByName("Phonograph Cylinder", true); + + if (cylinder) { + CQueryCylinderMsg queryMsg; + queryMsg.execute(cylinder); + msg->_name = queryMsg._name; + } + + return true; +} + +bool CRestaurantCylinderHolder::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (_field118) + return CDropTarget::MouseDragStartMsg(msg); + else + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/restaurant_cylinder_holder.h b/engines/titanic/game/restaurant_cylinder_holder.h index 3aa979b0a5..cd0b0783bd 100644 --- a/engines/titanic/game/restaurant_cylinder_holder.h +++ b/engines/titanic/game/restaurant_cylinder_holder.h @@ -28,14 +28,21 @@ namespace Titanic { class CRestaurantCylinderHolder : public CDropTarget { + DECLARE_MESSAGE_MAP; + bool EjectCylinderMsg(CEjectCylinderMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool QueryCylinderHolderMsg(CQueryCylinderHolderMsg *msg); + bool QueryCylinderNameMsg(CQueryCylinderNameMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); private: int _field118; int _field11C; - CString _string5; + CString _target; int _field12C; int _field130; - CString _string6; - int _field140; + CString _ejectSoundName; + CursorId _defaultCursorId; public: CLASSDEF; CRestaurantCylinderHolder(); diff --git a/engines/titanic/game/restaurant_phonograph.cpp b/engines/titanic/game/restaurant_phonograph.cpp index 83a4ac3e71..881079e020 100644 --- a/engines/titanic/game/restaurant_phonograph.cpp +++ b/engines/titanic/game/restaurant_phonograph.cpp @@ -21,9 +21,20 @@ */ #include "titanic/game/restaurant_phonograph.h" +#include "titanic/core/room_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CRestaurantPhonograph, CPhonograph) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(PhonographPlayMsg) + ON_MESSAGE(PhonographStopMsg) + ON_MESSAGE(PhonographReadyToPlayMsg) + ON_MESSAGE(EjectCylinderMsg) + ON_MESSAGE(QueryPhonographState) + ON_MESSAGE(LockPhonographMsg) +END_MESSAGE_MAP() + CRestaurantPhonograph::CRestaurantPhonograph() : CPhonograph(), _fieldF8(1), _field114(0) {} @@ -48,4 +59,89 @@ void CRestaurantPhonograph::load(SimpleFile *file) { CPhonograph::load(file); } +bool CRestaurantPhonograph::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (!_fieldF8 && !_fieldE0) { + CQueryCylinderHolderMsg holderMsg; + holderMsg.execute(this); + + if (!holderMsg._value1) { + CPhonographPlayMsg playMsg; + playMsg.execute(this); + } else if (holderMsg._value2) { + CEjectCylinderMsg ejectMsg; + ejectMsg.execute(this); + + _fieldE8 = true; + if (_field114) { + loadFrame(_fieldEC); + playSound(_ejectSoundName); + } + } + } + + return true; +} + +bool CRestaurantPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) { + if (_fieldE0) { + if (findView() == getView() && (!_fieldE8 || !_field114)) { + loadFrame(_fieldEC); + playSound(_ejectSoundName); + } + + CQueryCylinderNameMsg nameMsg; + nameMsg.execute(this); + CRestaurantMusicChanged musicMsg(nameMsg._name); + musicMsg.execute(findRoom()); + } else { + loadFrame(_fieldF0); + } + + return true; +} + +bool CRestaurantPhonograph::PhonographStopMsg(CPhonographStopMsg *msg) { + bool flag = _fieldE0; + CPhonograph::PhonographStopMsg(msg); + + if (_fieldE0) { + loadFrame(_fieldF0); + if (flag) + playSound(_string3); + } else { + loadFrame(_fieldEC); + } + + return true; +} + +bool CRestaurantPhonograph::PhonographReadyToPlayMsg(CPhonographReadyToPlayMsg *msg) { + if (_fieldE8) { + CPhonographPlayMsg playMsg; + playMsg.execute(this); + _fieldE8 = false; + } + + return true; +} + +bool CRestaurantPhonograph::EjectCylinderMsg(CEjectCylinderMsg *msg) { + if (_fieldE0) { + CPhonographStopMsg stopMsg; + stopMsg.execute(this); + } + + return true; +} + +bool CRestaurantPhonograph::QueryPhonographState(CQueryPhonographState *msg) { + msg->_value = _fieldF8; + return true; +} + +bool CRestaurantPhonograph::LockPhonographMsg(CLockPhonographMsg *msg) { + _fieldF8 = msg->_value; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/restaurant_phonograph.h b/engines/titanic/game/restaurant_phonograph.h index 710a2edd73..9661df0dfb 100644 --- a/engines/titanic/game/restaurant_phonograph.h +++ b/engines/titanic/game/restaurant_phonograph.h @@ -28,9 +28,17 @@ namespace Titanic { class CRestaurantPhonograph : public CPhonograph { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool PhonographPlayMsg(CPhonographPlayMsg *msg); + bool PhonographStopMsg(CPhonographStopMsg *msg); + bool PhonographReadyToPlayMsg(CPhonographReadyToPlayMsg *msg); + bool EjectCylinderMsg(CEjectCylinderMsg *msg); + bool QueryPhonographState(CQueryPhonographState *msg); + bool LockPhonographMsg(CLockPhonographMsg *msg); private: int _fieldF8; - CString _string2; + CString _ejectSoundName; CString _string3; int _field114; public: diff --git a/engines/titanic/game/sauce_dispensor.cpp b/engines/titanic/game/sauce_dispensor.cpp index 8dc818d917..fda7082ba6 100644 --- a/engines/titanic/game/sauce_dispensor.cpp +++ b/engines/titanic/game/sauce_dispensor.cpp @@ -21,9 +21,20 @@ */ #include "titanic/game/sauce_dispensor.h" +#include "titanic/carry/chicken.h" +#include "titanic/carry/glass.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CSauceDispensor, CBackground) + ON_MESSAGE(Use) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(ActMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(StatusChangeMsg) +END_MESSAGE_MAP() + CSauceDispensor::CSauceDispensor() : CBackground(), _fieldEC(0), _fieldF0(0), _field104(0), _field108(0) { } @@ -54,4 +65,105 @@ void CSauceDispensor::load(SimpleFile *file) { CBackground::load(file); } +bool CSauceDispensor::Use(CUse *msg) { + CVisibleMsg visibleMsg(true); + + if (msg->_item->isEquals("Chicken")) { + CChicken *chicken = static_cast<CChicken *>(msg->_item); + _field104 = true; + if (_fieldF0) { + playSound("b#15.wav", 50); + + if (chicken->_string6 != "None") { + petDisplayMessage(1, "This foodstuff is already sufficiently garnished."); + msg->execute("Chicken"); + } else { + setVisible(true); + if (chicken->_field12C) { + playMovie(_pos1.x, _pos1.y, MOVIE_NOTIFY_OBJECT); + } else { + CActMsg actMsg(_string3); + actMsg.execute("Chicken"); + playMovie(_pos2.x, _pos2.y, MOVIE_NOTIFY_OBJECT); + } + } + + if (_fieldF0) + return true; + } + + CMovieEndMsg endMsg(0, 0); + endMsg.execute(this); + playSound("z#120.wav"); + + petDisplayMessage(1, "Sadly, this dispenser is currently empty."); + } else if (msg->_item->isEquals("BeerGlass")) { + CGlass *glass = dynamic_cast<CGlass *>(msg->_item); + _field108 = true; + + if (_field104 || _fieldF0) { + petAddToInventory(); + } else if (glass->_string6 != "None") { + visibleMsg.execute("BeerGlass"); + } else if (_fieldEC) { + glass->setPosition(Point( + _bounds.left + (_bounds.width() / 2) - (glass->_bounds.width() / 2), + 300)); + setVisible(true); + + CActMsg actMsg(_string3); + actMsg.execute("BeerGlass"); + } + } + + return true; +} + +bool CSauceDispensor::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(false); + _fieldEC = false; + + CActMsg actMsg("GoToPET"); + if (_field104) + actMsg.execute("Chicken"); + if (_field108) + actMsg.execute("BeerGlass"); + + _field104 = false; + _field108 = false; + return true; +} + +bool CSauceDispensor::ActMsg(CActMsg *msg) { + if (msg->_action == "StarlingsDead") + _fieldF0 = true; + + return true; +} + +bool CSauceDispensor::LeaveViewMsg(CLeaveViewMsg *msg) { + setVisible(false); + loadFrame(0); + + if (_field108) { + CGameObject *glass = findRoomObject("Beerglass"); + if (glass) + glass->petAddToInventory(); + } + + _field104 = false; + _field108 = false; + return true; +} + +bool CSauceDispensor::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + petDisplayMessage(1, "Please place food source beneath dispenser for sauce delivery."); + return true; +} + +bool CSauceDispensor::StatusChangeMsg(CStatusChangeMsg *msg) { + petDisplayMessage(1, "Please place food source beneath dispenser for sauce delivery."); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sauce_dispensor.h b/engines/titanic/game/sauce_dispensor.h index aa177050d5..f8021f368b 100644 --- a/engines/titanic/game/sauce_dispensor.h +++ b/engines/titanic/game/sauce_dispensor.h @@ -28,6 +28,13 @@ namespace Titanic { class CSauceDispensor : public CBackground { + DECLARE_MESSAGE_MAP; + bool Use(CUse *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool ActMsg(CActMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); public: CString _string3; int _fieldEC; diff --git a/engines/titanic/game/search_point.cpp b/engines/titanic/game/search_point.cpp index f60a3132b7..bbe923267a 100644 --- a/engines/titanic/game/search_point.cpp +++ b/engines/titanic/game/search_point.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSearchPoint, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CSearchPoint::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value, indent); @@ -36,4 +40,21 @@ void CSearchPoint::load(SimpleFile *file) { CGameObject::load(file); } +bool CSearchPoint::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_value > 0) { + CGameObject *child = dynamic_cast<CGameObject *>(getFirstChild()); + if (child) { + child->petAddToInventory(); + CVisibleMsg visibleMsg(true); + visibleMsg.execute(child->getName()); + playSound("z#47.wav"); + } + + if (--_value == 0) + _cursorId = CURSOR_ARROW; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/search_point.h b/engines/titanic/game/search_point.h index 3c5639b104..421f272804 100644 --- a/engines/titanic/game/search_point.h +++ b/engines/titanic/game/search_point.h @@ -28,6 +28,8 @@ namespace Titanic { class CSearchPoint : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: int _value; public: diff --git a/engines/titanic/game/season_background.cpp b/engines/titanic/game/season_background.cpp index 1c63f3d892..20ad6aca1d 100644 --- a/engines/titanic/game/season_background.cpp +++ b/engines/titanic/game/season_background.cpp @@ -24,28 +24,113 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSeasonBackground, CBackground) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + CSeasonBackground::CSeasonBackground() : CBackground(), - _fieldE0(0), _fieldE4(0), _fieldE8(46), _fieldEC(0) { + _seasonNum(SEASON_SUMMER), _flag(false), _defaultFrame(46), _unused(0) { } void CSeasonBackground::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); - file->writeNumberLine(_fieldEC, indent); + file->writeNumberLine(_seasonNum, indent); + file->writeNumberLine(_flag, indent); + file->writeNumberLine(_defaultFrame, indent); + file->writeNumberLine(_unused, indent); CBackground::save(file, indent); } void CSeasonBackground::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); - _fieldEC = file->readNumber(); + _seasonNum = (Season)file->readNumber(); + _flag = file->readNumber(); + _defaultFrame = file->readNumber(); + _unused = file->readNumber(); CBackground::load(file); } +bool CSeasonBackground::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_defaultFrame); + return true; +} + +bool CSeasonBackground::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _seasonNum = (Season)(((int)_seasonNum + 1) % 4); + + switch (_seasonNum) { + case SEASON_SUMMER: + playMovie(0, 45, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 45; + break; + + case SEASON_AUTUMN: + if (_flag) { + playMovie(232, 278, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 278; + } else { + playMovie(45, 91, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 91; + } + break; + + case SEASON_WINTER: + if (_flag) { + playMovie(278, 326, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 326; + } else { + CStatusChangeMsg changeMsg; + changeMsg._newStatus = 0; + changeMsg.execute("PickUpSpeechCentre"); + playMovie(91, 139, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 139; + } + break; + + case SEASON_SPRING: + if (_flag) { + playMovie(326, 417, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 417; + } else { + playMovie(139, 228, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + _defaultFrame = 228; + } + break; + + default: + break; + } + + return true; +} + +bool CSeasonBackground::MovieEndMsg(CMovieEndMsg *msg) { + if (msg->_endFrame == _defaultFrame) { + CTurnOn onMsg; + onMsg.execute("SeasonalAdjust"); + } + + if (msg->_endFrame == 91 && !_flag) { + CStatusChangeMsg changeMsg; + changeMsg.execute("PickUpSpeechCentre"); + } + + return true; +} + +bool CSeasonBackground::ActMsg(CActMsg *msg) { + if (msg->_action == "PlayerGetsSpeechCentre") { + loadFrame(278); + _defaultFrame = 278; + _flag = true; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/season_background.h b/engines/titanic/game/season_background.h index f0fd2cdc63..d30fd7aedc 100644 --- a/engines/titanic/game/season_background.h +++ b/engines/titanic/game/season_background.h @@ -28,11 +28,16 @@ namespace Titanic { class CSeasonBackground : public CBackground { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool ActMsg(CActMsg *msg); public: - int _fieldE0; - int _fieldE4; - int _fieldE8; - int _fieldEC; + Season _seasonNum; + bool _flag; + int _defaultFrame; + int _unused; public: CLASSDEF; CSeasonBackground(); diff --git a/engines/titanic/game/season_barrel.cpp b/engines/titanic/game/season_barrel.cpp index 9594396885..e08cdf323b 100644 --- a/engines/titanic/game/season_barrel.cpp +++ b/engines/titanic/game/season_barrel.cpp @@ -24,19 +24,38 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSeasonBarrel, CBackground) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + void CSeasonBarrel::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_unused, indent); + file->writeNumberLine(_startFrame, indent); CBackground::save(file, indent); } void CSeasonBarrel::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _unused = file->readNumber(); + _startFrame = file->readNumber(); CBackground::load(file); } +bool CSeasonBarrel::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + if (_startFrame >= 28) + _startFrame = 0; + + playMovie(_startFrame, _startFrame + 7, 0); + _startFrame += 7; + return true; +} + +bool CSeasonBarrel::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_startFrame); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/season_barrel.h b/engines/titanic/game/season_barrel.h index f77864599d..6296b6f7b1 100644 --- a/engines/titanic/game/season_barrel.h +++ b/engines/titanic/game/season_barrel.h @@ -28,12 +28,15 @@ namespace Titanic { class CSeasonBarrel : public CBackground { + DECLARE_MESSAGE_MAP; + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); public: - int _fieldE0; - int _fieldE4; + int _unused; + int _startFrame; public: CLASSDEF; - CSeasonBarrel() : CBackground(), _fieldE0(0), _fieldE4(7) {} + CSeasonBarrel() : CBackground(), _unused(0), _startFrame(7) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/seasonal_adjustment.cpp b/engines/titanic/game/seasonal_adjustment.cpp index 33a0ae89c5..1f1cb88afb 100644 --- a/engines/titanic/game/seasonal_adjustment.cpp +++ b/engines/titanic/game/seasonal_adjustment.cpp @@ -21,9 +21,20 @@ */ #include "titanic/game/seasonal_adjustment.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CSeasonalAdjustment, CBackground) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + void CSeasonalAdjustment::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); @@ -40,4 +51,86 @@ void CSeasonalAdjustment::load(SimpleFile *file) { CBackground::load(file); } +bool CSeasonalAdjustment::StatusChangeMsg(CStatusChangeMsg *msg) { + CChangeSeasonMsg changeMsg; + switch (stateGetSeason()) { + case SEASON_SUMMER: + changeMsg._season = "Summer"; + break; + case SEASON_AUTUMN: + changeMsg._season = "Autumn"; + break; + case SEASON_WINTER: + changeMsg._season = "Winter"; + break; + case SEASON_SPRING: + changeMsg._season = "Spring"; + break; + default: + break; + } + + changeMsg.execute(getRoot(), nullptr, MSGFLAG_SCAN); + return true; +} + +bool CSeasonalAdjustment::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CSeasonalAdjustment::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + playSound("z#42.wav"); + if (!_fieldE4) { + petDisplayMessage(1, "The Seasonal Adjustment switch is not operational at the present time."); + } else if (!_fieldE0) { + playMovie(0, 6, MOVIE_NOTIFY_OBJECT); + playMovie(6, 18, 0); + } + + return true; +} + +bool CSeasonalAdjustment::MovieEndMsg(CMovieEndMsg *msg) { + if (msg->_endFrame == 6) { + stateChangeSeason(); + CStatusChangeMsg changeMsg; + changeMsg.execute(this); + CTurnOff offMsg; + offMsg.execute(this); + offMsg.execute("LeftPanExit"); + offMsg.execute("RightPanExit"); + } + + return true; +} + +bool CSeasonalAdjustment::TurnOn(CTurnOn *msg) { + if (_fieldE0) { + _fieldE0 = false; + CTurnOn onMsg; + onMsg.execute("LeftPanExit"); + onMsg.execute("RightPanExit"); + } + + return true; +} + +bool CSeasonalAdjustment::TurnOff(CTurnOff *msg) { + _fieldE0 = true; + return true; +} + +bool CSeasonalAdjustment::ActMsg(CActMsg *msg) { + if (msg->_action == "PlayerGetsSpeechCentre") { + msg->execute("SeasonBackground"); + msg->execute("ArbGate"); + } else if (msg->_action == "EnableObject") { + _fieldE4 = true; + } else if (msg->_action == "DisableObject") { + _fieldE4 = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/seasonal_adjustment.h b/engines/titanic/game/seasonal_adjustment.h index f96c13619d..4b7ef3d4f6 100644 --- a/engines/titanic/game/seasonal_adjustment.h +++ b/engines/titanic/game/seasonal_adjustment.h @@ -27,15 +27,16 @@ namespace Titanic { -enum Season { - SPRING = 0, - SUMMER = 1, - AUTUMN = 2, - WINTER = 3 -}; - class CSeasonalAdjustment : public CBackground { -public: + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool ActMsg(CActMsg *msg); +private: int _fieldE0; int _fieldE4; public: diff --git a/engines/titanic/game/service_elevator_window.cpp b/engines/titanic/game/service_elevator_window.cpp index 95b2735b37..b0cc53abb4 100644 --- a/engines/titanic/game/service_elevator_window.cpp +++ b/engines/titanic/game/service_elevator_window.cpp @@ -21,9 +21,19 @@ */ #include "titanic/game/service_elevator_window.h" +#include "titanic/core/room_item.h" +#include "titanic/npcs/doorbot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CServiceElevatorWindow, CBackground) + ON_MESSAGE(ServiceElevatorFloorChangeMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +static const int FACTORS[4] = { 0, 20, 100, 0 }; + CServiceElevatorWindow::CServiceElevatorWindow() : CBackground(), _fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0) { } @@ -48,4 +58,57 @@ void CServiceElevatorWindow::load(SimpleFile *file) { CBackground::load(file); } +bool CServiceElevatorWindow::ServiceElevatorFloorChangeMsg(CServiceElevatorFloorChangeMsg *msg) { + if (getView() == findView()) { + CDoorbot *doorbot = dynamic_cast<CDoorbot *>(findRoom()->findByName("Doorbot")); + int val = (_fieldE8 && doorbot) ? 65 : 15; + CMovieClip *clip = _movieClips.findByName("Going Up"); + + if (!clip) + return true; + + int count = _endFrame - _startFrame; + setMovieFrameRate(1.0 * count / val); + + int startFrame = clip->_startFrame + count * FACTORS[msg->_value1] / 100; + int endFrame = clip->_startFrame + count * FACTORS[msg->_value2] / 100; + + if (_fieldE4) { + playMovie(startFrame, endFrame, MOVIE_NOTIFY_OBJECT); + } else { + playMovie(startFrame, endFrame, 0); + if (_fieldEC) + playClip("Into Space"); + } + } + + _fieldE0 = msg->_value2; + return true; +} + +bool CServiceElevatorWindow::MovieEndMsg(CMovieEndMsg *msg) { + CServiceElevatorMsg elevMsg(5); + elevMsg.execute(findRoom()->findByName("Service Elevator Entity")); + return true; +} + +bool CServiceElevatorWindow::EnterViewMsg(CEnterViewMsg *msg) { + if (_fieldEC) { + playClip("Fade Up"); + playMovie(1, 2, 0); + } else { + CMovieClip *clip = _movieClips.findByName("Going Up"); + + if (clip) { + int frameNum = clip->_startFrame + (clip->_endFrame - clip->_startFrame) + * FACTORS[_fieldE0] / 100; + loadFrame(frameNum); + } else { + loadFrame(0); + } + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/service_elevator_window.h b/engines/titanic/game/service_elevator_window.h index 4233b8405a..88e1663aba 100644 --- a/engines/titanic/game/service_elevator_window.h +++ b/engines/titanic/game/service_elevator_window.h @@ -28,6 +28,10 @@ namespace Titanic { class CServiceElevatorWindow : public CBackground { + DECLARE_MESSAGE_MAP; + bool ServiceElevatorFloorChangeMsg(CServiceElevatorFloorChangeMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); public: int _fieldE0; int _fieldE4; diff --git a/engines/titanic/game/sgt/bedhead.cpp b/engines/titanic/game/sgt/bedhead.cpp index f911a83ae3..216d22ee71 100644 --- a/engines/titanic/game/sgt/bedhead.cpp +++ b/engines/titanic/game/sgt/bedhead.cpp @@ -43,7 +43,7 @@ void BedheadEntry::load(Common::SeekableReadStream *s) { void BedheadEntries::load(Common::SeekableReadStream *s, int count) { resize(count); - for (uint idx = 0; idx < count; ++idx) + for (int idx = 0; idx < count; ++idx) (*this)[idx].load(s); } diff --git a/engines/titanic/game/sgt/sgt_doors.cpp b/engines/titanic/game/sgt/sgt_doors.cpp index 516b0f1351..71eae9800c 100644 --- a/engines/titanic/game/sgt/sgt_doors.cpp +++ b/engines/titanic/game/sgt/sgt_doors.cpp @@ -21,13 +21,21 @@ */ #include "titanic/game/sgt/sgt_doors.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTDoors, CGameObject) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(LeaveRoomMsg) +END_MESSAGE_MAP() + void CSGTDoors::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value1, indent); - file->writeNumberLine(_value2, indent); + file->writeNumberLine(_open, indent); CGameObject::save(file, indent); } @@ -35,9 +43,58 @@ void CSGTDoors::save(SimpleFile *file, int indent) { void CSGTDoors::load(SimpleFile *file) { file->readNumber(); _value1 = file->readNumber(); - _value2 = file->readNumber(); + _open = file->readNumber(); CGameObject::load(file); } +bool CSGTDoors::EnterViewMsg(CEnterViewMsg *msg) { + setVisible(true); + _open = true; + CPetControl *pet = getPetControl(); + + if (pet) { + int roomNum = pet->getRoomsRoomNum(); + static const int START_FRAMES[7] = { 0, 26, 30, 34, 38, 42, 46 }; + static const int END_FRAMES[7] = { 12, 29, 33, 37, 41, 45, 49 }; + + if (pet->getRooms1CC() == 1) + playMovie(START_FRAMES[roomNum], END_FRAMES[roomNum], + MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + else + playMovie(0, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + return true; +} + +bool CSGTDoors::LeaveViewMsg(CLeaveViewMsg *msg) { + return true; +} + +bool CSGTDoors::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(!_open); + return true; +} + +bool CSGTDoors::LeaveRoomMsg(CLeaveRoomMsg *msg) { + setVisible(true); + _open = false; + CPetControl *pet = getPetControl(); + + if (pet) { + int roomNum = pet->getRoomsRoomNum(); + static const int START_FRAMES[7] = { 12, 69, 65, 61, 57, 53, 49 }; + static const int END_FRAMES[7] = { 25, 72, 68, 64, 60, 56, 52 }; + + if (pet->getRooms1CC() == 1) + playMovie(START_FRAMES[roomNum], END_FRAMES[roomNum], + MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + else + playMovie(12, 25, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_doors.h b/engines/titanic/game/sgt/sgt_doors.h index 4b4f4a3153..b19c5860af 100644 --- a/engines/titanic/game/sgt/sgt_doors.h +++ b/engines/titanic/game/sgt/sgt_doors.h @@ -28,11 +28,17 @@ namespace Titanic { class CSGTDoors : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); public: - int _value1, _value2; + int _value1; + bool _open; public: CLASSDEF; - CSGTDoors() : CGameObject(), _value1(0), _value2(0) {} + CSGTDoors() : CGameObject(), _value1(0), _open(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/sgt/sgt_nav.cpp b/engines/titanic/game/sgt/sgt_nav.cpp index f98e486fd0..c004f947d2 100644 --- a/engines/titanic/game/sgt/sgt_nav.cpp +++ b/engines/titanic/game/sgt/sgt_nav.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(SGTNav, CSGTStateRoom) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseMoveMsg) +END_MESSAGE_MAP() + void SGTNav::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +39,43 @@ void SGTNav::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool SGTNav::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CTurnOn onMsg; + CTurnOff offMsg; + + if (_statics->_v6 == "Open" && _statics->_v1 == "Open") { + if (_statics->_v3 == "Open") + offMsg.execute("Vase"); + if (_statics->_v4 == "Closed") + onMsg.execute("SGTTV"); + if (_statics->_v7 == "Open") + offMsg.execute("Drawer"); + if (_statics->_v8 == "Open") + offMsg.execute("Armchair"); + if (_statics->_v9 == "Open") + offMsg.execute("Deskchair"); + if (_statics->_v12 == "Open") + offMsg.execute("Toilet"); + + changeView("SGTState.Node 2.E"); + } else if (_statics->_v1 == "Open") { + petDisplayMessage(1, "This is your stateroom. It is for sleeping. If you desire " + "entertainment or relaxation, please visit your local leisure lounge."); + } else if (_statics->_v6 == "Closed") { + petDisplayMessage(1, "The bed will not currently support your weight." + " We are working on this problem but are unlikely to be able to fix it."); + } + + return true; +} + +bool SGTNav::MouseMoveMsg(CMouseMoveMsg *msg) { + if (_statics->_v6 == "Open" && _statics->_v1 == "Open") + _cursorId = CURSOR_MOVE_FORWARD; + else + _cursorId = CURSOR_ARROW; + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_nav.h b/engines/titanic/game/sgt/sgt_nav.h index 40fdc4eff1..78f6417229 100644 --- a/engines/titanic/game/sgt/sgt_nav.h +++ b/engines/titanic/game/sgt/sgt_nav.h @@ -28,6 +28,9 @@ namespace Titanic { class SGTNav : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseMoveMsg(CMouseMoveMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sgt/sgt_navigation.cpp b/engines/titanic/game/sgt/sgt_navigation.cpp index 7bb64f934d..031226226f 100644 --- a/engines/titanic/game/sgt/sgt_navigation.cpp +++ b/engines/titanic/game/sgt/sgt_navigation.cpp @@ -21,9 +21,16 @@ */ #include "titanic/game/sgt/sgt_navigation.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTNavigation, CGameObject) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + CSGTNavigationStatics *CSGTNavigation::_statics; void CSGTNavigation::init() { @@ -36,7 +43,7 @@ void CSGTNavigation::deinit() { void CSGTNavigation::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_statics->_changeViewFlag, indent); + file->writeNumberLine(_statics->_changeViewNum, indent); file->writeQuotedLine(_statics->_destView, indent); file->writeQuotedLine(_statics->_destRoom, indent); @@ -45,11 +52,79 @@ void CSGTNavigation::save(SimpleFile *file, int indent) { void CSGTNavigation::load(SimpleFile *file) { file->readNumber(); - _statics->_changeViewFlag = file->readNumber(); + _statics->_changeViewNum = file->readNumber(); _statics->_destView = file->readString(); _statics->_destRoom = file->readString(); CGameObject::load(file); } +bool CSGTNavigation::StatusChangeMsg(CStatusChangeMsg *msg) { + CPetControl *pet = getPetControl(); + + if (isEquals("SGTLL")) { + static const int FRAMES[7] = { 0, 149, 112, 74, 0, 36, 74 }; + _statics->_changeViewNum = msg->_newStatus; + if (pet->getRooms1CC() != _statics->_changeViewNum) { + changeView("SGTLittleLift.Node 1.N"); + } + + int startVal = pet->getRooms1CC(); + if (startVal > _statics->_changeViewNum) + playMovie(FRAMES[startVal], FRAMES[_statics->_changeViewNum], MOVIE_GAMESTATE); + else + playMovie(FRAMES[startVal + 3], FRAMES[_statics->_changeViewNum + 3], MOVIE_GAMESTATE); + + _cursorId = _statics->_changeViewNum != 1 ? CURSOR_MOVE_FORWARD : CURSOR_INVALID; + + pet->setRooms1CC(_statics->_changeViewNum); + pet->resetRoomsHighlight(); + } + + return true; +} + +bool CSGTNavigation::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (compareRoomNameTo("SgtLobby")) { + _statics->_destView = getRoomNodeName(); + _statics->_destRoom = "SgtLobby"; + changeView("SGTState.Node 1.S"); + } else if (compareRoomNameTo("SGTLittleLift")) { + if (_statics->_changeViewNum != 1) { + _statics->_destRoom = "SGTLittleLift"; + changeView("SGTState.Node 1.S"); + } + } else if (compareRoomNameTo("SGTState")) { + if (_statics->_destRoom == "SgtLobby") { + if (compareViewNameTo("SGTState.Node 2.N")) { + changeView("SGTState.Node 1.N"); + _statics->_destView += ".S"; + } else { + _statics->_destView += ".N"; + } + + changeView(_statics->_destView); + } else if (_statics->_destRoom == "SGTLittleLift") { + if (compareViewNameTo("SGTState.Node 1.S")) { + changeView("SGTLittleLift.Node 1.N"); + } else { + changeView("SGTState.Node 1.N"); + changeView("SGTLittleLift.Node 1.S"); + } + } + } + + return true; +} + +bool CSGTNavigation::EnterViewMsg(CEnterViewMsg *msg) { + if (isEquals("SGTLL")) { + static const int FRAMES[3] = { 0, 36, 74 }; + CPetControl *pet = getPetControl(); + loadFrame(FRAMES[pet->getRooms1CC() - 1]); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_navigation.h b/engines/titanic/game/sgt/sgt_navigation.h index ed58d918e9..69ecd1267a 100644 --- a/engines/titanic/game/sgt/sgt_navigation.h +++ b/engines/titanic/game/sgt/sgt_navigation.h @@ -28,12 +28,16 @@ namespace Titanic { struct CSGTNavigationStatics { - bool _changeViewFlag; + int _changeViewNum; CString _destView; CString _destRoom; }; class CSGTNavigation : public CGameObject { + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); protected: static CSGTNavigationStatics *_statics; public: diff --git a/engines/titanic/game/sgt/sgt_restaurant_doors.cpp b/engines/titanic/game/sgt/sgt_restaurant_doors.cpp index 74a71e75b2..5c36ceb0ff 100644 --- a/engines/titanic/game/sgt/sgt_restaurant_doors.cpp +++ b/engines/titanic/game/sgt/sgt_restaurant_doors.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTRestaurantDoors, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CSGTRestaurantDoors::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldBC, indent); @@ -36,4 +40,10 @@ void CSGTRestaurantDoors::load(SimpleFile *file) { CGameObject::load(file); } +bool CSGTRestaurantDoors::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CTurnOff offMsg; + offMsg.execute("ChickenDispenser"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_restaurant_doors.h b/engines/titanic/game/sgt/sgt_restaurant_doors.h index 2a10d8f059..bcaaa71014 100644 --- a/engines/titanic/game/sgt/sgt_restaurant_doors.h +++ b/engines/titanic/game/sgt/sgt_restaurant_doors.h @@ -28,6 +28,8 @@ namespace Titanic { class CSGTRestaurantDoors : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); private: int _fieldBC; public: diff --git a/engines/titanic/game/sgt/sgt_state_control.cpp b/engines/titanic/game/sgt/sgt_state_control.cpp index 07c1f5efc0..9617f2f127 100644 --- a/engines/titanic/game/sgt/sgt_state_control.cpp +++ b/engines/titanic/game/sgt/sgt_state_control.cpp @@ -24,16 +24,59 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTStateControl, CBackground) + ON_MESSAGE(PETUpMsg) + ON_MESSAGE(PETDownMsg) + ON_MESSAGE(PETActivateMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + void CSGTStateControl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); + file->writeNumberLine(_state, indent); CBackground::save(file, indent); } void CSGTStateControl::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); + _state = file->readNumber(); CBackground::load(file); } +bool CSGTStateControl::PETUpMsg(CPETUpMsg *msg) { + // WORKAROUND: Redundant code in original not included + return true; +} + +bool CSGTStateControl::PETDownMsg(CPETDownMsg *msg) { + // WORKAROUND: Redundant code in original not included + return true; +} + +bool CSGTStateControl::PETActivateMsg(CPETActivateMsg *msg) { + if (msg->_name == "SGTSelector") { + static const char *const TARGETS[] = { + "Vase", "Bedfoot", "Toilet", "Drawer", "SGTTV", "Armchair", "BedHead", + "WashStand", "Desk", "DeskChair", "Basin", "ChestOfDrawers" + }; + _state = msg->_numValue; + CActMsg actMsg; + actMsg.execute(TARGETS[_state]); + } + + return true; +} + +bool CSGTStateControl::EnterViewMsg(CEnterViewMsg *msg) { + _state = 1; + petSetRemoteTarget(); + return true; +} + +bool CSGTStateControl::LeaveViewMsg(CLeaveViewMsg *msg) { + petClear(); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_state_control.h b/engines/titanic/game/sgt/sgt_state_control.h index 49fd5113cd..6f96359761 100644 --- a/engines/titanic/game/sgt/sgt_state_control.h +++ b/engines/titanic/game/sgt/sgt_state_control.h @@ -24,15 +24,22 @@ #define TITANIC_SGT_STATE_CONTROL_H #include "titanic/core/background.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CSGTStateControl : public CBackground { + DECLARE_MESSAGE_MAP; + bool PETUpMsg(CPETUpMsg *msg); + bool PETDownMsg(CPETDownMsg *msg); + bool PETActivateMsg(CPETActivateMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); private: - int _fieldE0; + int _state; public: CLASSDEF; - CSGTStateControl() : CBackground(), _fieldE0(1) {} + CSGTStateControl() : CBackground(), _state(1) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/sgt/sgt_tv.cpp b/engines/titanic/game/sgt/sgt_tv.cpp index ae4c59e2f9..08ed381b2b 100644 --- a/engines/titanic/game/sgt/sgt_tv.cpp +++ b/engines/titanic/game/sgt/sgt_tv.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSGTTV, CSGTStateRoom) + ON_MESSAGE(TurnOff) + ON_MESSAGE(TurnOn) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CSGTTV::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,35 @@ void CSGTTV::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CSGTTV::TurnOff(CTurnOff *msg) { + if (CSGTStateRoom::_statics->_v4 == "Open") { + CSGTStateRoom::_statics->_v4 = "Closed"; + _fieldE0 = true; + _startFrame = 6; + _endFrame = 12; + playMovie(6, 12, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + return true; +} + +bool CSGTTV::TurnOn(CTurnOn *msg) { + if (CSGTStateRoom::_statics->_v4 == "Closed" && + CSGTStateRoom::_statics->_v2 == "Closed") { + CSGTStateRoom::_statics->_v4 = "Open"; + setVisible(true); + _fieldE0 = false; + _startFrame = 1; + _endFrame = 6; + playMovie(1, 6, MOVIE_GAMESTATE); + } + + return true; +} + +bool CSGTTV::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(false); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/sgt_tv.h b/engines/titanic/game/sgt/sgt_tv.h index 90fed90efe..e5de38e84b 100644 --- a/engines/titanic/game/sgt/sgt_tv.h +++ b/engines/titanic/game/sgt/sgt_tv.h @@ -28,6 +28,10 @@ namespace Titanic { class CSGTTV : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOff(CTurnOff *msg); + bool TurnOn(CTurnOn *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sgt/toilet.cpp b/engines/titanic/game/sgt/toilet.cpp index 799abd6c76..b8e87b645a 100644 --- a/engines/titanic/game/sgt/toilet.cpp +++ b/engines/titanic/game/sgt/toilet.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CToilet, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CToilet::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,42 @@ void CToilet::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CToilet::TurnOn(CTurnOn *msg) { + if (CSGTStateRoom::_statics->_v12 == "Closed" + && CSGTStateRoom::_statics->_v10 == "Open" + && CSGTStateRoom::_statics->_v8 == "Closed") { + setVisible(true); + CSGTStateRoom::_statics->_v12 = "Open"; + + _fieldE0 = false; + _startFrame = 0; + _endFrame = 11; + playMovie(0, 11, MOVIE_GAMESTATE); + playSound("b#1.wav"); + } + + return true; +} + +bool CToilet::TurnOff(CTurnOff *msg) { + if (CSGTStateRoom::_statics->_v12 == "Open") { + CSGTStateRoom::_statics->_v12 = "Closed"; + + _fieldE0 = true; + _startFrame = 11; + _endFrame = 18; + playMovie(11, 18, MOVIE_GAMESTATE); + playSound("b#1.wav"); + } + + return true; +} + +bool CToilet::MovieEndMsg(CMovieEndMsg *msg) { + if (CSGTStateRoom::_statics->_v12 == "Closed") + setVisible(false); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/toilet.h b/engines/titanic/game/sgt/toilet.h index d87531ad7a..a4bc318fb2 100644 --- a/engines/titanic/game/sgt/toilet.h +++ b/engines/titanic/game/sgt/toilet.h @@ -28,6 +28,10 @@ namespace Titanic { class CToilet : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sgt/vase.cpp b/engines/titanic/game/sgt/vase.cpp index 3e04b5db9e..2d37818340 100644 --- a/engines/titanic/game/sgt/vase.cpp +++ b/engines/titanic/game/sgt/vase.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CVase, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CVase::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,38 @@ void CVase::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CVase::TurnOn(CTurnOn *msg) { + if (CSGTStateRoom::_statics->_v3 == "Closed") { + CSGTStateRoom::_statics->_v3 = "Open"; + setVisible(true); + _fieldE0 = false; + _startFrame = 1; + _endFrame = 12; + playMovie(1, 12, MOVIE_GAMESTATE); + } + + return true; +} + +bool CVase::TurnOff(CTurnOff *msg) { + if (CSGTStateRoom::_statics->_v3 == "Open" + && CSGTStateRoom::_statics->_v1 != "RestingV" + && CSGTStateRoom::_statics->_v1 != "RestingUV") { + CSGTStateRoom::_statics->_v3 = "Closed"; + _fieldE0 = true; + _startFrame = 12; + _endFrame = 25; + playMovie(12, 25, MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + } + + return true; +} + +bool CVase::MovieEndMsg(CMovieEndMsg *msg) { + if (CSGTStateRoom::_statics->_v3 == "Closed") + setVisible(false); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/vase.h b/engines/titanic/game/sgt/vase.h index 8aa35acdf5..e07d9efb80 100644 --- a/engines/titanic/game/sgt/vase.h +++ b/engines/titanic/game/sgt/vase.h @@ -28,6 +28,10 @@ namespace Titanic { class CVase : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sgt/washstand.cpp b/engines/titanic/game/sgt/washstand.cpp index 8127a59a59..afdc74414d 100644 --- a/engines/titanic/game/sgt/washstand.cpp +++ b/engines/titanic/game/sgt/washstand.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CWashstand, CSGTStateRoom) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CWashstand::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CSGTStateRoom::save(file, indent); @@ -34,4 +40,36 @@ void CWashstand::load(SimpleFile *file) { CSGTStateRoom::load(file); } +bool CWashstand::TurnOn(CTurnOn *msg) { + if (_statics->_v10 == "Closed" && _statics->_v2 == "NotOnWashstand") { + setVisible(true); + _statics->_v10 = "Open"; + _fieldE0 = false; + _startFrame = 0; + _endFrame = 14; + playMovie(0, 14, MOVIE_GAMESTATE); + playSound("b#14.wav"); + } + + return true; +} + +bool CWashstand::TurnOff(CTurnOff *msg) { + if (_statics->_v10 == "Open" && _statics->_v11 == "Closed" + && _statics->_v12 == "Closed" && _statics->_v2 == "Open") { + _statics->_v10 = "Closed"; + _fieldE0 = true; + _startFrame = 14; + _endFrame = 28; + playMovie(14, 28, MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playSound("b#14.wav"); + } + + return true; +} + +bool CWashstand::MovieEndMsg(CMovieEndMsg *msg) { + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sgt/washstand.h b/engines/titanic/game/sgt/washstand.h index f140b17f49..1b72cfa1c4 100644 --- a/engines/titanic/game/sgt/washstand.h +++ b/engines/titanic/game/sgt/washstand.h @@ -28,6 +28,10 @@ namespace Titanic { class CWashstand : public CSGTStateRoom { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MovieEndMsg(CMovieEndMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/ship_setting.cpp b/engines/titanic/game/ship_setting.cpp index 462f396501..93800e899b 100644 --- a/engines/titanic/game/ship_setting.cpp +++ b/engines/titanic/game/ship_setting.cpp @@ -21,35 +21,109 @@ */ #include "titanic/game/ship_setting.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CShipSetting, CBackground) + ON_MESSAGE(AddHeadPieceMsg) + ON_MESSAGE(SetFrameMsg) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(MouseDragStartMsg) +END_MESSAGE_MAP() + CShipSetting::CShipSetting() : CBackground(), - _string4("NULL"), _string5("NULL") { + _itemName("NULL"), _frameTarget("NULL") { } void CShipSetting::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string3, indent); + file->writeQuotedLine(_target, indent); file->writePoint(_pos1, indent); - file->writeQuotedLine(_string4, indent); - file->writeQuotedLine(_string5, indent); + file->writeQuotedLine(_itemName, indent); + file->writeQuotedLine(_frameTarget, indent); CBackground::save(file, indent); } void CShipSetting::load(SimpleFile *file) { file->readNumber(); - _string3 = file->readString(); + _target = file->readString(); _pos1 = file->readPoint(); - _string4 = file->readString(); - _string5 = file->readString(); + _itemName = file->readString(); + _frameTarget = file->readString(); CBackground::load(file); } +bool CShipSetting::AddHeadPieceMsg(CAddHeadPieceMsg *msg) { + _cursorId = CURSOR_HAND; + + if (msg->_value == "Enable") { + CTurnOn onMsg; + onMsg.execute(_target); + + if (isEquals("ChickenSetting")) { + CActMsg actMsg("DecreaseQuantity"); + actMsg.execute("ChickenDispenser"); + } + } else { + CTurnOff offMsg; + offMsg.execute(_target); + } + + return true; +} + +bool CShipSetting::SetFrameMsg(CSetFrameMsg *msg) { + msg->execute(_frameTarget); + return true; +} + bool CShipSetting::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CShipSetting::handleEvent"); + CSetFrameMsg frameMsg; + + if (_itemName == "ChickenBridge") + frameMsg._frameNumber = 1; + else if (_itemName == "FanBridge") + frameMsg._frameNumber = 2; + else if (_itemName == "SeasonBridge") + frameMsg._frameNumber = 3; + else if (_itemName == "BeamBridge") + frameMsg._frameNumber = 4; + + frameMsg.execute(this); + return true; +} + +bool CShipSetting::MouseDragStartMsg(CMouseDragStartMsg *msg) { + if (!checkStartDragging(msg)) + return false; + if (_itemName == "NULL") + return true; + + CTurnOff offMsg; + offMsg.execute(_target); + + if (isEquals("ChickenSetting") || _itemName == "ChickenBridge") { + CActMsg actMsg("IncreaseQuantity"); + actMsg.execute("ChickenDispenser"); + } + + if (_itemName != "NULL") { + CPassOnDragStartMsg passMsg(msg->_mousePos, 1); + passMsg.execute(_itemName); + + msg->_dragItem = getRoot()->findByName(_itemName); + + CVisibleMsg visibleMsg(true); + visibleMsg.execute(_itemName); + } + + CSetFrameMsg frameMsg(0); + frameMsg.execute(_frameTarget); + _itemName = "NULL"; + _cursorId = CURSOR_ARROW; return true; } diff --git a/engines/titanic/game/ship_setting.h b/engines/titanic/game/ship_setting.h index 4fcc10a424..198d97d250 100644 --- a/engines/titanic/game/ship_setting.h +++ b/engines/titanic/game/ship_setting.h @@ -29,12 +29,16 @@ namespace Titanic { class CShipSetting : public CBackground { + DECLARE_MESSAGE_MAP; + bool AddHeadPieceMsg(CAddHeadPieceMsg *msg); + bool SetFrameMsg(CSetFrameMsg *msg); bool EnterRoomMsg(CEnterRoomMsg *msg); + bool MouseDragStartMsg(CMouseDragStartMsg *msg); public: - CString _string3; + CString _target; Point _pos1; - CString _string4; - CString _string5; + CString _itemName; + CString _frameTarget; public: CLASSDEF; CShipSetting(); diff --git a/engines/titanic/game/ship_setting_button.cpp b/engines/titanic/game/ship_setting_button.cpp index 7dc2cabac0..d485e06668 100644 --- a/engines/titanic/game/ship_setting_button.cpp +++ b/engines/titanic/game/ship_setting_button.cpp @@ -24,25 +24,69 @@ namespace Titanic { -CShipSettingButton::CShipSettingButton() : CGameObject(), _fieldC8(0), _fieldCC(0) { +BEGIN_MESSAGE_MAP(CShipSettingButton, CGameObject) + ON_MESSAGE(TurnOn) + ON_MESSAGE(TurnOff) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + +CShipSettingButton::CShipSettingButton() : CGameObject(), _pressed(false), _enabled(false) { } void CShipSettingButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string1, indent); - file->writeNumberLine(_fieldC8, indent); - file->writeNumberLine(_fieldCC, indent); + file->writeQuotedLine(_target, indent); + file->writeNumberLine(_pressed, indent); + file->writeNumberLine(_enabled, indent); CGameObject::save(file, indent); } void CShipSettingButton::load(SimpleFile *file) { file->readNumber(); - _string1 = file->readString(); - _fieldC8 = file->readNumber(); - _fieldCC = file->readNumber(); + _target = file->readString(); + _pressed = file->readNumber(); + _enabled = file->readNumber(); CGameObject::load(file); } +bool CShipSettingButton::TurnOn(CTurnOn *msg) { + _pressed = true; + return true; +} + +bool CShipSettingButton::TurnOff(CTurnOff *msg) { + _pressed = false; + return true; +} + +bool CShipSettingButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_pressed) { + if (_enabled) + playMovie(8, 16, 0); + else + playMovie(0, 8, 0); + + _enabled = !_enabled; + CActMsg actMsg(_enabled ? "EnableObject" : "DisableObject"); + actMsg.execute(_target); + } else { + if (_enabled) { + playMovie(8, 16, 0); + playMovie(0, 8, 0); + } else { + playMovie(0, 16, 0); + } + } + + return true; +} + +bool CShipSettingButton::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_enabled ? 8 : 16); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/ship_setting_button.h b/engines/titanic/game/ship_setting_button.h index e152e8e2c3..e5457fa532 100644 --- a/engines/titanic/game/ship_setting_button.h +++ b/engines/titanic/game/ship_setting_button.h @@ -28,10 +28,15 @@ namespace Titanic { class CShipSettingButton : public CGameObject { + DECLARE_MESSAGE_MAP; + bool TurnOn(CTurnOn *msg); + bool TurnOff(CTurnOff *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); private: - CString _string1; - int _fieldC8; - int _fieldCC; + CString _target; + bool _pressed; + bool _enabled; public: CLASSDEF; CShipSettingButton(); diff --git a/engines/titanic/game/show_cell_points.cpp b/engines/titanic/game/show_cell_points.cpp index 7d54401a02..985cb93734 100644 --- a/engines/titanic/game/show_cell_points.cpp +++ b/engines/titanic/game/show_cell_points.cpp @@ -21,21 +21,50 @@ */ #include "titanic/game/show_cell_points.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CShowCellpoints, CGameObject) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + void CShowCellpoints::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_strValue, indent); - file->writeNumberLine(_numValue, indent); + file->writeQuotedLine(_npcName, indent); + file->writeNumberLine(_flag, indent); CGameObject::save(file, indent); } void CShowCellpoints::load(SimpleFile *file) { file->readNumber(); - _strValue = file->readString(); - _numValue = file->readNumber(); + _npcName = file->readString(); + _flag = file->readNumber(); CGameObject::load(file); } +bool CShowCellpoints::EnterViewMsg(CEnterViewMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet) { + petSetArea(PET_CONVERSATION); + pet->setActiveNPC(_npcName); + pet->incAreaLocks(); + _flag = true; + } + + return true; +} + +bool CShowCellpoints::LeaveViewMsg(CLeaveViewMsg *msg) { + CPetControl *pet = getPetControl(); + if (pet && _flag) { + pet->resetDials0(); + pet->decAreaLocks(); + _flag = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/show_cell_points.h b/engines/titanic/game/show_cell_points.h index 9de2e06dca..205547d7c2 100644 --- a/engines/titanic/game/show_cell_points.h +++ b/engines/titanic/game/show_cell_points.h @@ -28,12 +28,15 @@ namespace Titanic { class CShowCellpoints : public CGameObject { + DECLARE_MESSAGE_MAP; + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: - CString _strValue; - int _numValue; + CString _npcName; + bool _flag; public: CLASSDEF; - CShowCellpoints() : CGameObject(), _numValue(0) {} + CShowCellpoints() : CGameObject(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/speech_dispensor.cpp b/engines/titanic/game/speech_dispensor.cpp index f9cc019672..20ff3c69e0 100644 --- a/engines/titanic/game/speech_dispensor.cpp +++ b/engines/titanic/game/speech_dispensor.cpp @@ -24,15 +24,26 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSpeechDispensor, CBackground) + ON_MESSAGE(FrameMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(ChangeSeasonMsg) +END_MESSAGE_MAP() + +CSpeechDispensor::CSpeechDispensor() : CBackground(), _dragItem(nullptr), + _fieldE0(0), _state(0), _fieldEC(0), _fieldF8(0), _seasonNum(SEASON_SUMMER) { +} + void CSpeechDispensor::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_state, indent); file->writeNumberLine(_fieldEC, indent); - file->writeNumberLine(_fieldF0, indent); - file->writeNumberLine(_fieldF4, indent); + file->writeNumberLine(_itemPos.x, indent); + file->writeNumberLine(_itemPos.y, indent); file->writeNumberLine(_fieldF8, indent); - file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_seasonNum, indent); CBackground::save(file, indent); } @@ -40,14 +51,93 @@ void CSpeechDispensor::save(SimpleFile *file, int indent) { void CSpeechDispensor::load(SimpleFile *file) { file->readNumber(); _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _state = file->readNumber(); _fieldEC = file->readNumber(); - _fieldF0 = file->readNumber(); - _fieldF4 = file->readNumber(); + _itemPos.x = file->readNumber(); + _itemPos.y = file->readNumber(); _fieldF8 = file->readNumber(); - _fieldFC = file->readNumber(); + _seasonNum = (Season)file->readNumber(); CBackground::load(file); } +bool CSpeechDispensor::FrameMsg(CFrameMsg *msg) { + if (_fieldEC || _seasonNum == SEASON_SUMMER || _seasonNum == SEASON_SPRING) + return true; + + CGameObject *dragObject = getDraggingObject(); + if (!_dragItem && dragObject && getView() == findView()) { + if (dragObject->isEquals("Perch")) { + petDisplayMessage(1, "This stick is too short to reach the branches."); + return true; + } + + if (dragObject->isEquals("LongStick")) + _dragItem = dragObject; + } + + if (_dragItem) { + Point pt(_itemPos.x + _dragItem->_bounds.left, + _itemPos.y + _dragItem->_bounds.top); + if (!checkPoint(pt, true)) + return true; + + switch (_state) { + case 0: + playSound("z#93.wav"); + if (_seasonNum == SEASON_WINTER) { + petDisplayMessage(1, "You cannot get this, it is frozen to the branch."); + _fieldE0 = false; + _state = 1; + } else { + if (++_fieldE0 >= 5) { + CActMsg actMsg("PlayerGetsSpeechCentre"); + actMsg.execute("SeasonalAdjust"); + CSpeechFallsFromTreeMsg fallMsg(pt); + fallMsg.execute("SpeechCentre"); + + _fieldEC = true; + _fieldE0 = false; + } + + _state = 1; + } + break; + + case 2: + _state = 0; + ++_fieldE0; + break; + + default: + break; + } + } + + return true; +} + +bool CSpeechDispensor::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (!_fieldEC) { + playSound("z#93.wav"); + if (_fieldF8) { + petDisplayMessage(1, "Sadly, this is out of your reach."); + } else { + petDisplayMessage(1, "You can't pick this up on account of it being stuck to the branch."); + } + } + + return true; +} + +bool CSpeechDispensor::StatusChangeMsg(CStatusChangeMsg *msg) { + _fieldF8 = msg->_newStatus == 1; + return true; +} + +bool CSpeechDispensor::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _seasonNum = (Season)(((int)_seasonNum + 1) % 4); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/speech_dispensor.h b/engines/titanic/game/speech_dispensor.h index 3b877e8d99..038cc024cc 100644 --- a/engines/titanic/game/speech_dispensor.h +++ b/engines/titanic/game/speech_dispensor.h @@ -28,17 +28,22 @@ namespace Titanic { class CSpeechDispensor : public CBackground { + DECLARE_MESSAGE_MAP; + bool FrameMsg(CFrameMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); private: int _fieldE0; - int _fieldE4; - int _fieldE8; + int _state; + CGameObject *_dragItem; int _fieldEC; - int _fieldF0; - int _fieldF4; + Point _itemPos; int _fieldF8; - int _fieldFC; + Season _seasonNum; public: CLASSDEF; + CSpeechDispensor(); /** * Save the data for the class to file diff --git a/engines/titanic/game/starling_puret.cpp b/engines/titanic/game/starling_puret.cpp index 359ad774df..2f1909d963 100644 --- a/engines/titanic/game/starling_puret.cpp +++ b/engines/titanic/game/starling_puret.cpp @@ -24,16 +24,56 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CStarlingPuret, CGameObject) + ON_MESSAGE(StatusChangeMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CStarlingPuret::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_flag, indent); CGameObject::save(file, indent); } void CStarlingPuret::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _flag = file->readNumber(); CGameObject::load(file); } +bool CStarlingPuret::StatusChangeMsg(CStatusChangeMsg *msg) { + _flag = msg->_newStatus == 1; + if (_flag) { + CStatusChangeMsg changeMsg; + changeMsg._newStatus = 1; + changeMsg.execute("StarlingLoop01"); + } + + return true; +} + +bool CStarlingPuret::EnterViewMsg(CEnterViewMsg *msg) { + if (_flag) { + CStatusChangeMsg changeMsg; + changeMsg._newStatus = 1; + changeMsg.execute("PromDeckStarlings"); + + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + CSignalObject signalMsg; + signalMsg._numValue = 4; + signalMsg.execute("PromDeckStarlings"); + _flag = false; + } + + return true; +} + +bool CStarlingPuret::MovieEndMsg(CMovieEndMsg *msg) { + CActMsg actMsg("StarlingsDead"); + actMsg.execute("FanController"); + actMsg.execute("BirdSauceDisp"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/starling_puret.h b/engines/titanic/game/starling_puret.h index fcd3319958..62a6173093 100644 --- a/engines/titanic/game/starling_puret.h +++ b/engines/titanic/game/starling_puret.h @@ -28,11 +28,15 @@ namespace Titanic { class CStarlingPuret : public CGameObject { + DECLARE_MESSAGE_MAP; + bool StatusChangeMsg(CStatusChangeMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); private: - int _value; + bool _flag; public: CLASSDEF; - CStarlingPuret() : CGameObject(), _value(0) {} + CStarlingPuret() : CGameObject(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/stop_phonograph_button.cpp b/engines/titanic/game/stop_phonograph_button.cpp index d18f4713ac..75e0ca9337 100644 --- a/engines/titanic/game/stop_phonograph_button.cpp +++ b/engines/titanic/game/stop_phonograph_button.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CStopPhonographButton, CBackground) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CStopPhonographButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBackground::save(file, indent); @@ -34,4 +38,19 @@ void CStopPhonographButton::load(SimpleFile *file) { CBackground::load(file); } +bool CStopPhonographButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CQueryPhonographState queryMsg; + queryMsg.execute(getParent()); + + if (!queryMsg._value) { + playMovie(0, 1, 0); + playMovie(1, 0, 0); + + CPhonographStopMsg stopMsg; + stopMsg.execute(getParent()); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/stop_phonograph_button.h b/engines/titanic/game/stop_phonograph_button.h index b469375e20..d416c4f8fe 100644 --- a/engines/titanic/game/stop_phonograph_button.h +++ b/engines/titanic/game/stop_phonograph_button.h @@ -28,6 +28,8 @@ namespace Titanic { class CStopPhonographButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/sub_glass.cpp b/engines/titanic/game/sub_glass.cpp index f1349f06ea..041f49097d 100644 --- a/engines/titanic/game/sub_glass.cpp +++ b/engines/titanic/game/sub_glass.cpp @@ -24,17 +24,25 @@ namespace Titanic { -CSUBGlass::CSUBGlass() : _fieldBC(0), _fieldC0(0), _fieldC4(1), _fieldC8(0) { +BEGIN_MESSAGE_MAP(CSUBGlass, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseButtonUpMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(SignalObject) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + +CSUBGlass::CSUBGlass() : _fieldBC(0), _startFrame(0), _endFrame(1), _signalStartFrame(0) { } void CSUBGlass::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->writeQuotedLine(_string, indent); + file->writeNumberLine(_startFrame, indent); + file->writeNumberLine(_endFrame, indent); + file->writeNumberLine(_signalStartFrame, indent); + file->writeNumberLine(_signalEndFrame, indent); + file->writeQuotedLine(_target, indent); CGameObject::save(file, indent); } @@ -42,13 +50,58 @@ void CSUBGlass::save(SimpleFile *file, int indent) { void CSUBGlass::load(SimpleFile *file) { file->readNumber(); _fieldBC = file->readNumber(); - _fieldC0 = file->readNumber(); - _fieldC4 = file->readNumber(); - _fieldC8 = file->readNumber(); - _fieldCC = file->readNumber(); - _string = file->readString(); + _startFrame = file->readNumber(); + _endFrame = file->readNumber(); + _signalStartFrame = file->readNumber(); + _signalEndFrame = file->readNumber(); + _target = file->readString(); CGameObject::load(file); } +bool CSUBGlass::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + return true; +} + +bool CSUBGlass::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + if (!_fieldBC && _startFrame >= 0) { + _fieldBC = true; + playMovie(_startFrame, _endFrame, MOVIE_NOTIFY_OBJECT); + playSound("z#30.wav"); + } + + return true; +} + +bool CSUBGlass::MovieEndMsg(CMovieEndMsg *msg) { + if (msg->_endFrame == _endFrame) { + _fieldBC = true; + CSignalObject signalMsg(getName(), 1); + signalMsg.execute(_target); + } + + return true; +} + +bool CSUBGlass::SignalObject(CSignalObject *msg) { + if (msg->_numValue == 1) { + setVisible(true); + + if (_signalStartFrame >= 0) { + playMovie(_signalStartFrame, _signalEndFrame, MOVIE_GAMESTATE); + playSound("z#30.wav"); + _fieldBC = false; + } + } + + return true; +} + +bool CSUBGlass::LeaveViewMsg(CLeaveViewMsg *msg) { + _fieldBC = false; + setVisible(true); + loadFrame(0); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sub_glass.h b/engines/titanic/game/sub_glass.h index aab5c8400e..22d16ff4d5 100644 --- a/engines/titanic/game/sub_glass.h +++ b/engines/titanic/game/sub_glass.h @@ -28,13 +28,19 @@ namespace Titanic { class CSUBGlass : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool SignalObject(CSignalObject *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); private: int _fieldBC; - int _fieldC0; - int _fieldC4; - int _fieldC8; - int _fieldCC; - CString _string; + int _startFrame; + int _endFrame; + int _signalStartFrame; + int _signalEndFrame; + CString _target; public: CLASSDEF; CSUBGlass(); diff --git a/engines/titanic/game/sub_wrapper.cpp b/engines/titanic/game/sub_wrapper.cpp index dcc489316b..4080487d6d 100644 --- a/engines/titanic/game/sub_wrapper.cpp +++ b/engines/titanic/game/sub_wrapper.cpp @@ -24,16 +24,56 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSUBWrapper, CGameObject) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(SignalObject) +END_MESSAGE_MAP() + void CSUBWrapper::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_flag, indent); CGameObject::save(file, indent); } void CSUBWrapper::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _flag = file->readNumber(); CGameObject::load(file); } +bool CSUBWrapper::MovieEndMsg(CMovieEndMsg *msg) { + if (_flag) { + stopMovie(); + setVisible(false); + _flag = false; + } + + return true; +} + +bool CSUBWrapper::SignalObject(CSignalObject *msg) { + switch (msg->_numValue) { + case 1: + if (!_flag) { + loadFrame(0); + setVisible(true); + playMovie(MOVIE_NOTIFY_OBJECT); + _flag = true; + } + break; + + case 2: + if (!_flag) { + setVisible(true); + _flag = true; + } + break; + + default: + break; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sub_wrapper.h b/engines/titanic/game/sub_wrapper.h index 81f8fdc941..1094a2e677 100644 --- a/engines/titanic/game/sub_wrapper.h +++ b/engines/titanic/game/sub_wrapper.h @@ -28,11 +28,14 @@ namespace Titanic { class CSUBWrapper : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MovieEndMsg(CMovieEndMsg *msg); + bool SignalObject(CSignalObject *msg); public: - int _value; + bool _flag; public: CLASSDEF; - CSUBWrapper() : CGameObject(), _value(0) {} + CSUBWrapper() : CGameObject(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/sweet_bowl.cpp b/engines/titanic/game/sweet_bowl.cpp index e14f900e77..d0a2525bc4 100644 --- a/engines/titanic/game/sweet_bowl.cpp +++ b/engines/titanic/game/sweet_bowl.cpp @@ -24,6 +24,12 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CSweetBowl, CGameObject) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + void CSweetBowl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +40,28 @@ void CSweetBowl::load(SimpleFile *file) { CGameObject::load(file); } +bool CSweetBowl::MovieEndMsg(CMovieEndMsg *msg) { + setVisible(false); + return true; +} + +bool CSweetBowl::EnterViewMsg(CEnterViewMsg *msg) { + setVisible(false); + loadSound("b#43.wav"); + playSound("b#42.wav"); + return true; +} + +bool CSweetBowl::ActMsg(CActMsg *msg) { + if (msg->_action == "Jiggle") { + setVisible(true); + playMovie(MOVIE_GAMESTATE | MOVIE_NOTIFY_OBJECT); + playSound(getRandomNumber(1) == 1 ? "b#42.wav" : "b#43.wav"); + } + + petDisplayMessage(isEquals("BowlNutsRustler") ? + "A bowl of pistachio nuts." : "Not a bowl of pistachio nuts."); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/sweet_bowl.h b/engines/titanic/game/sweet_bowl.h index cf3d0023a4..53433c8c08 100644 --- a/engines/titanic/game/sweet_bowl.h +++ b/engines/titanic/game/sweet_bowl.h @@ -28,6 +28,10 @@ namespace Titanic { class CSweetBowl : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MovieEndMsg(CMovieEndMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool ActMsg(CActMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/television.cpp b/engines/titanic/game/television.cpp index ba30fbe281..780f92b5ad 100644 --- a/engines/titanic/game/television.cpp +++ b/engines/titanic/game/television.cpp @@ -237,8 +237,8 @@ bool CTelevision::MovieEndMsg(CMovieEndMsg *msg) { } if (_fieldE0 == 3 && compareRoomNameTo("SGTState") && !getPassengerClass()) { - playSound("z#47.wav", 100, 0, 0); - _soundHandle = playSound("b#20.wav", 100, 0, 0); + playSound("z#47.wav"); + _soundHandle = playSound("b#20.wav"); CMagazine *magazine = dynamic_cast<CMagazine *>(getRoot()->findByName("Magazine")); if (magazine) { diff --git a/engines/titanic/game/third_class_canal.cpp b/engines/titanic/game/third_class_canal.cpp index 6b0a101f7b..97b559e35d 100644 --- a/engines/titanic/game/third_class_canal.cpp +++ b/engines/titanic/game/third_class_canal.cpp @@ -24,6 +24,10 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CThirdClassCanal, CBackground) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CThirdClassCanal::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CBackground::save(file, indent); @@ -34,4 +38,9 @@ void CThirdClassCanal::load(SimpleFile *file) { CBackground::load(file); } +bool CThirdClassCanal::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + petDisplayMessage("This area is off limits to passengers."); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/third_class_canal.h b/engines/titanic/game/third_class_canal.h index f6fc471444..d0be8c05aa 100644 --- a/engines/titanic/game/third_class_canal.h +++ b/engines/titanic/game/third_class_canal.h @@ -28,6 +28,8 @@ namespace Titanic { class CThirdClassCanal : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/throw_tv_down_well.cpp b/engines/titanic/game/throw_tv_down_well.cpp index c8a9fc7c9e..9de028cbde 100644 --- a/engines/titanic/game/throw_tv_down_well.cpp +++ b/engines/titanic/game/throw_tv_down_well.cpp @@ -24,18 +24,73 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CThrowTVDownWell, CGameObject) + ON_MESSAGE(ActMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(MovieFrameMsg) +END_MESSAGE_MAP() + void CThrowTVDownWell::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_strValue, indent); - file->writeNumberLine(_numValue, indent); + file->writeQuotedLine(_viewName, indent); + file->writeNumberLine(_flag, indent); CGameObject::save(file, indent); } void CThrowTVDownWell::load(SimpleFile *file) { file->readNumber(); - _strValue = file->readString(); - _numValue = file->readNumber(); + _viewName = file->readString(); + _flag = file->readNumber(); CGameObject::load(file); } +bool CThrowTVDownWell::ActMsg(CActMsg *msg) { + if (msg->_action == "ThrowTVDownWell" && !_flag) { + CString viewName = getFullViewName(); + lockMouse(); + addTimer(1, 8000, 0); + + CActMsg actMsg("ThrownTVDownWell"); + actMsg.execute("BOWTelevisionMonitor"); + } + + return true; +} + +bool CThrowTVDownWell::EnterViewMsg(CEnterViewMsg *msg) { + playMovie(MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE); + movieEvent(49); + return true; +} + +bool CThrowTVDownWell::MovieEndMsg(CMovieEndMsg *msg) { + sleep(2000); + changeView("ParrotLobby.Node 11.N"); + playSound("z#471.wav"); + addTimer(2, 7000, 0); + return true; +} + +bool CThrowTVDownWell::TimerMsg(CTimerMsg *msg) { + if (msg->_actionVal == 1) { + changeView("ParrotLobby.Node 10.N"); + } else if (msg->_actionVal == 2) { + playSound("z#468.wav", 50); + sleep(1500); + changeView(_viewName); + _viewName = "NULL"; + unlockMouse(); + playSound("z#47.wav"); + } + + return true; +} + +bool CThrowTVDownWell::MovieFrameMsg(CMovieFrameMsg *msg) { + playSound("z#470.wav"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/throw_tv_down_well.h b/engines/titanic/game/throw_tv_down_well.h index b6003aa3ef..c9e8fd57a9 100644 --- a/engines/titanic/game/throw_tv_down_well.h +++ b/engines/titanic/game/throw_tv_down_well.h @@ -28,12 +28,18 @@ namespace Titanic { class CThrowTVDownWell : public CGameObject { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool MovieFrameMsg(CMovieFrameMsg *msg); public: - CString _strValue; - int _numValue; + CString _viewName; + bool _flag; public: CLASSDEF; - CThrowTVDownWell() : CGameObject(), _numValue(0) {} + CThrowTVDownWell() : CGameObject(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/titania_still_control.cpp b/engines/titanic/game/titania_still_control.cpp index 67866ecdcb..1ce0a85b4e 100644 --- a/engines/titanic/game/titania_still_control.cpp +++ b/engines/titanic/game/titania_still_control.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CTitaniaStillControl, CGameObject) + ON_MESSAGE(SetFrameMsg) + ON_MESSAGE(VisibleMsg) +END_MESSAGE_MAP() + void CTitaniaStillControl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +39,15 @@ void CTitaniaStillControl::load(SimpleFile *file) { CGameObject::load(file); } +bool CTitaniaStillControl::SetFrameMsg(CSetFrameMsg *msg) { + loadFrame(msg->_frameNumber); + setVisible(true); + return true; +} + +bool CTitaniaStillControl::VisibleMsg(CVisibleMsg *msg) { + setVisible(false); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/titania_still_control.h b/engines/titanic/game/titania_still_control.h index 66c3045187..b77227a539 100644 --- a/engines/titanic/game/titania_still_control.h +++ b/engines/titanic/game/titania_still_control.h @@ -28,6 +28,9 @@ namespace Titanic { class CTitaniaStillControl : public CGameObject { + DECLARE_MESSAGE_MAP; + bool SetFrameMsg(CSetFrameMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/tow_parrot_nav.cpp b/engines/titanic/game/tow_parrot_nav.cpp index 9361808870..57f1649add 100644 --- a/engines/titanic/game/tow_parrot_nav.cpp +++ b/engines/titanic/game/tow_parrot_nav.cpp @@ -21,9 +21,14 @@ */ #include "titanic/game/tow_parrot_nav.h" +#include "titanic/npcs/parrot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CTOWParrotNav, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CTOWParrotNav::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CGameObject::save(file, indent); @@ -34,4 +39,16 @@ void CTOWParrotNav::load(SimpleFile *file) { CGameObject::load(file); } +bool CTOWParrotNav::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CActMsg actMsg("EnteringFromTOW"); + actMsg.execute("PerchedParrot"); + + CString clipString = "_EXIT,36,1,N,9,3,N"; + if (CParrot::_v4) + clipString += 'a'; + changeView("ParrotLobby.Node 3.N", clipString); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/tow_parrot_nav.h b/engines/titanic/game/tow_parrot_nav.h index 17618ff6de..252d9b631d 100644 --- a/engines/titanic/game/tow_parrot_nav.h +++ b/engines/titanic/game/tow_parrot_nav.h @@ -28,6 +28,8 @@ namespace Titanic { class CTOWParrotNav : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/transport/exit_pellerator.cpp b/engines/titanic/game/transport/exit_pellerator.cpp index 400214a140..12ea9c3906 100644 --- a/engines/titanic/game/transport/exit_pellerator.cpp +++ b/engines/titanic/game/transport/exit_pellerator.cpp @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #include "titanic/game/transport/pellerator.h" diff --git a/engines/titanic/game/transport/exit_pellerator.h b/engines/titanic/game/transport/exit_pellerator.h index 53056c7417..794f162b03 100644 --- a/engines/titanic/game/transport/exit_pellerator.h +++ b/engines/titanic/game/transport/exit_pellerator.h @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #ifndef TITANIC_PELLERATOR_H #define TITANIC_PELLERATOR_H diff --git a/engines/titanic/game/transport/lift.h b/engines/titanic/game/transport/lift.h index c45d2b64d0..c69f7a02e6 100644 --- a/engines/titanic/game/transport/lift.h +++ b/engines/titanic/game/transport/lift.h @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #ifndef TITANIC_LIFT_H #define TITANIC_LIFT_H diff --git a/engines/titanic/game/transport/pellerator.cpp b/engines/titanic/game/transport/pellerator.cpp index 5bc2423478..e4af40c334 100644 --- a/engines/titanic/game/transport/pellerator.cpp +++ b/engines/titanic/game/transport/pellerator.cpp @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #include "titanic/game/transport/pellerator.h" #include "titanic/core/room_item.h" diff --git a/engines/titanic/game/transport/pellerator.h b/engines/titanic/game/transport/pellerator.h index c634f435cc..2ba4a1347a 100644 --- a/engines/titanic/game/transport/pellerator.h +++ b/engines/titanic/game/transport/pellerator.h @@ -1,24 +1,24 @@ /* ScummVM - Graphic Adventure Engine -* -* ScummVM is the legal property of its developers, whose names -* are too numerous to list here. Please refer to the COPYRIGHT -* file distributed with this source distribution. -* -* This program is free software; you can redistribute it and/or -* modify it under the terms of the GNU General Public License -* as published by the Free Software Foundation; either version 2 -* of the License, or (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program; if not, write to the Free Software -* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -* -*/ + * + * ScummVM is the legal property of its developers, whose names + * are too numerous to list here. Please refer to the COPYRIGHT + * file distributed with this source distribution. + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + */ #ifndef TITANIC_PELLERATOR_H #define TITANIC_PELLERATOR_H diff --git a/engines/titanic/game/transport/service_elevator.cpp b/engines/titanic/game/transport/service_elevator.cpp index 1ea8d14e36..1980825cb6 100644 --- a/engines/titanic/game/transport/service_elevator.cpp +++ b/engines/titanic/game/transport/service_elevator.cpp @@ -21,15 +21,27 @@ */ #include "titanic/game/transport/service_elevator.h" +#include "titanic/core/room_item.h" +#include "titanic/npcs/doorbot.h" -namespace Titanic { +namespace Titanic { -int CServiceElevator::_v1; +BEGIN_MESSAGE_MAP(CServiceElevator, CTransport) + ON_MESSAGE(BodyInBilgeRoomMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(ServiceElevatorMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(ServiceElevatorFloorRequestMsg) + ON_MESSAGE(LeaveRoomMsg) + ON_MESSAGE(OpeningCreditsMsg) +END_MESSAGE_MAP() + +bool CServiceElevator::_v1; int CServiceElevator::_v2; int CServiceElevator::_v3; CServiceElevator::CServiceElevator() : CTransport(), - _fieldF8(0), _fieldFC(0), _field100(0), _field104(0) { + _fieldF8(0), _soundHandle1(0), _timerId(0), _soundHandle2(0) { } void CServiceElevator::save(SimpleFile *file, int indent) { @@ -38,9 +50,9 @@ void CServiceElevator::save(SimpleFile *file, int indent) { file->writeNumberLine(_v2, indent); file->writeNumberLine(_v3, indent); file->writeNumberLine(_fieldF8, indent); - file->writeNumberLine(_fieldFC, indent); - file->writeNumberLine(_field100, indent); - file->writeNumberLine(_field104, indent); + file->writeNumberLine(_soundHandle1, indent); + file->writeNumberLine(_timerId, indent); + file->writeNumberLine(_soundHandle2, indent); CTransport::save(file, indent); } @@ -51,11 +63,208 @@ void CServiceElevator::load(SimpleFile *file) { _v2 = file->readNumber(); _v3 = file->readNumber(); _fieldF8 = file->readNumber(); - _fieldFC = file->readNumber(); - _field100 = file->readNumber(); - _field104 = file->readNumber(); + _soundHandle1 = file->readNumber(); + _timerId = file->readNumber(); + _soundHandle2 = file->readNumber(); CTransport::load(file); } +bool CServiceElevator::BodyInBilgeRoomMsg(CBodyInBilgeRoomMsg *msg) { + _v2 = true; + _string1 = "BilgeRoomWith.Node 2.N"; + return true; +} + +bool CServiceElevator::EnterViewMsg(CEnterViewMsg *msg) { + petShow(); + return true; +} + +bool CServiceElevator::ServiceElevatorMsg(CServiceElevatorMsg *msg) { + switch (msg->_value) { + case 1: + case 2: + case 3: { + switch (msg->_value) { + case 1: + _v3 = 0; + break; + case 2: + _v3 = 1; + break; + case 3: + _v3 = 2; + break; + } + + CServiceElevatorFloorRequestMsg requestMsg; + requestMsg.execute(this); + break; + } + + case 4: + if (!_string1.empty()) { + if (_string1 == "DeepSpace") { + disableMouse(); + _soundHandle1 = playSound("z#413.wav", 50); + _timerId = addTimer(1, 1000, 500); + } else { + changeView(_string1); + } + } + break; + + case 5: + _fieldF8 = false; + _fieldDC = _v3; + loadSound("z#423.wav"); + stopSound(_soundHandle2); + _soundHandle2 = playSound("z#423.wav", 80); + + switch (_fieldDC) { + case 0: + _string1 = "DeepSpace"; + _string2 = "a#2.wav"; + queueSound("z#416.wav", _soundHandle2, 50); + break; + + case 1: + _string1 = _v2 ? "BilgeRoomWith.Node 2.N" : "BilgeRoom.Node 1.N"; + queueSound("z#421.wav", _soundHandle2, 50); + break; + + case 2: + _string1 = _v1 ? "MoonEmbLobby.Node 1.NE" : "EmbLobby.Node 1.NE"; + queueSound("z#411.wav", _soundHandle2, 50); + break; + + default: + break; + } + + enableMouse(); + if (findRoom()->findByName("Doorbot")) + addTimer(3, 3000, 0); + break; + + default: + break; + } + + return true; +} + +bool CServiceElevator::TimerMsg(CTimerMsg *msg) { + CDoorbot *doorbot = dynamic_cast<CDoorbot *>(findRoom()->findByName("Doorbot")); + + switch (msg->_actionVal) { + case 0: + case 1: + if (!isSoundActive(_soundHandle1)) { + stopAnimTimer(_timerId); + if (msg->_actionVal == 0) { + _fieldF8 = true; + CServiceElevatorFloorChangeMsg changeMsg(_fieldDC, _v3); + changeMsg.execute(getRoom()); + _soundHandle2 = playSound("z#424.wav"); + + if (doorbot) { + CActMsg actMsg("DoorbotPlayerPressedTopButton"); + actMsg.execute(doorbot); + } + } else { + enableMouse(); + if (doorbot) { + CActMsg actMsg; + if (_v3 == 0) + actMsg._action = "DoorbotPlayerPressedBottomButton"; + else if (_v3 == 1) + actMsg._action = "DoorbotPlayerPressedMiddleButton"; + + actMsg.execute(doorbot); + } + } + } + break; + + case 3: { + CActMsg actMsg("DoorbotReachedEmbLobby"); + actMsg.execute(doorbot); + break; + } + + default: + break; + } + + return true; +} + +bool CServiceElevator::ServiceElevatorFloorRequestMsg(CServiceElevatorFloorRequestMsg *msg) { + disableMouse(); + CDoorbot *doorbot = dynamic_cast<CDoorbot *>(findRoom()->findByName("Doorbot")); + + if (doorbot && _v3 == 0) { + _soundHandle1 = playSound("z#415.wav", 50); + addTimer(1, 1000, 500); + } else if (doorbot && _v3 == 1) { + _soundHandle1 = playSound("z#417.wav", 50); + addTimer(1, 1000, 500); + } else if (_fieldDC == _v3) { + switch (_v3) { + case 0: + _soundHandle1 = playSound("z#415.wav", 50); + break; + case 1: + _soundHandle1 = playSound("z#420.wav", 50); + break; + case 2: + _soundHandle1 = playSound("z#410.wav", 50); + break; + default: + break; + } + + addTimer(1, 1000, 500); + } else { + switch (_v3) { + case 0: + _soundHandle1 = playSound("z#414.wav", 50); + break; + case 1: + _soundHandle1 = playSound(_fieldDC ? "z#419.wav" : "z#418.wav", 50); + break; + case 2: + _soundHandle1 = playSound("z#414.wav", 50); + break; + default: + break; + } + + addTimer(0, 1000, 500); + } + + return true; +} + +bool CServiceElevator::LeaveRoomMsg(CLeaveRoomMsg *msg) { + CDoorbot *doorbot = dynamic_cast<CDoorbot *>(findRoom()->findByName("Doorbot")); + + if (doorbot) { + CPutBotBackInHisBoxMsg boxMsg(0); + boxMsg.execute("Doorbot"); + doorbot->performAction(false); + enableMouse(); + } + + return true; +} + +bool CServiceElevator::OpeningCreditsMsg(COpeningCreditsMsg *msg) { + _v1 = false; + _string1 = "EmbLobby.Node 1.NE"; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/transport/service_elevator.h b/engines/titanic/game/transport/service_elevator.h index b2c135021a..5cf1f6f0d5 100644 --- a/engines/titanic/game/transport/service_elevator.h +++ b/engines/titanic/game/transport/service_elevator.h @@ -28,15 +28,23 @@ namespace Titanic { class CServiceElevator : public CTransport { + DECLARE_MESSAGE_MAP; + bool BodyInBilgeRoomMsg(CBodyInBilgeRoomMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool ServiceElevatorMsg(CServiceElevatorMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool ServiceElevatorFloorRequestMsg(CServiceElevatorFloorRequestMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); + bool OpeningCreditsMsg(COpeningCreditsMsg *msg); private: - static int _v1; + static bool _v1; static int _v2; static int _v3; int _fieldF8; - int _fieldFC; - int _field100; - int _field104; + int _soundHandle1; + int _timerId; + int _soundHandle2; public: CLASSDEF; CServiceElevator(); diff --git a/engines/titanic/game/up_lighter.cpp b/engines/titanic/game/up_lighter.cpp index f03b8f37a0..d133a7e9df 100644 --- a/engines/titanic/game/up_lighter.cpp +++ b/engines/titanic/game/up_lighter.cpp @@ -21,9 +21,21 @@ */ #include "titanic/game/up_lighter.h" +#include "titanic/core/project_item.h" +#include "titanic/npcs/parrot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CUpLighter, CDropTarget) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(PumpingMsg) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterRoomMsg) + ON_MESSAGE(ChangeSeasonMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(LeaveRoomMsg) +END_MESSAGE_MAP() + CUpLighter::CUpLighter() : CDropTarget(), _field118(0), _field11C(0), _field120(0), _field124(0) { } @@ -48,8 +60,61 @@ void CUpLighter::load(SimpleFile *file) { CDropTarget::load(file); } +bool CUpLighter::MovieEndMsg(CMovieEndMsg *msg) { + if (_field118) { + playSound("z#47.wav"); + _field124 = true; + + CVisibleMsg visibleMsg(true); + visibleMsg.execute("NoseHolder"); + CDropZoneLostObjectMsg lostMsg(nullptr); + lostMsg.execute(this); + _clipName.clear(); + _itemMatchName = "Nothing"; + _field118 = 0; + } + + return true; +} + +bool CUpLighter::PumpingMsg(CPumpingMsg *msg) { + _field118 = msg->_value; + _clipName = (_field118 && !_field124) ? "WholeSequence" : "HoseToNose"; + return true; +} + +bool CUpLighter::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CTrueTalkTriggerActionMsg triggerMsg(280245, 0, 0); + triggerMsg.execute(getRoot(), CParrot::_type, + MSGFLAG_BREAK_IF_HANDLED | MSGFLAG_CLASS_DEF | MSGFLAG_SCAN); + return true; +} + bool CUpLighter::EnterRoomMsg(CEnterRoomMsg *msg) { - warning("CUpLighter::handleEvent"); + _field11C = true; + addTimer(5000 + getRandomNumber(15000), 0); + return true; +} + +bool CUpLighter::ChangeSeasonMsg(CChangeSeasonMsg *msg) { + _field120 = msg->_season == "Spring"; + if (_field120) + addTimer(5000 + getRandomNumber(15000), 0); + return true; +} + +bool CUpLighter::TimerMsg(CTimerMsg *msg) { + if (_field120 && _field11C & !_field118) { + CActMsg actMsg("Sneeze"); + actMsg.execute(findRoom()->findByName("NoseHolder")); + addTimer(1000 + getRandomNumber(19000), 0); + } + + return true; +} + +bool CUpLighter::LeaveRoomMsg(CLeaveRoomMsg *msg) { + _field11C = false; return true; } diff --git a/engines/titanic/game/up_lighter.h b/engines/titanic/game/up_lighter.h index 2367e41314..e6a53cf7bd 100644 --- a/engines/titanic/game/up_lighter.h +++ b/engines/titanic/game/up_lighter.h @@ -29,7 +29,14 @@ namespace Titanic { class CUpLighter : public CDropTarget { + DECLARE_MESSAGE_MAP; + bool MovieEndMsg(CMovieEndMsg *msg); + bool PumpingMsg(CPumpingMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); bool EnterRoomMsg(CEnterRoomMsg *msg); + bool ChangeSeasonMsg(CChangeSeasonMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool LeaveRoomMsg(CLeaveRoomMsg *msg); private: int _field118; int _field11C; diff --git a/engines/titanic/game/useless_lever.cpp b/engines/titanic/game/useless_lever.cpp index e48ad55a71..82d8983710 100644 --- a/engines/titanic/game/useless_lever.cpp +++ b/engines/titanic/game/useless_lever.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CUselessLever, CToggleButton) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(EnterViewMsg) +END_MESSAGE_MAP() + void CUselessLever::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CToggleButton::save(file, indent); @@ -34,4 +39,23 @@ void CUselessLever::load(SimpleFile *file) { CToggleButton::load(file); } +bool CUselessLever::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_fieldE0) { + playMovie(15, 30, 0); + playSound("z#56.wav"); + _fieldE0 = false; + } else { + playMovie(0, 14, 0); + playSound("z#56.wav"); + _fieldE0 = true; + } + + return true; +} + +bool CUselessLever::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_fieldE0 ? 15 : 0); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/useless_lever.h b/engines/titanic/game/useless_lever.h index 27397de216..33ed94b2ac 100644 --- a/engines/titanic/game/useless_lever.h +++ b/engines/titanic/game/useless_lever.h @@ -28,6 +28,9 @@ namespace Titanic { class CUselessLever : public CToggleButton { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/wheel_button.cpp b/engines/titanic/game/wheel_button.cpp index 19c42a8807..730a5d9005 100644 --- a/engines/titanic/game/wheel_button.cpp +++ b/engines/titanic/game/wheel_button.cpp @@ -24,14 +24,20 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CWheelButton, CBackground) + ON_MESSAGE(SignalObject) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(LeaveViewMsg) +END_MESSAGE_MAP() + CWheelButton::CWheelButton() : CBackground(), - _fieldE0(0), _fieldE4(0), _fieldE8(0) { + _fieldE0(false), _timerId(0), _fieldE8(0) { } void CWheelButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); + file->writeNumberLine(_timerId, indent); file->writeNumberLine(_fieldE8, indent); CBackground::save(file, indent); @@ -40,10 +46,43 @@ void CWheelButton::save(SimpleFile *file, int indent) { void CWheelButton::load(SimpleFile *file) { file->readNumber(); _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); + _timerId = file->readNumber(); _fieldE8 = file->readNumber(); CBackground::load(file); } +bool CWheelButton::SignalObject(CSignalObject *msg) { + bool oldFlag = _fieldE0; + _fieldE0 = msg->_numValue != 0; + + if (oldFlag != _fieldE0) { + if (_fieldE0) { + _timerId = addTimer(500, 500); + } else { + stopAnimTimer(_timerId); + _timerId = 0; + setVisible(false); + } + } + + return true; +} + +bool CWheelButton::TimerMsg(CTimerMsg *msg) { + setVisible(!_visible); + makeDirty(); + return true; +} + +bool CWheelButton::LeaveViewMsg(CLeaveViewMsg *msg) { + if (_timerId) { + stopAnimTimer(_timerId); + _timerId = 0; + setVisible(false); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/wheel_button.h b/engines/titanic/game/wheel_button.h index cb089a660f..2725e60622 100644 --- a/engines/titanic/game/wheel_button.h +++ b/engines/titanic/game/wheel_button.h @@ -28,9 +28,13 @@ namespace Titanic { class CWheelButton : public CBackground { + DECLARE_MESSAGE_MAP; + bool SignalObject(CSignalObject *msg); + bool TimerMsg(CTimerMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); public: - int _fieldE0; - int _fieldE4; + bool _fieldE0; + int _timerId; int _fieldE8; public: CLASSDEF; diff --git a/engines/titanic/game/wheel_hotspot.cpp b/engines/titanic/game/wheel_hotspot.cpp index f9af594cd5..544e6f5470 100644 --- a/engines/titanic/game/wheel_hotspot.cpp +++ b/engines/titanic/game/wheel_hotspot.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CWheelHotSpot, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(SignalObject) +END_MESSAGE_MAP() + void CWheelHotSpot::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_fieldE0, indent); @@ -40,4 +45,39 @@ void CWheelHotSpot::load(SimpleFile *file) { CBackground::load(file); } +bool CWheelHotSpot::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_fieldE0) { + CActMsg actMsg; + + switch (_fieldE4) { + case 1: + actMsg._action = "Stop"; + actMsg.execute("CaptainsWheel"); + break; + + case 2: + actMsg._action = "Cruise"; + actMsg.execute("CaptainsWheel"); + break; + + case 3: + actMsg._action = "Go"; + actMsg.execute("CaptainsWheel"); + break; + + default: + break; + } + } else if (_fieldE4 == 3) { + petDisplayMessage("Go where?"); + } + + return true; +} + +bool CWheelHotSpot::SignalObject(CSignalObject *msg) { + _fieldE0 = msg->_numValue != 0; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/wheel_hotspot.h b/engines/titanic/game/wheel_hotspot.h index 364fe9a060..e9071a2fa4 100644 --- a/engines/titanic/game/wheel_hotspot.h +++ b/engines/titanic/game/wheel_hotspot.h @@ -28,6 +28,9 @@ namespace Titanic { class CWheelHotSpot : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool SignalObject(CSignalObject *msg); public: int _fieldE0; int _fieldE4; diff --git a/engines/titanic/game/wheel_spin.cpp b/engines/titanic/game/wheel_spin.cpp index daa9918e29..79f83873e1 100644 --- a/engines/titanic/game/wheel_spin.cpp +++ b/engines/titanic/game/wheel_spin.cpp @@ -24,16 +24,36 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CWheelSpin, CBackground) + ON_MESSAGE(SignalObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CWheelSpin::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_active, indent); CBackground::save(file, indent); } void CWheelSpin::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _active = file->readNumber(); CBackground::load(file); } +bool CWheelSpin::SignalObject(CSignalObject *msg) { + _active = msg->_numValue != 0; + setVisible(_active); + return true; +} + +bool CWheelSpin::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_active) { + CActMsg actMsg("Spin"); + actMsg.execute("CaptainsWheel"); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/wheel_spin.h b/engines/titanic/game/wheel_spin.h index 509db1a4bf..f7993f0188 100644 --- a/engines/titanic/game/wheel_spin.h +++ b/engines/titanic/game/wheel_spin.h @@ -28,11 +28,14 @@ namespace Titanic { class CWheelSpin : public CBackground { + DECLARE_MESSAGE_MAP; + bool SignalObject(CSignalObject *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: - int _value; + bool _active; public: CLASSDEF; - CWheelSpin() : CBackground(), _value(0) {} + CWheelSpin() : CBackground(), _active(false) {} /** * Save the data for the class to file |