diff options
author | Paul Gilbert | 2016-05-06 20:00:00 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:38:34 -0400 |
commit | 82299474029d0568c3de0bcbcc485ad9e14cf7dd (patch) | |
tree | e7bfb01418ac1debf20d18f479566a31d336dc45 /engines | |
parent | 2a2eaebdc294a7958260ed40d48fef25e1396355 (diff) | |
download | scummvm-rg350-82299474029d0568c3de0bcbcc485ad9e14cf7dd.tar.gz scummvm-rg350-82299474029d0568c3de0bcbcc485ad9e14cf7dd.tar.bz2 scummvm-rg350-82299474029d0568c3de0bcbcc485ad9e14cf7dd.zip |
TITANIC: In progress message handlers for CTrueTalkNPC
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/npcs/parrot.cpp | 12 | ||||
-rw-r--r-- | engines/titanic/npcs/true_talk_npc.cpp | 141 | ||||
-rw-r--r-- | engines/titanic/npcs/true_talk_npc.h | 28 |
3 files changed, 160 insertions, 21 deletions
diff --git a/engines/titanic/npcs/parrot.cpp b/engines/titanic/npcs/parrot.cpp index c350079f76..a4cfa0872b 100644 --- a/engines/titanic/npcs/parrot.cpp +++ b/engines/titanic/npcs/parrot.cpp @@ -88,15 +88,15 @@ CParrot::CParrot() : CTrueTalkNPC() { _field1E8 = 0; _field1EC = 30; - _string1 = "z454.dlg"; - _fieldD4 = 0x13880; + _assetName = "z454.dlg"; + _assetNumber = 0x13880; } void CParrot::save(SimpleFile *file, int indent) const { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldD4, indent); + file->writeNumberLine(_assetNumber, indent); - file->writeQuotedLine(_string1, indent); + file->writeQuotedLine(_assetName, indent); file->writeNumberLine(_field108, indent); file->writeNumberLine(_v1, indent); file->writeNumberLine(_v2, indent); @@ -118,9 +118,9 @@ void CParrot::save(SimpleFile *file, int indent) const { void CParrot::load(SimpleFile *file) { file->readNumber(); - _fieldD4 = file->readNumber(); + _assetNumber = file->readNumber(); - _string1 = file->readString(); + _assetName = file->readString(); _field108 = file->readNumber(); _v1 = file->readNumber(); _v2 = file->readNumber(); diff --git a/engines/titanic/npcs/true_talk_npc.cpp b/engines/titanic/npcs/true_talk_npc.cpp index 924ea5657c..72b3cf2537 100644 --- a/engines/titanic/npcs/true_talk_npc.cpp +++ b/engines/titanic/npcs/true_talk_npc.cpp @@ -21,25 +21,39 @@ */ #include "titanic/npcs/true_talk_npc.h" +#include "titanic/core/view_item.h" +#include "titanic/titanic.h" namespace Titanic { -CTrueTalkNPC::CTrueTalkNPC() : _string1("z451.dlg"), - _fieldD4(0x11170), _fieldE4(0), _fieldE8(0), _fieldEC(0), _fieldF0(0), - _fieldF4(0), _fieldF8(0), _fieldFC(0), _field100(0), _field104(0) { +BEGIN_MESSAGE_MAP(CTrueTalkNPC, CCharacter) + ON_MESSAGE(TextInputMsg) + ON_MESSAGE(TrueTalkGetAssetDetailsMsg) + ON_MESSAGE(DismissBotMsg) + ON_MESSAGE(TrueTalkNotifySpeechStartedMsg) + ON_MESSAGE(TrueTalkNotifySpeechEndedMsg) + ON_MESSAGE(MovieEndMsg) + ON_MESSAGE(NPCQueueIdleAnimMsg) + ON_MESSAGE(TimerMsg) + ON_MESSAGE(NPCPlayAnimationMsg) +END_MESSAGE_MAP() + +CTrueTalkNPC::CTrueTalkNPC() : _assetName("z451.dlg"), + _assetNumber(0x11170), _fieldE4(0), _npcFlags(0), _fieldEC(0), _fieldF0(0), + _fieldF4(0), _fieldF8(0), _speechTimerId(0), _field100(0), _field104(0) { } void CTrueTalkNPC::save(SimpleFile *file, int indent) const { file->writeNumberLine(1, indent); - file->writeNumberLine(_fieldD4, indent); - file->writeQuotedLine(_string1, indent); + file->writeNumberLine(_assetNumber, indent); + file->writeQuotedLine(_assetName, indent); file->writeNumberLine(_fieldE4, indent); - file->writeNumberLine(_fieldE8, indent); + file->writeNumberLine(_npcFlags, indent); file->writeNumberLine(_fieldEC, indent); file->writeNumberLine(_fieldF0, indent); file->writeNumberLine(_fieldF4, indent); file->writeNumberLine(_fieldF8, indent); - file->writeNumberLine(_fieldFC, indent); + file->writeNumberLine(_speechTimerId, indent); file->writeNumberLine(_field100, indent); file->writeNumberLine(_field104, indent); @@ -48,19 +62,124 @@ void CTrueTalkNPC::save(SimpleFile *file, int indent) const { void CTrueTalkNPC::load(SimpleFile *file) { file->readNumber(); - _fieldD4 = file->readNumber(); - _string1 = file->readString(); + _assetNumber = file->readNumber(); + _assetName = file->readString(); _fieldE4 = file->readNumber(); - _fieldE8 = file->readNumber(); + _npcFlags = file->readNumber(); _fieldEC = file->readNumber(); _fieldF0 = file->readNumber(); _fieldF4 = file->readNumber(); _fieldF8 = file->readNumber(); - _fieldFC = file->readNumber(); + _speechTimerId = file->readNumber(); _field100 = file->readNumber(); _field104 = file->readNumber(); CCharacter::load(file); } +bool CTrueTalkNPC::TextInputMsg(CTextInputMsg *msg) { + processInput(msg, _field104 ? findView() : nullptr); + return true; +} + +bool CTrueTalkNPC::TrueTalkGetAssetDetailsMsg(CTrueTalkGetAssetDetailsMsg *msg) { + msg->_filename = _assetName; + msg->_numValue = _assetNumber; + return true; +} + +bool CTrueTalkNPC::DismissBotMsg(CDismissBotMsg *msg) { + performAction(1, 0); + return true; +} + +bool CTrueTalkNPC::TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg) { + _npcFlags |= NPCFLAG_SPEAKING; + ++_field100; + + if (!(_npcFlags & NPCFLAG_8)) { + if (_speechTimerId) + stopTimer(_speechTimerId); + + _fieldEC = msg->_value1; + _fieldF0 = g_vm->_events->getTicksCount(); + + if (hasActiveMovie() || (_npcFlags & NPCFLAG_2)) { + _npcFlags &= ~NPCFLAG_2; + stopMovie(); + + CNPCPlayTalkingAnimationMsg msg1(_fieldEC, 0, 0); + msg1.execute(this); + + if (msg1._value3) { + CNPCPlayAnimationMsg msg2(msg1._value3, msg1._value1); + msg2.execute(this); + } + } + } + + return true; +} + +bool CTrueTalkNPC::TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg) { + _npcFlags &= ~NPCFLAG_SPEAKING; + --_field100; + _fieldEC = 0; + + if (!(_npcFlags & NPCFLAG_8)) { + CNPCPlayTalkingAnimationMsg msg1(0, 2, 0); + msg1.execute(this); + CNPCQueueIdleAnimMsg msg2; + msg2.execute(this); + } + + return true; +} + +bool CTrueTalkNPC::MovieEndMsg(CMovieEndMsg *msg) { + if (_npcFlags & NPCFLAG_2) { + _npcFlags &= ~NPCFLAG_2; + CNPCQueueIdleAnimMsg idleMsg; + idleMsg.execute(this); + return true; + } else if (!(_npcFlags & NPCFLAG_SPEAKING)) { + return false; + } + + int diff = g_vm->_events->getTicksCount() - _fieldF0; + int ticks = MAX((int)_fieldEC - diff, 0); + CNPCPlayTalkingAnimationMsg msg1(ticks, ticks > 1000 ? 2 : 1, 0); + msg1.execute(this); + + if (msg1._value3) { + CNPCPlayAnimationMsg msg2(msg1._value3, msg1._value1); + msg2.execute(this); + } + + return true; +} + +bool CTrueTalkNPC::NPCQueueIdleAnimMsg(CNPCQueueIdleAnimMsg *msg) { + // TODO + return false; +} + +bool CTrueTalkNPC::TimerMsg(CTimerMsg *msg) { + // TODO + return false; +} + +bool CTrueTalkNPC::NPCPlayAnimationMsg(CNPCPlayAnimationMsg *msg) { + // TODO + return false; +} + +void CTrueTalkNPC::processInput(CTextInputMsg *msg, CViewItem *view) { + // TODO +} + +void CTrueTalkNPC::performAction(int val1, int val2) { + // TODO +} + } // End of namespace Titanic diff --git a/engines/titanic/npcs/true_talk_npc.h b/engines/titanic/npcs/true_talk_npc.h index 9546f18e0c..74bf044a57 100644 --- a/engines/titanic/npcs/true_talk_npc.h +++ b/engines/titanic/npcs/true_talk_npc.h @@ -24,22 +24,42 @@ #define TITANIC_TRUE_TALK_NPC_H #include "titanic/npcs/character.h" +#include "titanic/messages/messages.h" namespace Titanic { +enum NpcFlag { + NPCFLAG_SPEAKING = 1, NPCFLAG_2 = 2, NPCFLAG_4 = 4, NPCFLAG_8 = 8 +}; + +class CViewItem; + class CTrueTalkNPC : public CCharacter { + DECLARE_MESSAGE_MAP + bool TextInputMsg(CTextInputMsg *msg); + bool TrueTalkGetAssetDetailsMsg(CTrueTalkGetAssetDetailsMsg *msg); + bool DismissBotMsg(CDismissBotMsg *msg); + bool TrueTalkNotifySpeechStartedMsg(CTrueTalkNotifySpeechStartedMsg *msg); + bool TrueTalkNotifySpeechEndedMsg(CTrueTalkNotifySpeechEndedMsg *msg); + bool MovieEndMsg(CMovieEndMsg *msg); + bool NPCQueueIdleAnimMsg(CNPCQueueIdleAnimMsg *msg); + bool TimerMsg(CTimerMsg *msg); + bool NPCPlayAnimationMsg(CNPCPlayAnimationMsg *msg); protected: - int _fieldD4; - CString _string1; + int _assetNumber; + CString _assetName; int _fieldE4; - int _fieldE8; + uint _npcFlags; int _fieldEC; int _fieldF0; int _fieldF4; int _fieldF8; - int _fieldFC; + int _speechTimerId; int _field100; int _field104; +protected: + void processInput(CTextInputMsg *msg, CViewItem *view); + void performAction(int val1, int val2); public: CLASSDEF CTrueTalkNPC(); |