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 BLADERUNNER_SUBTITLES_H 24 #define BLADERUNNER_SUBTITLES_H 25 26 #include "bladerunner/bladerunner.h" 27 28 #include "common/str.h" 29 #include "common/ustr.h" 30 31 namespace Graphics { 32 class Font; 33 } 34 35 namespace BladeRunner { 36 37 class BladeRunnerEngine; 38 class TextResource; 39 40 class Subtitles { 41 friend class Debugger; 42 friend class KIASectionSettings; 43 // 44 // Subtitles could be in 6 possible languages are EN_ANY, DE_DEU, FR_FRA, IT_ITA, RU_RUS, ES_ESP 45 // with corresponding _vm->_languageCode values: "E", "G", "F", "I", "E", "S" (Russian version is built on top of English one) 46 static const uint kPreferedLine = 2; // Prefer drawing from this line (the bottom-most of available subtitle lines index is 0) by default 47 static const int kMarginBottom = 12; // In pixels. This is the bottom margin beneath the subtitles space 48 static const int kTextMaxWidth = 610; // In pixels 49 static const int kMaxTextResourceEntries = 27; // Support in-game subs (1) and all possible VQAs (26) with spoken dialogue or translatable text 50 static const int kMaxLanguageSelectionNum = 1024; // Max allowed number of languages to select from (should be available in the MIX file) 51 52 static const char *SUBTITLES_FILENAME_PREFIXES[kMaxTextResourceEntries]; 53 static const char *SUBTITLES_FONT_FILENAME_EXTERNAL; 54 static const char *SUBTITLES_VERSION_TRENAME; 55 56 BladeRunnerEngine *_vm; 57 58 enum SubtitlesFontType { 59 kSubtitlesFontTypeInternal, 60 kSubtitlesFontTypeTTF 61 }; 62 63 struct SubtitlesInfo { 64 Common::String versionStr; 65 Common::String dateOfCompile; 66 Common::String languageMode; 67 Common::String credits; 68 SubtitlesFontType fontType; 69 Common::String fontName; 70 }; 71 72 SubtitlesInfo _subtitlesInfo; 73 TextResource *_vqaSubsTextResourceEntries[kMaxTextResourceEntries]; 74 75 Graphics::Font *_font; 76 bool _useUTF8; 77 78 bool _isVisible; 79 bool _forceShowWhenNoSpeech; 80 Common::U32String _currentText; 81 Common::U32String _prevText; 82 83 Common::Array<Common::U32String> lines; 84 85 bool _gameSubsResourceEntriesFound[kMaxTextResourceEntries]; // false if a TRE file did not open successfully 86 bool _isSystemActive; // true if the whole subtitles subsystem should be disabled (due to missing required resources) 87 88 public: 89 Subtitles(BladeRunnerEngine *vm); 90 ~Subtitles(); 91 isSystemActive()92 bool isSystemActive() const { return _isSystemActive; } 93 94 void init(); 95 SubtitlesInfo getSubtitlesInfo() const; 96 void loadInGameSubsText(int actorId, int speech_id); // get the text for actorId, quoteId (in-game subs) 97 void loadOuttakeSubsText(const Common::String &outtakesName, int frame); // get the text for this frame if any 98 99 void setGameSubsText(Common::String dbgQuote, bool force); // for debugging - explicit set subs text 100 bool show(); 101 bool hide(); 102 bool isVisible() const; 103 void tick(Graphics::Surface &s); 104 void tickOuttakes(Graphics::Surface &s); 105 106 private: 107 void draw(Graphics::Surface &s); 108 109 int getIdxForSubsTreName(const Common::String &treName) const; 110 111 void clear(); 112 void reset(); 113 114 }; 115 116 } // End of namespace BladeRunner 117 118 #endif // BLADERUNNER_SUBTITLES_H 119