diff options
52 files changed, 1445 insertions, 135 deletions
diff --git a/devtools/create_titanic/create_titanic_dat.cpp b/devtools/create_titanic/create_titanic_dat.cpp index a7dbe53e97..7171467bf4 100644 --- a/devtools/create_titanic/create_titanic_dat.cpp +++ b/devtools/create_titanic/create_titanic_dat.cpp @@ -285,7 +285,7 @@ static const FrameRange BARBOT_FRAME_RANGES[60] = { { 202, 281 }, { 182, 202 }, { 165, 182 }, { 96, 165 }, { 0, 95 } }; -const char *const MISSIVEOMAT_MESSAGES[3] = { +static const char *const MISSIVEOMAT_MESSAGES[3] = { "Welcome, Leovinus.\n" "\n" "This is your Missive-O-Mat.\n" @@ -363,6 +363,58 @@ const char *const MISSIVEOMAT_MESSAGES[3] = { "His Loftiness Leovinus are here." }; +struct BedheadEntry { + const char *_name1; + const char *_name2; + const char *_name3; + const char *_name4; + int _startFrame; + int _endFrame; +}; + +static const BedheadEntry ON_CLOSED[4] = { + { "Closed", "Closed", "Open", "Open", 0, 12 }, + { "Open", "Any", "Any", "RestingUTV", 0, 4 }, + { "Closed", "Open", "Any", "RestingV", 0, 6 }, + { "Closed", "Closed", "Closed", "RestingG", 0, 21 } +}; +static const BedheadEntry ON_RESTING_TV[2] = { + { "Any", "Closed", "Open", "Open", 6, 12 }, + { "Any", "Closed", "Closed", "RestingG", 6, 21 } +}; +static const BedheadEntry ON_RESTING_UV[2] = { + { "Any", "Any", "Open", "Open", 8, 12 }, + { "Any", "Any", "Closed", "RestingG", 8, 21 } +}; +static const BedheadEntry ON_CLOSED_WRONG[2] = { + { "Any", "Any", "Closed", "OpenWrong", 42, 56 }, + { "Any", "Any", "Open", "RestingDWrong", 42, 52 } +}; + +static const BedheadEntry OFF_OPEN[3] = { + { "Closed", "Closed", "Open", "Closed", 27, 41 }, + { "Any", "Open", "Any", "RestingUV", 27, 29 }, + { "Open", "Closed", "Any", "RestingTV", 27, 33 } +}; +static const BedheadEntry OFF_RESTING_UTV[1] = { + { "Any", "Any", "Any", "Closed", 36, 41 } +}; +static const BedheadEntry OFF_RESTING_V[1] = { + { "Closed", "Any", "Any", "Closed", 32, 41 } +}; +static const BedheadEntry OFF_RESTING_G[3] = { + { "Closed", "Closed", "Closed", "Closed", 21, 41 }, + { "Any", "Open", "Closed", "RestingUV", 21, 29 }, + { "Open", "Closed", "Closed", "RestingTV", 21, 33 } +}; +static const BedheadEntry OFF_OPEN_WRONG[1] = { + { "Any", "Any", "Any", "ClosedWrong", 56, 70 } +}; +static const BedheadEntry OFF_RESTING_D_WRONG[1] = { + { "Any", "Any", "Any", "ClosedWrong", 59, 70 } +}; + + void NORETURN_PRE error(const char *s, ...) { printf("%s\n", s); exit(1); @@ -715,6 +767,36 @@ void writeMissiveOMatMessages() { writeStringArray("TEXT/MISSIVEOMAT/TO", TO[_version], 58); } +void writeBedheadGroup(const BedheadEntry *data, int count) { + for (int idx = 0; idx < count; ++idx, ++data) { + outputFile.writeString(data->_name1); + outputFile.writeString(data->_name2); + outputFile.writeString(data->_name3); + outputFile.writeString(data->_name4); + outputFile.writeLong(data->_startFrame); + outputFile.writeLong(data->_endFrame); + } +} + +void writeBedheadData() { + outputFile.seek(dataOffset); + + writeBedheadGroup(ON_CLOSED, 4); + writeBedheadGroup(ON_RESTING_TV, 2); + writeBedheadGroup(ON_RESTING_UV, 2); + writeBedheadGroup(ON_CLOSED_WRONG, 2); + writeBedheadGroup(OFF_OPEN, 3); + writeBedheadGroup(OFF_RESTING_UTV, 1); + writeBedheadGroup(OFF_RESTING_V, 1); + writeBedheadGroup(OFF_RESTING_G, 3); + writeBedheadGroup(OFF_OPEN_WRONG, 1); + writeBedheadGroup(OFF_RESTING_D_WRONG, 1); + + uint size = outputFile.size() - dataOffset; + writeEntryHeader("DATA/BEDHEAD", dataOffset, size); + dataOffset += size; +} + void writeHeader() { // Write out magic string const char *MAGIC_STR = "SVTN"; @@ -886,6 +968,7 @@ void writeData() { writeAllScriptPreResponses(); writeBarbotFrameRanges(); writeMissiveOMatMessages(); + writeBedheadData(); } void createScriptMap() { diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index a5bbf21151..e0fc1f6b04 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -108,20 +108,22 @@ bool StepArray::gotoNextPoint() { void StepArray::insertPoints(Common::Point **points, int pointsCount) { if (_currPointIndex + pointsCount >= _pointsCount) { - _points = (Common::Point **)realloc(_points, sizeof(Common::Point *) * (_currPointIndex + pointsCount)); + _points = (Common::Point **)realloc(_points, sizeof(Common::Point *) * (_pointsCount + pointsCount)); if (!_points) { error("Out of memory at StepArray::insertPoints()"); } + + for(int i = 0; i < pointsCount; i++) + _points[_pointsCount + i] = new Common::Point; + + _pointsCount += pointsCount; } _maxPointIndex = _currPointIndex + pointsCount; - for (int i = 0; i < pointsCount; i++) { - _points[_currPointIndex + i] = new Common::Point; - + for (int i = 0; i < pointsCount; i++) *_points[_currPointIndex + i] = *points[i]; - } } StaticANIObject::StaticANIObject() { @@ -2152,11 +2154,17 @@ void Movement::gotoFirstFrame() { void Movement::gotoLastFrame() { if (_currMovement) { - while ((uint)_currDynamicPhaseIndex != _currMovement->_dynamicPhases.size() - 1) - gotoNextFrame(0, 0); + if ((uint)_currDynamicPhaseIndex != _currMovement->_dynamicPhases.size() - 1) { + do { + gotoNextFrame(0, 0); + } while ((uint)_currDynamicPhaseIndex != _currMovement->_dynamicPhases.size() - 1); + } } else { - while ((uint)_currDynamicPhaseIndex != _dynamicPhases.size() - 1) - gotoNextFrame(0, 0); + if ((uint)_currDynamicPhaseIndex != _dynamicPhases.size() - 1) { + do { + gotoNextFrame(0, 0); + } while ((uint)_currDynamicPhaseIndex != _dynamicPhases.size() - 1); + } } } diff --git a/engines/titanic/carry/mouth.cpp b/engines/titanic/carry/mouth.cpp index 8c3791fa9c..e48929a391 100644 --- a/engines/titanic/carry/mouth.cpp +++ b/engines/titanic/carry/mouth.cpp @@ -21,9 +21,16 @@ */ #include "titanic/carry/mouth.h" +#include "titanic/game/head_slot.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMouth, CHeadPiece) + ON_MESSAGE(UseWithOtherMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(PETGainedObjectMsg) +END_MESSAGE_MAP() + CMouth::CMouth() : CHeadPiece() { } @@ -37,4 +44,37 @@ void CMouth::load(SimpleFile *file) { CHeadPiece::load(file); } +bool CMouth::UseWithOtherMsg(CUseWithOtherMsg *msg) { + CHeadSlot *slot = dynamic_cast<CHeadSlot *>(msg->_other); + if (!slot) + return CHeadPiece::UseWithOtherMsg(msg); + + _flag = true; + setVisible(false); + setPosition(Point(0, 0)); + petMoveToHiddenRoom(); + + CAddHeadPieceMsg addMsg(getName()); + if (addMsg._value != "NULL") + addMsg.execute("MouthSlot"); + + return true; +} + +bool CMouth::MovieEndMsg(CMovieEndMsg *msg) { + return true; +} + +bool CMouth::PETGainedObjectMsg(CPETGainedObjectMsg *msg) { + _visibleFrame = 2; + loadFrame(2); + setVisible(true); + if (!_field13C) { + stateInc38(); + _field13C = true; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/carry/mouth.h b/engines/titanic/carry/mouth.h index e394330494..f5f0f53b45 100644 --- a/engines/titanic/carry/mouth.h +++ b/engines/titanic/carry/mouth.h @@ -28,6 +28,10 @@ namespace Titanic { class CMouth : public CHeadPiece { + DECLARE_MESSAGE_MAP; + bool UseWithOtherMsg(CUseWithOtherMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool PETGainedObjectMsg(CPETGainedObjectMsg *msg); public: CLASSDEF; CMouth(); diff --git a/engines/titanic/carry/napkin.cpp b/engines/titanic/carry/napkin.cpp index ace5a389a0..d25e8b5975 100644 --- a/engines/titanic/carry/napkin.cpp +++ b/engines/titanic/carry/napkin.cpp @@ -57,5 +57,4 @@ bool CNapkin::UseWithOtherMsg(CUseWithOtherMsg *msg) { return CCarry::UseWithOtherMsg(msg); } - } // End of namespace Titanic diff --git a/engines/titanic/core/multi_drop_target.cpp b/engines/titanic/core/multi_drop_target.cpp index f2998199b1..b95696577f 100644 --- a/engines/titanic/core/multi_drop_target.cpp +++ b/engines/titanic/core/multi_drop_target.cpp @@ -21,9 +21,14 @@ */ #include "titanic/core/multi_drop_target.h" +#include "titanic/support/string_parser.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMultiDropTarget, CDropTarget) + ON_MESSAGE(DropObjectMsg) +END_MESSAGE_MAP() + void CMultiDropTarget::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeQuotedLine(_string5, indent); @@ -40,4 +45,20 @@ void CMultiDropTarget::load(SimpleFile *file) { CDropTarget::load(file); } +bool CMultiDropTarget::DropObjectMsg(CDropObjectMsg *msg) { + CStringParser parser1(_string5); + CStringParser parser2(_string6); + CString seperatorChars = ","; + + while (parser2.parse(_itemMatchName, seperatorChars)) { + _dropFrame = parser1.readInt(); + CDropTarget::DropObjectMsg(msg); + + parser1.skipSeperators(seperatorChars); + parser2.skipSeperators(seperatorChars); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/core/multi_drop_target.h b/engines/titanic/core/multi_drop_target.h index c004b9bece..ab552f96e1 100644 --- a/engines/titanic/core/multi_drop_target.h +++ b/engines/titanic/core/multi_drop_target.h @@ -28,6 +28,8 @@ namespace Titanic { class CMultiDropTarget : public CDropTarget { + DECLARE_MESSAGE_MAP; + bool DropObjectMsg(CDropObjectMsg *msg); public: CString _string5; CString _string6; diff --git a/engines/titanic/game/missiveomat_button.cpp b/engines/titanic/game/missiveomat_button.cpp index d5ae75dbc2..b7ad7f8f6f 100644 --- a/engines/titanic/game/missiveomat_button.cpp +++ b/engines/titanic/game/missiveomat_button.cpp @@ -21,21 +21,47 @@ */ #include "titanic/game/missiveomat_button.h" +#include "titanic/core/room_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMissiveOMatButton, CEditControl) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(VisibleMsg) + ON_MESSAGE(MouseDoubleClickMsg) +END_MESSAGE_MAP() + void CMissiveOMatButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_buttonId, indent); CEditControl::save(file, indent); } void CMissiveOMatButton::load(SimpleFile *file) { file->readNumber(); - _fieldFC = file->readNumber(); + _buttonId = file->readNumber(); CEditControl::load(file); } +bool CMissiveOMatButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CMissiveOMatActionMsg actionMsg; + actionMsg._action = _buttonId; + actionMsg.execute(findRoom()->findByName("MissiveOMat")); + return true; +} + +bool CMissiveOMatButton::VisibleMsg(CVisibleMsg *msg) { + setVisible(msg->_visible); + return true; +} + +bool CMissiveOMatButton::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + CMissiveOMatActionMsg actionMsg; + actionMsg._action = _buttonId; + actionMsg.execute(findRoom()->findByName("MissiveOMat")); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/missiveomat_button.h b/engines/titanic/game/missiveomat_button.h index d36f5bd958..6dbfd4cd56 100644 --- a/engines/titanic/game/missiveomat_button.h +++ b/engines/titanic/game/missiveomat_button.h @@ -28,11 +28,15 @@ namespace Titanic { class CMissiveOMatButton : public CEditControl { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool VisibleMsg(CVisibleMsg *msg); + bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); public: - int _fieldFC; + int _buttonId; public: CLASSDEF; - CMissiveOMatButton() : CEditControl(), _fieldFC(2) {} + CMissiveOMatButton() : CEditControl(), _buttonId(2) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/movie_tester.cpp b/engines/titanic/game/movie_tester.cpp index 1b266d9c7e..bbd66a9bce 100644 --- a/engines/titanic/game/movie_tester.cpp +++ b/engines/titanic/game/movie_tester.cpp @@ -24,18 +24,36 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CMovieTester, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + void CMovieTester::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value1, indent); - file->writeNumberLine(_value2, indent); + file->writeNumberLine(_movieNumFrames, indent); + file->writeNumberLine(_movieFrameNum, indent); CGameObject::save(file, indent); } void CMovieTester::load(SimpleFile *file) { file->readNumber(); - _value1 = file->readNumber(); - _value2 = file->readNumber(); + _movieNumFrames = file->readNumber(); + _movieFrameNum = file->readNumber(); CGameObject::load(file); } +bool CMovieTester::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (msg->_buttons == MB_RIGHT) { + if (--_movieFrameNum < 0) { + _movieFrameNum = _movieNumFrames - 1; + } + } else { + if (++_movieFrameNum >= _movieNumFrames) + _movieFrameNum = 0; + } + + loadFrame(_movieFrameNum); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/movie_tester.h b/engines/titanic/game/movie_tester.h index de2ef2cc5e..17a7d489d8 100644 --- a/engines/titanic/game/movie_tester.h +++ b/engines/titanic/game/movie_tester.h @@ -28,11 +28,13 @@ namespace Titanic { class CMovieTester : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: - int _value1, _value2; + int _movieNumFrames, _movieFrameNum; public: CLASSDEF; - CMovieTester() : CGameObject(), _value1(0), _value2(0) {} + CMovieTester() : CGameObject(), _movieNumFrames(0), _movieFrameNum(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/music_console_button.cpp b/engines/titanic/game/music_console_button.cpp index 1bc78ffe23..9cf385e3a7 100644 --- a/engines/titanic/game/music_console_button.cpp +++ b/engines/titanic/game/music_console_button.cpp @@ -21,9 +21,18 @@ */ #include "titanic/game/music_console_button.h" +#include "titanic/core/room_item.h" +#include "titanic/sound/music_handler.h" +#include "titanic/titanic.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMusicConsoleButton, CMusicPlayer) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(SetMusicControlsMsg) +END_MESSAGE_MAP() + void CMusicConsoleButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); CMusicPlayer::save(file, indent); @@ -34,4 +43,91 @@ void CMusicConsoleButton::load(SimpleFile *file) { CMusicPlayer::load(file); } +bool CMusicConsoleButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_isActive) { + CStopMusicMsg stopMsg(this); + stopMsg.execute(this); + stopMovie(); + loadFrame(0); + } else { + CStartMusicMsg startMsg(this); + startMsg.execute(this); + playMovie(MOVIE_REPEAT); + + CMusicHasStartedMsg startedMsg; + startedMsg.execute("Music Room Phonograph"); + + if (CMusicRoom::_musicHandler->checkSound(1) + && CMusicRoom::_musicHandler->checkSound(2) + && CMusicRoom::_musicHandler->checkSound(3)) { + CCorrectMusicPlayedMsg correctMsg; + correctMsg.execute(findRoom()); + } + } + + return true; +} + +bool CMusicConsoleButton::LeaveViewMsg(CLeaveViewMsg *msg) { + if (_isActive) { + CStopMusicMsg stopMsg(this); + stopMsg.execute(this); + stopMovie(); + loadFrame(0); + } + + return true; +} + +bool CMusicConsoleButton::SetMusicControlsMsg(CSetMusicControlsMsg *msg) { + CMusicRoom *musicRoom = getMusicRoom(); + CQueryMusicControlSettingMsg queryMsg; + + queryMsg.execute("Bells Mute Control"); + musicRoom->setItem5(BELLS, queryMsg._value == 1 ? 1 : 0); + queryMsg.execute("Bells Pitch Control"); + musicRoom->setItem2(BELLS, queryMsg._value); + queryMsg.execute("Bells Speed Control"); + musicRoom->setItem1(BELLS, queryMsg._value); + queryMsg.execute("Bells Inversion Control"); + musicRoom->setItem4(BELLS, queryMsg._value == 0 ? 1 : 0); + queryMsg.execute("Bells Direction Control"); + musicRoom->setItem3(BELLS, queryMsg._value == 0 ? 1 : 0); + + queryMsg.execute("Snake Mute Control"); + musicRoom->setItem5(SNAKE, queryMsg._value == 1 ? 1 : 0); + queryMsg.execute("Snake Pitch Control"); + musicRoom->setItem2(SNAKE, queryMsg._value); + queryMsg.execute("Snake Speed Control"); + musicRoom->setItem1(SNAKE, queryMsg._value); + queryMsg.execute("Snake Inversion Control"); + musicRoom->setItem4(SNAKE, queryMsg._value == 0 ? 1 : 0); + queryMsg.execute("Snake Direction Control"); + musicRoom->setItem3(SNAKE, queryMsg._value == 0 ? 1 : 0); + + queryMsg.execute("Piano Mute Control"); + musicRoom->setItem5(PIANO, queryMsg._value == 1 ? 1 : 0); + queryMsg.execute("Piano Pitch Control"); + musicRoom->setItem2(PIANO, queryMsg._value); + queryMsg.execute("Piano Speed Control"); + musicRoom->setItem1(PIANO, queryMsg._value); + queryMsg.execute("Piano Inversion Control"); + musicRoom->setItem4(PIANO, queryMsg._value == 0 ? 1 : 0); + queryMsg.execute("Piano Direction Control"); + musicRoom->setItem3(PIANO, queryMsg._value == 0 ? 1 : 0); + + queryMsg.execute("Bass Mute Control"); + musicRoom->setItem5(BASS, queryMsg._value == 1 ? 1 : 0); + queryMsg.execute("Bass Pitch Control"); + musicRoom->setItem2(BASS, queryMsg._value); + queryMsg.execute("Bass Speed Control"); + musicRoom->setItem1(BASS, queryMsg._value); + queryMsg.execute("Bass Inversion Control"); + musicRoom->setItem4(BASS, queryMsg._value == 0 ? 1 : 0); + queryMsg.execute("Bass Direction Control"); + musicRoom->setItem3(BASS, queryMsg._value == 0 ? 1 : 0); + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/music_console_button.h b/engines/titanic/game/music_console_button.h index 8e05b698d7..80ce719c96 100644 --- a/engines/titanic/game/music_console_button.h +++ b/engines/titanic/game/music_console_button.h @@ -28,6 +28,10 @@ namespace Titanic { class CMusicConsoleButton : public CMusicPlayer { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool SetMusicControlsMsg(CSetMusicControlsMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/game/music_room_stop_phonograph_button.cpp b/engines/titanic/game/music_room_stop_phonograph_button.cpp index 44342fc2d6..dee2c0883e 100644 --- a/engines/titanic/game/music_room_stop_phonograph_button.cpp +++ b/engines/titanic/game/music_room_stop_phonograph_button.cpp @@ -24,16 +24,52 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CMusicRoomStopPhonographButton, CEjectPhonographButton) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(FrameMsg) +END_MESSAGE_MAP() + void CMusicRoomStopPhonographButton::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_field100, indent); + file->writeNumberLine(_ticks, indent); CEjectPhonographButton::save(file, indent); } void CMusicRoomStopPhonographButton::load(SimpleFile *file) { file->readNumber(); - _field100 = file->readNumber(); + _ticks = file->readNumber(); CEjectPhonographButton::load(file); } +bool CMusicRoomStopPhonographButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (!_ejected) { + loadFrame(1); + playSound(_soundName); + _readyFlag = true; + + CPhonographStopMsg stopMsg; + stopMsg.execute(getParent(), nullptr, MSGFLAG_SCAN); + if (stopMsg._value2) { + _ticks = getTicksCount(); + } else { + CEjectCylinderMsg ejectMsg; + ejectMsg.execute(getParent(), nullptr, MSGFLAG_SCAN); + _ejected = true; + } + } + + return true; +} + +bool CMusicRoomStopPhonographButton::FrameMsg(CFrameMsg *msg) { + if (_readyFlag && _ticks && msg->_ticks >= (_ticks + 100)) { + loadFrame(0); + playSound(_readySoundName); + _ticks = 0; + _readyFlag = false; + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/music_room_stop_phonograph_button.h b/engines/titanic/game/music_room_stop_phonograph_button.h index 7260e5aaab..dd9e8b4bc0 100644 --- a/engines/titanic/game/music_room_stop_phonograph_button.h +++ b/engines/titanic/game/music_room_stop_phonograph_button.h @@ -28,11 +28,14 @@ namespace Titanic { class CMusicRoomStopPhonographButton : public CEjectPhonographButton { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool FrameMsg(CFrameMsg *msg); private: - int _field100; + uint _ticks; public: CLASSDEF; - CMusicRoomStopPhonographButton() : CEjectPhonographButton(), _field100(0) {} + CMusicRoomStopPhonographButton() : CEjectPhonographButton(), _ticks(0) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/music_system_lock.cpp b/engines/titanic/game/music_system_lock.cpp index f1e062b3ee..074864e7c3 100644 --- a/engines/titanic/game/music_system_lock.cpp +++ b/engines/titanic/game/music_system_lock.cpp @@ -21,9 +21,16 @@ */ #include "titanic/game/music_system_lock.h" +#include "titanic/core/room_item.h" +#include "titanic/carry/carry.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMusicSystemLock, CDropTarget) + ON_MESSAGE(DropObjectMsg) + ON_MESSAGE(MovieEndMsg) +END_MESSAGE_MAP() + void CMusicSystemLock::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); file->writeNumberLine(_value, indent); @@ -36,4 +43,25 @@ void CMusicSystemLock::load(SimpleFile *file) { CDropTarget::load(file); } +bool CMusicSystemLock::DropObjectMsg(CDropObjectMsg *msg) { + CTreeItem *key = msg->_item->findByName("Music System Key"); + if (key) { + setVisible(true); + playMovie(MOVIE_NOTIFY_OBJECT); + } + + return true; +} + +bool CMusicSystemLock::MovieEndMsg(CMovieEndMsg *msg) { + CTreeItem *phonograph = findRoom()->findByName("Restaurant Phonograph"); + CQueryPhonographState queryMsg; + queryMsg.execute(phonograph); + CLockPhonographMsg lockMsg(queryMsg._value); + lockMsg.execute(phonograph, nullptr, MSGFLAG_SCAN); + + setVisible(false); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/music_system_lock.h b/engines/titanic/game/music_system_lock.h index ff826f5c77..0947915caa 100644 --- a/engines/titanic/game/music_system_lock.h +++ b/engines/titanic/game/music_system_lock.h @@ -28,6 +28,9 @@ namespace Titanic { class CMusicSystemLock : public CDropTarget { + DECLARE_MESSAGE_MAP; + bool DropObjectMsg(CDropObjectMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); private: int _value; public: diff --git a/engines/titanic/game/nav_helmet.cpp b/engines/titanic/game/nav_helmet.cpp index 770eb7375e..08ff073c26 100644 --- a/engines/titanic/game/nav_helmet.cpp +++ b/engines/titanic/game/nav_helmet.cpp @@ -21,19 +21,114 @@ */ #include "titanic/game/nav_helmet.h" +#include "titanic/pet_control/pet_control.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CNavHelmet, CGameObject) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(LeaveViewMsg) + ON_MESSAGE(PETHelmetOnOffMsg) + ON_MESSAGE(PETPhotoOnOffMsg) + ON_MESSAGE(PETStarFieldLockMsg) + ON_MESSAGE(PETSetStarDestinationMsg) +END_MESSAGE_MAP() + void CNavHelmet::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_value, indent); + file->writeNumberLine(_flag, indent); CGameObject::save(file, indent); } void CNavHelmet::load(SimpleFile *file) { file->readNumber(); - _value = file->readNumber(); + _flag = file->readNumber(); CGameObject::load(file); } +bool CNavHelmet::MovieEndMsg(CMovieEndMsg *msg) { + if (_flag) { + setVisible(false); + + CPetControl *pet = getPetControl(); + if (pet) { + pet->setArea(PET_STARFIELD); + petDisplayMessage(1, "Now would be an excellent opportunity to adjust your viewing apparatus."); + pet->incAreaLocks(); + } + + starFn1(0); + starFn1(12); + } + + return true; +} + +bool CNavHelmet::EnterViewMsg(CEnterViewMsg *msg) { + petSetRemoteTarget(); + return true; +} + +bool CNavHelmet::LeaveViewMsg(CLeaveViewMsg *msg) { + petClear(); + return true; +} + +bool CNavHelmet::PETHelmetOnOffMsg(CPETHelmetOnOffMsg *msg) { + CPetControl *pet = getPetControl(); + + if (_flag) { + _flag = false; + setVisible(true); + starFn1(1); + playMovie(61, 120, MOVIE_NOTIFY_OBJECT); + playSound("a#47.wav"); + playSound("a#48.wav"); + + if (pet) { + pet->decAreaLocks(); + pet->setArea(PET_REMOTE); + } + + dec54(); + } else { + inc54(); + _flag = true; + setVisible(true); + playMovie(0, 60, MOVIE_NOTIFY_OBJECT); + playSound("a#48.wav"); + playSound("a#47.wav"); + } + + return true; +} + +bool CNavHelmet::PETPhotoOnOffMsg(CPETPhotoOnOffMsg *msg) { + if (_flag) + starFn1(9); + + return true; +} + +bool CNavHelmet::PETStarFieldLockMsg(CPETStarFieldLockMsg *msg) { + if (_flag) { + if (msg->_value) { + playSound("a#6.wav"); + starFn1(17); + } else { + playSound("a#5.wav"); + starFn1(18); + } + } + + return true; +} + +bool CNavHelmet::PETSetStarDestinationMsg(CPETSetStarDestinationMsg *msg) { + CActMsg actMsg("SetDestin"); + actMsg.execute("CaptainsWheel"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/game/nav_helmet.h b/engines/titanic/game/nav_helmet.h index 74caa52534..c408d05c97 100644 --- a/engines/titanic/game/nav_helmet.h +++ b/engines/titanic/game/nav_helmet.h @@ -24,15 +24,24 @@ #define TITANIC_NAV_HELMET_H #include "titanic/core/game_object.h" +#include "titanic/messages/pet_messages.h" namespace Titanic { class CNavHelmet : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MovieEndMsg(CMovieEndMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool LeaveViewMsg(CLeaveViewMsg *msg); + bool PETHelmetOnOffMsg(CPETHelmetOnOffMsg *msg); + bool PETPhotoOnOffMsg(CPETPhotoOnOffMsg *msg); + bool PETStarFieldLockMsg(CPETStarFieldLockMsg *msg); + bool PETSetStarDestinationMsg(CPETSetStarDestinationMsg *msg); private: - int _value; + bool _flag; public: CLASSDEF; - CNavHelmet() : CGameObject(), _value(0) {} + CNavHelmet() : CGameObject(), _flag(false) {} /** * Save the data for the class to file diff --git a/engines/titanic/game/nav_helmet_off.cpp b/engines/titanic/game/nav_helmet_off.cpp new file mode 100644 index 0000000000..289e9e3f55 --- /dev/null +++ b/engines/titanic/game/nav_helmet_off.cpp @@ -0,0 +1,49 @@ +/* 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. + * + */ + +#include "titanic/game/nav_helmet_off.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CNavHelmetOff, CNavHelmet) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + +void CNavHelmetOff::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_target, indent); +} + +void CNavHelmetOff::load(SimpleFile *file) { + file->readNumber(); + _target = file->readString(); +} + +bool CNavHelmetOff::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + CDoffNavHelmet doffMsg; + doffMsg.execute(_target); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/nav_helmet_off.h b/engines/titanic/game/nav_helmet_off.h new file mode 100644 index 0000000000..c9529fe8e9 --- /dev/null +++ b/engines/titanic/game/nav_helmet_off.h @@ -0,0 +1,53 @@ +/* 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. + * + */ + +#ifndef TITANIC_NAV_HELMET_OFF_H +#define TITANIC_NAV_HELMET_OFF_H + +#include "titanic/game/nav_helmet.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +class CNavHelmetOff : public CNavHelmet { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); +private: + CString _target; +public: + CLASSDEF; + CNavHelmetOff() : CNavHelmet(), _target("NULL") {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NAV_HELMET_OFF_H */ diff --git a/engines/titanic/game/nav_helmet_on.cpp b/engines/titanic/game/nav_helmet_on.cpp new file mode 100644 index 0000000000..59ceebc4ad --- /dev/null +++ b/engines/titanic/game/nav_helmet_on.cpp @@ -0,0 +1,49 @@ +/* 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. + * + */ + +#include "titanic/game/nav_helmet_on.h" +#include "titanic/pet_control/pet_control.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CNavHelmetOn, CNavHelmet) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + +void CNavHelmetOn::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + file->writeQuotedLine(_target, indent); +} + +void CNavHelmetOn::load(SimpleFile *file) { + file->readNumber(); + _target = file->readString(); +} + +bool CNavHelmetOn::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + CDonNavHelmet donMsg; + donMsg.execute(_target); + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/game/nav_helmet_on.h b/engines/titanic/game/nav_helmet_on.h new file mode 100644 index 0000000000..452637c48a --- /dev/null +++ b/engines/titanic/game/nav_helmet_on.h @@ -0,0 +1,53 @@ +/* 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. + * + */ + +#ifndef TITANIC_NAV_HELMET_ON_H +#define TITANIC_NAV_HELMET_ON_H + +#include "titanic/game/nav_helmet.h" +#include "titanic/messages/pet_messages.h" + +namespace Titanic { + +class CNavHelmetOn : public CNavHelmet { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); +private: + CString _target; +public: + CLASSDEF; + CNavHelmetOn() : CNavHelmet(), _target("NULL") {} + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; + +} // End of namespace Titanic + +#endif /* TITANIC_NAV_HELMET_ON_H */ diff --git a/engines/titanic/game/sgt/bedhead.cpp b/engines/titanic/game/sgt/bedhead.cpp index 45031bd6b3..f911a83ae3 100644 --- a/engines/titanic/game/sgt/bedhead.cpp +++ b/engines/titanic/game/sgt/bedhead.cpp @@ -21,6 +21,7 @@ */ #include "titanic/game/sgt/bedhead.h" +#include "titanic/titanic.h" namespace Titanic { @@ -30,41 +31,49 @@ BEGIN_MESSAGE_MAP(CBedhead, CSGTStateRoom) END_MESSAGE_MAP() void BedheadEntry::load(Common::SeekableReadStream *s) { - // TODO + _name1 = readStringFromStream(s); + _name2 = readStringFromStream(s); + _name3 = readStringFromStream(s); + _name4 = readStringFromStream(s); + _startFrame = s->readUint32LE(); + _endFrame = s->readUint32LE(); } /*------------------------------------------------------------------------*/ -void BedheadEntries::load(Common::SeekableReadStream *s) { - resize(s->readUint32LE()); - for (uint idx = 0; idx < size(); ++idx) +void BedheadEntries::load(Common::SeekableReadStream *s, int count) { + resize(count); + for (uint idx = 0; idx < count; ++idx) (*this)[idx].load(s); } /*------------------------------------------------------------------------*/ void TurnOnEntries::load(Common::SeekableReadStream *s) { - _closed.load(s); - _restingTV.load(s); - _restingUV.load(s); - _closedWrong.load(s); + _closed.load(s, 4); + _restingTV.load(s, 2); + _restingUV.load(s, 2); + _closedWrong.load(s, 2); } /*------------------------------------------------------------------------*/ void TurnOffEntries::load(Common::SeekableReadStream *s) { - _open.load(s); - _restingUTV.load(s); - _restingV.load(s); - _restingG.load(s); - _openWrong.load(s); - _restingDWrong.load(s); + _open.load(s, 3); + _restingUTV.load(s, 1); + _restingV.load(s, 1); + _restingG.load(s, 3); + _openWrong.load(s, 1); + _restingDWrong.load(s, 1); } /*------------------------------------------------------------------------*/ CBedhead::CBedhead() : CSGTStateRoom() { - // TODO: Load data for turn on/off methods + Common::SeekableReadStream *s = g_vm->_filesManager->getResource("DATA/BEDHEAD"); + _on.load(s); + _off.load(s); + delete s; } void CBedhead::save(SimpleFile *file, int indent) { diff --git a/engines/titanic/game/sgt/bedhead.h b/engines/titanic/game/sgt/bedhead.h index 53c61e19d8..7784cb8caf 100644 --- a/engines/titanic/game/sgt/bedhead.h +++ b/engines/titanic/game/sgt/bedhead.h @@ -40,7 +40,7 @@ struct BedheadEntry { }; class BedheadEntries : public Common::Array<BedheadEntry> { public: - void load(Common::SeekableReadStream *s); + void load(Common::SeekableReadStream *s, int count); }; struct TurnOnEntries { diff --git a/engines/titanic/gfx/move_object_button.cpp b/engines/titanic/gfx/move_object_button.cpp index bdc90a673c..bcd2b2bd76 100644 --- a/engines/titanic/gfx/move_object_button.cpp +++ b/engines/titanic/gfx/move_object_button.cpp @@ -21,9 +21,14 @@ */ #include "titanic/gfx/move_object_button.h" +#include "titanic/core/project_item.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMoveObjectButton, CSTButton) + ON_MESSAGE(MouseButtonUpMsg) +END_MESSAGE_MAP() + CMoveObjectButton::CMoveObjectButton() : CSTButton(), _field11C(1) { } @@ -43,4 +48,14 @@ void CMoveObjectButton::load(SimpleFile *file) { CSTButton::load(file); } +bool CMoveObjectButton::MouseButtonUpMsg(CMouseButtonUpMsg *msg) { + CGameObject *obj = dynamic_cast<CGameObject *>(getRoot()->findByName(_actionTarget)); + if (obj) { + obj->petAddToInventory(); + obj->setVisible(_field11C); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/gfx/move_object_button.h b/engines/titanic/gfx/move_object_button.h index eb2fdc4ff2..46c49c36e2 100644 --- a/engines/titanic/gfx/move_object_button.h +++ b/engines/titanic/gfx/move_object_button.h @@ -28,6 +28,8 @@ namespace Titanic { class CMoveObjectButton : public CSTButton { + DECLARE_MESSAGE_MAP; + bool MouseButtonUpMsg(CMouseButtonUpMsg *msg); private: Point _pos1; int _field11C; diff --git a/engines/titanic/gfx/music_control.cpp b/engines/titanic/gfx/music_control.cpp index 85a3d777ef..317bec209f 100644 --- a/engines/titanic/gfx/music_control.cpp +++ b/engines/titanic/gfx/music_control.cpp @@ -24,15 +24,20 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CMusicControl, CBackground) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(MouseDoubleClickMsg) +END_MESSAGE_MAP() + CMusicControl::CMusicControl() : CBackground(), - _fieldE0(0), _fieldE4(0), _fieldE8(1), _fieldEC(1) { + _controlArea(BELLS), _controlVal(0), _controlMax(1), _fieldEC(1) { } void CMusicControl::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldE0, indent); - file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_controlArea, indent); + file->writeNumberLine(_controlVal, indent); + file->writeNumberLine(_controlMax, indent); file->writeNumberLine(_fieldEC, indent); CBackground::save(file, indent); @@ -40,12 +45,24 @@ void CMusicControl::save(SimpleFile *file, int indent) { void CMusicControl::load(SimpleFile *file) { file->readNumber(); - _fieldE0 = file->readNumber(); - _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); + _controlArea = (MusicControlArea)file->readNumber(); + _controlVal = file->readNumber(); + _controlMax = file->readNumber(); _fieldEC = file->readNumber(); CBackground::load(file); } +bool CMusicControl::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CMusicSettingChangedMsg changedMsg; + changedMsg.execute(this); + return true; +} + +bool CMusicControl::MouseDoubleClickMsg(CMouseDoubleClickMsg *msg) { + CMusicSettingChangedMsg changedMsg; + changedMsg.execute(this); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/gfx/music_control.h b/engines/titanic/gfx/music_control.h index 04085f789c..a0e73392f9 100644 --- a/engines/titanic/gfx/music_control.h +++ b/engines/titanic/gfx/music_control.h @@ -24,14 +24,18 @@ #define TITANIC_MUSIC_CONTROL_H #include "titanic/core/background.h" +#include "titanic/sound/music_room.h" namespace Titanic { class CMusicControl : public CBackground { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool MouseDoubleClickMsg(CMouseDoubleClickMsg *msg); public: - int _fieldE0; - int _fieldE4; - int _fieldE8; + MusicControlArea _controlArea; + int _controlVal; + int _controlMax; int _fieldEC; public: CLASSDEF; diff --git a/engines/titanic/gfx/music_slider_pitch.cpp b/engines/titanic/gfx/music_slider_pitch.cpp new file mode 100644 index 0000000000..5f0432e742 --- /dev/null +++ b/engines/titanic/gfx/music_slider_pitch.cpp @@ -0,0 +1,67 @@ +/* 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. + * + */ + +#include "titanic/gfx/music_slider_pitch.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CMusicSliderPitch, CMusicSlider) + ON_MESSAGE(MusicSettingChangedMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(QueryMusicControlSettingMsg) +END_MESSAGE_MAP() + +void CMusicSliderPitch::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicSlider::save(file, indent); +} + +void CMusicSliderPitch::load(SimpleFile *file) { + file->readNumber(); + CMusicSlider::load(file); +} + +bool CMusicSliderPitch::MusicSettingChangedMsg(CMusicSettingChangedMsg *msg) { + if (_fieldEC) { + if (++_controlVal > _controlMax) + _controlVal = 0; + + loadFrame(3 - _controlVal); + playSound("z#54.wav", 50); + } else { + playSound("z#46.wav"); + } + + return true; +} + +bool CMusicSliderPitch::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(3 - _controlVal); + return true; +} + +bool CMusicSliderPitch::QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg) { + msg->_value = _controlVal - 2; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/music_slider_pitch.h b/engines/titanic/gfx/music_slider_pitch.h index 10c1d62c3a..c375c6db33 100644 --- a/engines/titanic/gfx/music_slider_pitch.h +++ b/engines/titanic/gfx/music_slider_pitch.h @@ -28,24 +28,22 @@ namespace Titanic { class CMusicSliderPitch : public CMusicSlider { + DECLARE_MESSAGE_MAP; + bool MusicSettingChangedMsg(CMusicSettingChangedMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg); public: CLASSDEF; /** * Save the data for the class to file */ - virtual void save(SimpleFile *file, int indent) { - file->writeNumberLine(1, indent); - CMusicSlider::save(file, indent); - } + virtual void save(SimpleFile *file, int indent); /** * Load the data for the class from file */ - virtual void load(SimpleFile *file) { - file->readNumber(); - CMusicSlider::load(file); - } + virtual void load(SimpleFile *file); }; } // End of namespace Titanic diff --git a/engines/titanic/gfx/music_slider_speed.cpp b/engines/titanic/gfx/music_slider_speed.cpp new file mode 100644 index 0000000000..93af5d82b7 --- /dev/null +++ b/engines/titanic/gfx/music_slider_speed.cpp @@ -0,0 +1,67 @@ +/* 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. + * + */ + +#include "titanic/gfx/music_slider_speed.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CMusicSliderSpeed, CMusicSlider) + ON_MESSAGE(MusicSettingChangedMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(QueryMusicControlSettingMsg) +END_MESSAGE_MAP() + +void CMusicSliderSpeed::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicSlider::save(file, indent); +} + +void CMusicSliderSpeed::load(SimpleFile *file) { + file->readNumber(); + CMusicSlider::load(file); +} + +bool CMusicSliderSpeed::MusicSettingChangedMsg(CMusicSettingChangedMsg *msg) { + if (_fieldEC) { + if (++_controlVal > _controlMax) + _controlVal = 0; + + loadFrame(3 - _controlVal); + playSound("z#54.wav", 50); + } else { + playSound("z#46.wav"); + } + + return true; +} + +bool CMusicSliderSpeed::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(3 - _controlVal); + return true; +} + +bool CMusicSliderSpeed::QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg) { + msg->_value = _controlVal - 1; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/music_slider_speed.h b/engines/titanic/gfx/music_slider_speed.h index 9814ca0312..2d54f4487c 100644 --- a/engines/titanic/gfx/music_slider_speed.h +++ b/engines/titanic/gfx/music_slider_speed.h @@ -27,26 +27,24 @@ namespace Titanic { - class CMusicSliderSpeed : public CMusicSlider { - public: - CLASSDEF; - - /** - * Save the data for the class to file - */ - virtual void save(SimpleFile *file, int indent) { - file->writeNumberLine(1, indent); - CMusicSlider::save(file, indent); - } - - /** - * Load the data for the class from file - */ - virtual void load(SimpleFile *file) { - file->readNumber(); - CMusicSlider::load(file); - } - }; +class CMusicSliderSpeed : public CMusicSlider { + DECLARE_MESSAGE_MAP; + bool MusicSettingChangedMsg(CMusicSettingChangedMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; } // End of namespace Titanic diff --git a/engines/titanic/gfx/music_switch_inversion.cpp b/engines/titanic/gfx/music_switch_inversion.cpp new file mode 100644 index 0000000000..d11df79ab4 --- /dev/null +++ b/engines/titanic/gfx/music_switch_inversion.cpp @@ -0,0 +1,67 @@ +/* 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. + * + */ + +#include "titanic/gfx/music_switch_inversion.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CMusicSwitchInversion, CMusicSwitch) + ON_MESSAGE(MusicSettingChangedMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(QueryMusicControlSettingMsg) +END_MESSAGE_MAP() + +void CMusicSwitchInversion::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicSwitch::save(file, indent); +} + +void CMusicSwitchInversion::load(SimpleFile *file) { + file->readNumber(); + CMusicSwitch::load(file); +} + +bool CMusicSwitchInversion::MusicSettingChangedMsg(CMusicSettingChangedMsg *msg) { + if (_fieldEC) { + if (++_controlVal > _controlMax) + _controlVal = 0; + + loadFrame(_controlVal); + playSound("z#59.wav", 50); + } else { + playSound("z#46.wav"); + } + + return true; +} + +bool CMusicSwitchInversion::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_controlVal); + return true; +} + +bool CMusicSwitchInversion::QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg) { + msg->_value = _controlVal; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/music_switch_inversion.h b/engines/titanic/gfx/music_switch_inversion.h index 8b3718cf14..869b4745ea 100644 --- a/engines/titanic/gfx/music_switch_inversion.h +++ b/engines/titanic/gfx/music_switch_inversion.h @@ -28,24 +28,22 @@ namespace Titanic { class CMusicSwitchInversion : public CMusicSwitch { + DECLARE_MESSAGE_MAP; + bool MusicSettingChangedMsg(CMusicSettingChangedMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg); public: CLASSDEF; /** * Save the data for the class to file */ - virtual void save(SimpleFile *file, int indent) { - file->writeNumberLine(1, indent); - CMusicSwitch::save(file, indent); - } + virtual void save(SimpleFile *file, int indent); /** * Load the data for the class from file */ - virtual void load(SimpleFile *file) { - file->readNumber(); - CMusicSwitch::load(file); - } + virtual void load(SimpleFile *file); }; } // End of namespace Titanic diff --git a/engines/titanic/gfx/music_switch_reverse.cpp b/engines/titanic/gfx/music_switch_reverse.cpp new file mode 100644 index 0000000000..9fe6d51d47 --- /dev/null +++ b/engines/titanic/gfx/music_switch_reverse.cpp @@ -0,0 +1,66 @@ +/* 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. + * + */ + +#include "titanic/gfx/music_switch_reverse.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CMusicSwitchReverse, CMusicSwitch) + ON_MESSAGE(MusicSettingChangedMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(QueryMusicControlSettingMsg) +END_MESSAGE_MAP() + +void CMusicSwitchReverse::save(SimpleFile *file, int indent) { + file->writeNumberLine(1, indent); + CMusicSwitch::save(file, indent); +} + +void CMusicSwitchReverse::load(SimpleFile *file) { + file->readNumber(); + CMusicSwitch::load(file); +} +bool CMusicSwitchReverse::MusicSettingChangedMsg(CMusicSettingChangedMsg *msg) { + if (_fieldEC) { + if (++_controlVal > _controlMax) + _controlVal = 0; + + loadFrame(_controlVal); + playSound("z#59.wav", 50); + } else { + playSound("z#46.wav"); + } + + return true; +} + +bool CMusicSwitchReverse::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(_controlVal); + return true; +} + +bool CMusicSwitchReverse::QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg) { + msg->_value = _controlVal; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/music_switch_reverse.h b/engines/titanic/gfx/music_switch_reverse.h index 3bfcb53b00..c101f19d25 100644 --- a/engines/titanic/gfx/music_switch_reverse.h +++ b/engines/titanic/gfx/music_switch_reverse.h @@ -27,26 +27,24 @@ namespace Titanic { - class CMusicSwitchReverse : public CMusicSwitch { - public: - CLASSDEF; - - /** - * Save the data for the class to file - */ - virtual void save(SimpleFile *file, int indent) { - file->writeNumberLine(1, indent); - CMusicSwitch::save(file, indent); - } - - /** - * Load the data for the class from file - */ - virtual void load(SimpleFile *file) { - file->readNumber(); - CMusicSwitch::load(file); - } - }; +class CMusicSwitchReverse : public CMusicSwitch { + DECLARE_MESSAGE_MAP; + bool MusicSettingChangedMsg(CMusicSettingChangedMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg); +public: + CLASSDEF; + + /** + * Save the data for the class to file + */ + virtual void save(SimpleFile *file, int indent); + + /** + * Load the data for the class from file + */ + virtual void load(SimpleFile *file); +}; } // End of namespace Titanic diff --git a/engines/titanic/gfx/music_voice_mute.cpp b/engines/titanic/gfx/music_voice_mute.cpp new file mode 100644 index 0000000000..ff59edc988 --- /dev/null +++ b/engines/titanic/gfx/music_voice_mute.cpp @@ -0,0 +1,59 @@ +/* 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. + * + */ + +#include "titanic/gfx/music_voice_mute.h" +#include "titanic/sound/music_room.h" + +namespace Titanic { + +BEGIN_MESSAGE_MAP(CMusicVoiceMute, CMusicControl) + ON_MESSAGE(MusicSettingChangedMsg) + ON_MESSAGE(EnterViewMsg) + ON_MESSAGE(QueryMusicControlSettingMsg) +END_MESSAGE_MAP() + +bool CMusicVoiceMute::MusicSettingChangedMsg(CMusicSettingChangedMsg *msg) { + if (++_controlVal > _controlMax) + _controlVal = 0; + + CMusicRoom *musicRoom = getMusicRoom(); + musicRoom->setItem5(_controlArea, _controlVal == 1 ? 1 : 0); + loadFrame(1 - _controlVal); + playSound("z#55.wav", 50); + + return true; +} + +bool CMusicVoiceMute::EnterViewMsg(CEnterViewMsg *msg) { + loadFrame(1 - _controlVal); + CMusicRoom *musicRoom = getMusicRoom(); + musicRoom->setItem5(_controlArea, _controlVal == 1 ? 1 : 0); + + return true; +} + +bool CMusicVoiceMute::QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg) { + msg->_value = _controlVal; + return true; +} + +} // End of namespace Titanic diff --git a/engines/titanic/gfx/music_voice_mute.h b/engines/titanic/gfx/music_voice_mute.h index ca15806c09..f64b107423 100644 --- a/engines/titanic/gfx/music_voice_mute.h +++ b/engines/titanic/gfx/music_voice_mute.h @@ -28,6 +28,10 @@ namespace Titanic { class CMusicVoiceMute : public CMusicControl { + DECLARE_MESSAGE_MAP; + bool MusicSettingChangedMsg(CMusicSettingChangedMsg *msg); + bool EnterViewMsg(CEnterViewMsg *msg); + bool QueryMusicControlSettingMsg(CQueryMusicControlSettingMsg *msg); public: CLASSDEF; diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index 82e9a55c40..afe1c2c27e 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -306,7 +306,7 @@ MESSAGE2(CSignalObject, CString, strValue, "", int, numValue, 0); MESSAGE2(CSpeechFallsFromTreeMsg, int, value1, 0, int, value2, 0); MESSAGE1(CStartMusicMsg, CMusicPlayer *, musicPlayer, (CMusicPlayer *)nullptr); MESSAGE3(CStatusChangeMsg, int, oldStatus, 0, int, newStatus, 0, bool, success, false); -MESSAGE1(CStopMusicMsg, int, value, 0); +MESSAGE1(CStopMusicMsg, CMusicPlayer *, musicPlayer, (CMusicPlayer *)nullptr); MESSAGE4(CSubAcceptCCarryMsg, CString, string1, "", int, value1, 0, int, value2, 0, CCarry *, item, nullptr); MESSAGE0(CSubDeliverCCarryMsg); MESSAGE0(CSubSendCCarryMsg); diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index a3afc7e4a4..2182f58ac3 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -157,6 +157,8 @@ MODULE_OBJS := \ game/music_system_lock.o \ game/musical_instrument.o \ game/nav_helmet.o \ + game/nav_helmet_off.o \ + game/nav_helmet_on.o \ game/navigation_computer.o \ game/no_nut_bowl.o \ game/nose_holder.o \ @@ -294,7 +296,12 @@ MODULE_OBJS := \ gfx/move_object_button.o \ gfx/music_control.o \ gfx/music_slider.o \ + gfx/music_slider_pitch.o \ + gfx/music_slider_speed.o \ gfx/music_switch.o \ + gfx/music_switch_inversion.o \ + gfx/music_switch_reverse.o \ + gfx/music_voice_mute.o \ gfx/send_to_succ.o \ gfx/sgt_selector.o \ gfx/slider_button.o \ @@ -468,6 +475,7 @@ MODULE_OBJS := \ support/screen_manager.o \ support/simple_file.o \ support/string.o \ + support/string_parser.o \ support/text_cursor.o \ support/time_event_info.o \ support/video_surface.o \ diff --git a/engines/titanic/moves/move_player_in_parrot_room.cpp b/engines/titanic/moves/move_player_in_parrot_room.cpp index df38c63cd4..1ef2e96e92 100644 --- a/engines/titanic/moves/move_player_in_parrot_room.cpp +++ b/engines/titanic/moves/move_player_in_parrot_room.cpp @@ -24,6 +24,11 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CMovePlayerInParrotRoom, CMovePlayerTo) + ON_MESSAGE(ActMsg) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + CMovePlayerInParrotRoom::CMovePlayerInParrotRoom() : CMovePlayerTo() { } @@ -37,4 +42,20 @@ void CMovePlayerInParrotRoom::load(SimpleFile *file) { CMovePlayerTo::load(file); } +bool CMovePlayerInParrotRoom::ActMsg(CActMsg *msg) { + if (msg->_action == "PanAwayFromParrot") { + unlockMouse(); + changeView(_destination); + } + + return true; +} + +bool CMovePlayerInParrotRoom::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + lockMouse(); + CPanningAwayFromParrotMsg awayMsg(this); + awayMsg.execute("PerchedParrot"); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/move_player_in_parrot_room.h b/engines/titanic/moves/move_player_in_parrot_room.h index de693fe2e2..54dc2eb992 100644 --- a/engines/titanic/moves/move_player_in_parrot_room.h +++ b/engines/titanic/moves/move_player_in_parrot_room.h @@ -28,6 +28,9 @@ namespace Titanic { class CMovePlayerInParrotRoom : public CMovePlayerTo { + DECLARE_MESSAGE_MAP; + bool ActMsg(CActMsg *msg); + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); public: CLASSDEF; CMovePlayerInParrotRoom(); diff --git a/engines/titanic/moves/move_player_to.cpp b/engines/titanic/moves/move_player_to.cpp index 9b6000c4f8..a91215b539 100644 --- a/engines/titanic/moves/move_player_to.cpp +++ b/engines/titanic/moves/move_player_to.cpp @@ -21,9 +21,15 @@ */ #include "titanic/moves/move_player_to.h" +#include "titanic/game_manager.h" namespace Titanic { +BEGIN_MESSAGE_MAP(CMovePlayerTo, CGameObject) + ON_MESSAGE(MouseButtonDownMsg) + ON_MESSAGE(ActMsg) +END_MESSAGE_MAP() + CMovePlayerTo::CMovePlayerTo() : CGameObject() { } @@ -41,4 +47,17 @@ void CMovePlayerTo::load(SimpleFile *file) { CGameObject::load(file); } +bool CMovePlayerTo::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + CGameManager *gameManager = getGameManager(); + if (gameManager) + changeView(_destination); + + return true; +} + +bool CMovePlayerTo::ActMsg(CActMsg *msg) { + _destination = msg->_action; + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/move_player_to.h b/engines/titanic/moves/move_player_to.h index 4bfffcb0b2..822df69422 100644 --- a/engines/titanic/moves/move_player_to.h +++ b/engines/titanic/moves/move_player_to.h @@ -28,6 +28,9 @@ namespace Titanic { class CMovePlayerTo : public CGameObject { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); + bool ActMsg(CActMsg *msg); protected: CString _destination; public: diff --git a/engines/titanic/moves/move_player_to_from.cpp b/engines/titanic/moves/move_player_to_from.cpp index 1a67dc8505..c57cc2cf51 100644 --- a/engines/titanic/moves/move_player_to_from.cpp +++ b/engines/titanic/moves/move_player_to_from.cpp @@ -21,10 +21,16 @@ */ #include "titanic/moves/move_player_to_from.h" +#include "titanic/core/view_item.h" +#include "titanic/core/link_item.h" namespace Titanic { -CMovePlayerToFrom::CMovePlayerToFrom() : CGameObject() { +BEGIN_MESSAGE_MAP(CMovePlayerToFrom, CMovePlayerTo) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + +CMovePlayerToFrom::CMovePlayerToFrom() : CMovePlayerTo() { } void CMovePlayerToFrom::save(SimpleFile *file, int indent) { @@ -41,4 +47,17 @@ void CMovePlayerToFrom::load(SimpleFile *file) { CGameObject::load(file); } +bool CMovePlayerToFrom::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + if (_string2.empty()) { + changeView(_destination); + } else { + CViewItem *view = parseView(_string2); + CViewItem *destView = parseView(_destination); + CLinkItem *link = view->findLink(destView); + changeView(_destination, link->getName()); + } + + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/move_player_to_from.h b/engines/titanic/moves/move_player_to_from.h index c9eefe532f..fde4e94ab5 100644 --- a/engines/titanic/moves/move_player_to_from.h +++ b/engines/titanic/moves/move_player_to_from.h @@ -23,11 +23,13 @@ #ifndef TITANIC_MOVE_PLAYER_TO_FROM_H #define TITANIC_MOVE_PLAYER_TO_FROM_H -#include "titanic/core/game_object.h" +#include "titanic/moves/move_player_to.h" namespace Titanic { -class CMovePlayerToFrom : public CGameObject { +class CMovePlayerToFrom : public CMovePlayerTo { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); private: CString _string2; public: diff --git a/engines/titanic/moves/multi_move.cpp b/engines/titanic/moves/multi_move.cpp index fb5570df9b..4ca4fdb8f3 100644 --- a/engines/titanic/moves/multi_move.cpp +++ b/engines/titanic/moves/multi_move.cpp @@ -24,29 +24,37 @@ namespace Titanic { +BEGIN_MESSAGE_MAP(CMultiMove, CMovePlayerTo) + ON_MESSAGE(MouseButtonDownMsg) +END_MESSAGE_MAP() + CMultiMove::CMultiMove() : CMovePlayerTo() { } void CMultiMove::save(SimpleFile *file, int indent) { file->writeNumberLine(1, indent); - file->writeQuotedLine(_string1, indent); - file->writeQuotedLine(_string2, indent); - file->writeQuotedLine(_string3, indent); - file->writeQuotedLine(_string4, indent); - file->writeQuotedLine(_string5, indent); + for (int idx = 0; idx < 5; ++idx) + file->writeQuotedLine(_viewNames[idx], indent); CMovePlayerTo::save(file, indent); } void CMultiMove::load(SimpleFile *file) { file->readNumber(); - _string1 = file->readString(); - _string2 = file->readString(); - _string3 = file->readString(); - _string5 = file->readString(); - _string4 = file->readString(); + for (int idx = 0; idx < 5; ++idx) + _viewNames[idx] = file->readString(); CMovePlayerTo::load(file); } +bool CMultiMove::MouseButtonDownMsg(CMouseButtonDownMsg *msg) { + lockMouse(); + + for (int idx = 0; idx < 5 && _viewNames[idx] != "NULL"; ++idx) + changeView(_viewNames[idx]); + + unlockMouse(); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/moves/multi_move.h b/engines/titanic/moves/multi_move.h index 977afc2a20..12dd246823 100644 --- a/engines/titanic/moves/multi_move.h +++ b/engines/titanic/moves/multi_move.h @@ -28,12 +28,10 @@ namespace Titanic { class CMultiMove : public CMovePlayerTo { + DECLARE_MESSAGE_MAP; + bool MouseButtonDownMsg(CMouseButtonDownMsg *msg); private: - CString _string1; - CString _string2; - CString _string3; - CString _string4; - CString _string5; + CString _viewNames[5]; public: CLASSDEF; CMultiMove(); diff --git a/engines/titanic/sound/music_room.h b/engines/titanic/sound/music_room.h index 15363ef392..5f0b271ab3 100644 --- a/engines/titanic/sound/music_room.h +++ b/engines/titanic/sound/music_room.h @@ -31,6 +31,8 @@ namespace Titanic { class CGameManager; class CSound; +enum MusicControlArea { BELLS = 0, SNAKE = 1, PIANO = 2, BASS = 3 }; + class CMusicRoom { struct Entry { uint _val1; @@ -62,11 +64,11 @@ public: */ void destroyMusicHandler(); - void setItem1(int index, int val) { _items[index]._val1 = val; } - void setItem2(int index, int val) { _items[index]._val2 = val; } - void setItem3(int index, int val) { _items[index]._val3 = val; } - void setItem4(int index, int val) { _items[index]._val4 = val; } - void setItem5(int index, int val) { _items[index]._val5 = val; } + void setItem1(MusicControlArea index, int val) { _items[index]._val1 = val; } + void setItem2(MusicControlArea index, int val) { _items[index]._val2 = val; } + void setItem3(MusicControlArea index, int val) { _items[index]._val3 = val; } + void setItem4(MusicControlArea index, int val) { _items[index]._val4 = val; } + void setItem5(MusicControlArea index, int val) { _items[index]._val5 = val; } /** * Start playing a given music number diff --git a/engines/titanic/support/string_parser.cpp b/engines/titanic/support/string_parser.cpp new file mode 100644 index 0000000000..496440a973 --- /dev/null +++ b/engines/titanic/support/string_parser.cpp @@ -0,0 +1,97 @@ +/* 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. + * + */ + +#include "titanic/support/string_parser.h" +#include "common/util.h" + +namespace Titanic { + +void CStringParser::skipSeperators(const CString &seperatorChars) { + for (; _index < size(); ++_index) { + char c = (*this)[_index]; + if (seperatorChars.indexOf(c) == -1) + break; + } +} + +bool CStringParser::parse(CString &resultStr, const CString &seperatorChars, bool allowQuotes) { + if (_index >= size()) + return false; + + resultStr.clear(); + bool quoteFlag = false; + while (_index < size()) { + char c = (*this)[_index]; + if (!quoteFlag && seperatorChars.indexOf(c) >= 0) + break; + + if (allowQuotes) { + if (quoteFlag) { + if (c == '"') { + // End of quoted string + ++_index; + break; + } + } else { + if (c == '"') { + // Start of quoted string + ++_index; + quoteFlag = true; + continue; + } + } + } + + resultStr += c; + ++_index; + } + + return true; +} + +uint CStringParser::readInt() { + // Get digits from the string + CString numStr; + while (Common::isDigit(currentChar())) + numStr += getNextChar(); + + // Throw a wobbly if there wasn't a number + if (numStr.empty()) + error("ReadInt(): No number to read"); + + return atoi(numStr.c_str()); +} + +char CStringParser::currentChar() const { + return (_index >= size()) ? '\0' : (*this)[_index]; +} + +char CStringParser::getNextChar() { + return (_index >= size()) ? '\0' : (*this)[_index++]; +} + +void CStringParser::skipSpaces() { + while (_index < size() && Common::isSpace(currentChar())) + ++_index; +} + +} // End of namespace Titanic diff --git a/engines/titanic/support/string_parser.h b/engines/titanic/support/string_parser.h new file mode 100644 index 0000000000..f89caacfb5 --- /dev/null +++ b/engines/titanic/support/string_parser.h @@ -0,0 +1,76 @@ +/* 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. + * + */ + +#ifndef TITANIC_STRING_PARSER_H +#define TITANIC_STRING_PARSER_H + +#include "titanic/support/string.h" + +namespace Titanic { + +class CStringParser : public CString { +private: + uint _index; +private: + /** + * Gets the character at the current index + */ + char currentChar() const; + + /** + * Gets the next character, and increments the parsing index + */ + char getNextChar(); + + /** + * Skips over any spaces + */ + void skipSpaces(); +public: + CStringParser() : CString(), _index(0) {} + CStringParser(const CString &str) : CString(str), _index(0) {} + + /** + * Skips over any specified seperator characters in our string + * at the current index + */ + void skipSeperators(const CString &seperatorChars); + + /** + * Parses out a string from a source string at the current index + * @param resultStr String to hold the resulting sring + * @param seperatorChras List of characters that seperate string values + * @param allowQuotes If true, handles double-quoted substrings + * @returns True if a string entry was extracted + */ + bool parse(CString &resultStr, const CString &seperatorChars, bool allowQuotes = false); + + /** + * Reads an integer from the string + */ + uint readInt(); + +}; + +} // End of namespace Titanic + +#endif /* TITANIC_STRING_PARSER_H */ |