1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef TITANIC_TRUE_TALK_MANAGER_H 24 #define TITANIC_TRUE_TALK_MANAGER_H 25 26 #include "titanic/messages/messages.h" 27 #include "titanic/support/simple_file.h" 28 #include "titanic/true_talk/dialogue_file.h" 29 #include "titanic/true_talk/title_engine.h" 30 #include "titanic/true_talk/tt_quotes.h" 31 #include "titanic/true_talk/tt_quotes_tree.h" 32 #include "titanic/true_talk/tt_scripts.h" 33 #include "titanic/true_talk/tt_talker.h" 34 #include "titanic/game_state.h" 35 36 namespace Titanic { 37 38 class CGameManager; 39 class CGameState; 40 class CTreeItem; 41 class CViewItem; 42 class CTrueTalkManager; 43 class CTrueTalkNPC; 44 45 class CTrueTalkManager { 46 private: 47 CGameManager *_gameManager; 48 STtitleEngine _titleEngine; 49 TTscripts _scripts; 50 int _currentCharId; 51 CDialogueFile *_dialogueFile; 52 int _dialogueId; 53 int _speechDuration; 54 TTtalkerList _talkers; 55 private: 56 /** 57 * Loads the statics for the class 58 */ 59 static void loadStatics(SimpleFile *file); 60 61 /** 62 * Saves the statics associated with the class 63 */ 64 static void saveStatics(SimpleFile *file); 65 66 /** 67 * Loads an NPC from file 68 */ 69 void loadNPC(SimpleFile *file, int charId); 70 71 /** 72 * Saves the specified NPC to file 73 */ 74 void saveNPC(SimpleFile *file, int charId) const; 75 76 /** 77 * Gets the script associated with an NPC game object 78 */ 79 TTnpcScript *getNpcScript(CTrueTalkNPC *npc) const; 80 81 /** 82 * Gets the script associated with the current room 83 */ 84 TTroomScript *getRoomScript() const; 85 86 /** 87 * Loads assets for the current character, if it's changed 88 */ 89 void loadAssets(CTrueTalkNPC *npc, int charId); 90 91 void setDialogue(CTrueTalkNPC *npc, TTroomScript *roomScript, CViewItem *view); 92 93 /** 94 * Read in text from the dialogue file 95 */ 96 CString readDialogueString(); 97 98 /** 99 * Read in the speech from the dialogue file 100 * @returns Duration of the speech in seconds 101 */ 102 uint readDialogueSpeech(); 103 104 /** 105 * Triggers animation for the NPC 106 */ 107 void triggerNPC(CTrueTalkNPC *npc); 108 109 /** 110 * Plays speech specified by the manager's indexes array 111 */ 112 void playSpeech(TTtalker *talker, TTroomScript *roomScript, CViewItem *view, bool isParrot); 113 114 /** 115 * Called when a talker finishes 116 */ 117 static void talkerEnd(TTtalker *talker); 118 119 /** 120 * Return the game state 121 */ 122 CGameState *getGameState() const; 123 public: 124 static int _v1; 125 static int _v2; 126 static int _v3; 127 static bool _v4; 128 static bool _v5; 129 static int _v6; 130 static int _v7; 131 static bool _v8; 132 static int _v9; 133 static bool _v10; 134 static int _v11[41]; 135 static CTrueTalkNPC *_currentNPC; 136 137 static void setFlags(int index, int val); 138 public: 139 TTquotes _quotes; 140 TTquotesTree _quotesTree; 141 public: 142 /** 143 * Get a specified state value from the currently set NPC 144 */ 145 static int getStateValue(int stateNum); 146 147 /** 148 * Trigger an NPC action 149 */ 150 static bool triggerAction(int action, int param); 151 public: 152 CTrueTalkManager(CGameManager *owner); 153 ~CTrueTalkManager(); 154 155 /** 156 * Save the data for the class to file 157 */ 158 void save(SimpleFile *file) const; 159 160 /** 161 * Load the data for the class from file 162 */ 163 void load(SimpleFile *file); 164 165 /** 166 * Clear the manager 167 */ 168 void clear(); 169 170 /** 171 * Called when a game is about to be loaded 172 */ 173 void preLoad(); 174 175 /** 176 * Called when loading a game is complete 177 */ postLoad()178 void postLoad() {} 179 180 /** 181 * Called when a game is about to be saved 182 */ preSave()183 void preSave() {} 184 185 /** 186 * Called when a game has finished being saved 187 */ postSave()188 void postSave() {} 189 190 /** 191 * Returns the scripts for the manager 192 */ getScripts()193 TTscripts &getScripts() { return _scripts; } 194 195 /** 196 * Remove any completed talkers 197 */ 198 void removeCompleted(); 199 200 /** 201 * Return the game manager 202 */ 203 CGameManager *getGameManager() const; 204 205 /** 206 * Start a TrueTalk conversation 207 */ 208 void start(CTrueTalkNPC *npc, uint id, CViewItem *view); 209 210 /** 211 * Start a TrueTalk conversation 212 */ 213 void start3(CTrueTalkNPC *npc, CViewItem *view); 214 215 /** 216 * Start a TrueTalk conversation 217 */ 218 void start4(CTrueTalkNPC *npc, CViewItem *view); 219 220 /** 221 * Return a TrueTalk talker/script 222 */ 223 TTnpcScript *getTalker(const CString &name) const; 224 225 /** 226 * Process player's input 227 */ 228 void processInput(CTrueTalkNPC *npc, CTextInputMsg *msg, CViewItem *view); 229 230 /** 231 * Gets the script associated with a specific room 232 */ 233 TTroomScript *getRoomScript(int roomId) const; 234 235 /** 236 * Get the player's passenger class 237 */ 238 int getPassengerClass() const; 239 240 Season getCurrentSeason() const; 241 }; 242 243 } // End of namespace Titanic 244 245 #endif /* TITANIC_TRUE_TALK_MANAGER_H */ 246