From 2f28926f22cd954c3db3e725b280339cac2a7297 Mon Sep 17 00:00:00 2001 From: antoniou79 Date: Wed, 1 Aug 2018 20:15:37 +0300 Subject: BLADERUNNER: removed BLADERUNNER_SUBTITLES_EXTERNAL_FONT --- engines/bladerunner/bladerunner.h | 2 - engines/bladerunner/font.cpp | 8 +--- engines/bladerunner/font.h | 4 +- engines/bladerunner/subtitles.cpp | 84 +++++++++++++++++++-------------------- engines/bladerunner/subtitles.h | 10 ++--- 5 files changed, 48 insertions(+), 60 deletions(-) (limited to 'engines/bladerunner') diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index 4943689cf4..75ff0c8173 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -39,8 +39,6 @@ #define BLADERUNNER_DEBUG_CONSOLE 0 #define BLADERUNNER_DEBUG_GAME 0 -#define BLADERUNNER_SUBTITLES_EXTERNAL_FONT 1 - namespace Common { struct Event; } diff --git a/engines/bladerunner/font.cpp b/engines/bladerunner/font.cpp index 19fad67df6..535144f581 100644 --- a/engines/bladerunner/font.cpp +++ b/engines/bladerunner/font.cpp @@ -68,7 +68,6 @@ bool Font::open(const Common::String &fileName, int screenWidth, int screenHeigh _characters[i].width = stream->readUint32LE(); _characters[i].height = stream->readUint32LE(); _characters[i].dataOffset = stream->readUint32LE(); - #if !BLADERUNNER_SUBTITLES_EXTERNAL_FONT // special explicit alignment fixes for TAHOMA18 (INTERNAL) font if (fileName == "TAHOMA18.FON") { // fix P -> i = 81 (ascii code 80 + 1) @@ -84,7 +83,6 @@ bool Font::open(const Common::String &fileName, int screenWidth, int screenHeigh } } //debug("char::%d character x: %d, y: %d, w: %d, h:%d, do: %d", i, _characters[i].x, _characters[i].y, _characters[i].width, _characters[i].height, _characters[i].dataOffset); - #endif // !BLADERUNNER_SUBTITLES_EXTERNAL_FONT } for (int i = 0; i < _dataSize; i++) { _data[i] = stream->readUint16LE(); @@ -193,9 +191,8 @@ void Font::replaceColor(uint16 oldColor, uint16 newColor) { } } -#if !BLADERUNNER_SUBTITLES_EXTERNAL_FONT -// This was needed as a hack for using a duplicate of the font to act as shadow effect for the glyphs -// Mainly needed for the internal font, since an external font can have shadow already drawn for the glyphs +// This is useful when using a duplicate of the internal font to act as shadow effect for the glyphs for subtitles +// Mainly needed for the internal font for subtitles, since an external font can have shadow already drawn for the glyphs void Font::setBlackColor() { if (!_data || !_dataSize) { return; @@ -207,7 +204,6 @@ void Font::setBlackColor() { } } } -#endif // !BLADERUNNER_SUBTITLES_EXTERNAL_FONT void Font::drawCharacter(const uint8 character, Graphics::Surface &surface, int x, int y) const { uint8 characterIndex = character + 1; diff --git a/engines/bladerunner/font.h b/engines/bladerunner/font.h index 001a947ca2..d7a4eafc7f 100644 --- a/engines/bladerunner/font.h +++ b/engines/bladerunner/font.h @@ -68,9 +68,7 @@ public: void setSpacing(int spacing1, int spacing2); void setColor(uint16 color); - #if !BLADERUNNER_SUBTITLES_EXTERNAL_FONT - void setBlackColor(); // for subtitles (when using internal font) - emulate shadows - #endif // !BLADERUNNER_SUBTITLES_EXTERNAL_FONT + void setBlackColor(); // for subtitles (when using internal font) - in order to emulate shadows void draw(const Common::String &text, Graphics::Surface &surface, int x, int y) const; void drawColor(const Common::String &text, Graphics::Surface &surface, int x, int y, uint16 color); diff --git a/engines/bladerunner/subtitles.cpp b/engines/bladerunner/subtitles.cpp index 3a760eed45..98283ef8f1 100644 --- a/engines/bladerunner/subtitles.cpp +++ b/engines/bladerunner/subtitles.cpp @@ -64,11 +64,8 @@ namespace BladeRunner { * DONE - OK - CHECK what happens in VQA when no corresponding TRE subs file? */ -#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT -const Common::String Subtitles::SUBTITLES_FONT_FILENAME = "SUBTLS_E.FON"; -#else -const Common::String Subtitles::SUBTITLES_FONT_FILENAME = "TAHOMA18.FON"; -#endif +const Common::String Subtitles::SUBTITLES_FONT_FILENAME_EXTERNAL = "SUBTLS_E.FON"; +const Common::String Subtitles::SUBTITLES_FONT_FILENAME_INTERNAL = "TAHOMA18.FON"; /* * All entries need to have the language code appended (after a '_'). @@ -114,12 +111,8 @@ Subtitles::Subtitles(BladeRunnerEngine *vm) { for (int i = 0; i < kMaxTextResourceEntries; i++) { _vqaSubsTextResourceEntries[i] = nullptr; } -#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT - _subsFont = nullptr; -#else _subsFont = nullptr; _subsBgFont = nullptr; -#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT reset(); } @@ -141,13 +134,12 @@ Subtitles::~Subtitles() { delete _subsFont; _subsFont = nullptr; } -#if !BLADERUNNER_SUBTITLES_EXTERNAL_FONT + // _subsBgFont is only used for the internal subtitles font case if (_subsBgFont != nullptr) { _subsBgFont->close(); delete _subsBgFont; _subsBgFont = nullptr; } -#endif // !BLADERUNNER_SUBTITLES_EXTERNAL_FONT } // @@ -174,26 +166,28 @@ void Subtitles::init(void) { _subsFont = new Font(_vm); // Use TAHOMA18.FON (is corrupted in places) // 10PT or TAHOMA24 or KIA6PT have all caps glyphs (and also are too big or too small) so they are not appropriate. - if (_subsFont ->open(SUBTITLES_FONT_FILENAME, 640, 480, -1, 0, 0)) { // Color setting does not seem to affect the TAHOMA fonts or does it affect the black outline since we give 0 here? -#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT + if (_subsFont ->open(SUBTITLES_FONT_FILENAME_EXTERNAL, 640, 480, -1, 0, 0)) { // Color setting does not seem to affect the TAHOMA fonts or does it affect the black outline since we give 0 here? _subsFont->setSpacing(-1, 0); -#else + _subsFontsLoaded = true; + _subsFontsExternal = true; + } else if (_subsFont ->open(SUBTITLES_FONT_FILENAME_INTERNAL, 640, 480, -1, 0, 0)) { _subsFont->setSpacing(1, 0); - _subsFont->setWhiteColor(); -#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT _subsFontsLoaded = true; + _subsFontsExternal = false; } else { + _subsFontsExternal = false; _subsFontsLoaded = false; } -#if !BLADERUNNER_SUBTITLES_EXTERNAL_FONT - _subsBgFont = new Font(_vm); - if (_subsFontsLoaded && _subsBgFont ->open(SUBTITLES_FONT_FILENAME, 640, 480, -1, 0, 0)) { // TODO dark color? --- color does not seem to affect the TAHOMA fonts or does it affect the black outline since we give 0 here? ?? - we should give the original color here. What is it for TAHOMA? - _subsBgFont ->setSpacing(1, 0); - _subsBgFont ->setBlackColor(); - } else { - _subsFontsLoaded = false; + + if (!_subsFontsExternal) { + _subsBgFont = new Font(_vm); + if (_subsFontsLoaded && _subsBgFont ->open(SUBTITLES_FONT_FILENAME_INTERNAL, 640, 480, -1, 0, 0)) { // TODO dark color? --- color does not seem to affect the TAHOMA fonts or does it affect the black outline since we give 0 here? ?? - we should give the original color here. What is it for TAHOMA? + _subsBgFont ->setSpacing(1, 0); + _subsBgFont ->setBlackColor(); + } else { + _subsFontsLoaded = false; + } } -#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT //Done - Initializing/Loading Subtitles' Fonts // // calculate the Screen Y position of the subtitle lines @@ -379,24 +373,25 @@ void Subtitles::draw(Graphics::Surface &s) { _subtitlesQuoteChanged = false; } -#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT - for (int i = 0; i < _currentSubtitleLines; ++i) { - _subsFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i]); - } -#else - // INTERNAL FONT. NEEDS HACK (_subsBgFont) FOR SHADOW EFFECT - for (int i = 0; i < _currentSubtitleLines; ++i) { - _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i] - 1); - _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i] + 1); - _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i] + 1, _subtitleLineScreenY[i] + 1); - _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i] + 1, _subtitleLineScreenY[i] - 1); - if (_subtitleLineScreenX[i] > 0) { - _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i] - 1, _subtitleLineScreenY[i] - 1); - _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i] - 1, _subtitleLineScreenY[i] + 1); - } - _subsFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i]); - } -#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT + if (_subsFontsExternal) { + for (int i = 0; i < _currentSubtitleLines; ++i) { + _subsFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i]); + } + } + else { + // INTERNAL FONT. NEEDS HACK (_subsBgFont) FOR SHADOW EFFECT + for (int i = 0; i < _currentSubtitleLines; ++i) { + _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i] - 1); + _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i] + 1); + _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i] + 1, _subtitleLineScreenY[i] + 1); + _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i] + 1, _subtitleLineScreenY[i] - 1); + if (_subtitleLineScreenX[i] > 0) { + _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i] - 1, _subtitleLineScreenY[i] - 1); + _subsBgFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i] - 1, _subtitleLineScreenY[i] + 1); + } + _subsFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i]); + } + } } /** @@ -562,14 +557,15 @@ void Subtitles::reset() { delete _subsFont; _subsFont = nullptr; } -#if !BLADERUNNER_SUBTITLES_EXTERNAL_FONT + if (_subsBgFont != nullptr) { _subsBgFont->close(); delete _subsBgFont; _subsBgFont = nullptr; } -#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT + _subsFontsLoaded = false; + _subsFontsExternal = false; } } // End of namespace BladeRunner diff --git a/engines/bladerunner/subtitles.h b/engines/bladerunner/subtitles.h index 1f2465f3ee..97020f6b99 100644 --- a/engines/bladerunner/subtitles.h +++ b/engines/bladerunner/subtitles.h @@ -50,16 +50,15 @@ class Subtitles { static const int kMaxWidthPerLineToAutoSplitThresholdPx = 610; static const int kMaxTextResourceEntries = 1 + 25; // Support in-game subs (1) and all possible VQAs (26) with spoken dialogue! static const Common::String SUBTITLES_FILENAME_PREFIXES[kMaxTextResourceEntries]; - static const Common::String SUBTITLES_FONT_FILENAME; + static const Common::String SUBTITLES_FONT_FILENAME_EXTERNAL; + static const Common::String SUBTITLES_FONT_FILENAME_INTERNAL; BladeRunnerEngine *_vm; TextResource *_vqaSubsTextResourceEntries[kMaxTextResourceEntries]; Font *_subsFont; -#if !BLADERUNNER_SUBTITLES_EXTERNAL_FONT Font *_subsBgFont; // needed for internal font to be used as a shadow effect and make subtitles more legible in certain situations -#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT bool _isVisible; Common::String _currentSubtitleTextFull; @@ -70,8 +69,9 @@ class Subtitles { int _currentSubtitleLines; bool _subtitlesQuoteChanged; - bool _gameSubsResourceEntriesFound[kMaxTextResourceEntries]; // false if a TRE file did not open successfully - bool _subsFontsLoaded; // false if external fonts did not load, or internal fonts (fore and background) did not load + bool _gameSubsResourceEntriesFound[kMaxTextResourceEntries]; // false if a TRE file did not open successfully + bool _subsFontsExternal; // true if we are using the external font, false otherwise + bool _subsFontsLoaded; // false if external fonts and internal fonts (fore and background) did not load bool _subtitlesSystemInactive; // true if the whole subtitles subsystem should be disabled (due to missing required resources) public: -- cgit v1.2.3