aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/game/music_console_button.cpp
blob: 639aebd9c959c4c8a24e53240f5325663173f258 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/* 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/music_console_button.h"
#include "titanic/core/room_item.h"
#include "titanic/sound/music_room_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);
}

void CMusicConsoleButton::load(SimpleFile *file) {
	file->readNumber();
	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->checkInstrument(SNAKE)
				&& CMusicRoom::_musicHandler->checkInstrument(PIANO)
				&& CMusicRoom::_musicHandler->checkInstrument(BASS)) {
			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->setMuteControl(BELLS, queryMsg._value == 1);
	queryMsg.execute("Bells Pitch Control");
	musicRoom->setPitchControl(BELLS, queryMsg._value);
	queryMsg.execute("Bells Speed Control");
	musicRoom->setSpeedControl(BELLS, queryMsg._value);
	queryMsg.execute("Bells Inversion Control");
	musicRoom->setInversionControl(BELLS, queryMsg._value == 1);
	queryMsg.execute("Bells Direction Control");
	musicRoom->setDirectionControl(BELLS, queryMsg._value == 1);

	queryMsg.execute("Snake Mute Control");
	musicRoom->setMuteControl(SNAKE, queryMsg._value == 1);
	queryMsg.execute("Snake Pitch Control");
	musicRoom->setPitchControl(SNAKE, queryMsg._value);
	queryMsg.execute("Snake Speed Control");
	musicRoom->setSpeedControl(SNAKE, queryMsg._value);
	queryMsg.execute("Snake Inversion Control");
	musicRoom->setInversionControl(SNAKE, queryMsg._value == 1);
	queryMsg.execute("Snake Direction Control");
	musicRoom->setDirectionControl(SNAKE, queryMsg._value == 1);

	queryMsg.execute("Piano Mute Control");
	musicRoom->setMuteControl(PIANO, queryMsg._value == 1);
	queryMsg.execute("Piano Pitch Control");
	musicRoom->setPitchControl(PIANO, queryMsg._value);
	queryMsg.execute("Piano Speed Control");
	musicRoom->setSpeedControl(PIANO, queryMsg._value);
	queryMsg.execute("Piano Inversion Control");
	musicRoom->setInversionControl(PIANO, queryMsg._value == 1);
	queryMsg.execute("Piano Direction Control");
	musicRoom->setDirectionControl(PIANO, queryMsg._value == 1);

	queryMsg.execute("Bass Mute Control");
	musicRoom->setMuteControl(BASS, queryMsg._value == 1);
	queryMsg.execute("Bass Pitch Control");
	musicRoom->setPitchControl(BASS, queryMsg._value);
	queryMsg.execute("Bass Speed Control");
	musicRoom->setSpeedControl(BASS, queryMsg._value);
	queryMsg.execute("Bass Inversion Control");
	musicRoom->setInversionControl(BASS, queryMsg._value == 1);
	queryMsg.execute("Bass Direction Control");
	musicRoom->setDirectionControl(BASS, queryMsg._value == 1);

	return true;
}

} // End of namespace Titanic