aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-13 13:24:41 -0400
committerPaul Gilbert2016-07-10 16:10:59 -0400
commitc096bfa5d89f43e68fffbe390e73bad08e4f1745 (patch)
treede5c8c1b07a180d2c8122759dacab1f3d5bd4799 /engines/titanic
parent36d60d7476b62aef07914325adb6f9fd7b30132f (diff)
downloadscummvm-rg350-c096bfa5d89f43e68fffbe390e73bad08e4f1745.tar.gz
scummvm-rg350-c096bfa5d89f43e68fffbe390e73bad08e4f1745.tar.bz2
scummvm-rg350-c096bfa5d89f43e68fffbe390e73bad08e4f1745.zip
TITANIC: Implementing CArm message handlers
Diffstat (limited to 'engines/titanic')
-rw-r--r--engines/titanic/carry/arm.cpp96
-rw-r--r--engines/titanic/carry/arm.h16
-rw-r--r--engines/titanic/carry/carry.cpp4
-rw-r--r--engines/titanic/carry/carry.h12
-rw-r--r--engines/titanic/core/game_object.cpp4
-rw-r--r--engines/titanic/core/game_object.h12
-rw-r--r--engines/titanic/core/saveable_object.cpp2
-rw-r--r--engines/titanic/messages/messages.h1
8 files changed, 125 insertions, 22 deletions
diff --git a/engines/titanic/carry/arm.cpp b/engines/titanic/carry/arm.cpp
index fdf73e93f3..f2c7d5233f 100644
--- a/engines/titanic/carry/arm.cpp
+++ b/engines/titanic/carry/arm.cpp
@@ -24,10 +24,20 @@
namespace Titanic {
+BEGIN_MESSAGE_MAP(CArm, CCarry)
+ ON_MESSAGE(PuzzleSolvedMsg)
+ ON_MESSAGE(TranslateObjectMsg)
+ ON_MESSAGE(UseWithOtherMsg)
+ ON_MESSAGE(MouseDragStartMsg)
+ ON_MESSAGE(MaitreDHappyMsg)
+ ON_MESSAGE(PETGainedObjectMsg)
+ ON_MESSAGE(MouseDragMoveMsg)
+END_MESSAGE_MAP()
+
CArm::CArm() : CCarry(), _string6("Key"),
_field138(0), _field13C(0), _field140(0), _field144(0),
- _field148(0), _field158(0), _field15C(220), _field160(208),
- _field164(409), _field168(350), _field16C(3), _field170(0) {
+ _field148(0), _field158(0), _armRect(220, 208, 409, 350),
+ _field16C(3), _field170(0) {
}
void CArm::save(SimpleFile *file, int indent) const {
@@ -41,10 +51,10 @@ void CArm::save(SimpleFile *file, int indent) const {
file->writeQuotedLine(_string7, indent);
file->writeNumberLine(_field158, indent);
- file->writeNumberLine(_field15C, indent);
- file->writeNumberLine(_field160, indent);
- file->writeNumberLine(_field164, indent);
- file->writeNumberLine(_field168, indent);
+ file->writeNumberLine(_armRect.left, indent);
+ file->writeNumberLine(_armRect.top, indent);
+ file->writeNumberLine(_armRect.right, indent);
+ file->writeNumberLine(_armRect.bottom, indent);
file->writeNumberLine(_field16C, indent);
file->writeNumberLine(_field170, indent);
@@ -62,14 +72,80 @@ void CArm::load(SimpleFile *file) {
_string7 = file->readString();
_field158 = file->readNumber();
- _field15C = file->readNumber();
- _field160 = file->readNumber();
- _field164 = file->readNumber();
- _field168 = file->readNumber();
+ _armRect.left = file->readNumber();
+ _armRect.top = file->readNumber();
+ _armRect.right = file->readNumber();
+ _armRect.bottom = file->readNumber();
_field16C = file->readNumber();
_field170 = file->readNumber();
CCarry::load(file);
}
+bool CArm::PuzzleSolvedMsg(CPuzzleSolvedMsg *msg) {
+ _field138 = 0;
+ _fieldE0 = 1;
+
+ CString name = getName();
+ if (name == "Arm1") {
+ CActMsg actMsg("LoseArm");
+ actMsg.execute("MaitreD");
+ CPuzzleSolvedMsg solvedMsg;
+ solvedMsg.execute("AuditoryCentre");
+ } else if (name == "Arm2") {
+ CPuzzleSolvedMsg solvedMsg;
+ solvedMsg.execute("Key");
+ }
+
+ return true;
+}
+
+bool CArm::TranslateObjectMsg(CTranslateObjectMsg *msg) {
+ Point newPos(_bounds.left - msg->_delta.x, _bounds.top - msg->_delta.y);
+ setPosition(newPos);
+ return true;
+}
+
+bool CArm::UseWithOtherMsg(CUseWithOtherMsg *msg) {
+ return true;
+}
+
+bool CArm::MouseDragStartMsg(CMouseDragStartMsg *msg) {
+ return true;
+}
+
+bool CArm::MaitreDHappyMsg(CMaitreDHappyMsg *msg) {
+ // TODO
+ return true;
+}
+
+bool CArm::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
+ if (_field158) {
+ if (_string6 == "Key" || _string6 == "AuditoryCentre") {
+ CCarry *child = static_cast<CCarry *>(getFirstChild());
+ if (child) {
+ _visibleFrame = _field170;
+ loadFrame(_visibleFrame);
+ child->setVisible(true);
+ child->dropOnPet();
+ }
+
+ _string6 = "None";
+ }
+ }
+
+ return true;
+}
+
+bool CArm::MouseDragMoveMsg(CMouseDragMoveMsg *msg) {
+ setPosition(msg->_mousePos - _tempPos);
+
+ if (_string6 != "None" && compareViewNameTo("FrozenArboretum.Node 5.S")) {
+ loadFrame(_armRect.contains(msg->_mousePos) ?
+ _field16C : _visibleFrame);
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/carry/arm.h b/engines/titanic/carry/arm.h
index 1f93009d04..60f597e71f 100644
--- a/engines/titanic/carry/arm.h
+++ b/engines/titanic/carry/arm.h
@@ -24,10 +24,21 @@
#define TITANIC_ARM_H
#include "titanic/carry/carry.h"
+#include "titanic/messages/messages.h"
+#include "titanic/messages/mouse_messages.h"
+#include "titanic/messages/pet_messages.h"
namespace Titanic {
class CArm : public CCarry {
+ DECLARE_MESSAGE_MAP
+ bool PuzzleSolvedMsg(CPuzzleSolvedMsg *msg);
+ bool TranslateObjectMsg(CTranslateObjectMsg *msg);
+ bool UseWithOtherMsg(CUseWithOtherMsg *msg);
+ bool MouseDragStartMsg(CMouseDragStartMsg *msg);
+ bool MaitreDHappyMsg(CMaitreDHappyMsg *msg);
+ bool PETGainedObjectMsg(CPETGainedObjectMsg *msg);
+ bool MouseDragMoveMsg(CMouseDragMoveMsg *msg);
private:
CString _string6;
int _field138;
@@ -37,10 +48,7 @@ private:
int _field148;
CString _string7;
int _field158;
- int _field15C;
- int _field160;
- int _field164;
- int _field168;
+ Rect _armRect;
int _field16C;
int _field170;
public:
diff --git a/engines/titanic/carry/carry.cpp b/engines/titanic/carry/carry.cpp
index cc12fd1a72..9968c523ee 100644
--- a/engines/titanic/carry/carry.cpp
+++ b/engines/titanic/carry/carry.cpp
@@ -43,8 +43,8 @@ BEGIN_MESSAGE_MAP(CCarry, CGameObject)
END_MESSAGE_MAP()
CCarry::CCarry() : CGameObject(), _fieldDC(0), _fieldE0(1),
- _field100(0), _field104(0), _field108(0), _field10C(0),
- _itemFrame(0), _enterFrame(0), _enterFrameSet(false), _visibleFrame(0),
+ _field100(0), _field104(0), _field108(0), _field10C(0),
+ _itemFrame(0), _enterFrame(0), _enterFrameSet(false), _visibleFrame(0),
_string1("None"),
_fullViewName("NULL"),
_string3("That doesn't seem to do anything."),
diff --git a/engines/titanic/carry/carry.h b/engines/titanic/carry/carry.h
index e292eb2897..b14ba05934 100644
--- a/engines/titanic/carry/carry.h
+++ b/engines/titanic/carry/carry.h
@@ -43,7 +43,7 @@ class CCarry : public CGameObject {
bool MoveToStartPosMsg(CMoveToStartPosMsg *msg);
bool EnterViewMsg(CEnterViewMsg *msg);
bool PassOnDragStartMsg(CPassOnDragStartMsg *msg);
-private:
+protected:
CString _string1;
Point _origPos;
CString _fullViewName;
@@ -62,10 +62,7 @@ private:
bool _enterFrameSet;
int _visibleFrame;
protected:
- /**
- * Called when an item is dropped onto the PET
- */
- void dropOnPet();
+
public:
CLASSDEF
CCarry();
@@ -79,6 +76,11 @@ public:
* Load the data for the class from file
*/
virtual void load(SimpleFile *file);
+
+ /**
+ * Called to drop an item into the PET
+ */
+ void dropOnPet();
};
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index 0bd246d529..4628ccccf2 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -558,4 +558,8 @@ Point CGameObject::getMousePos() const {
return getGameManager()->_gameState.getMousePos();
}
+bool CGameObject::compareViewNameTo(const CString &name) const {
+ return getViewFullName().compareToIgnoreCase(name);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 9e84a453c7..658c8449fb 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -127,7 +127,6 @@ protected:
bool soundFn1(int val);
void soundFn2(int val, int val2);
- void setVisible(bool val);
void petFn2(int val);
void petFn3(CTreeItem *item);
@@ -155,6 +154,12 @@ protected:
* Get the current mouse cursor position
*/
Point getMousePos() const;
+
+ /*
+ * Compares the current view's name in a Room.Node.View tuplet
+ * string form to the passed string
+ */
+ bool compareViewNameTo(const CString &name) const;
public:
int _field60;
CursorId _cursorId;
@@ -230,6 +235,11 @@ public:
* Return the current view/node/room as a single string
*/
CString getViewFullName() const;
+
+ /**
+ * Sets whether the object is visible
+ */
+ void setVisible(bool val);
};
} // End of namespace Titanic
diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp
index 5b0453732b..2eacbba4a0 100644
--- a/engines/titanic/core/saveable_object.cpp
+++ b/engines/titanic/core/saveable_object.cpp
@@ -925,6 +925,7 @@ DEFFN(CTimeMsg)
DEFFN(CTimerMsg)
DEFFN(CTitleSequenceEndedMsg)
DEFFN(CTransitMsg)
+DEFFN(CTranslateObjectMsg)
DEFFN(CTransportMsg)
DEFFN(CTriggerAutoMusicPlayerMsg)
DEFFN(CTriggerNPCEvent)
@@ -1510,6 +1511,7 @@ void CSaveableObject::initClassList() {
ADDFN(CTimerMsg, CTimeMsg);
ADDFN(CTitleSequenceEndedMsg, CMessage);
ADDFN(CTransitMsg, CMessage);
+ ADDFN(CTranslateObjectMsg, CMessage);
ADDFN(CTransportMsg, CMessage);
ADDFN(CTriggerAutoMusicPlayerMsg, CMessage);
ADDFN(CTriggerNPCEvent, CMessage);
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index ab3078dd56..6d0df5ba90 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -366,6 +366,7 @@ MESSAGE2(CTextInputMsg, CString, value1, "", CString, value2, "");
MESSAGE1(CTimeDilationMsg, int, value, 0);
MESSAGE0(CTitleSequenceEndedMsg);
MESSAGE0(CTransitMsg);
+MESSAGE1(CTranslateObjectMsg, Point, delta, Point());
MESSAGE1(CTriggerAutoMusicPlayerMsg, int, value, 0);
MESSAGE1(CTriggerNPCEvent, int, value, 0);
MESSAGE4(CTrueTalkGetAnimSetMsg, int, value1, 0, int, value2, 0, int, value3, 0, int, value4, 0);