aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/true_talk
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-07 21:54:34 -0400
committerPaul Gilbert2016-07-10 16:38:46 -0400
commite85b171db811d1dac22c2411299b2ce0da7effeb (patch)
tree1855a7d10b0e614376fa82d4f84cfd379b93ff21 /engines/titanic/true_talk
parentbabdf0aa036a62e098be2e0aef7082e315afbf62 (diff)
downloadscummvm-rg350-e85b171db811d1dac22c2411299b2ce0da7effeb.tar.gz
scummvm-rg350-e85b171db811d1dac22c2411299b2ce0da7effeb.tar.bz2
scummvm-rg350-e85b171db811d1dac22c2411299b2ce0da7effeb.zip
TITANIC: Adding CTrueTalkManager support methods
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp36
-rw-r--r--engines/titanic/true_talk/true_talk_manager.h15
-rw-r--r--engines/titanic/true_talk/tt_talker.h6
3 files changed, 50 insertions, 7 deletions
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);
};