1 /* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 */
22
23 #include "titanic/game/music_console_button.h"
24 #include "titanic/core/room_item.h"
25 #include "titanic/sound/music_room.h"
26 #include "titanic/sound/music_room_handler.h"
27 #include "titanic/titanic.h"
28
29 namespace Titanic {
30
BEGIN_MESSAGE_MAP(CMusicConsoleButton,CMusicPlayer)31 BEGIN_MESSAGE_MAP(CMusicConsoleButton, CMusicPlayer)
32 ON_MESSAGE(MouseButtonDownMsg)
33 ON_MESSAGE(LeaveViewMsg)
34 ON_MESSAGE(SetMusicControlsMsg)
35 END_MESSAGE_MAP()
36
37 void CMusicConsoleButton::save(SimpleFile *file, int indent) {
38 file->writeNumberLine(1, indent);
39 CMusicPlayer::save(file, indent);
40 }
41
load(SimpleFile * file)42 void CMusicConsoleButton::load(SimpleFile *file) {
43 file->readNumber();
44 CMusicPlayer::load(file);
45 }
46
MouseButtonDownMsg(CMouseButtonDownMsg * msg)47 bool CMusicConsoleButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
48 if (_isActive) {
49 CStopMusicMsg stopMsg(this);
50 stopMsg.execute(this);
51 stopMovie();
52 loadFrame(0);
53 } else {
54 CStartMusicMsg startMsg(this);
55 startMsg.execute(this);
56 playMovie(MOVIE_REPEAT);
57
58 CMusicHasStartedMsg startedMsg;
59 startedMsg.execute("Music Room Phonograph");
60
61 if (CMusicRoom::_musicHandler->checkInstrument(SNAKE)
62 && CMusicRoom::_musicHandler->checkInstrument(PIANO)
63 && CMusicRoom::_musicHandler->checkInstrument(BASS)) {
64 // All three instruments have the correct settings
65 CCorrectMusicPlayedMsg correctMsg;
66 correctMsg.execute(findRoom());
67 }
68 }
69
70 return true;
71 }
72
LeaveViewMsg(CLeaveViewMsg * msg)73 bool CMusicConsoleButton::LeaveViewMsg(CLeaveViewMsg *msg) {
74 if (_isActive) {
75 // Stop playing the active music
76 CStopMusicMsg stopMsg(this);
77 stopMsg.execute(this);
78 stopMovie();
79 loadFrame(0);
80 }
81
82 return true;
83 }
84
SetMusicControlsMsg(CSetMusicControlsMsg * msg)85 bool CMusicConsoleButton::SetMusicControlsMsg(CSetMusicControlsMsg *msg) {
86 CMusicRoom *musicRoom = getMusicRoom();
87 CQueryMusicControlSettingMsg queryMsg;
88
89 queryMsg.execute("Bells Pitch Control");
90 musicRoom->setPitchControl(BELLS, queryMsg._value);
91 queryMsg.execute("Bells Speed Control");
92 musicRoom->setSpeedControl(BELLS, queryMsg._value);
93 queryMsg.execute("Bells Inversion Control");
94 musicRoom->setInversionControl(BELLS, queryMsg._value == 1);
95 queryMsg.execute("Bells Direction Control");
96 musicRoom->setDirectionControl(BELLS, queryMsg._value == 1);
97 queryMsg.execute("Bells Mute Control");
98 musicRoom->setMuteControl(BELLS, queryMsg._value == 1);
99
100 queryMsg.execute("Snake Pitch Control");
101 musicRoom->setPitchControl(SNAKE, queryMsg._value);
102 queryMsg.execute("Snake Speed Control");
103 musicRoom->setSpeedControl(SNAKE, queryMsg._value);
104 queryMsg.execute("Snake Inversion Control");
105 musicRoom->setInversionControl(SNAKE, queryMsg._value == 1);
106 queryMsg.execute("Snake Direction Control");
107 musicRoom->setDirectionControl(SNAKE, queryMsg._value == 1);
108 queryMsg.execute("Snake Mute Control");
109 musicRoom->setMuteControl(SNAKE, queryMsg._value == 1);
110
111 queryMsg.execute("Piano Pitch Control");
112 musicRoom->setPitchControl(PIANO, queryMsg._value);
113 queryMsg.execute("Piano Speed Control");
114 musicRoom->setSpeedControl(PIANO, queryMsg._value);
115 queryMsg.execute("Piano Inversion Control");
116 musicRoom->setInversionControl(PIANO, queryMsg._value == 1);
117 queryMsg.execute("Piano Direction Control");
118 musicRoom->setDirectionControl(PIANO, queryMsg._value == 1);
119 queryMsg.execute("Piano Mute Control");
120 musicRoom->setMuteControl(PIANO, queryMsg._value == 1);
121
122 queryMsg.execute("Bass Pitch Control");
123 musicRoom->setPitchControl(BASS, queryMsg._value);
124 queryMsg.execute("Bass Speed Control");
125 musicRoom->setSpeedControl(BASS, queryMsg._value);
126 queryMsg.execute("Bass Inversion Control");
127 musicRoom->setInversionControl(BASS, queryMsg._value == 1);
128 queryMsg.execute("Bass Direction Control");
129 musicRoom->setDirectionControl(BASS, queryMsg._value == 1);
130 queryMsg.execute("Bass Mute Control");
131 musicRoom->setMuteControl(BASS, queryMsg._value == 1);
132
133 return true;
134 }
135
136 } // End of namespace Titanic
137