TITANIC: Implemented phonograph classes

This commit is contained in:
Paul Gilbert 2016-08-27 11:15:23 -04:00
parent 795cdb6365
commit 40ec26b343
6 changed files with 209 additions and 13 deletions

View File

@ -22,6 +22,7 @@
#include "titanic/carry/phonograph_cylinder.h"
#include "titanic/game/phonograph.h"
#include "titanic/sound/music_room.h"
namespace Titanic {
@ -162,10 +163,33 @@ bool CPhonographCylinder::RecordOntoCylinderMsg(CRecordOntoCylinderMsg *msg) {
}
bool CPhonographCylinder::SetMusicControlsMsg(CSetMusicControlsMsg *msg) {
if (_itemName.left(7) == "STMusic") {
//todo
warning("TODO");
}
if (!_itemName.hasPrefix("STMusic"))
return true;
CMusicRoom *musicRoom = getMusicRoom();
musicRoom->setItem5(BELLS, _bellsMuteControl);
musicRoom->setItem2(BELLS, _bellsPitchControl);
musicRoom->setItem1(BELLS, _bellsSpeedControl);
musicRoom->setItem4(BELLS, _bellsInversionControl);
musicRoom->setItem3(BELLS, _bellsDirectionControl);
musicRoom->setItem5(SNAKE, _snakeMuteControl);
musicRoom->setItem2(SNAKE, _snakePitchControl);
musicRoom->setItem1(SNAKE, _snakeSpeedControl);
musicRoom->setItem4(SNAKE, _snakeInversionControl);
musicRoom->setItem3(SNAKE, _snakeDirectionControl);
musicRoom->setItem5(PIANO, _pianoMuteControl);
musicRoom->setItem2(PIANO, _pianoPitchControl);
musicRoom->setItem1(PIANO, _pianoSpeedControl);
musicRoom->setItem4(PIANO, _pianoInversionControl);
musicRoom->setItem3(PIANO, _pianoDirectionControl);
musicRoom->setItem5(BASS, _bassMuteControl);
musicRoom->setItem2(BASS, _bassPitchControl);
musicRoom->setItem1(BASS, _bassSpeedControl);
musicRoom->setItem4(BASS, _bassInversionControl);
musicRoom->setItem3(BASS, _bassDirectionControl);
return true;
}

View File

@ -24,9 +24,18 @@
namespace Titanic {
BEGIN_MESSAGE_MAP(CPhonograph, CMusicPlayer)
ON_MESSAGE(PhonographPlayMsg)
ON_MESSAGE(PhonographStopMsg)
ON_MESSAGE(PhonographRecordMsg)
ON_MESSAGE(EnterRoomMsg)
ON_MESSAGE(LeaveRoomMsg)
ON_MESSAGE(MusicHasStartedMsg)
END_MESSAGE_MAP()
CPhonograph::CPhonograph() : CMusicPlayer(),
_fieldE0(0), _fieldE4(0), _fieldE8(0), _fieldEC(0),
_fieldF0(0), _fieldF4(0) {
_fieldE0(false), _fieldE4(0), _fieldE8(0), _fieldEC(0),
_fieldF0(0), _fieldF4(0) {
}
void CPhonograph::save(SimpleFile *file, int indent) {
@ -55,8 +64,113 @@ void CPhonograph::load(SimpleFile *file) {
CMusicPlayer::load(file);
}
bool CPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) {
CQueryCylinderHolderMsg holderMsg;
holderMsg.execute(this);
if (!holderMsg._value2) {
_fieldE0 = false;
return true;
}
CQueryCylinderMsg cylinderMsg;
cylinderMsg.execute(holderMsg._target);
if (cylinderMsg._name.empty()) {
_fieldE0 = false;
} else if (cylinderMsg._name.hasPrefix("STMusic")) {
CStartMusicMsg startMsg(this);
startMsg.execute(this);
_fieldE0 = true;
msg->_value = 1;
} else {
stopGlobalSound(0, -1);
playGlobalSound(cylinderMsg._name, -2, true, true, 0);
_fieldE0 = true;
msg->_value = 1;
}
return true;
}
bool CPhonograph::PhonographStopMsg(CPhonographStopMsg *msg) {
CQueryCylinderHolderMsg holderMsg;
holderMsg.execute(this);
if (!holderMsg._value2)
return true;
_fieldE0 = false;
CQueryCylinderMsg cylinderMsg;
cylinderMsg.execute(holderMsg._target);
if (_fieldE0) {
if (!cylinderMsg._name.empty()) {
if (cylinderMsg._name.hasPrefix("STMusic")) {
CStopMusicMsg stopMsg;
stopMsg.execute(this);
} else {
stopGlobalSound(msg->_value1, -1);
}
msg->_value2 = 1;
}
if (!msg->_value3)
_fieldE0 = false;
} else if (_fieldE4) {
_fieldE4 = false;
msg->_value2 = 1;
}
return true;
}
bool CPhonograph::PhonographRecordMsg(CPhonographRecordMsg *msg) {
if (!_fieldE0 && !_fieldE4 && !_fieldE8) {
CQueryCylinderHolderMsg holderMsg;
holderMsg.execute(this);
if (holderMsg._value2) {
_fieldE4 = true;
CErasePhonographCylinderMsg eraseMsg;
eraseMsg.execute(holderMsg._target);
} else {
_fieldE4 = false;
}
}
return true;
}
bool CPhonograph::EnterRoomMsg(CEnterRoomMsg *msg) {
warning("CPhonograph::handleEvent");
if (_fieldE0) {
CPhonographPlayMsg playMsg;
playMsg.execute(this);
}
return true;
}
bool CPhonograph::LeaveRoomMsg(CLeaveRoomMsg *msg) {
if (_fieldE0) {
CPhonographStopMsg stopMsg;
stopMsg._value1 = 1;
stopMsg.execute(this);
}
return true;
}
bool CPhonograph::MusicHasStartedMsg(CMusicHasStartedMsg *msg) {
if (_fieldE4) {
CQueryCylinderHolderMsg holderMsg;
holderMsg.execute(this);
if (holderMsg._value2) {
CRecordOntoCylinderMsg recordMsg;
recordMsg.execute(holderMsg._target);
} else {
_fieldE4 = false;
}
}
return true;
}

View File

@ -29,10 +29,16 @@
namespace Titanic {
class CPhonograph : public CMusicPlayer {
DECLARE_MESSAGE_MAP;
bool PhonographPlayMsg(CPhonographPlayMsg *msg);
bool PhonographStopMsg(CPhonographStopMsg *msg);
bool PhonographRecordMsg(CPhonographRecordMsg *msg);
bool EnterRoomMsg(CEnterRoomMsg *msg);
bool LeaveRoomMsg(CLeaveRoomMsg *msg);
bool MusicHasStartedMsg(CMusicHasStartedMsg *msg);
protected:
CString _string2;
int _fieldE0;
bool _fieldE0;
int _fieldE4;
int _fieldE8;
int _fieldEC;

View File

@ -24,16 +24,63 @@
namespace Titanic {
BEGIN_MESSAGE_MAP(CPhonographLid, CGameObject)
ON_MESSAGE(MouseButtonDownMsg)
ON_MESSAGE(MovieEndMsg)
ON_MESSAGE(LockPhonographMsg)
ON_MESSAGE(LeaveViewMsg)
END_MESSAGE_MAP()
void CPhonographLid::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_value, indent);
file->writeNumberLine(_open, indent);
CGameObject::save(file, indent);
}
void CPhonographLid::load(SimpleFile *file) {
file->readNumber();
_value = file->readNumber();
_open = file->readNumber();
CGameObject::load(file);
}
bool CPhonographLid::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
CQueryPhonographState stateMsg;
stateMsg.execute(getParent(), nullptr, MSGFLAG_SCAN);
if (stateMsg._value) {
if (_open) {
CGameObject *lock = dynamic_cast<CGameObject *>(findByName("Music System Lock"));
if (lock)
lock->setVisible(false);
playMovie(0, 27, 0);
} else {
playMovie(27, 55, 0);
}
_open = !_open;
} else {
petDisplayMessage(0, "This is the restaurant music system. It appears to be locked.");
}
return true;
}
bool CPhonographLid::MovieEndMsg(CMovieEndMsg *msg) {
// WORKAROUND: Redundant code in original not included
return true;
}
bool CPhonographLid::LockPhonographMsg(CLockPhonographMsg *msg) {
_cursorId = msg->_value ? CURSOR_INVALID : CURSOR_ARROW;
return true;
}
bool CPhonographLid::LeaveViewMsg(CLeaveViewMsg *msg) {
if (_open) {
playMovie(27, 55, MOVIE_GAMESTATE);
_open = false;
}
return true;
}
} // End of namespace Titanic

View File

@ -28,11 +28,16 @@
namespace Titanic {
class CPhonographLid : public CGameObject {
DECLARE_MESSAGE_MAP;
bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
bool MovieEndMsg(CMovieEndMsg *msg);
bool LockPhonographMsg(CLockPhonographMsg *msg);
bool LeaveViewMsg(CLeaveViewMsg *msg);
private:
int _value;
bool _open;
public:
CLASSDEF;
CPhonographLid() : CGameObject(), _value(0) {}
CPhonographLid() : CGameObject(), _open(false) {}
/**
* Save the data for the class to file

View File

@ -274,7 +274,7 @@ MESSAGE2(CPumpingMsg, int, value, 0, CGameObject *, object, nullptr);
MESSAGE1(CPutBotBackInHisBoxMsg, int, value, 0);
MESSAGE1(CPutParrotBackMsg, int, value, 0);
MESSAGE0(CPuzzleSolvedMsg);
MESSAGE3(CQueryCylinderHolderMsg, int, value1, 0, int, value2, 0, int, value3, 0);
MESSAGE3(CQueryCylinderHolderMsg, int, value1, 0, int, value2, 0, CTreeItem *, target, (CTreeItem *)nullptr);
MESSAGE1(CQueryCylinderMsg, CString, name, "");
MESSAGE1(CQueryCylinderNameMsg, CString, name, "");
MESSAGE3(CQueryCylinderTypeMsg, int, value1, 0, int, value2, 0, int, value3, 0);