From 9a71c9166b1ef8c7d0e57cfdfac6eb25f5332c69 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Thu, 25 Aug 2016 22:13:04 -0400 Subject: TITANIC: Implemented more game classes and music widget classes --- engines/titanic/core/multi_drop_target.cpp | 1 - engines/titanic/game/music_console_button.cpp | 96 ++++++++++++++++++++++ engines/titanic/game/music_console_button.h | 4 + .../game/music_room_stop_phonograph_button.cpp | 40 ++++++++- .../game/music_room_stop_phonograph_button.h | 7 +- engines/titanic/game/music_system_lock.cpp | 28 +++++++ engines/titanic/game/music_system_lock.h | 3 + engines/titanic/gfx/music_control.cpp | 31 +++++-- engines/titanic/gfx/music_control.h | 10 ++- engines/titanic/gfx/music_slider_pitch.cpp | 67 +++++++++++++++ engines/titanic/gfx/music_slider_pitch.h | 14 ++-- engines/titanic/gfx/music_slider_speed.cpp | 67 +++++++++++++++ engines/titanic/gfx/music_slider_speed.h | 38 ++++----- engines/titanic/gfx/music_switch_inversion.cpp | 67 +++++++++++++++ engines/titanic/gfx/music_switch_inversion.h | 14 ++-- engines/titanic/gfx/music_switch_reverse.cpp | 66 +++++++++++++++ engines/titanic/gfx/music_switch_reverse.h | 38 ++++----- engines/titanic/gfx/music_voice_mute.cpp | 59 +++++++++++++ engines/titanic/gfx/music_voice_mute.h | 4 + engines/titanic/messages/messages.h | 2 +- engines/titanic/module.mk | 5 ++ engines/titanic/moves/multi_move.cpp | 28 ++++--- engines/titanic/moves/multi_move.h | 8 +- engines/titanic/sound/music_room.h | 12 +-- 24 files changed, 617 insertions(+), 92 deletions(-) create mode 100644 engines/titanic/gfx/music_slider_pitch.cpp create mode 100644 engines/titanic/gfx/music_slider_speed.cpp create mode 100644 engines/titanic/gfx/music_switch_inversion.cpp create mode 100644 engines/titanic/gfx/music_switch_reverse.cpp create mode 100644 engines/titanic/gfx/music_voice_mute.cpp (limited to 'engines') diff --git a/engines/titanic/core/multi_drop_target.cpp b/engines/titanic/core/multi_drop_target.cpp index ad709fe38b..b95696577f 100644 --- a/engines/titanic/core/multi_drop_target.cpp +++ b/engines/titanic/core/multi_drop_target.cpp @@ -49,7 +49,6 @@ bool CMultiDropTarget::DropObjectMsg(CDropObjectMsg *msg) { CStringParser parser1(_string5); CStringParser parser2(_string6); CString seperatorChars = ","; - int dropFrame = _dropFrame; while (parser2.parse(_itemMatchName, seperatorChars)) { _dropFrame = parser1.readInt(); 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/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 65e7367ed1..924adb61ae 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -294,7 +294,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 \ 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 -- cgit v1.2.3