diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/titanic/game_manager.cpp | 2 | ||||
-rw-r--r-- | engines/titanic/messages/messages.h | 2 | ||||
-rw-r--r-- | engines/titanic/module.mk | 1 | ||||
-rw-r--r-- | engines/titanic/true_talk/dialogue_file.cpp | 51 | ||||
-rw-r--r-- | engines/titanic/true_talk/dialogue_file.h | 55 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.cpp | 37 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.h | 19 |
7 files changed, 154 insertions, 13 deletions
diff --git a/engines/titanic/game_manager.cpp b/engines/titanic/game_manager.cpp index 0d1714a3a6..bfd6984a73 100644 --- a/engines/titanic/game_manager.cpp +++ b/engines/titanic/game_manager.cpp @@ -199,7 +199,7 @@ void CGameManager::viewChange() { _videoSurface1 = nullptr; _videoSurface2 = CScreenManager::_screenManagerPtr->createSurface(600, 340); - _trueTalkManager.viewChange(); + _trueTalkManager.clear(); for (CTreeItem *treeItem = _project; treeItem; treeItem = treeItem->scan(_project)) treeItem->viewChange(); diff --git a/engines/titanic/messages/messages.h b/engines/titanic/messages/messages.h index b3ca1effd9..fb3169cc71 100644 --- a/engines/titanic/messages/messages.h +++ b/engines/titanic/messages/messages.h @@ -342,7 +342,7 @@ MESSAGE3(CTransportMsg, CString, roomName, "", int, value1, 0, int, value2, 0); MESSAGE1(CTriggerAutoMusicPlayerMsg, int, value, 0); MESSAGE1(CTriggerNPCEvent, int, value, 0); MESSAGE4(CTrueTalkGetAnimSetMsg, int, value1, 0, int, value2, 0, int, value3, 0, int, value4, 0); -MESSAGE2(CTrueTalkGetAssetDetailsMsg, CString, strValue, "", int, numValue, 0); +MESSAGE2(CTrueTalkGetAssetDetailsMsg, CString, filename, "", int, numValue, 0); MESSAGE2(CTrueTalkGetStateValueMsg, int, value1, 0, int, value2, -1000); MESSAGE2(CTrueTalkNotifySpeechEndedMsg, int, value1, 0, int, value2, 0); MESSAGE3(CTrueTalkNotifySpeechStartedMsg, int, value1, 0, int, value2, 0, int, value, 0); diff --git a/engines/titanic/module.mk b/engines/titanic/module.mk index a1529317fd..0f301b93ff 100644 --- a/engines/titanic/module.mk +++ b/engines/titanic/module.mk @@ -450,6 +450,7 @@ MODULE_OBJS := \ true_talk/barbot_script.o \ true_talk/bellbot_script.o \ true_talk/deskbot_script.o \ + true_talk/dialogue_file.o \ true_talk/doorbot_script.o \ true_talk/liftbot_script.o \ true_talk/maitred_script.o \ 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; } |