aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/messages
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-24 21:02:25 -0400
committerPaul Gilbert2016-03-24 21:02:25 -0400
commitc948e8812ebb619f22adb7794da6dcfb6d5d6b9e (patch)
tree8b87bcb0ceb513dcdd810dde682bf9c550e71251 /engines/titanic/messages
parentfd78a874ccfdbc652241dc4402f6ca96ca188170 (diff)
downloadscummvm-rg350-c948e8812ebb619f22adb7794da6dcfb6d5d6b9e.tar.gz
scummvm-rg350-c948e8812ebb619f22adb7794da6dcfb6d5d6b9e.tar.bz2
scummvm-rg350-c948e8812ebb619f22adb7794da6dcfb6d5d6b9e.zip
TITANIC: Support methods needed by CTelevision
Diffstat (limited to 'engines/titanic/messages')
-rw-r--r--engines/titanic/messages/messages.cpp12
-rw-r--r--engines/titanic/messages/messages.h7
-rw-r--r--engines/titanic/messages/pet_messages.h19
3 files changed, 38 insertions, 0 deletions
diff --git a/engines/titanic/messages/messages.cpp b/engines/titanic/messages/messages.cpp
index 28b8856578..1c3d406b1b 100644
--- a/engines/titanic/messages/messages.cpp
+++ b/engines/titanic/messages/messages.cpp
@@ -24,6 +24,7 @@
#include "titanic/messages/mouse_messages.h"
#include "titanic/core/game_object.h"
#include "titanic/core/tree_item.h"
+#include "titanic/titanic.h"
namespace Titanic {
@@ -67,6 +68,17 @@ bool CMessage::execute(CTreeItem *target, const ClassDef *classDef, int flags) {
return result;
}
+bool CMessage::execute(const CString &target, const ClassDef *classDef, int flags) {
+ // Scan for the target by name
+ CProjectItem *project = g_vm->_window->_project;
+ for (CTreeItem *treeItem = project; treeItem; treeItem = treeItem->scan(project)) {
+ if (treeItem->getName().compareToIgnoreCase(target))
+ return execute(treeItem, classDef, flags);
+ }
+
+ return false;
+}
+
bool CMessage::isMouseMsg() const {
return dynamic_cast<const CMouseMsg *>(this) != nullptr;
}
diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h
index c945ad7736..b7a7cd6e7b 100644
--- a/engines/titanic/messages/messages.h
+++ b/engines/titanic/messages/messages.h
@@ -54,6 +54,13 @@ public:
bool execute(CTreeItem *target, const ClassDef *classDef = nullptr,
int flags = MSGFLAG_SCAN | MSGFLAG_BREAK_IF_HANDLED);
+ /**
+ * Executes the message, passing it on to the designated target,
+ * and optionally it's children
+ */
+ bool execute(const CString &target, const ClassDef *classDef = nullptr,
+ int flags = MSGFLAG_SCAN | MSGFLAG_BREAK_IF_HANDLED);
+
virtual bool perform(CTreeItem *treeItem) { return false; }
/**
diff --git a/engines/titanic/messages/pet_messages.h b/engines/titanic/messages/pet_messages.h
index ac9c3ccc75..caca53dfee 100644
--- a/engines/titanic/messages/pet_messages.h
+++ b/engines/titanic/messages/pet_messages.h
@@ -42,6 +42,25 @@ MESSAGE1(CPETStarFieldLockMsg, int, value, 0);
MESSAGE0(CPETStereoFieldOnOffMsg);
MESSAGE2(CPETTargetMsg, CString, strValue, "", int, numValue, -1);
+#define PET_MESSAGE(NAME) MSGTARGET(NAME); \
+ class NAME: public CPETTargetMsg { \
+ public: \
+ NAME() : CPETTargetMsg() {} \
+ NAME(const CString &name, int num) : CPETTargetMsg(name, num) {} \
+ 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); \
+ } }
+
+PET_MESSAGE(CPETDownMsg);
+PET_MESSAGE(CPETUpMsg);
+PET_MESSAGE(CPETLeftMsg);
+PET_MESSAGE(CPETRightMsg);
+PET_MESSAGE(CPETActivateMsg);
+
} // End of namespace Titanic
#endif /* TITANIC_PET_MESSAGES_H */