aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/core/saveable_object.cpp2
-rw-r--r--engines/titanic/messages/messages.h141
-rw-r--r--engines/titanic/pet_control/pet_control.cpp99
-rw-r--r--engines/titanic/pet_control/pet_control.h25
-rw-r--r--engines/titanic/pet_control/pet_section.h8
5 files changed, 212 insertions, 63 deletions
diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp
index 022a72b33a..c77bd2bfc3 100644
--- a/engines/titanic/core/saveable_object.cpp
+++ b/engines/titanic/core/saveable_object.cpp
@@ -920,6 +920,7 @@ DEFFN(CTakeHeadPieceMsg)
DEFFN(CTextInputMsg)
DEFFN(CTimeDilationMsg)
DEFFN(CTimeMsg)
+DEFFN(CTimerMsg)
DEFFN(CTitleSequenceEndedMsg)
DEFFN(CTransitMsg)
DEFFN(CTransportMsg)
@@ -1503,6 +1504,7 @@ void CSaveableObject::initClassList() {
ADDFN(CTextInputMsg, CMessage);
ADDFN(CTimeDilationMsg, CMessage);
ADDFN(CTimeMsg, CMessage);
+ ADDFN(CTimerMsg, CTimeMsg);
ADDFN(CTitleSequenceEndedMsg, CMessage);
ADDFN(CTransitMsg, CMessage);
ADDFN(CTransportMsg, CMessage);
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index 99df239eda..b78fac481c 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -23,6 +23,7 @@
#ifndef TITANIC_MESSAGES_H
#define TITANIC_MESSAGES_H
+#include "common/keyboard.h"
#include "titanic/core/saveable_object.h"
#include "titanic/core/tree_item.h"
@@ -37,6 +38,65 @@ enum MessageFlag {
#define MSGTARGET(NAME) class NAME; class NAME##Target { public: \
virtual bool handleMessage(NAME &msg) = 0; }
+#define MESSAGE0(NAME) MSGTARGET(NAME); \
+ class NAME: public CMessage { \
+ public: NAME() : CMessage() {} \
+ CLASSDEF \
+ static bool isSupportedBy(const CTreeItem *item) { \
+ return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
+ virtual bool perform(CTreeItem *treeItem) { \
+ NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
+ return dest != nullptr && dest->handleMessage(*this); \
+ } }
+#define MESSAGE1(NAME, F1, N1, V1) MSGTARGET(NAME); \
+ class NAME: public CMessage { \
+ public: F1 _##N1; \
+ NAME() : CMessage(), _##N1(V1) {} \
+ NAME(F1 N1) : CMessage(), _##N1(N1) {} \
+ CLASSDEF \
+ static bool isSupportedBy(const CTreeItem *item) { \
+ return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
+ virtual bool perform(CTreeItem *treeItem) { \
+ NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
+ return dest != nullptr && dest->handleMessage(*this); \
+ } }
+#define MESSAGE2(NAME, F1, N1, V1, F2, N2, V2) MSGTARGET(NAME); \
+ class NAME: public CMessage { \
+ public: F1 _##N1; F2 _##N2; \
+ NAME() : CMessage(), _##N1(V1), _##N2(V2) {} \
+ NAME(F1 N1, F2 N2) : CMessage(), _##N1(N1), _##N2(N2) {} \
+ CLASSDEF \
+ static bool isSupportedBy(const CTreeItem *item) { \
+ return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
+ virtual bool perform(CTreeItem *treeItem) { \
+ NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
+ return dest != nullptr && dest->handleMessage(*this); \
+ } }
+#define MESSAGE3(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3) MSGTARGET(NAME); \
+ class NAME: public CMessage { \
+ public: F1 _##N1; F2 _##N2; F3 _##N3; \
+ NAME() : CMessage(), _##N1(V1), _##N2(V2), _##N3(V3) {} \
+ NAME(F1 N1, F2 N2, F3 N3) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3) {} \
+ CLASSDEF \
+ static bool isSupportedBy(const CTreeItem *item) { \
+ return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
+ virtual bool perform(CTreeItem *treeItem) { \
+ NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
+ return dest != nullptr && dest->handleMessage(*this); \
+ } }
+#define MESSAGE4(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3, F4, N4, V4) MSGTARGET(NAME); \
+ class NAME: public CMessage { \
+ public: F1 _##N1; F2 _##N2; F3 _##N3; F4 _##N4; \
+ NAME() : CMessage(), _##N1(V1), _##N2(V2), _##N3(V3), _##N4(V4) {} \
+ NAME(F1 N1, F2 N2, F3 N3, F4 N4) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3), _##N4(N4) {} \
+ CLASSDEF \
+ static bool isSupportedBy(const CTreeItem *item) { \
+ return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
+ virtual bool perform(CTreeItem *treeItem) { \
+ NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
+ return dest != nullptr && dest->handleMessage(*this); \
+ } }
+
class CGameObject;
class CRoomItem;
class CNodeItem;
@@ -193,64 +253,26 @@ public:
}
};
-#define MESSAGE0(NAME) MSGTARGET(NAME); \
- class NAME: public CMessage { \
- public: NAME() : CMessage() {} \
- CLASSDEF \
- static bool isSupportedBy(const CTreeItem *item) { \
- return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
- virtual bool perform(CTreeItem *treeItem) { \
- NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
- return dest != nullptr && dest->handleMessage(*this); \
- } }
-#define MESSAGE1(NAME, F1, N1, V1) MSGTARGET(NAME); \
- class NAME: public CMessage { \
- public: F1 _##N1; \
- NAME() : CMessage(), _##N1(V1) {} \
- NAME(F1 N1) : CMessage(), _##N1(N1) {} \
- CLASSDEF \
- static bool isSupportedBy(const CTreeItem *item) { \
- return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
- virtual bool perform(CTreeItem *treeItem) { \
- NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
- return dest != nullptr && dest->handleMessage(*this); \
- } }
-#define MESSAGE2(NAME, F1, N1, V1, F2, N2, V2) MSGTARGET(NAME); \
- class NAME: public CMessage { \
- public: F1 _##N1; F2 _##N2; \
- NAME() : CMessage(), _##N1(V1), _##N2(V2) {} \
- NAME(F1 N1, F2 N2) : CMessage(), _##N1(N1), _##N2(N2) {} \
- CLASSDEF \
- static bool isSupportedBy(const CTreeItem *item) { \
- return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
- virtual bool perform(CTreeItem *treeItem) { \
- NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
- return dest != nullptr && dest->handleMessage(*this); \
- } }
-#define MESSAGE3(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3) MSGTARGET(NAME); \
- class NAME: public CMessage { \
- public: F1 _##N1; F2 _##N2; F3 _##N3; \
- NAME() : CMessage(), _##N1(V1), _##N2(V2), _##N3(V3) {} \
- NAME(F1 N1, F2 N2, F3 N3) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3) {} \
- CLASSDEF \
- static bool isSupportedBy(const CTreeItem *item) { \
- return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
- virtual bool perform(CTreeItem *treeItem) { \
- NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
- return dest != nullptr && dest->handleMessage(*this); \
- } }
-#define MESSAGE4(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3, F4, N4, V4) MSGTARGET(NAME); \
- class NAME: public CMessage { \
- public: F1 _##N1; F2 _##N2; F3 _##N3; F4 _##N4; \
- NAME() : CMessage(), _##N1(V1), _##N2(V2), _##N3(V3), _##N4(V4) {} \
- NAME(F1 N1, F2 N2, F3 N3, F4 N4) : CMessage(), _##N1(N1), _##N2(N2), _##N3(N3), _##N4(N4) {} \
- CLASSDEF \
- static bool isSupportedBy(const CTreeItem *item) { \
- return dynamic_cast<const NAME##Target *>(item) != nullptr; } \
- virtual bool perform(CTreeItem *treeItem) { \
- NAME##Target *dest = dynamic_cast<NAME##Target *>(treeItem); \
- return dest != nullptr && dest->handleMessage(*this); \
- } }
+MESSAGE1(CTimeMsg, int, value, 0);
+
+MSGTARGET(CTimerMsg);
+class CTimerMsg : public CTimeMsg {
+public:
+ int _field8;
+ int _fieldC;
+ CString _string1;
+public:
+ CLASSDEF
+ CTimerMsg() : CTimeMsg(), _field8(0), _fieldC(0) {}
+
+ static bool isSupportedBy(const CTreeItem *item) {
+ return dynamic_cast<const CTimerMsgTarget *>(item) != nullptr;
+ }
+ virtual bool perform(CTreeItem *treeItem) {
+ CTimerMsgTarget *dest = dynamic_cast<CTimerMsgTarget *>(treeItem);
+ return dest != nullptr && dest->handleMessage(*this);
+ }
+};
MESSAGE1(CActMsg, CString, action, "");
MESSAGE1(CActivationmsg, CString, value, "");
@@ -387,7 +409,6 @@ MESSAGE1(CSummonBotQuerryMsg, CString, value, "");
MESSAGE1(CTakeHeadPieceMsg, CString, value, "");
MESSAGE2(CTextInputMsg, CString, value1, "", CString, value2, "");
MESSAGE1(CTimeDilationMsg, int, value, 0);
-MESSAGE1(CTimeMsg, int, value, 0);
MESSAGE0(CTitleSequenceEndedMsg);
MESSAGE0(CTransitMsg);
MESSAGE1(CTriggerAutoMusicPlayerMsg, int, value, 0);
@@ -405,7 +426,7 @@ MESSAGE0(CTurnOn);
MESSAGE1(CUse, int, value, 0);
MESSAGE1(CUseWithCharMsg, int, value, 0);
MESSAGE1(CUseWithOtherMsg, int, value, 0);
-MESSAGE1(CVirtualKeyCharMsg, int, value, 0);
+MESSAGE1(CVirtualKeyCharMsg, Common::KeyState, keyState, Common::KeyState());
MESSAGE1(CVisibleMsg, bool, visible, true);
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control.cpp b/engines/titanic/pet_control/pet_control.cpp
index 6df688ef75..9d2622ffb6 100644
--- a/engines/titanic/pet_control/pet_control.cpp
+++ b/engines/titanic/pet_control/pet_control.cpp
@@ -157,7 +157,7 @@ Rect CPetControl::getBounds() {
return _sub7.getBounds();
break;
default:
- break;
+ return Rect();
}
}
@@ -342,4 +342,101 @@ bool CPetControl::containsPt(const Common::Point &pt) const {
return _drawBounds.contains(pt);
}
+bool CPetControl::getC0() const {
+ return _fieldC0 > 0;
+}
+
+bool CPetControl::handleMessage(CMouseButtonDownMsg &msg) {
+ return true;
+}
+
+bool CPetControl::handleMessage(CMouseDragStartMsg &msg) {
+ return true;
+}
+
+bool CPetControl::handleMessage(CMouseDragMoveMsg &msg) {
+ return true;
+}
+
+bool CPetControl::handleMessage(CMouseDragEndMsg &msg) {
+ return true;
+}
+
+bool CPetControl::handleMessage(CMouseButtonUpMsg &msg) {
+ return true;
+}
+
+bool CPetControl::handleMessage(CMouseDoubleClickMsg &msg) {
+ return true;
+}
+
+bool CPetControl::handleMessage(CKeyCharMsg &msg) {
+ return true;
+}
+
+bool CPetControl::handleMessage(CVirtualKeyCharMsg &msg) {
+ if (getC0())
+ return false;
+
+ bool result = false;
+ switch (_currentArea) {
+ case PET_INVENTORY:
+ result = _inventory.handleMessage(msg);
+ break;
+ case PET_CONVERSATION:
+ result = _conversations.handleMessage(msg);
+ break;
+ case PET_REMOTE:
+ result = _remote.handleMessage(msg);
+ break;
+ case PET_ROOMS:
+ result = _rooms.handleMessage(msg);
+ break;
+ case PET_SAVE:
+ result = _saves.handleMessage(msg);
+ break;
+ case PET_5:
+ result = _sub5.handleMessage(msg);
+ break;
+ case PET_6:
+ result = _sub7.handleMessage(msg);
+ break;
+ default:
+ break;
+ }
+
+ if (!result) {
+ switch (msg._keyState.keycode) {
+ case Common::KEYCODE_F1:
+ result = true;
+ setArea(PET_INVENTORY);
+ break;
+ case Common::KEYCODE_F2:
+ result = true;
+ setArea(PET_CONVERSATION);
+ break;
+ case Common::KEYCODE_F3:
+ result = true;
+ setArea(PET_REMOTE);
+ break;
+ case Common::KEYCODE_F4:
+ result = true;
+ setArea(PET_ROOMS);
+ break;
+ case Common::KEYCODE_F5:
+ result = true;
+ setArea(PET_SAVE);
+ break;
+ default:
+ break;
+ }
+ }
+
+ return result;
+}
+
+bool CPetControl::handleMessage(CTimerMsg &msg) {
+ return true;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/pet_control/pet_control.h b/engines/titanic/pet_control/pet_control.h
index 24ab78a963..be3b4a6118 100644
--- a/engines/titanic/pet_control/pet_control.h
+++ b/engines/titanic/pet_control/pet_control.h
@@ -26,6 +26,8 @@
#include "titanic/core/game_object.h"
#include "titanic/core/node_item.h"
#include "titanic/core/room_item.h"
+#include "titanic/messages/messages.h"
+#include "titanic/messages/mouse_messages.h"
#include "titanic/pet_control/pet_conversation_section.h"
#include "titanic/pet_control/pet_frame.h"
#include "titanic/pet_control/pet_inventory_section.h"
@@ -37,7 +39,16 @@
namespace Titanic {
-class CPetControl : public CGameObject {
+class CPetControl : public CGameObject,
+ public CMouseButtonDownMsgTarget,
+ public CMouseDragStartMsgTarget,
+ public CMouseDragMoveMsgTarget,
+ public CMouseDragEndMsgTarget,
+ public CMouseButtonUpMsgTarget,
+ public CMouseDoubleClickMsgTarget,
+ public CKeyCharMsgTarget,
+ public CVirtualKeyCharMsgTarget,
+ public CTimerMsgTarget {
private:
int _fieldC0;
int _locked;
@@ -86,6 +97,18 @@ private:
* Returns true if the draw bounds contains the specified point
*/
bool containsPt(const Common::Point &pt) const;
+
+ bool getC0() const;
+protected:
+ bool handleMessage(CMouseButtonDownMsg &msg);
+ bool handleMessage(CMouseDragStartMsg &msg);
+ bool handleMessage(CMouseDragMoveMsg &msg);
+ bool handleMessage(CMouseDragEndMsg &msg);
+ bool handleMessage(CMouseButtonUpMsg &msg);
+ bool handleMessage(CMouseDoubleClickMsg &msg);
+ bool handleMessage(CKeyCharMsg &msg);
+ bool handleMessage(CVirtualKeyCharMsg &msg);
+ bool handleMessage(CTimerMsg &msg);
public:
PetArea _currentArea;
public:
diff --git a/engines/titanic/pet_control/pet_section.h b/engines/titanic/pet_control/pet_section.h
index b08e4d6869..f81e8d0aa9 100644
--- a/engines/titanic/pet_control/pet_section.h
+++ b/engines/titanic/pet_control/pet_section.h
@@ -23,6 +23,7 @@
#ifndef TITANIC_PET_SECTION_H
#define TITANIC_PET_SECTION_H
+#include "titanic/messages/messages.h"
#include "titanic/simple_file.h"
namespace Titanic {
@@ -81,7 +82,12 @@ public:
virtual int proc10() { return 0; }
virtual int proc11() { return 0; }
virtual int proc12() { return 0; }
- virtual int proc13() { return 0; }
+
+ /**
+ * Handles special keypresses
+ */
+ virtual bool handleMessage(CVirtualKeyCharMsg &msg) { return false; }
+
virtual int proc14() { return 0; }
virtual int proc15() { return 0; }
virtual void proc16();