diff options
author | Paul Gilbert | 2016-05-07 21:54:34 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:38:46 -0400 |
commit | e85b171db811d1dac22c2411299b2ce0da7effeb (patch) | |
tree | 1855a7d10b0e614376fa82d4f84cfd379b93ff21 /engines | |
parent | babdf0aa036a62e098be2e0aef7082e315afbf62 (diff) | |
download | scummvm-rg350-e85b171db811d1dac22c2411299b2ce0da7effeb.tar.gz scummvm-rg350-e85b171db811d1dac22c2411299b2ce0da7effeb.tar.bz2 scummvm-rg350-e85b171db811d1dac22c2411299b2ce0da7effeb.zip |
TITANIC: Adding CTrueTalkManager support methods
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/game_manager.cpp | 3 | ||||
-rw-r--r-- | engines/titanic/messages/messages.h | 4 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.cpp | 36 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.h | 15 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_talker.h | 6 |
5 files changed, 54 insertions, 10 deletions
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index bfd6984a73..1ce9436685 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -100,6 +100,7 @@ void CGameManager::preSave(CProjectItem *project) { void CGameManager::postSave() { _timers.postSave(); _trueTalkManager.postSave(); + _sound.postSave(); } void CGameManager::initBounds() { @@ -118,7 +119,7 @@ void CGameManager::update() { updateMovies(); frameMessage(getRoom()); _timers.update(g_vm->_events->getTicksCount()); - _trueTalkManager.update1(); + _trueTalkManager.removeCompleted(); _trueTalkManager.update2(); CScreenManager::_screenManagerPtr->_mouseCursor->update(); diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index ad5c4bc485..f592434152 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -343,12 +343,12 @@ MESSAGE1(CTriggerAutoMusicPlayerMsg, int, value, 0); MESSAGE1(CTriggerNPCEvent, int, value, 0); MESSAGE4(CTrueTalkGetAnimSetMsg, int, value1, 0, uint, index, 0, uint, startFrame, 0, uint, endFrame, 0); MESSAGE2(CTrueTalkGetAssetDetailsMsg, CString, filename, "", int, numValue, 0); -MESSAGE2(CTrueTalkGetStateValueMsg, int, value1, 0, int, value2, -1000); +MESSAGE2(CTrueTalkGetStateValueMsg, int, stateNum, 0, int, stateVal, -1000); MESSAGE2(CTrueTalkNotifySpeechEndedMsg, int, value1, 0, int, value2, 0); MESSAGE3(CTrueTalkNotifySpeechStartedMsg, uint, soundId, 0, uint, dialogueId, 0, int, value, 0); MESSAGE1(CTrueTalkQueueUpAnimSetMsg, int, value, 0); MESSAGE0(CTrueTalkSelfQueueAnimSetMsg); -MESSAGE3(CTrueTalkTriggerActionMsg, int, value1, 0, int, value2, 0, int, value3, 0); +MESSAGE3(CTrueTalkTriggerActionMsg, int, action, 0, int, param1, 0, int, param2, 0); MESSAGE0(CTurnOff); MESSAGE0(CTurnOn); MESSAGE1(CUse, CCarry *, item, nullptr); diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp index fefa2fa824..2bbac3b0f8 100644 --- a/engines/titanic/true_talk/true_talk_manager.cpp +++ b/engines/titanic/true_talk/true_talk_manager.cpp @@ -192,11 +192,23 @@ void CTrueTalkManager::saveNPC(SimpleFile *file, int charId) const { } void CTrueTalkManager::preLoad() { - warning("TODO: CTrueTalkManager::preLoad"); + // Delete any previous talkers + for (TTTalkerList::iterator i = _talkers.begin(); i != _talkers.end(); ++i) + delete *i; + _talkers.clear(); } -void CTrueTalkManager::update1() { - //warning("CTrueTalkManager::update1"); +void CTrueTalkManager::removeCompleted() { + for (TTTalkerList::iterator i = _talkers.begin(); i != _talkers.end(); ) { + TTTalker *talker = *i; + + if (talker->_done) { + i = _talkers.erase(i); + delete talker; + } else { + ++i; + } + } } void CTrueTalkManager::update2() { @@ -412,4 +424,22 @@ void CTrueTalkManager::setTalker(TTTalker *talker, TTRoomScript *roomScript, CVi warning("TODO: CTrueTalkManager::setTalker"); } +int CTrueTalkManager::getStateVal(int stateNum) { + if (!_currentNPC) + return -1000; + + CTrueTalkGetStateValueMsg msg(stateNum, -1000); + msg.execute(_currentNPC); + return msg._stateVal; +} + +bool CTrueTalkManager::triggerAction(int action, int param) { + if (!_currentNPC) + return false; + + CTrueTalkTriggerActionMsg msg(action, param, 0); + msg.execute(_currentNPC); + return true; +} + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/true_talk_manager.h b/engines/titanic/true_talk/true_talk_manager.h index 1f6bf1641d..a7933be47f 100644 --- a/engines/titanic/true_talk/true_talk_manager.h +++ b/engines/titanic/true_talk/true_talk_manager.h @@ -118,6 +118,16 @@ public: static void setFlags(int index, int val); public: + /** + * Get a specified state value from the currently set NPC + */ + static int getStateVal(int stateNum); + + /** + * Trigger an NPC action + */ + static bool triggerAction(int action, int param); +public: CTrueTalkManager(CGameManager *owner); ~CTrueTalkManager(); @@ -161,7 +171,10 @@ public: */ TTScripts &getScripts() { return _scripts; } - void update1(); + /** + * Remove any completed talkers + */ + void removeCompleted(); void update2(); diff --git a/engines/titanic/true_talk/tt_talker.h b/engines/titanic/true_talk/tt_talker.h index 792c84c505..622bcc67d1 100644 --- a/engines/titanic/true_talk/tt_talker.h +++ b/engines/titanic/true_talk/tt_talker.h @@ -38,12 +38,12 @@ public: CString _string1; int _dialogueId; int _field24; - int _field28; + int _done; public: TTTalker() : _owner(nullptr), _npc(nullptr), - _dialogueId(0), _field24(0), _field28(0) {} + _dialogueId(0), _field24(0), _done(0) {} TTTalker(CTrueTalkManager *owner, CTrueTalkNPC *npc) : - _owner(owner), _npc(npc), _dialogueId(0), _field24(0), _field28(0) {} + _owner(owner), _npc(npc), _dialogueId(0), _field24(0), _done(0) {} void speechStarted(const CString &dialogueStr, uint dialogueId, uint soundId); }; |