Skip to content

Commit

Permalink
TITANIC: Cleanup of music room setup code
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Jan 29, 2017
1 parent dc640ab commit a9abeb5
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 18 deletions.
6 changes: 3 additions & 3 deletions engines/titanic/game/music_console_button.cpp
Expand Up @@ -57,9 +57,9 @@ bool CMusicConsoleButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
CMusicHasStartedMsg startedMsg;
startedMsg.execute("Music Room Phonograph");

if (CMusicRoom::_musicHandler->checkSound(1)
&& CMusicRoom::_musicHandler->checkSound(2)
&& CMusicRoom::_musicHandler->checkSound(3)) {
if (CMusicRoom::_musicHandler->checkInstrument(SNAKE)
&& CMusicRoom::_musicHandler->checkInstrument(PIANO)
&& CMusicRoom::_musicHandler->checkInstrument(BASS)) {
CCorrectMusicPlayedMsg correctMsg;
correctMsg.execute(findRoom());
}
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/game/play_music_button.cpp
Expand Up @@ -54,7 +54,7 @@ bool CPlayMusicButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
loadFrame(0);
_flag = false;
} else {
musicRoom->startMusic(100);
musicRoom->setupMusic(100);
playMovie(MOVIE_REPEAT);
_ticks = getTicksCount();
_flag = true;
Expand Down
6 changes: 3 additions & 3 deletions engines/titanic/npcs/maitre_d.cpp
Expand Up @@ -122,11 +122,11 @@ bool CMaitreD::EnterViewMsg(CEnterViewMsg *msg) {

if (_string3.contains("nasty ambient"))
startTalking(this, 111, findView());
else if (!CMusicRoom::_musicHandler->checkSound(1))
else if (!CMusicRoom::_musicHandler->checkInstrument(SNAKE))
startTalking(this, 114, findView());
else if (!CMusicRoom::_musicHandler->checkSound(3))
else if (!CMusicRoom::_musicHandler->checkInstrument(BASS))
startTalking(this, 113, findView());
else if (!CMusicRoom::_musicHandler->checkSound(2))
else if (!CMusicRoom::_musicHandler->checkInstrument(PIANO))
startTalking(this, 115, findView());
else {
startTalking(this, 110, findView());
Expand Down
9 changes: 5 additions & 4 deletions engines/titanic/sound/music_player.cpp
Expand Up @@ -40,7 +40,7 @@ void CMusicPlayer::save(SimpleFile *file, int indent) {
file->writeNumberLine(_isActive, indent);
file->writeQuotedLine(_stopTarget, indent);
file->writeNumberLine(_stopWaves, indent);
file->writeNumberLine(_musicId, indent);
file->writeNumberLine(_volume, indent);

CGameObject::save(file, indent);
}
Expand All @@ -50,13 +50,13 @@ void CMusicPlayer::load(SimpleFile *file) {
_isActive = file->readNumber();
_stopTarget = file->readString();
_stopWaves = file->readNumber();
_musicId = file->readNumber();
_volume = file->readNumber();

CGameObject::load(file);
}

bool CMusicPlayer::StartMusicMsg(CStartMusicMsg *msg) {
if (msg->_musicPlayer == this) {
if (msg->_musicPlayer != this) {
if (_isActive) {
CStopMusicMsg stopMusicMsg;
stopMusicMsg.execute(this);
Expand All @@ -73,8 +73,9 @@ bool CMusicPlayer::StartMusicMsg(CStartMusicMsg *msg) {
CSetMusicControlsMsg controlsMsg;
controlsMsg.execute(this, nullptr, MSGFLAG_SCAN);

getMusicRoom()->startMusic(_musicId);
getMusicRoom()->setupMusic(_volume);
_isActive = true;
unlockMouse();
}

return true;
Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/sound/music_player.h
Expand Up @@ -42,11 +42,11 @@ class CMusicPlayer : public CGameObject {
bool _isActive;
CString _stopTarget;
bool _stopWaves;
int _musicId;
int _volume;
public:
CLASSDEF;
CMusicPlayer() : CGameObject(),
_isActive(false), _stopWaves(false), _musicId(100) {}
_isActive(false), _stopWaves(false), _volume(100) {}

/**
* Save the data for the class to file
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/sound/music_room.cpp
Expand Up @@ -52,7 +52,7 @@ void CMusicRoom::destroyMusicHandler() {
_musicHandler = nullptr;
}

void CMusicRoom::startMusic(int volume) {
void CMusicRoom::setupMusic(int volume) {
if (_musicHandler) {
_musicHandler->setSpeedControl2(BELLS, 0);
_musicHandler->setSpeedControl2(SNAKE, 1);
Expand Down
4 changes: 2 additions & 2 deletions engines/titanic/sound/music_room.h
Expand Up @@ -70,9 +70,9 @@ class CMusicRoom {
void setMuteControl(MusicControlArea index, int val) { _controls[index]._muteControl = val; }

/**
* Start playing a given music number
* Sets up the music controls
*/
void startMusic(int volume = 100);
void setupMusic(int volume);

/**
* Stop playing music
Expand Down
2 changes: 1 addition & 1 deletion engines/titanic/sound/music_room_handler.cpp
Expand Up @@ -85,7 +85,7 @@ void CMusicRoomHandler::stop() {
}
}

bool CMusicRoomHandler::checkSound(int index) const {
bool CMusicRoomHandler::checkInstrument(MusicControlArea area) const {
// TODO
return false;
}
Expand Down
5 changes: 4 additions & 1 deletion engines/titanic/sound/music_room_handler.h
Expand Up @@ -92,7 +92,10 @@ class CMusicRoomHandler {
*/
void stop();

bool checkSound(int index) const;
/**
* Checks the specified instrument to see if it's settings are "correct"
*/
bool checkInstrument(MusicControlArea area) const;

/**
* Set a setting
Expand Down

0 comments on commit a9abeb5

Please sign in to comment.