aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/true_talk
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-07 16:50:39 -0400
committerPaul Gilbert2016-07-10 16:38:42 -0400
commit339df8657e883ba62bd5c4c474ab920dfa3d19c8 (patch)
tree2265a2fe2ce116b8ea7d91f34c1a66fd8508169f /engines/titanic/true_talk
parent0692d261eeea7dd9260e00dc6bc43dda963a41d4 (diff)
downloadscummvm-rg350-339df8657e883ba62bd5c4c474ab920dfa3d19c8.tar.gz
scummvm-rg350-339df8657e883ba62bd5c4c474ab920dfa3d19c8.tar.bz2
scummvm-rg350-339df8657e883ba62bd5c4c474ab920dfa3d19c8.zip
TITANIC: Implement CTrueTalkManager triggerNPC
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r--engines/titanic/true_talk/script_handler.cpp2
-rw-r--r--engines/titanic/true_talk/script_handler.h2
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp69
-rw-r--r--engines/titanic/true_talk/true_talk_manager.h38
4 files changed, 99 insertions, 12 deletions
diff --git a/engines/titanic/true_talk/script_handler.cpp b/engines/titanic/true_talk/script_handler.cpp
index eb7979e1e5..a46a03301c 100644
--- a/engines/titanic/true_talk/script_handler.cpp
+++ b/engines/titanic/true_talk/script_handler.cpp
@@ -29,7 +29,7 @@ namespace Titanic {
CScriptHandler::CScriptHandler(CTitleEngine *owner, int val1, int val2) {
}
-void CScriptHandler::setup(TTNamedScript *npcScript, TTRoomScript *roomScript, uint charId) {
+void CScriptHandler::setup(TTRoomScript *roomScript, TTNamedScript *npcScript, uint charId) {
// TODO
}
diff --git a/engines/titanic/true_talk/script_handler.h b/engines/titanic/true_talk/script_handler.h
index 1959468ed0..8d5c78dbc3 100644
--- a/engines/titanic/true_talk/script_handler.h
+++ b/engines/titanic/true_talk/script_handler.h
@@ -40,7 +40,7 @@ public:
/**
* Set the character and room
*/
- void setup(TTNamedScript *npcScript, TTRoomScript *roomScript, uint charId);
+ void setup(TTRoomScript *roomScript, TTNamedScript *npcScript, uint charId);
void processInput(TTNamedScript *npcScript, TTRoomScript *roomScript,
const TTString &line);
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index 6552a5db5c..9e7fb773e5 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -44,7 +44,7 @@ CTrueTalkNPC *CTrueTalkManager::_currentNPC;
CTrueTalkManager::CTrueTalkManager(CGameManager *owner) :
_gameManager(owner), _scripts(&_titleEngine), _currentCharId(0),
- _dialogueFile(nullptr), _dialogueIndex(0) {
+ _dialogueFile(nullptr), _dialogueId(0) {
}
CTrueTalkManager::~CTrueTalkManager() {
@@ -210,10 +210,10 @@ void CTrueTalkManager::start(CTrueTalkNPC *npc, uint id, CViewItem *view) {
loadAssets(npc, charId);
_currentNPC = npc;
- _titleEngine._scriptHandler->setup(npcScript, roomScript, charId);
+ _titleEngine._scriptHandler->setup(roomScript, npcScript, charId);
_currentNPC = nullptr;
- setDialogue(npcScript, roomScript, view);
+ setDialogue(npc, roomScript, view);
}
TTNamedScript *CTrueTalkManager::getTalker(const CString &name) const {
@@ -282,7 +282,7 @@ void CTrueTalkManager::loadAssets(CTrueTalkNPC *npc, int charId) {
if (!detailsMsg._filename.empty()) {
_dialogueFile = new CDialogueFile(detailsMsg._filename, 20);
- _dialogueIndex = detailsMsg._numValue + 1;
+ _dialogueId = detailsMsg._numValue + 1;
}
}
@@ -298,13 +298,25 @@ void CTrueTalkManager::processInput(CTrueTalkNPC *npc, CTextInputMsg *msg, CView
_currentNPC = nullptr;
loadAssets(npc, npcScript->charId());
- setDialogue(npcScript, roomScript, view);
+ setDialogue(npc, roomScript, view);
}
_currentNPC = nullptr;
}
-void CTrueTalkManager::setDialogue(TTNamedScript *npcScript, TTRoomScript *roomScript, CViewItem *view) {
+void CTrueTalkManager::setDialogue(CTrueTalkNPC *npc, TTRoomScript *roomScript, CViewItem *view) {
+ // Get the dialog text
+ CString dialogStr = readDialogueString();
+ if (dialogStr.empty())
+ return;
+
+ TTTalker *talker = new TTTalker(this, npc);
+ _talkers.push_back(talker);
+
+ bool isParrot = npc->getName() == "parrot";
+
+
+
warning("TODO: CTrueTalkManager::setDialogue");
}
@@ -320,7 +332,7 @@ CString CTrueTalkManager::readDialogueString() {
// Open a text entry from the dialogue file for access
DialogueResource *textRes = _dialogueFile->openTextEntry(
- _titleEngine._indexes[idx] - _dialogueIndex);
+ _titleEngine._indexes[idx] - _dialogueId);
if (!textRes)
continue;
@@ -351,4 +363,47 @@ CString CTrueTalkManager::readDialogueString() {
return result;
}
+int CTrueTalkManager::readDialogSound() {
+ _field18 = 0;
+
+ for (uint idx = 0; idx < _titleEngine._indexes.size(); ++idx) {
+ CSoundItem *soundItem = _gameManager->_sound.getTrueTalkSound(
+ _dialogueFile, _titleEngine._indexes[idx] - _dialogueId);
+ if (soundItem) {
+ _field18 = soundItem->fn1();
+ }
+ }
+
+ return _field18;
+}
+
+void CTrueTalkManager::triggerNPC(CTrueTalkNPC *npc) {
+ CTrueTalkSelfQueueAnimSetMsg queueSetMsg;
+ if (queueSetMsg.execute(npc)) {
+ if (_field18 > 300) {
+ CTrueTalkQueueUpAnimSetMsg upMsg(_field18);
+ upMsg.execute(npc);
+ }
+ } else {
+ CTrueTalkGetAnimSetMsg getAnimMsg;
+ if (_field18 > 300) {
+ do {
+ getAnimMsg.execute(npc);
+ if (!getAnimMsg._endFrame)
+ break;
+
+ npc->playMovie(getAnimMsg._startFrame, getAnimMsg._endFrame, 0);
+ getAnimMsg._endFrame = 0;
+
+ uint numFrames = getAnimMsg._endFrame - getAnimMsg._startFrame;
+ int64 val = (numFrames * 1000) * 0x88888889;
+ uint diff = (val >> (32 + 5)) - 500;
+ _field18 += diff;
+
+ getAnimMsg._index++;
+ } while (_field18 > 0);
+ }
+ }
+}
+
} // 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 3843483e5a..c11c34f326 100644
--- a/engines/titanic/true_talk/true_talk_manager.h
+++ b/engines/titanic/true_talk/true_talk_manager.h
@@ -34,8 +34,28 @@ namespace Titanic {
class CGameManager;
class CTreeItem;
class CViewItem;
+class CTrueTalkManager;
class CTrueTalkNPC;
+class TTTalker : public ListItem {
+public:
+ CTrueTalkManager *_owner;
+ CTrueTalkNPC *_npc;
+ CString _string1;
+ int _field20;
+ int _field24;
+ int _field28;
+public:
+ TTTalker() : _owner(nullptr), _npc(nullptr),
+ _field20(0), _field24(0), _field28(0) {}
+ TTTalker(CTrueTalkManager *owner, CTrueTalkNPC *npc) :
+ _owner(owner), _npc(npc), _field20(0), _field24(0), _field28(0) {}
+
+};
+
+class TTTalkerList : public List<TTTalker> {
+};
+
class CTrueTalkManager {
private:
CGameManager *_gameManager;
@@ -43,7 +63,9 @@ private:
TTScripts _scripts;
int _currentCharId;
CDialogueFile *_dialogueFile;
- int _dialogueIndex;
+ int _dialogueId;
+ int _field18;
+ TTTalkerList _talkers;
private:
/**
* Loads the statics for the class
@@ -80,12 +102,22 @@ private:
*/
void loadAssets(CTrueTalkNPC *npc, int charId);
- void setDialogue(TTNamedScript *npcScript, TTRoomScript *roomScript, CViewItem *view);
+ void setDialogue(CTrueTalkNPC *npc, TTRoomScript *roomScript, CViewItem *view);
/**
- * Read in a string from the resource
+ * Read in text from the dialogue file
*/
CString readDialogueString();
+
+ /**
+ * Read in the sound from the dialogue file
+ */
+ int readDialogSound();
+
+ /**
+ * Triggers animation for the NPC
+ */
+ void triggerNPC(CTrueTalkNPC *npc);
public:
static int _v1;
static int _v2;