aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-08-27 18:29:16 -0400
committerPaul Gilbert2016-08-27 18:29:16 -0400
commit311006c84cd85897cb9c536e948bc6f5d36b3805 (patch)
treee1e33b74090a7abfda909d964b8e25c769e42f9b /engines/titanic
parent1694680acea712db0149c74de412e309dbd0c1cc (diff)
downloadscummvm-rg350-311006c84cd85897cb9c536e948bc6f5d36b3805.tar.gz
scummvm-rg350-311006c84cd85897cb9c536e948bc6f5d36b3805.tar.bz2
scummvm-rg350-311006c84cd85897cb9c536e948bc6f5d36b3805.zip
TITANIC: Implemented restaurant related game classes
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/game/record_phonograph_button.cpp32
-rw-r--r--engines/titanic/game/record_phonograph_button.h7
-rw-r--r--engines/titanic/game/replacement_ear.cpp11
-rw-r--r--engines/titanic/game/replacement_ear.h2
-rw-r--r--engines/titanic/game/reserved_table.cpp41
-rw-r--r--engines/titanic/game/reserved_table.h8
-rw-r--r--engines/titanic/game/restaurant_cylinder_holder.cpp108
-rw-r--r--engines/titanic/game/restaurant_cylinder_holder.h13
-rw-r--r--engines/titanic/game/restaurant_phonograph.cpp96
-rw-r--r--engines/titanic/game/restaurant_phonograph.h10
-rw-r--r--engines/titanic/messages/messages.h2
-rw-r--r--engines/titanic/moves/restaurant_pan_handler.cpp30
-rw-r--r--engines/titanic/moves/restaurant_pan_handler.h13
13 files changed, 339 insertions, 34 deletions
diff --git a/engines/titanic/game/record_phonograph_button.cpp b/engines/titanic/game/record_phonograph_button.cpp
index f022957dbb..1ffaec4228 100644
--- a/engines/titanic/game/record_phonograph_button.cpp
+++ b/engines/titanic/game/record_phonograph_button.cpp
@@ -24,16 +24,44 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CRecordPhonographButton, CBackground)
+ ON_MESSAGE(MouseButtonDownMsg)
+ ON_MESSAGE(PhonographStopMsg)
+END_MESSAGE_MAP()
+
void CRecordPhonographButton::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_value, indent);
+ file->writeNumberLine(_active, indent);
CBackground::save(file, indent);
}
void CRecordPhonographButton::load(SimpleFile *file) {
file->readNumber();
- _value = file->readNumber();
+ _active = file->readNumber();
CBackground::load(file);
}
+bool CRecordPhonographButton::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+ CPhonographRecordMsg recordMsg;
+ recordMsg.execute(getParent());
+
+ if (recordMsg._value) {
+ playSound("z#58.wav");
+ loadFrame(1);
+ _active = true;
+ }
+
+ return true;
+}
+
+bool CRecordPhonographButton::PhonographStopMsg(CPhonographStopMsg *msg) {
+ if (_active) {
+ playSound("z#57.wav");
+ loadFrame(0);
+ _active = false;
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/record_phonograph_button.h b/engines/titanic/game/record_phonograph_button.h
index 3383c01e31..985a4c4576 100644
--- a/engines/titanic/game/record_phonograph_button.h
+++ b/engines/titanic/game/record_phonograph_button.h
@@ -28,11 +28,14 @@
namespace Titanic {
class CRecordPhonographButton : public CBackground {
+ DECLARE_MESSAGE_MAP;
+ bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
+ bool PhonographStopMsg(CPhonographStopMsg *msg);
public:
- int _value;
+ bool _active;
public:
CLASSDEF;
- CRecordPhonographButton() : CBackground(), _value(0) {}
+ CRecordPhonographButton() : CBackground(), _active(false) {}
/**
* Save the data for the class to file
diff --git a/engines/titanic/game/replacement_ear.cpp b/engines/titanic/game/replacement_ear.cpp
index 1f9960365d..e8bd384207 100644
--- a/engines/titanic/game/replacement_ear.cpp
+++ b/engines/titanic/game/replacement_ear.cpp
@@ -24,6 +24,10 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CReplacementEar, CBackground)
+ ON_MESSAGE(VisibleMsg)
+END_MESSAGE_MAP()
+
void CReplacementEar::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
CBackground::save(file, indent);
@@ -34,4 +38,11 @@ void CReplacementEar::load(SimpleFile *file) {
CBackground::load(file);
}
+bool CReplacementEar::VisibleMsg(CVisibleMsg *msg) {
+ setVisible(true);
+ playMovie(MOVIE_GAMESTATE);
+ playSound("z#64.wav");
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/replacement_ear.h b/engines/titanic/game/replacement_ear.h
index 0d282b7fb4..7775a9631a 100644
--- a/engines/titanic/game/replacement_ear.h
+++ b/engines/titanic/game/replacement_ear.h
@@ -28,6 +28,8 @@
namespace Titanic {
class CReplacementEar : public CBackground {
+ DECLARE_MESSAGE_MAP;
+ bool VisibleMsg(CVisibleMsg *msg);
public:
CLASSDEF;
diff --git a/engines/titanic/game/reserved_table.cpp b/engines/titanic/game/reserved_table.cpp
index a600190709..734d53af45 100644
--- a/engines/titanic/game/reserved_table.cpp
+++ b/engines/titanic/game/reserved_table.cpp
@@ -21,22 +21,55 @@
*/
#include "titanic/game/reserved_table.h"
+#include "titanic/core/room_item.h"
+#include "titanic/core/view_item.h"
+#include "titanic/npcs/maitre_d.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CReservedTable, CGameObject)
+ ON_MESSAGE(MouseButtonDownMsg)
+ ON_MESSAGE(PlayerTriesRestaurantTableMsg)
+END_MESSAGE_MAP()
+
void CReservedTable::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_value1, indent);
- file->writeNumberLine(_value2, indent);
+ file->writeNumberLine(_flag, indent);
+ file->writeNumberLine(_tableId, indent);
CGameObject::save(file, indent);
}
void CReservedTable::load(SimpleFile *file) {
file->readNumber();
- _value1 = file->readNumber();
- _value2 = file->readNumber();
+ _flag = file->readNumber();
+ _tableId = file->readNumber();
CGameObject::load(file);
}
+bool CReservedTable::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+ if (!_flag) {
+ CPlayerTriesRestaurantTableMsg tryMsg(_tableId, 0);
+ tryMsg.execute(findRoom(), CReservedTable::_type, MSGFLAG_CLASS_DEF | MSGFLAG_SCAN);
+ }
+
+ return true;
+}
+
+bool CReservedTable::PlayerTriesRestaurantTableMsg(CPlayerTriesRestaurantTableMsg *msg) {
+ if (msg->_tableId == _tableId) {
+ if (!msg->_result) {
+ CMaitreD *maitreD = dynamic_cast<CMaitreD *>(findRoomObject("MaitreD"));
+ startTalking(maitreD, 118, maitreD->findView());
+ msg->_result = true;
+ }
+
+ _cursorId = CURSOR_INVALID;
+ _flag = true;
+ return true;
+ } else {
+ return false;
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/reserved_table.h b/engines/titanic/game/reserved_table.h
index a3532c7d14..bc037ae3d9 100644
--- a/engines/titanic/game/reserved_table.h
+++ b/engines/titanic/game/reserved_table.h
@@ -28,11 +28,15 @@
namespace Titanic {
class CReservedTable : public CGameObject {
+ DECLARE_MESSAGE_MAP;
+ bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
+ bool PlayerTriesRestaurantTableMsg(CPlayerTriesRestaurantTableMsg *msg);
public:
- int _value1, _value2;
+ bool _flag;
+ int _tableId;
public:
CLASSDEF;
- CReservedTable() : CGameObject(), _value1(0), _value2(0) {}
+ CReservedTable() : CGameObject(), _flag(false), _tableId(0) {}
/**
* Save the data for the class to file
diff --git a/engines/titanic/game/restaurant_cylinder_holder.cpp b/engines/titanic/game/restaurant_cylinder_holder.cpp
index d70009f151..8726d1a925 100644
--- a/engines/titanic/game/restaurant_cylinder_holder.cpp
+++ b/engines/titanic/game/restaurant_cylinder_holder.cpp
@@ -24,20 +24,29 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CRestaurantCylinderHolder, CDropTarget)
+ ON_MESSAGE(EjectCylinderMsg)
+ ON_MESSAGE(EnterViewMsg)
+ ON_MESSAGE(MovieEndMsg)
+ ON_MESSAGE(QueryCylinderHolderMsg)
+ ON_MESSAGE(QueryCylinderNameMsg)
+ ON_MESSAGE(MouseDragStartMsg)
+END_MESSAGE_MAP()
+
CRestaurantCylinderHolder::CRestaurantCylinderHolder() : CDropTarget(),
_field118(0), _field11C(0), _field12C(0), _field130(0),
- _string6("z#61.wav"), _field140(1) {
+ _ejectSoundName("z#61.wav"), _defaultCursorId(CURSOR_ARROW) {
}
void CRestaurantCylinderHolder::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
file->writeNumberLine(_field118, indent);
file->writeNumberLine(_field11C, indent);
- file->writeQuotedLine(_string5, indent);
+ file->writeQuotedLine(_target, indent);
file->writeNumberLine(_field12C, indent);
file->writeNumberLine(_field130, indent);
- file->writeQuotedLine(_string6, indent);
- file->writeNumberLine(_field140, indent);
+ file->writeQuotedLine(_ejectSoundName, indent);
+ file->writeNumberLine(_defaultCursorId, indent);
CDropTarget::save(file, indent);
}
@@ -46,13 +55,98 @@ void CRestaurantCylinderHolder::load(SimpleFile *file) {
file->readNumber();
_field118 = file->readNumber();
_field11C = file->readNumber();
- _string5 = file->readString();
+ _target = file->readString();
_field12C = file->readNumber();
_field130 = file->readNumber();
- _string6 = file->readString();
- _field140 = file->readNumber();
+ _ejectSoundName = file->readString();
+ _defaultCursorId = (CursorId)file->readNumber();
CDropTarget::load(file);
}
+bool CRestaurantCylinderHolder::EjectCylinderMsg(CEjectCylinderMsg *msg) {
+ _field11C = true;
+ bool hasCylinder = findByName("Phonograph Cylinder") != nullptr;
+
+ if (_field118) {
+ playClip(hasCylinder ? "CloseHolder_Full" : "CloseHolder_Empty",
+ MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ _fieldF4 = 1;
+ } else {
+ playClip(hasCylinder ? "OpenHolder_Full" : "OpenHolder_Empty",
+ MOVIE_NOTIFY_OBJECT | MOVIE_GAMESTATE);
+ }
+
+ playSound(_ejectSoundName, 50);
+ return true;
+}
+
+bool CRestaurantCylinderHolder::EnterViewMsg(CEnterViewMsg *msg) {
+ if (_field118) {
+ CTreeItem *cylinder = findByName("Phonograph Cylinder", true);
+ if (cylinder) {
+ loadFrame(_dropFrame);
+ _cursorId = _dropCursorId;
+ } else {
+ loadFrame(_dragFrame);
+ _cursorId = _dragCursorId;
+ }
+ } else {
+ loadFrame(_field130);
+ _cursorId = _defaultCursorId;
+ }
+
+ return true;
+}
+
+bool CRestaurantCylinderHolder::MovieEndMsg(CMovieEndMsg *msg) {
+ _field11C = false;
+ if (_field118) {
+ _field118 = false;
+ _cursorId = _defaultCursorId;
+
+ CPhonographReadyToPlayMsg readyMsg;
+ readyMsg.execute(_target);
+ } else {
+ _field118 = true;
+ _fieldF4 = false;
+ _cursorId = findByName("Phonograph Cylinder") ? _dropCursorId : _dragCursorId;
+ }
+
+ CCylinderHolderReadyMsg holderMsg;
+ holderMsg.execute(_target);
+ return true;
+}
+
+bool CRestaurantCylinderHolder::QueryCylinderHolderMsg(CQueryCylinderHolderMsg *msg) {
+ CNamedItem *cylinder = findByName("Phonograph Cylinder", true);
+
+ msg->_value1 = _field118;
+ if (cylinder) {
+ msg->_value2 = 1;
+ msg->_target = cylinder;
+ }
+
+ return true;
+}
+
+bool CRestaurantCylinderHolder::QueryCylinderNameMsg(CQueryCylinderNameMsg *msg) {
+ CNamedItem *cylinder = findByName("Phonograph Cylinder", true);
+
+ if (cylinder) {
+ CQueryCylinderMsg queryMsg;
+ queryMsg.execute(cylinder);
+ msg->_name = queryMsg._name;
+ }
+
+ return true;
+}
+
+bool CRestaurantCylinderHolder::MouseDragStartMsg(CMouseDragStartMsg *msg) {
+ if (_field118)
+ return CDropTarget::MouseDragStartMsg(msg);
+ else
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/restaurant_cylinder_holder.h b/engines/titanic/game/restaurant_cylinder_holder.h
index 3aa979b0a5..cd0b0783bd 100644
--- a/engines/titanic/game/restaurant_cylinder_holder.h
+++ b/engines/titanic/game/restaurant_cylinder_holder.h
@@ -28,14 +28,21 @@
namespace Titanic {
class CRestaurantCylinderHolder : public CDropTarget {
+ DECLARE_MESSAGE_MAP;
+ bool EjectCylinderMsg(CEjectCylinderMsg *msg);
+ bool EnterViewMsg(CEnterViewMsg *msg);
+ bool MovieEndMsg(CMovieEndMsg *msg);
+ bool QueryCylinderHolderMsg(CQueryCylinderHolderMsg *msg);
+ bool QueryCylinderNameMsg(CQueryCylinderNameMsg *msg);
+ bool MouseDragStartMsg(CMouseDragStartMsg *msg);
private:
int _field118;
int _field11C;
- CString _string5;
+ CString _target;
int _field12C;
int _field130;
- CString _string6;
- int _field140;
+ CString _ejectSoundName;
+ CursorId _defaultCursorId;
public:
CLASSDEF;
CRestaurantCylinderHolder();
diff --git a/engines/titanic/game/restaurant_phonograph.cpp b/engines/titanic/game/restaurant_phonograph.cpp
index 83a4ac3e71..881079e020 100644
--- a/engines/titanic/game/restaurant_phonograph.cpp
+++ b/engines/titanic/game/restaurant_phonograph.cpp
@@ -21,9 +21,20 @@
*/
#include "titanic/game/restaurant_phonograph.h"
+#include "titanic/core/room_item.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CRestaurantPhonograph, CPhonograph)
+ ON_MESSAGE(MouseButtonDownMsg)
+ ON_MESSAGE(PhonographPlayMsg)
+ ON_MESSAGE(PhonographStopMsg)
+ ON_MESSAGE(PhonographReadyToPlayMsg)
+ ON_MESSAGE(EjectCylinderMsg)
+ ON_MESSAGE(QueryPhonographState)
+ ON_MESSAGE(LockPhonographMsg)
+END_MESSAGE_MAP()
+
CRestaurantPhonograph::CRestaurantPhonograph() : CPhonograph(),
_fieldF8(1), _field114(0) {}
@@ -48,4 +59,89 @@ void CRestaurantPhonograph::load(SimpleFile *file) {
CPhonograph::load(file);
}
+bool CRestaurantPhonograph::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+ if (!_fieldF8 && !_fieldE0) {
+ CQueryCylinderHolderMsg holderMsg;
+ holderMsg.execute(this);
+
+ if (!holderMsg._value1) {
+ CPhonographPlayMsg playMsg;
+ playMsg.execute(this);
+ } else if (holderMsg._value2) {
+ CEjectCylinderMsg ejectMsg;
+ ejectMsg.execute(this);
+
+ _fieldE8 = true;
+ if (_field114) {
+ loadFrame(_fieldEC);
+ playSound(_ejectSoundName);
+ }
+ }
+ }
+
+ return true;
+}
+
+bool CRestaurantPhonograph::PhonographPlayMsg(CPhonographPlayMsg *msg) {
+ if (_fieldE0) {
+ if (findView() == getView() && (!_fieldE8 || !_field114)) {
+ loadFrame(_fieldEC);
+ playSound(_ejectSoundName);
+ }
+
+ CQueryCylinderNameMsg nameMsg;
+ nameMsg.execute(this);
+ CRestaurantMusicChanged musicMsg(nameMsg._name);
+ musicMsg.execute(findRoom());
+ } else {
+ loadFrame(_fieldF0);
+ }
+
+ return true;
+}
+
+bool CRestaurantPhonograph::PhonographStopMsg(CPhonographStopMsg *msg) {
+ bool flag = _fieldE0;
+ CPhonograph::PhonographStopMsg(msg);
+
+ if (_fieldE0) {
+ loadFrame(_fieldF0);
+ if (flag)
+ playSound(_string3);
+ } else {
+ loadFrame(_fieldEC);
+ }
+
+ return true;
+}
+
+bool CRestaurantPhonograph::PhonographReadyToPlayMsg(CPhonographReadyToPlayMsg *msg) {
+ if (_fieldE8) {
+ CPhonographPlayMsg playMsg;
+ playMsg.execute(this);
+ _fieldE8 = false;
+ }
+
+ return true;
+}
+
+bool CRestaurantPhonograph::EjectCylinderMsg(CEjectCylinderMsg *msg) {
+ if (_fieldE0) {
+ CPhonographStopMsg stopMsg;
+ stopMsg.execute(this);
+ }
+
+ return true;
+}
+
+bool CRestaurantPhonograph::QueryPhonographState(CQueryPhonographState *msg) {
+ msg->_value = _fieldF8;
+ return true;
+}
+
+bool CRestaurantPhonograph::LockPhonographMsg(CLockPhonographMsg *msg) {
+ _fieldF8 = msg->_value;
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/game/restaurant_phonograph.h b/engines/titanic/game/restaurant_phonograph.h
index 710a2edd73..9661df0dfb 100644
--- a/engines/titanic/game/restaurant_phonograph.h
+++ b/engines/titanic/game/restaurant_phonograph.h
@@ -28,9 +28,17 @@
namespace Titanic {
class CRestaurantPhonograph : public CPhonograph {
+ DECLARE_MESSAGE_MAP;
+ bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
+ bool PhonographPlayMsg(CPhonographPlayMsg *msg);
+ bool PhonographStopMsg(CPhonographStopMsg *msg);
+ bool PhonographReadyToPlayMsg(CPhonographReadyToPlayMsg *msg);
+ bool EjectCylinderMsg(CEjectCylinderMsg *msg);
+ bool QueryPhonographState(CQueryPhonographState *msg);
+ bool LockPhonographMsg(CLockPhonographMsg *msg);
private:
int _fieldF8;
- CString _string2;
+ CString _ejectSoundName;
CString _string3;
int _field114;
public:
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index 7ce92d190f..5ca0c516e4 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -267,7 +267,7 @@ MESSAGE0(CPhonographReadyToPlayMsg);
MESSAGE1(CPhonographRecordMsg, int, value, 0);
MESSAGE3(CPhonographStopMsg, int, value1, 0, int, value2, 0, int, value3, 0);
MESSAGE2(CPlayRangeMsg, int, value1, 0, int, value2, 0);
-MESSAGE2(CPlayerTriesRestaurantTableMsg, int, value1, 0, int, value2, 0);
+MESSAGE2(CPlayerTriesRestaurantTableMsg, int, tableId, 0, bool, result, false);
MESSAGE1(CPreSaveMsg, int, value, 0);
MESSAGE1(CProdMaitreDMsg, int, value, 0);
MESSAGE2(CPumpingMsg, int, value, 0, CGameObject *, object, nullptr);
diff --git a/engines/titanic/moves/restaurant_pan_handler.cpp b/engines/titanic/moves/restaurant_pan_handler.cpp
index 92f55b46cc..d93e331254 100644
--- a/engines/titanic/moves/restaurant_pan_handler.cpp
+++ b/engines/titanic/moves/restaurant_pan_handler.cpp
@@ -24,24 +24,40 @@
namespace Titanic {
-int CRestaurantPanHandler::_v1;
+BEGIN_MESSAGE_MAP(CRestaurantPanHandler, CMovePlayerTo)
+ ON_MESSAGE(ArmPickedUpFromTableMsg)
+ ON_MESSAGE(MouseButtonDownMsg)
+END_MESSAGE_MAP()
+
+bool CRestaurantPanHandler::_armPickedUp;
void CRestaurantPanHandler::save(SimpleFile *file, int indent) {
file->writeNumberLine(1, indent);
- file->writeNumberLine(_v1, indent);
- file->writeQuotedLine(_string1, indent);
- file->writeQuotedLine(_string2, indent);
+ file->writeNumberLine(_armPickedUp, indent);
+ file->writeQuotedLine(_armlessDestination, indent);
+ file->writeQuotedLine(_armDestination, indent);
CMovePlayerTo::save(file, indent);
}
void CRestaurantPanHandler::load(SimpleFile *file) {
file->readNumber();
- _v1 = file->readNumber();
- _string1 = file->readString();
- _string2 = file->readString();
+ _armPickedUp = file->readNumber();
+ _armlessDestination = file->readString();
+ _armDestination = file->readString();
CMovePlayerTo::load(file);
}
+bool CRestaurantPanHandler::ArmPickedUpFromTableMsg(CArmPickedUpFromTableMsg *msg) {
+ _armPickedUp = true;
+ return true;
+}
+
+bool CRestaurantPanHandler::MouseButtonDownMsg(CMouseButtonDownMsg *msg) {
+ _destination = _armPickedUp ? _armDestination : _armlessDestination;
+ changeView(_destination);
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/moves/restaurant_pan_handler.h b/engines/titanic/moves/restaurant_pan_handler.h
index 4925aa685b..745cd5d564 100644
--- a/engines/titanic/moves/restaurant_pan_handler.h
+++ b/engines/titanic/moves/restaurant_pan_handler.h
@@ -28,11 +28,14 @@
namespace Titanic {
class CRestaurantPanHandler : public CMovePlayerTo {
-protected:
- static int _v1;
-
- CString _string1;
- CString _string2;
+ DECLARE_MESSAGE_MAP;
+ bool ArmPickedUpFromTableMsg(CArmPickedUpFromTableMsg *msg);
+ bool MouseButtonDownMsg(CMouseButtonDownMsg *msg);
+private:
+ CString _armDestination;
+ CString _armlessDestination;
+public:
+ static bool _armPickedUp;
public:
CLASSDEF;