aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/true_talk
diff options
context:
space:
mode:
authorPaul Gilbert2016-05-05 20:28:32 -0400
committerPaul Gilbert2016-07-10 16:38:30 -0400
commit03a8cbaf98fb44dcd4c915f4d8577adaef6b0d7a (patch)
treefae6d79e406b5b972e45d1b6d1c7c3cb8d1f802b /engines/titanic/true_talk
parentb1290d6dd93f2f442bb9649685a9fa713b14821d (diff)
downloadscummvm-rg350-03a8cbaf98fb44dcd4c915f4d8577adaef6b0d7a.tar.gz
scummvm-rg350-03a8cbaf98fb44dcd4c915f4d8577adaef6b0d7a.tar.bz2
scummvm-rg350-03a8cbaf98fb44dcd4c915f4d8577adaef6b0d7a.zip
TITANIC: Implemented TT manager loadAssets, beginnings of CDialogueFile
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r--engines/titanic/true_talk/dialogue_file.cpp51
-rw-r--r--engines/titanic/true_talk/dialogue_file.h55
-rw-r--r--engines/titanic/true_talk/true_talk_manager.cpp37
-rw-r--r--engines/titanic/true_talk/true_talk_manager.h19
4 files changed, 151 insertions, 11 deletions
diff --git a/engines/titanic/true_talk/dialogue_file.cpp b/engines/titanic/true_talk/dialogue_file.cpp
new file mode 100644
index 0000000000..341d973f36
--- /dev/null
+++ b/engines/titanic/true_talk/dialogue_file.cpp
@@ -0,0 +1,51 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "titanic/true_talk/dialogue_file.h"
+
+namespace Titanic {
+
+CDialogueFile::CDialogueFile(const CString &filename, uint count) {
+ if (!_file.open(filename))
+ error("Could not locate dialogue file - %s", filename.c_str());
+
+ _data1.resize(count);
+
+ _file.readUint32LE(); // Skip over file Id
+ _entries.resize(_file.readUint32LE());
+
+ // Read in the entries
+ for (uint idx = 0; idx < _entries.size(); ++idx) {
+ _entries[idx].v1 = _file.readUint32LE();
+ _entries[idx].v2 = _file.readUint32LE();
+ }
+}
+
+CDialogueFile::~CDialogueFile() {
+ clear();
+}
+
+void CDialogueFile::clear() {
+ _file.close();
+}
+
+} // End of namespace Titanic
diff --git a/engines/titanic/true_talk/dialogue_file.h b/engines/titanic/true_talk/dialogue_file.h
new file mode 100644
index 0000000000..00bacacbd2
--- /dev/null
+++ b/engines/titanic/true_talk/dialogue_file.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef TITANIC_DIALOGUE_FILE_H
+#define TITANIC_DIALOGUE_FILE_H
+
+#include "common/file.h"
+#include "titanic/support/string.h"
+
+namespace Titanic {
+
+class CDialogueFile {
+ struct CDialogueFileEntry {
+ uint v1;
+ uint v2;
+ };
+ struct EntryRec {
+ uint v1, v2, v3, v4, v5;
+ };
+private:
+ Common::File _file;
+ Common::Array<CDialogueFileEntry> _entries;
+ Common::Array<EntryRec> _data1;
+public:
+ CDialogueFile(const CString &filename, uint count);
+ ~CDialogueFile();
+
+ /**
+ * Clear the loaded data
+ */
+ void clear();
+};
+
+} // End of namespace Titanic
+
+#endif /* TITANIC_TITLE_ENGINE_H */
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp
index 6abce89148..2e43266b65 100644
--- a/engines/titanic/true_talk/true_talk_manager.cpp
+++ b/engines/titanic/true_talk/true_talk_manager.cpp
@@ -42,7 +42,12 @@ bool CTrueTalkManager::_v10;
int CTrueTalkManager::_v11[41];
CTrueTalkManager::CTrueTalkManager(CGameManager *owner) :
- _gameManager(owner), _scripts(&_titleEngine), _currentCharId(0) {
+ _gameManager(owner), _scripts(&_titleEngine), _currentCharId(0),
+ _dialogueFile(nullptr), _field14(0) {
+}
+
+CTrueTalkManager::~CTrueTalkManager() {
+ clear();
}
void CTrueTalkManager::save(SimpleFile *file) const {
@@ -127,6 +132,12 @@ void CTrueTalkManager::saveStatics(SimpleFile *file) {
file->writeNumber(_v11[idx]);
}
+void CTrueTalkManager::clear() {
+ delete _dialogueFile;
+ _dialogueFile = nullptr;
+ _currentCharId = 0;
+}
+
void CTrueTalkManager::setFlags(int index, int val) {
switch (index) {
case 1:
@@ -181,10 +192,6 @@ void CTrueTalkManager::preLoad() {
warning("TODO: CTrueTalkManager::preLoad");
}
-void CTrueTalkManager::viewChange() {
- warning("CTrueTalkManager::viewChange");
-}
-
void CTrueTalkManager::update1() {
//warning("CTrueTalkManager::update1");
}
@@ -194,7 +201,7 @@ void CTrueTalkManager::update2() {
}
void CTrueTalkManager::start(CTrueTalkNPC *npc, int val2, int val3) {
- warning("CTrueTalkManager::fn1");
+
}
TTNamedScript *CTrueTalkManager::getTalker(const CString &name) const {
@@ -249,4 +256,22 @@ TTRoomScript *CTrueTalkManager::getRoomScript() const {
return script;
}
+void CTrueTalkManager::loadAssets(CTrueTalkNPC *npc, int charId) {
+ // If assets for the character are already loaded, simply exit
+ if (_currentCharId == charId)
+ return;
+
+ // Clear any previously loaded data
+ clear();
+
+ // Signal the NPC to get the asset details
+ CTrueTalkGetAssetDetailsMsg detailsMsg;
+ detailsMsg.execute(npc);
+
+ if (!detailsMsg._filename.empty()) {
+ _dialogueFile = new CDialogueFile(detailsMsg._filename, 20);
+ _field14 = detailsMsg._numValue + 1;
+ }
+}
+
} // 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 5507cf2a4c..a7258c587f 100644
--- a/engines/titanic/true_talk/true_talk_manager.h
+++ b/engines/titanic/true_talk/true_talk_manager.h
@@ -24,6 +24,7 @@
#define TITANIC_TRUE_TALK_MANAGER_H
#include "titanic/support/simple_file.h"
+#include "titanic/true_talk/dialogue_file.h"
#include "titanic/true_talk/title_engine.h"
#include "titanic/true_talk/tt_scripts.h"
@@ -39,6 +40,8 @@ private:
CTitleEngine _titleEngine;
TTScripts _scripts;
int _currentCharId;
+ CDialogueFile *_dialogueFile;
+ int _field14;
private:
/**
* Loads the statics for the class
@@ -69,6 +72,11 @@ private:
* Gets the script associated with the current room
*/
TTRoomScript *getRoomScript() const;
+
+ /**
+ * Loads assets for the current character, if it's changed
+ */
+ void loadAssets(CTrueTalkNPC *npc, int charId);
public:
static int _v1;
static int _v2;
@@ -85,6 +93,7 @@ public:
static void setFlags(int index, int val);
public:
CTrueTalkManager(CGameManager *owner);
+ ~CTrueTalkManager();
/**
* Save the data for the class to file
@@ -97,6 +106,11 @@ public:
void load(SimpleFile *file);
/**
+ * Clear the manager
+ */
+ void clear();
+
+ /**
* Called when a game is about to be loaded
*/
void preLoad();
@@ -117,11 +131,6 @@ public:
void postSave() {}
/**
- * Called when the view changes
- */
- void viewChange();
-
- /**
* Returns the scripts for the manager
*/
TTScripts &getScripts() { return _scripts; }