diff options
author | Paul Gilbert | 2016-05-30 10:18:50 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-15 19:17:12 -0400 |
commit | 07c1b2b23d5e97d28707f4abf734fe1506da1999 (patch) | |
tree | 9792bd4de335883fe10688118065f72e58b9167e /engines/titanic/true_talk | |
parent | 9f6a3d36f7778c5e530c03063b856212b4805ab9 (diff) | |
download | scummvm-rg350-07c1b2b23d5e97d28707f4abf734fe1506da1999.tar.gz scummvm-rg350-07c1b2b23d5e97d28707f4abf734fe1506da1999.tar.bz2 scummvm-rg350-07c1b2b23d5e97d28707f4abf734fe1506da1999.zip |
TITANIC: Fleshing out of CTrueTalkManager class
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.cpp | 50 | ||||
-rw-r--r-- | engines/titanic/true_talk/true_talk_manager.h | 37 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.cpp | 7 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_npc_script.h | 2 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_room_script.h | 2 |
5 files changed, 90 insertions, 8 deletions
diff --git a/engines/titanic/true_talk/true_talk_manager.cpp b/engines/titanic/true_talk/true_talk_manager.cpp index bff4ba60ba..76937dab4b 100644 --- a/engines/titanic/true_talk/true_talk_manager.cpp +++ b/engines/titanic/true_talk/true_talk_manager.cpp @@ -32,7 +32,7 @@ namespace Titanic { int CTrueTalkManager::_v1; int CTrueTalkManager::_v2; -int CTrueTalkManager::_v3; +int CTrueTalkManager::_passengerClass; bool CTrueTalkManager::_v4; bool CTrueTalkManager::_v5; int CTrueTalkManager::_v6; @@ -50,10 +50,12 @@ CTrueTalkManager::CTrueTalkManager(CGameManager *owner) : _dialogueFile(nullptr), _dialogueId(0) { _titleEngine.setup(3, 3); _currentNPC = nullptr; + g_vm->_trueTalkManager = this; } CTrueTalkManager::~CTrueTalkManager() { clear(); + g_vm->_trueTalkManager = nullptr; } void CTrueTalkManager::save(SimpleFile *file) const { @@ -100,7 +102,7 @@ void CTrueTalkManager::loadStatics(SimpleFile *file) { int count = file->readNumber(); _v1 = file->readNumber(); _v2 = file->readNumber(); - _v3 = file->readNumber(); + _passengerClass = file->readNumber(); _v4 = file->readNumber() != 0; _v5 = file->readNumber() != 0; _v6 = file->readNumber(); @@ -124,7 +126,7 @@ void CTrueTalkManager::saveStatics(SimpleFile *file) { file->writeNumber(10); file->writeNumber(_v1); file->writeNumber(_v2); - file->writeNumber(_v3); + file->writeNumber(_passengerClass); file->writeNumber(_v4 ? 1 : 0); file->writeNumber(_v5 ? 1 : 0); file->writeNumber(_v6); @@ -148,7 +150,7 @@ void CTrueTalkManager::setFlags(int index, int val) { switch (index) { case 1: if (val >= 1 && val <= 3) - _v3 = val; + _passengerClass = val; break; case 2: @@ -233,6 +235,14 @@ void CTrueTalkManager::start(CTrueTalkNPC *npc, uint id, CViewItem *view) { setDialogue(npc, roomScript, view); } +void CTrueTalkManager::start3(CTrueTalkNPC *npc, CViewItem *view) { + start(npc, 3, view); +} + +void CTrueTalkManager::start4(CTrueTalkNPC *npc, CViewItem *view) { + start(npc, 4, view); +} + TTnpcScript *CTrueTalkManager::getTalker(const CString &name) const { if (name.contains("Doorbot")) return _scripts.getNpcScript(104); @@ -285,6 +295,18 @@ TTroomScript *CTrueTalkManager::getRoomScript() const { return script; } +TTroomScript *CTrueTalkManager::getRoomScript(int roomId) const { + TTroomScript *script = nullptr; + if (roomId) + script = _scripts.getRoomScript(roomId); + + if (!script) + // Fall back on the default Room script + script = _scripts.getRoomScript(110); + + return script; +} + void CTrueTalkManager::loadAssets(CTrueTalkNPC *npc, int charId) { // If assets for the character are already loaded, simply exit if (_currentCharId == charId) @@ -526,7 +548,7 @@ void CTrueTalkManager::playSpeech(TTtalker *talker, TTroomScript *roomScript, CV } } -int CTrueTalkManager::getStateVal(int stateNum) { +int CTrueTalkManager::getStateValue(int stateNum) { if (!_currentNPC) return -1000; @@ -549,4 +571,22 @@ bool CTrueTalkManager::proximityMethod1(int val) { return false; } +CGameManager *CTrueTalkManager::getGameManager() const { + return _gameManager; +} + +CGameState *CTrueTalkManager::getGameState() const { + return _gameManager ? &_gameManager->_gameState : nullptr; +} + +int CTrueTalkManager::getPassengerClass() const { + CGameState *gameState = getGameState(); + return gameState ? gameState->_passengerClass : 4; +} + +int CTrueTalkManager::getState14() const { + CGameState *gameState = getGameState(); + return gameState ? gameState->_field14 : 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 3467fe1cb5..89b9cfd7db 100644 --- a/engines/titanic/true_talk/true_talk_manager.h +++ b/engines/titanic/true_talk/true_talk_manager.h @@ -33,6 +33,7 @@ namespace Titanic { class CGameManager; +class CGameState; class CTreeItem; class CViewItem; class CTrueTalkManager; @@ -107,10 +108,27 @@ private: void playSpeech(TTtalker *talker, TTroomScript *roomScript, CViewItem *view, bool isParrot); static bool proximityMethod1(int val); + + /** + * Return the game manager + */ + CGameManager *getGameManager() const; + + /** + * Return the game state + */ + CGameState *getGameState() const; + + /** + * Get the player's passenger class + */ + int getPassengerClass() const; + + int getState14() const; public: static int _v1; static int _v2; - static int _v3; + static int _passengerClass; static bool _v4; static bool _v5; static int _v6; @@ -126,7 +144,7 @@ public: /** * Get a specified state value from the currently set NPC */ - static int getStateVal(int stateNum); + static int getStateValue(int stateNum); /** * Trigger an NPC action @@ -189,6 +207,16 @@ public: void start(CTrueTalkNPC *npc, uint id, CViewItem *view); /** + * Start a TrueTalk conversation + */ + void start3(CTrueTalkNPC *npc, CViewItem *view); + + /** + * Start a TrueTalk conversation + */ + void start4(CTrueTalkNPC *npc, CViewItem *view); + + /** * Return a TrueTalk talker/script */ TTnpcScript *getTalker(const CString &name) const; @@ -197,6 +225,11 @@ public: * Process player's input */ void processInput(CTrueTalkNPC *npc, CTextInputMsg *msg, CViewItem *view); + + /** + * Gets the script associated with a specific room + */ + TTroomScript *getRoomScript(int roomId) const; }; } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_npc_script.cpp b/engines/titanic/true_talk/tt_npc_script.cpp index 0775d09c08..2aa3b85726 100644 --- a/engines/titanic/true_talk/tt_npc_script.cpp +++ b/engines/titanic/true_talk/tt_npc_script.cpp @@ -23,6 +23,7 @@ #include "common/textconsole.h" #include "titanic/true_talk/tt_npc_script.h" #include "titanic/true_talk/true_talk_manager.h" +#include "titanic/titanic.h" namespace Titanic { @@ -229,4 +230,10 @@ void TTnpcScript::preLoad() { } } +int TTnpcScript::getRoom54(int roomId) { + TTroomScript *room = g_vm->_trueTalkManager->getRoomScript(roomId); + return room ? room->_field54 : 0; +} + + } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_npc_script.h b/engines/titanic/true_talk/tt_npc_script.h index 2396943025..2c6c6a007f 100644 --- a/engines/titanic/true_talk/tt_npc_script.h +++ b/engines/titanic/true_talk/tt_npc_script.h @@ -75,6 +75,8 @@ protected: void resetFlags(); void randomizeFlags(); + + static int getRoom54(int roomId); public: TTnpcScript(int charId, const char *charClass, int v2, const char *charName, int v3, int val2, int v4, diff --git a/engines/titanic/true_talk/tt_room_script.h b/engines/titanic/true_talk/tt_room_script.h index 7fd43f3c79..63aedd260c 100644 --- a/engines/titanic/true_talk/tt_room_script.h +++ b/engines/titanic/true_talk/tt_room_script.h @@ -52,7 +52,7 @@ public: class TTroomScript : public TTroomScriptBase { -private: +public: int _field54; public: TTroomScript(int scriptId); |