diff options
author | Paul Gilbert | 2016-04-06 23:28:42 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-04-06 23:28:42 -0400 |
commit | 51dc36a9a52f95815b4b1109b080d070247bf247 (patch) | |
tree | d53d8c288a593fd897536f943debbd2d7b46275e /engines/titanic/messages/messages.cpp | |
parent | 51df4d98d3a066e092f34cf7968c436a3e430df2 (diff) | |
download | scummvm-rg350-51dc36a9a52f95815b4b1109b080d070247bf247.tar.gz scummvm-rg350-51dc36a9a52f95815b4b1109b080d070247bf247.tar.bz2 scummvm-rg350-51dc36a9a52f95815b4b1109b080d070247bf247.zip |
TITANIC: Furhter in-progress message handling conversion
Diffstat (limited to 'engines/titanic/messages/messages.cpp')
-rw-r--r-- | engines/titanic/messages/messages.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/engines/titanic/messages/messages.cpp b/engines/titanic/messages/messages.cpp index 1c3d406b1b..9f46fef6ca 100644 --- a/engines/titanic/messages/messages.cpp +++ b/engines/titanic/messages/messages.cpp @@ -23,6 +23,7 @@ #include "titanic/messages/messages.h" #include "titanic/messages/mouse_messages.h" #include "titanic/core/game_object.h" +#include "titanic/core/message_target.h" #include "titanic/core/tree_item.h" #include "titanic/titanic.h" @@ -79,6 +80,33 @@ bool CMessage::execute(const CString &target, const ClassDef *classDef, int flag return false; } +const MSGMAP_ENTRY *CMessage::findMapEntry(const CTreeItem *treeItem, const ClassDef *classDef) { + // Iterate through the class and any parent classes + for (const MSGMAP *msgMap = treeItem->getMessageMap(); msgMap->pFnGetBaseMap; + msgMap = msgMap->pFnGetBaseMap()) { + // Iterate through the map entries for this class + for (const MSGMAP_ENTRY *entry = msgMap->lpEntries; + entry->_class != nullptr; ++entry) { + // Check if the class or any of it's ancesotrs is handled by this entry + for (const ClassDef *entryDef = entry->_class; entryDef; entryDef = entryDef->_parent) { + if (entryDef == classDef) + return entry; + } + } + } + + return nullptr; +} + +bool CMessage::perform(CTreeItem *treeItem) { + const MSGMAP_ENTRY *entry = findMapEntry(treeItem, getType()); + return entry && (*treeItem.*(entry->_fn))(this); +} + +bool CMessage::supports(const CTreeItem *treeItem, ClassDef *classDef) { + return findMapEntry(treeItem, classDef) != nullptr; +} + bool CMessage::isMouseMsg() const { return dynamic_cast<const CMouseMsg *>(this) != nullptr; } |