aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Gilbert2016-04-14 22:31:33 -0400
committerPaul Gilbert2016-07-10 16:11:09 -0400
commit2dcda26eb1253d884d6a921a3f2ead76021b9bc4 (patch)
tree304f4bf8bf69b3325cc7e06a099a9a6de884448d
parent7ddd5d1a8b97bda75e4eece9c91ff3286e3c3eca (diff)
downloadscummvm-rg350-2dcda26eb1253d884d6a921a3f2ead76021b9bc4.tar.gz
scummvm-rg350-2dcda26eb1253d884d6a921a3f2ead76021b9bc4.tar.bz2
scummvm-rg350-2dcda26eb1253d884d6a921a3f2ead76021b9bc4.zip
TITANIC: Implement CBridgePiece message handlers
-rw-r--r--engines/titanic/carry/brain.cpp86
-rw-r--r--engines/titanic/carry/brain.h9
-rw-r--r--engines/titanic/carry/bridge_piece.cpp47
-rw-r--r--engines/titanic/carry/bridge_piece.h3
-rw-r--r--engines/titanic/core/game_object.cpp18
-rw-r--r--engines/titanic/core/game_object.h11
-rw-r--r--engines/titanic/game/ship_setting.h2
-rw-r--r--engines/titanic/game_state.h2
-rw-r--r--engines/titanic/messages/messages.h2
-rw-r--r--engines/titanic/pet_control/pet_control.cpp8
-rw-r--r--engines/titanic/pet_control/pet_control.h5
11 files changed, 191 insertions, 2 deletions
diff --git a/engines/titanic/carry/brain.cpp b/engines/titanic/carry/brain.cpp
index 0d1cdf7518..acc29b3f0e 100644
--- a/engines/titanic/carry/brain.cpp
+++ b/engines/titanic/carry/brain.cpp
@@ -21,9 +21,18 @@
*/
#include "titanic/carry/brain.h"
+#include "titanic/game/brain_slot.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CBrain, CCarry)
+ ON_MESSAGE(UseWithOtherMsg)
+ ON_MESSAGE(VisibleMsg)
+ ON_MESSAGE(MouseDragStartMsg)
+ ON_MESSAGE(PassOnDragStartMsg)
+ ON_MESSAGE(PETGainedObjectMsg)
+END_MESSAGE_MAP()
+
CBrain::CBrain() : CCarry(), _field134(0), _field138(0) {
}
@@ -45,4 +54,81 @@ void CBrain::load(SimpleFile *file) {
CCarry::load(file);
}
+bool CBrain::UseWithOtherMsg(CUseWithOtherMsg *msg) {
+ CBrainSlot *slot = static_cast<CBrainSlot *>(msg->_other);
+ if (slot) {
+ if (slot->getName() == "CentralCore") {
+ setVisible(false);
+ moveToHiddenRoom();
+ CAddHeadPieceMsg headpieceMsg(getName());
+ headpieceMsg.execute("CentralCoreSlot");
+ }
+ else if (!slot->_value1 && slot->getName() == "CentralCoreSlot") {
+ setVisible(false);
+ moveToHiddenRoom();
+ CAddHeadPieceMsg headpieceMsg(getName());
+ headpieceMsg.execute(msg->_other);
+ playSound("z#116.wav", 100, 0, 0);
+ setPosition(Point(0, 0));
+ setVisible(false);
+ _field134 = 1;
+ }
+
+ return true;
+ }
+ else {
+ return CCarry::UseWithOtherMsg(msg);
+ }
+}
+
+bool CBrain::VisibleMsg(CVisibleMsg *msg) {
+ setVisible(msg->_visible);
+ return true;
+}
+
+bool CBrain::MouseDragStartMsg(CMouseDragStartMsg *msg) {
+ if (!checkStartDragging(msg))
+ return false;
+
+ if (_field134) {
+ CTakeHeadPieceMsg headpieceMsg(getName());
+ headpieceMsg.execute("TitaniaControl");
+
+ _field134 = 0;
+ setVisible(true);
+ moveToView();
+
+ setPosition(Point(msg->_mousePos.x - _bounds.width() / 2,
+ msg->_mousePos.y - _bounds.height() / 2));
+ }
+
+ return CCarry::MouseDragStartMsg(msg);
+}
+
+bool CBrain::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
+ if (_field134) {
+ CTakeHeadPieceMsg headpieceMsg(getName());
+ headpieceMsg.execute("TitaniaControl");
+ _field134 = 0;
+
+ setVisible(true);
+ moveToView();
+ setPosition(Point(msg->_mousePos.x - _bounds.width() / 2,
+ msg->_mousePos.y - _bounds.height() / 2));
+ }
+
+ return CCarry::PassOnDragStartMsg(msg);
+}
+
+bool CBrain::PETGainedObjectMsg(CPETGainedObjectMsg *msg) {
+ if (!_field138) {
+ if (getName() == "Perch") {
+ incState38();
+ _field138 = 1;
+ }
+ }
+
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/carry/brain.h b/engines/titanic/carry/brain.h
index 14f9b632a0..3e24f5215b 100644
--- a/engines/titanic/carry/brain.h
+++ b/engines/titanic/carry/brain.h
@@ -24,10 +24,19 @@
#define TITANIC_BRAIN_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 CBrain : public CCarry {
+ DECLARE_MESSAGE_MAP
+ bool UseWithOtherMsg(CUseWithOtherMsg *msg);
+ bool VisibleMsg(CVisibleMsg *msg);
+ bool MouseDragStartMsg(CMouseDragStartMsg *msg);
+ bool PassOnDragStartMsg(CPassOnDragStartMsg *msg);
+ bool PETGainedObjectMsg(CPETGainedObjectMsg *msg);
private:
Point _pos1;
int _field134;
diff --git a/engines/titanic/carry/bridge_piece.cpp b/engines/titanic/carry/bridge_piece.cpp
index e93d3c455a..0ed8ae6a9a 100644
--- a/engines/titanic/carry/bridge_piece.cpp
+++ b/engines/titanic/carry/bridge_piece.cpp
@@ -21,9 +21,15 @@
*/
#include "titanic/carry/bridge_piece.h"
+#include "titanic/game/ship_setting.h"
namespace Titanic {
+BEGIN_MESSAGE_MAP(CBridgePiece, CCarry)
+ ON_MESSAGE(UseWithOtherMsg)
+ ON_MESSAGE(PassOnDragStartMsg)
+END_MESSAGE_MAP()
+
CBridgePiece::CBridgePiece() : CCarry(), _field140(0) {
}
@@ -45,4 +51,45 @@ void CBridgePiece::load(SimpleFile *file) {
CCarry::load(file);
}
+bool CBridgePiece::UseWithOtherMsg(CUseWithOtherMsg *msg) {
+ CShipSetting *shipSetting = static_cast<CShipSetting *>(msg->_other);
+ if (!shipSetting) {
+ return CCarry::UseWithOtherMsg(msg);
+ } else if (shipSetting->_string4 == "NULL") {
+ dropOnPet();
+ return true;
+ } else {
+ setVisible(false);
+ playSound("z#54.wav", 100, 0, 0);
+ setPosition(shipSetting->_pos1);
+ shipSetting->_string4 = getName();
+ moveToHiddenRoom();
+
+ CAddHeadPieceMsg headpieceMsg(shipSetting->getName() == _string6 ?
+ "Enable" : "Disable");
+ CSetFrameMsg frameMsg;
+
+ CString name = getName();
+ if (name == "ChickenBridge") {
+ frameMsg._frameNumber = 1;
+ } else if (name == "FanBridge") {
+ frameMsg._frameNumber = 2;
+ } else if (name == "SeasonBridge") {
+ frameMsg._frameNumber = 3;
+ } else if (name == "BeamBridge") {
+ frameMsg._frameNumber = 0;
+ }
+
+ frameMsg.execute(shipSetting);
+ headpieceMsg.execute(shipSetting);
+ return true;
+ }
+}
+
+bool CBridgePiece::PassOnDragStartMsg(CPassOnDragStartMsg *msg) {
+ setVisible(true);
+ moveToView();
+ return CCarry::PassOnDragStartMsg(msg);
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/carry/bridge_piece.h b/engines/titanic/carry/bridge_piece.h
index a641eb4574..5041cbc049 100644
--- a/engines/titanic/carry/bridge_piece.h
+++ b/engines/titanic/carry/bridge_piece.h
@@ -28,6 +28,9 @@
namespace Titanic {
class CBridgePiece : public CCarry {
+ DECLARE_MESSAGE_MAP
+ bool UseWithOtherMsg(CUseWithOtherMsg *msg);
+ bool PassOnDragStartMsg(CPassOnDragStartMsg *msg);
private:
CString _string6;
Point _pos3;
diff --git a/engines/titanic/core/game_object.cpp b/engines/titanic/core/game_object.cpp
index ba8ab42c68..e0ca5ff6b9 100644
--- a/engines/titanic/core/game_object.cpp
+++ b/engines/titanic/core/game_object.cpp
@@ -626,4 +626,22 @@ Found CGameObject::find(const CString &name, CGameObject **item, int findAreas)
return FOUND_NONE;
}
+void CGameObject::moveToHiddenRoom() {
+ CPetControl *pet = getPetControl();
+ if (pet) {
+ makeDirty();
+ pet->moveToHiddenRoom(this);
+ }
+}
+
+void CGameObject::moveToView() {
+ CViewItem *view = getGameManager()->getView();
+ detach();
+ view->addUnder(this);
+}
+
+void CGameObject::incState38() {
+ getGameManager()->_gameState.inc38();
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/core/game_object.h b/engines/titanic/core/game_object.h
index 86687309e7..3848222436 100644
--- a/engines/titanic/core/game_object.h
+++ b/engines/titanic/core/game_object.h
@@ -132,6 +132,7 @@ protected:
void soundFn2(int val, int val2);
void petFn2(int val);
void petFn3(CTreeItem *item);
+ void incState38();
/**
* Plays a sound
@@ -188,6 +189,16 @@ protected:
* Finds an item in various system areas
*/
Found find(const CString &name, CGameObject **item, int findAreas);
+
+ /**
+ * Moves the item from it's original position to be under the hidden room
+ */
+ void moveToHiddenRoom();
+
+ /**
+ * Moves the item from it's original position to be under the current view
+ */
+ void moveToView();
public:
int _field60;
CursorId _cursorId;
diff --git a/engines/titanic/game/ship_setting.h b/engines/titanic/game/ship_setting.h
index 9783e69461..acc06d171f 100644
--- a/engines/titanic/game/ship_setting.h
+++ b/engines/titanic/game/ship_setting.h
@@ -30,7 +30,7 @@ namespace Titanic {
class CShipSetting : public CBackground {
bool EnterRoomMsg(CEnterRoomMsg *msg);
-private:
+public:
CString _string3;
Point _pos1;
CString _string4;
diff --git a/engines/titanic/game_state.h b/engines/titanic/game_state.h
index 0fe8e6ad14..1176b2f6f2 100644
--- a/engines/titanic/game_state.h
+++ b/engines/titanic/game_state.h
@@ -123,6 +123,8 @@ public:
* Adds a movie to the movie list
*/
void addMovie(CMovie *movie);
+
+ void inc38() { ++_field38; }
};
} // End of namespace Titanic
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index 4c26ec5b33..f1b782b9a1 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -344,7 +344,7 @@ MESSAGE0(CSubTurnOffMsg);
MESSAGE0(CSubTurnOnMsg);
MESSAGE2(CSummonBotMsg, CString, strValue, "", int, numValue, 0);
MESSAGE1(CSummonBotQuerryMsg, CString, value, "");
-MESSAGE1(CTakeHeadPieceMsg, CString, value, "");
+MESSAGE1(CTakeHeadPieceMsg, CString, value, "NULL");
MESSAGE2(CTextInputMsg, CString, value1, "", CString, value2, "");
MESSAGE1(CTimeDilationMsg, int, value, 0);
MESSAGE0(CTitleSequenceEndedMsg);
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index 2f119be5d3..a955b085cc 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -369,4 +369,12 @@ void CPetControl::addToInventory(CCarry *item) {
_inventory.addItem(item);
}
+void CPetControl::moveToHiddenRoom(CTreeItem *item) {
+ CRoomItem *room = getHiddenRoom();
+ if (room) {
+ item->detach();
+ room->addUnder(item);
+ }
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 73dc69b0ab..88a738f2d8 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -217,6 +217,11 @@ public:
* Adds an item to the PET inventory
*/
void addToInventory(CCarry *item);
+
+ /**
+ * Moves a tree item from it's original position to be under the hidden room
+ */
+ void moveToHiddenRoom(CTreeItem *item);
};
} // End of namespace Titanic