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/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 ++ 12 files changed, 409 insertions(+), 66 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/titanic/gfx') 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; -- cgit v1.2.3