diff options
Diffstat (limited to 'engines/titanic')
-rw-r--r-- | engines/titanic/core/saveable_object.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/game/arboretum_gate.h | 19 | ||||
-rw-r--r-- | engines/titanic/game_manager.cpp | 6 | ||||
-rw-r--r-- | engines/titanic/messages/messages.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/messages/messages.h | 93 | ||||
-rw-r--r-- | engines/titanic/messages/mouse_messages.h | 48 |
6 files changed, 153 insertions, 17 deletions
diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp index 7ec4f949f2..8e3ab1e067 100644 --- a/engines/titanic/core/saveable_object.cpp +++ b/engines/titanic/core/saveable_object.cpp @@ -796,6 +796,7 @@ DEFFN(CIsParrotPresentMsg) DEFFN(CKeyCharMsg) DEFFN(CLemonFallsFromTreeMsg) DEFFN(CLightsMsg) +DEFFN(CLoadSuccessMsg) DEFFN(CLockPhonographMsg) DEFFN(CMaitreDDefeatedMsg) DEFFN(CMaitreDHappyMsg) @@ -1360,6 +1361,7 @@ void CSaveableObject::initClassList() { ADDFN(CKeyCharMsg, CMessage); ADDFN(CLemonFallsFromTreeMsg, CMessage); ADDFN(CLightsMsg, CMessage); + ADDFN(CLoadSuccessMsg, CMessage); ADDFN(CLockPhonographMsg, CMessage); ADDFN(CMaitreDDefeatedMsg, CMessage); ADDFN(CMaitreDHappyMsg, CMessage); diff --git a/engines/titanic/game/arboretum_gate.h b/engines/titanic/game/arboretum_gate.h index eb82333f8f..2c2b81feab 100644 --- a/engines/titanic/game/arboretum_gate.h +++ b/engines/titanic/game/arboretum_gate.h @@ -24,15 +24,20 @@ #define TITANIC_ARBORETUM_GATE_H #include "titanic/core/background.h" +#include "titanic/messages/messages.h" +#include "titanic/messages/mouse_messages.h" namespace Titanic { -class CArboretumGate : public CBackground { -public: +class CArboretumGate : public CBackground, public CActMsgTarget, + public CLeaveViewMsgTarget, public CTurnOffTarget, + public CMouseButtonDownMsgTarget, public CEnterViewMsgTarget, + public CTurnOnTarget, public CMovieEndMsgTarget { +private: static int _v1; static int _v2; static int _v3; -public: +private: int _fieldE0; CString _string1; int _fieldE8; @@ -63,6 +68,14 @@ public: int _field14C; int _field150; CString _string2; +protected: + virtual bool handleEvent(const CActMsg &msg) { return false; } + virtual bool handleEvent(const CLeaveViewMsg &msg) { return false; } + virtual bool handleEvent(const CTurnOff &msg) { return false; } + virtual bool handleEvent(const CMouseButtonDownMsg &msg) { return false; } + virtual bool handleEvent(const CEnterViewMsg &msg) { return false; } + virtual bool handleEvent(const CTurnOn &msg) { return false; } + virtual bool handleEvent(const CMovieEndMsg &msg) { return false; } public: CLASSDEF CArboretumGate(); diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index 5e6496218f..6c9d5e1695 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -21,6 +21,7 @@ */ #include "titanic/game_manager.h" +#include "titanic/messages/messages.h" #include "titanic/screen_manager.h" namespace Titanic { @@ -36,6 +37,9 @@ void CGameManager::load(SimpleFile *file) { void CGameManager::gameLoaded() { // TODO + + //CLoadSuccessMsg msg(0); + } -} // End of namespace Titanic +} // End of namespace Titanic z diff --git a/engines/titanic/messages/messages.cpp b/engines/titanic/messages/messages.cpp index f9648f9dfb..1f7a5a07d4 100644 --- a/engines/titanic/messages/messages.cpp +++ b/engines/titanic/messages/messages.cpp @@ -51,7 +51,7 @@ bool CMessage::execute(CTreeItem *target, const ClassDef *classDef, int flags) { nextItem = item->scan(target); if (!(flags & MSGFLAG_CLASS_DEF) || item->isInstanceOf(*classDef)) { - bool handled = true; // item->handleEvent(this); + bool handled = perform(item); if (handled) { result = true; diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index e369157f1d..1908b7351c 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -34,6 +34,9 @@ enum MessageFlag { MSGFLAG_CLASS_DEF = 4 }; +#define MSGTARGET(NAME) class NAME; class NAME##Target { public: \ + virtual bool handleEvent(const NAME &msg) = 0; } + class CMessage : public CSaveableObject { public: CLASSDEF @@ -41,6 +44,8 @@ public: bool execute(CTreeItem *target, const ClassDef *classDef, int flags); + virtual bool perform(CTreeItem *treeItem) { return false; } + /** * Save the data for the class to file */ @@ -52,8 +57,11 @@ public: virtual void load(SimpleFile *file); }; +MSGTARGET(CEditControlMsg); class CEditControlMsg : public CMessage { -private: +protected: + virtual bool handleMessage(CEditControlMsg &msg) { return false; } +public: int _field4; int _field8; CString _string1; @@ -64,9 +72,17 @@ public: CLASSDEF CEditControlMsg() : _field4(0), _field8(0), _field18(0), _field1C(0), _field20(0) {} + + virtual bool perform(CTreeItem *treeItem) { + CEditControlMsg *dest = dynamic_cast<CEditControlMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; +MSGTARGET(CLightsMsg); class CLightsMsg : public CMessage { +protected: + virtual bool handleMessage(CLightsMsg &msg) { return false; } public: int _field4; int _field8; @@ -76,10 +92,18 @@ public: CLASSDEF CLightsMsg() : CMessage(), _field4(0), _field8(0), _fieldC(0), _field10(0) {} + + virtual bool perform(CTreeItem *treeItem) { + CLightsMsg *dest = dynamic_cast<CLightsMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; +MSGTARGET(CIsHookedOnMsg); class CIsHookedOnMsg : public CMessage { -private: +protected: + virtual bool handleMessage(CIsHookedOnMsg &msg) { return false; } +public: int _field4; int _field8; CString _string1; @@ -90,59 +114,100 @@ public: CLASSDEF CIsHookedOnMsg() : CMessage(), _field4(0), _field8(0), _field18(0), _field1C(0), _field20(0) {} + + virtual bool perform(CTreeItem *treeItem) { + CIsHookedOnMsg *dest = dynamic_cast<CIsHookedOnMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; +MSGTARGET(CSubAcceptCCarryMsg); class CSubAcceptCCarryMsg : public CMessage { +protected: + virtual bool handleMessage(CSubAcceptCCarryMsg &msg) { return false; } public: CString _string1; int _value1, _value2, _value3; public: CLASSDEF CSubAcceptCCarryMsg() : _value1(0), _value2(0), _value3(0) {} + + virtual bool perform(CTreeItem *treeItem) { + CSubAcceptCCarryMsg *dest = dynamic_cast<CSubAcceptCCarryMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; +MSGTARGET(CTransportMsg); class CTransportMsg : public CMessage { +protected: + virtual bool handleMessage(CTransportMsg &msg) { return false; } public: CString _string; int _value1, _value2; public: CLASSDEF CTransportMsg() : _value1(0), _value2(0) {} + + virtual bool perform(CTreeItem *treeItem) { + CTransportMsg *dest = dynamic_cast<CTransportMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; -#define MESSAGE0(NAME) \ +#define MESSAGE0(NAME) MSGTARGET(NAME); \ class NAME: public CMessage { \ public: NAME() : CMessage() {} \ CLASSDEF \ - } -#define MESSAGE1(NAME, F1, N1, V1) \ + virtual bool handleMessage(NAME &msg) { return false; } \ + virtual bool perform(CTreeItem *treeItem) { \ + NAME *dest = dynamic_cast<NAME *>(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 \ - } -#define MESSAGE2(NAME, F1, N1, V1, F2, N2, V2) \ + virtual bool handleMessage(NAME &msg) { return false; } \ + virtual bool perform(CTreeItem *treeItem) { \ + NAME *dest = dynamic_cast<NAME *>(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 \ - } -#define MESSAGE3(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3) \ + virtual bool handleMessage(NAME &msg) { return false; } \ + virtual bool perform(CTreeItem *treeItem) { \ + NAME *dest = dynamic_cast<NAME *>(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 \ - } -#define MESSAGE4(NAME, F1, N1, V1, F2, N2, V2, F3, N3, V3, F4, N4, V4) \ + virtual bool handleMessage(NAME &msg) { return false; } \ + virtual bool perform(CTreeItem *treeItem) { \ + NAME *dest = dynamic_cast<NAME *>(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 \ - } + virtual bool handleMessage(NAME &msg) { return false; } \ + virtual bool perform(CTreeItem *treeItem) { \ + NAME *dest = dynamic_cast<NAME *>(treeItem); \ + return dest != nullptr && dest->handleMessage(*this); \ + } } MESSAGE1(CActMsg, CString, value, ""); MESSAGE1(CActivationmsg, CString, value, ""); @@ -175,6 +240,8 @@ MESSAGE1(CDropobjectMsg, int, value, 0); MESSAGE1(CDropZoneGotObjectMsg, int, value, 0); MESSAGE1(CDropZoneLostObjectMsg, int, value, 0); MESSAGE1(CEjectCylinderMsg, int, value, 0); +MESSAGE0(CEnterNodeMsg); +MESSAGE0(CEnterViewMsg); MESSAGE0(CErasePhonographCylinderMsg); MESSAGE2(CFreshenCookieMsg, int, value1, 0, int, value2, 0); MESSAGE1(CGetChevClassBits, int, value, 0); @@ -191,7 +258,9 @@ MESSAGE0(CInitializeAnimMsg); MESSAGE1(CIsEarBowlPuzzleDone, int, value, 0); MESSAGE1(CIsParrotPresentMsg, int, value, 0); MESSAGE1(CKeyCharMsg, int, value, 32); +MESSAGE0(CLeaveViewMsg); MESSAGE2(CLemonFallsFromTreeMsg, int, value1, 0, int, value2, 0); +MESSAGE1(CLoadSuccessMsg, int, ticks, 0); MESSAGE1(CLockPhonographMsg, int, value, 0); MESSAGE0(CMaitreDDefeatedMsg); MESSAGE0(CMaitreDHappyMsg); diff --git a/engines/titanic/messages/mouse_messages.h b/engines/titanic/messages/mouse_messages.h index d3a0566f3d..79c45afcfa 100644 --- a/engines/titanic/messages/mouse_messages.h +++ b/engines/titanic/messages/mouse_messages.h @@ -36,9 +36,16 @@ public: CMouseMsg() : _buttons(0) {} }; +MSGTARGET(CMouseMoveMsg); class CMouseMoveMsg : public CMouseMsg { public: CLASSDEF + + virtual bool handleMessage(CMouseMoveMsg &msg) { return false; } + virtual bool perform(CTreeItem *treeItem) { + CMouseMoveMsg *dest = dynamic_cast<CMouseMoveMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; class CMouseButtonMsg : public CMouseMsg { @@ -49,19 +56,40 @@ public: CMouseButtonMsg() : CMouseMsg(), _field10(0) {} }; +MSGTARGET(CMouseButtonDownMsg); class CMouseButtonDownMsg : public CMouseButtonMsg { public: CLASSDEF + + virtual bool handleMessage(CMouseButtonDownMsg &msg) { return false; } + virtual bool perform(CTreeItem *treeItem) { + CMouseButtonDownMsg *dest = dynamic_cast<CMouseButtonDownMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; +MSGTARGET(CMouseButtonUpMsg); class CMouseButtonUpMsg : public CMouseButtonMsg { public: CLASSDEF + + virtual bool handleMessage(CMouseButtonUpMsg &msg) { return false; } + virtual bool perform(CTreeItem *treeItem) { + CMouseButtonUpMsg *dest = dynamic_cast<CMouseButtonUpMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; +MSGTARGET(CMouseButtonDoubleClickMsg); class CMouseButtonDoubleClickMsg : public CMouseButtonMsg { public: CLASSDEF + + virtual bool handleMessage(CMouseButtonDoubleClickMsg &msg) { return false; } + virtual bool perform(CTreeItem *treeItem) { + CMouseButtonDoubleClickMsg *dest = dynamic_cast<CMouseButtonDoubleClickMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; class CMouseDragMsg : public CMouseMsg { @@ -72,8 +100,15 @@ public: class CMouseDragMoveMsg : public CMouseDragMsg { public: CLASSDEF + + virtual bool handleMessage(CMouseDragMoveMsg &msg) { return false; } + virtual bool perform(CTreeItem *treeItem) { + CMouseDragMoveMsg *dest = dynamic_cast<CMouseDragMoveMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; +MSGTARGET(CMouseDragStartMsg); class CMouseDragStartMsg : public CMouseDragMsg { public: int _field10; @@ -81,14 +116,27 @@ public: public: CLASSDEF CMouseDragStartMsg() : CMouseDragMsg(), _field10(0), _field14(0) {} + + virtual bool handleMessage(CMouseDragStartMsg &msg) { return false; } + virtual bool perform(CTreeItem *treeItem) { + CMouseDragStartMsg *dest = dynamic_cast<CMouseDragStartMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; +MSGTARGET(CMouseDragEndMsg); class CMouseDragEndMsg : public CMouseDragMsg { public: int _field10; public: CLASSDEF CMouseDragEndMsg() : CMouseDragMsg(), _field10(0) {} + + virtual bool handleMessage(CMouseDragEndMsg &msg) { return false; } + virtual bool perform(CTreeItem *treeItem) { + CMouseDragEndMsg *dest = dynamic_cast<CMouseDragEndMsg *>(treeItem); + return dest != nullptr && dest->handleMessage(*this); + } }; } // End of namespace Titanic |