From f101906bc2d654c80ccadbf560261727759eea0c Mon Sep 17 00:00:00 2001 From: Thanasis Antoniou Date: Mon, 2 Jul 2018 10:45:17 +0300 Subject: BLADERUNNER: Removed compile time macros, added synch with GUI --- engines/bladerunner/actor.cpp | 22 +++---- engines/bladerunner/bladerunner.cpp | 57 +++++++++--------- engines/bladerunner/bladerunner.h | 22 +++---- engines/bladerunner/font.cpp | 80 ++++++++++++------------- engines/bladerunner/font.h | 14 ++--- engines/bladerunner/game_constants.h | 8 --- engines/bladerunner/outtake.cpp | 18 ++---- engines/bladerunner/subtitles.cpp | 40 +++++-------- engines/bladerunner/subtitles.h | 16 +++-- engines/bladerunner/text_resource.cpp | 10 +--- engines/bladerunner/text_resource.h | 10 +--- engines/bladerunner/ui/elevator.cpp | 7 +-- engines/bladerunner/ui/esper.cpp | 6 +- engines/bladerunner/ui/kia.cpp | 6 +- engines/bladerunner/ui/kia_section_settings.cpp | 46 ++------------ engines/bladerunner/ui/kia_section_settings.h | 4 -- engines/bladerunner/ui/vk.cpp | 6 +- 17 files changed, 129 insertions(+), 243 deletions(-) (limited to 'engines') diff --git a/engines/bladerunner/actor.cpp b/engines/bladerunner/actor.cpp index 062fc0f37c..974cfdc45c 100644 --- a/engines/bladerunner/actor.cpp +++ b/engines/bladerunner/actor.cpp @@ -41,9 +41,7 @@ #include "bladerunner/slice_animations.h" #include "bladerunner/slice_renderer.h" #include "bladerunner/time.h" -#if SUBTITLES_SUPPORT #include "bladerunner/subtitles.h" -#endif // SUBTITLES_SUPPORT #include "bladerunner/waypoints.h" #include "bladerunner/zbuffer.h" @@ -555,11 +553,11 @@ bool Actor::tick(bool forceDraw, Common::Rect *screenRect) { needsUpdate = true; timeLeft = 0; } -#if SUBTITLES_SUPPORT - if(!isSpeeching()) { - _vm->_subtitles->hide(); + + if (!isSpeeching()) { + _vm->_subtitles->hide(); } -#endif // SUBTITLES_SUPPORT + if (needsUpdate) { int newAnimation = 0, newFrame = 0; _vm->_aiScripts->updateAnimation(_id, &newAnimation, &newFrame); @@ -1099,18 +1097,14 @@ void Actor::speechPlay(int sentenceId, bool voiceOver) { balance = CLIP(balance, -127, 127); } -#if SUBTITLES_SUPPORT - _vm->_subtitles->getInGameSubsText(_id, sentenceId); - _vm->_subtitles->show(); -#endif // SUBTITLES_SUPPORT - + _vm->_subtitles->getInGameSubsText(_id, sentenceId); + _vm->_subtitles->show(); + _vm->_audioSpeech->playSpeech(name, balance); } void Actor::speechStop() { -#if SUBTITLES_SUPPORT - _vm->_subtitles->hide(); -#endif // SUBTITLES_SUPPORT + _vm->_subtitles->hide(); _vm->_audioSpeech->stopSpeech(); } diff --git a/engines/bladerunner/bladerunner.cpp b/engines/bladerunner/bladerunner.cpp index 52501aa651..030086aebe 100644 --- a/engines/bladerunner/bladerunner.cpp +++ b/engines/bladerunner/bladerunner.cpp @@ -60,9 +60,7 @@ #include "bladerunner/shape.h" #include "bladerunner/slice_animations.h" #include "bladerunner/slice_renderer.h" -#if SUBTITLES_SUPPORT #include "bladerunner/subtitles.h" -#endif // SUBTITLES_SUPPORT #include "bladerunner/suspects_database.h" #include "bladerunner/text_resource.h" #include "bladerunner/time.h" @@ -100,6 +98,7 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des _vqaIsPlaying = false; _vqaStopIsRequested = false; + _subtitlesEnabled = false; _playerLosesControlCounter = 0; @@ -184,9 +183,7 @@ BladeRunnerEngine::BladeRunnerEngine(OSystem *syst, const ADGameDescription *des _scores = nullptr; _elevator = nullptr; _mainFont = nullptr; - #if SUBTITLES_SUPPORT _subtitles = nullptr; - #endif // SUBTITLES_SUPPORT _esper = nullptr; _vk = nullptr; _policeMaze = nullptr; @@ -406,20 +403,11 @@ bool BladeRunnerEngine::startup(bool hasSavegames) { _gameFlags = new GameFlags(); _gameFlags->setFlagCount(_gameInfo->getFlagCount()); - - #if BLADERUNNER_RESTORED_CONTENT_GAME - // EDS flags - _extraGameFlagsForRestoredContent = new GameFlags(); //aux flags - custom - _extraGameFlagsForRestoredContent->setFlagCount(RESTORED_CONTENT_EXTRA_FLAGS + 1); // aux flags - custom // +1 since we don't assign something to 0 enum value - #if SUBTITLES_SUPPORT - #if SUBTITLES_ENABLED_BY_DEFAULT - // subtitles enable by default: - _extraGameFlagsForRestoredContent->set(kEDSFlagSubtitlesEnable); - #else - _extraGameFlagsForRestoredContent->reset(kEDSFlagSubtitlesEnable); - #endif // SUBTITLES_ENABLED_BY_DEFAULT - #endif // SUBTITLES_SUPPORT - #endif // BLADERUNNER_RESTORED_CONTENT_GAME + + // Assign default values to the ScummVM configuration manager, in case settings are missing + ConfMan.registerDefault("subtitles", "true"); + // get value from the ScummVM configuration manager + _subtitlesEnabled = ConfMan.getBool("subtitles"); _items = new Items(this); @@ -515,10 +503,8 @@ bool BladeRunnerEngine::startup(bool hasSavegames) { _mainFont = new Font(this); _mainFont->open("KIA6PT.FON", 640, 480, -1, 0, 0x252D); _mainFont->setSpacing(1, 0); - -#if SUBTITLES_SUPPORT + _subtitles = new Subtitles(this); -#endif // SUBTITLES_SUPPORT for (int i = 0; i != 43; ++i) { Shape *shape = new Shape(this); @@ -692,13 +678,11 @@ void BladeRunnerEngine::shutdown() { _mainFont = nullptr; } -#if SUBTITLES_SUPPORT - if(_subtitles) { - delete _subtitles; - _subtitles = nullptr; + if (_subtitles) { + delete _subtitles; + _subtitles = nullptr; } -#endif // SUBTITLES_SUPPORT// - + delete _items; _items = nullptr; @@ -968,9 +952,9 @@ void BladeRunnerEngine::gameTick() { if (_debugger->_viewObstacles) { _obstacles->draw(); } - #if SUBTITLES_SUPPORT + _subtitles->tick(_surfaceFront); - #endif // SUBTITLES_SUPPORT + blitToScreen(_surfaceFront); _system->delayMillis(10); } @@ -1699,6 +1683,21 @@ bool BladeRunnerEngine::isArchiveOpen(const Common::String &name) const { return false; } +void BladeRunnerEngine::syncSoundSettings() { + Engine::syncSoundSettings(); + + _subtitlesEnabled = ConfMan.getBool("subtitles"); +} + +bool BladeRunnerEngine::isSubtitlesEnabled() { + return _subtitlesEnabled; +} + +void BladeRunnerEngine::setSubtitlesEnabled(bool newVal) { + _subtitlesEnabled = newVal; + ConfMan.setBool("subtitles", newVal); +} + Common::SeekableReadStream *BladeRunnerEngine::getResourceStream(const Common::String &name) { for (int i = 0; i != kArchiveCount; ++i) { if (!_archives[i].isOpen()) { diff --git a/engines/bladerunner/bladerunner.h b/engines/bladerunner/bladerunner.h index 5c3cc88b9d..2888a6c109 100644 --- a/engines/bladerunner/bladerunner.h +++ b/engines/bladerunner/bladerunner.h @@ -39,13 +39,7 @@ #define BLADERUNNER_DEBUG_CONSOLE 0 #define BLADERUNNER_DEBUG_GAME 0 -#define SUBTITLES_SUPPORT 1 -#if SUBTITLES_SUPPORT -#define SUBTITLES_EXTERNAL_FONT 1 -#define SUBTITLES_ENABLED_BY_DEFAULT 1 -#endif // SUBTITLES_SUPPORT -#define BLADERUNNER_RESTORED_CONTENT_GAME 1 // needed for checkbox setting for subtitles enable/disable -#define RESTORED_CONTENT_EXTRA_FLAGS 1 // needed for checkbox setting for subtitles enable/disable +#define BLADERUNNER_SUBTITLES_EXTERNAL_FONT 1 namespace Common { struct Event; @@ -96,9 +90,7 @@ class Shape; class SliceAnimations; class SliceRenderer; class Spinner; -#if SUBTITLES_SUPPORT class Subtitles; -#endif class SuspectsDatabase; class TextResource; class Time; @@ -139,19 +131,13 @@ public: EndCredits *_endCredits; ESPER *_esper; GameFlags *_gameFlags; - #if BLADERUNNER_RESTORED_CONTENT_GAME - // EDS flags - GameFlags *_extraGameFlagsForRestoredContent; - #endif // BLADERUNNER_RESTORED_CONTENT_GAME GameInfo *_gameInfo; ItemPickup *_itemPickup; Items *_items; KIA *_kia; Lights *_lights; Font *_mainFont; - #if SUBTITLES_SUPPORT Subtitles *_subtitles; - #endif // SUBTITLES_SUPPORT Mouse *_mouse; Music *_music; Obstacles *_obstacles; @@ -209,6 +195,7 @@ public: bool _sceneIsLoading; bool _vqaIsPlaying; bool _vqaStopIsRequested; + bool _subtitlesEnabled; // tracks the state of whether subtitles are enabled or disabled from ScummVM GUI option or KIA checkbox (the states are synched) int _walkSoundId; int _walkSoundVolume; @@ -286,6 +273,11 @@ public: bool closeArchive(const Common::String &name); bool isArchiveOpen(const Common::String &name) const; + void syncSoundSettings(); + bool isSubtitlesEnabled(); + void setSubtitlesEnabled(bool newVal); + + Common::SeekableReadStream *getResourceStream(const Common::String &name); bool playerHasControl(); diff --git a/engines/bladerunner/font.cpp b/engines/bladerunner/font.cpp index e3a30aa0d4..94ec476495 100644 --- a/engines/bladerunner/font.cpp +++ b/engines/bladerunner/font.cpp @@ -37,11 +37,10 @@ Font::~Font() { close(); } -#if SUBTITLES_SUPPORT -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT // for external FON font file / subtitles support bool Font::openFromStream(Common::ScopedPtr &stream, int screenWidth, int screenHeight, int spacing1, int spacing2, uint16 color) { - reset(); + reset(); _screenWidth = screenWidth; _screenHeight = screenHeight; @@ -53,7 +52,7 @@ bool Font::openFromStream(Common::ScopedPtr &stream, return false; } _characterCount = stream->readUint32LE(); - debug("Font's character count: %d", _characterCount); + debug("Font's character count: %d", _characterCount); _maxWidth = stream->readUint32LE(); _maxHeight = stream->readUint32LE(); _dataSize = stream->readUint32LE(); @@ -76,8 +75,7 @@ bool Font::openFromStream(Common::ScopedPtr &stream, } return true; } -#endif // SUBTITLES_EXTERNAL_FONT -#endif // SUBTITLES_SUPPORT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT bool Font::open(const Common::String &fileName, int screenWidth, int screenHeight, int spacing1, int spacing2, uint16 color) { reset(); @@ -110,28 +108,23 @@ 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 SUBTITLES_SUPPORT - #if !SUBTITLES_EXTERNAL_FONT + #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) - if(i == 81 || i == 72 || i == 74 || i == 75 // P, G, I, J - || i == 46 // '-' - ) - { - _characters[i].x = 0;// from 1 - } - if(i == 81 // P - || i == 83 || i == 84 // R, S, - || i == 86 // U - || i == 87 || i == 88 || i == 89 || i == 90 || i == 91 // V, W, X, Y ,Z - ) { - _characters[i].y = 7;// from 6 // bring down a pixel - } - } + if (fileName == "TAHOMA18.FON") { + // fix P -> i = 81 (ascii code 80 + 1) + if (i == 81 || i == 72 || i == 74 || i == 75 // P, G, I, J + || i == 46) { // '-' + _characters[i].x = 0; // original value was 1 + } + if (i == 81 // P + || i == 83 || i == 84 // R, S, + || i == 86 // U + || i == 87 || i == 88 || i == 89 || i == 90 || i == 91) { // V, W, X, Y ,Z + _characters[i].y = 7; // original value was 6 -- bring them down for one (1) pixel + } + } //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 // SUBTITLES_EXTERNAL_FONT - #endif // SUBTITLES_SUPPORT + #endif // !BLADERUNNER_SUBTITLES_EXTERNAL_FONT } for (int i = 0; i < _dataSize; i++) { _data[i] = stream->readUint16LE(); @@ -240,20 +233,21 @@ void Font::replaceColor(uint16 oldColor, uint16 newColor) { } } -#if SUBTITLES_SUPPORT +#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 void Font::setBlackColor() { - // to create a font that can be used as a shadow effect if (!_data || !_dataSize) { return; } for (int i = 0; i < _dataSize; i++) { - //debug("COLOR EXISTING: %d", _data[i]); - if(_data[i] != 32768) { // 0x8000 transparent - _data[i] = 0x0000; // black - } + //debug("COLOR EXISTING: %d", _data[i]); + if (_data[i] != 32768) { // 0x8000 is transparent + _data[i] = 0x0000; // black + } } } -#endif // SUBTITLES_SUPPORT +#endif // !BLADERUNNER_SUBTITLES_EXTERNAL_FONT void Font::drawCharacter(const uint8 character, Graphics::Surface &surface, int x, int y) const { uint8 characterIndex = character + 1; @@ -271,14 +265,18 @@ void Font::drawCharacter(const uint8 character, Graphics::Surface &surface, int int endY = height + y - 1; int currentY = y; - -#if BLADERUNNER_RESTORED_CONTENT_GAME - // Temp Bug fix - Return if w h unnaturally big: -- the INTERNAL tahoma18 font is corrupted so it could cause crashes - if(width > 100 || height > 100) { - return; - } -#endif - + + // FIXME/TODO + // This width and height check were added as a temporary bug fix -- a sanity check which is only needed for the internal TAHOMA18.FON font. + // That font's glyph properties table is corrupted - the start of the file states that there are 0xF7 (=247) entries in the char properties table + // but that table get corrupted past the 176th entry. The image data glyph part of the FON file also only covers the 176 entries. + // So the following if clause-check will return here if the width and height values are unnaturally big. + // The bug only affects debug cases where all character glyph need to be displayed... + // ...or potential custom dialogue / translations that reference characters that are not within the range of Ascii values for the normal Latin characters. + if (width > 100 || height > 100) { + return; + } + while (currentY <= endY && currentY < _screenHeight) { int currentX = x; int endX = width + x - 1; diff --git a/engines/bladerunner/font.h b/engines/bladerunner/font.h index 4d43aaa875..4f1f1e9788 100644 --- a/engines/bladerunner/font.h +++ b/engines/bladerunner/font.h @@ -24,9 +24,7 @@ #define BLADERUNNER_FONT_H #include "bladerunner/bladerunner.h" // needed for definition of Common::ScopedPtr (subtitles font external font file support) -- and for the subtitles relevant macro defines -#if SUBTITLES_SUPPORT #include "common/util.h" -#endif #include "common/str.h" namespace Graphics { @@ -65,19 +63,17 @@ public: Font(BladeRunnerEngine *vm); ~Font(); - #if SUBTITLES_SUPPORT - #if SUBTITLES_EXTERNAL_FONT + #if BLADERUNNER_SUBTITLES_EXTERNAL_FONT bool openFromStream(Common::ScopedPtr &s, int screenWidth, int screenHeight, int spacing1, int spacing2, uint16 color); - #endif // SUBTITLES_EXTERNAL_FONT - #endif // SUBTITLES_SUPPORT + #endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT bool open(const Common::String &fileName, int screenWidth, int screenHeight, int spacing1, int spacing2, uint16 color); void close(); void setSpacing(int spacing1, int spacing2); void setColor(uint16 color); - #if SUBTITLES_SUPPORT - void setBlackColor(); // for subtitles - #endif + #if !BLADERUNNER_SUBTITLES_EXTERNAL_FONT + void setBlackColor(); // for subtitles (when using internal font) - emulate shadows + #endif // !BLADERUNNER_SUBTITLES_EXTERNAL_FONT 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/game_constants.h b/engines/bladerunner/game_constants.h index 280bcc8c92..0a9082a60a 100644 --- a/engines/bladerunner/game_constants.h +++ b/engines/bladerunner/game_constants.h @@ -547,14 +547,6 @@ enum Variables { kVariableNextTvNews = 52 }; -#if BLADERUNNER_RESTORED_CONTENT_GAME -// Aux enum from added/ restored content -// EDS Flags -enum _extraGameFlagsForRestoredContent { - kEDSFlagSubtitlesEnable = 1 -}; -#endif // BLADERUNNER_RESTORED_CONTENT_GAME - enum Outtakes { kOuttakeIntro = 0, kOuttakeMovieA = 1, diff --git a/engines/bladerunner/outtake.cpp b/engines/bladerunner/outtake.cpp index d52646b488..2a4da8f874 100644 --- a/engines/bladerunner/outtake.cpp +++ b/engines/bladerunner/outtake.cpp @@ -23,9 +23,7 @@ #include "bladerunner/outtake.h" #include "bladerunner/bladerunner.h" -#if SUBTITLES_SUPPORT #include "bladerunner/subtitles.h" -#endif // SUBTITLES_SUPPORT #include "bladerunner/vqa_player.h" #include "common/debug.h" @@ -46,12 +44,8 @@ void OuttakePlayer::play(const Common::String &name, bool noLocalization, int co } resName = resName + ".VQA"; - -#if SUBTITLES_SUPPORT - VQAPlayer vqa_player(_vm, &_vm->_surfaceBack); // fix for subtitles rendering properly -#else - VQAPlayer vqa_player(_vm, &_vm->_surfaceFront); // original -#endif // SUBTITLES_SUPPORT + + VQAPlayer vqa_player(_vm, &_vm->_surfaceBack); // surfaceBack is needed here for subtitles rendering properly, original was _surfaceFront here vqa_player.open(); @@ -63,17 +57,13 @@ void OuttakePlayer::play(const Common::String &name, bool noLocalization, int co return; int frame = vqa_player.update(); - #if SUBTITLES_SUPPORT - blit(_vm->_surfaceBack, _vm->_surfaceFront); // new tha hack - helps to make subtitles disappear if the proper video is rendered in surface back and then pushed to the front surface - #endif // SUBTITLES_SUPPORT + blit(_vm->_surfaceBack, _vm->_surfaceFront); // This helps to make subtitles disappear properly, if the video is rendered in surface back and then pushed to the front surface if (frame == -3) break; if (frame >= 0) { - #if SUBTITLES_SUPPORT - _vm->_subtitles->getOuttakeSubsText(resName + ".TRE" , frame); + _vm->_subtitles->getOuttakeSubsText(resName + ".TRE" , frame); _vm->_subtitles->tickOuttakes(_vm->_surfaceFront); - #endif // SUBTITLES_SUPPORT _vm->blitToScreen(_vm->_surfaceFront); } diff --git a/engines/bladerunner/subtitles.cpp b/engines/bladerunner/subtitles.cpp index b66360f81f..1711425caf 100644 --- a/engines/bladerunner/subtitles.cpp +++ b/engines/bladerunner/subtitles.cpp @@ -22,13 +22,10 @@ #include "bladerunner/subtitles.h" -#if SUBTITLES_SUPPORT - #include "bladerunner/bladerunner.h" #include "bladerunner/font.h" #include "bladerunner/text_resource.h" #include "bladerunner/audio_speech.h" -//#include "bladerunner/script/scene_script.h" // for Game_Flag_Query declaration (actually script.h, but this seems to be included in other source files instead) #include "bladerunner/game_flags.h" // for Game_Flag_Query declaration (actually script.h, but this seems to be included in other source files instead) #include "bladerunner/game_constants.h" // for EDS flags - for subtitle checkbox flag state #include "common/debug.h" @@ -68,7 +65,7 @@ namespace BladeRunner { * DONE - OK - CHECK what happens in VQA when no corresponding TRE subs file? */ -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT const Common::String Subtitles::SUBTITLES_FONT_FILENAME = "SUBTITLES.FON"; #else const Common::String Subtitles::SUBTITLES_FONT_FILENAME = "TAHOMA18.FON"; @@ -120,13 +117,13 @@ Subtitles::Subtitles(BladeRunnerEngine *vm) { _gameSubsFdEntries[i] = nullptr; _vqaSubsTextResourceEntries[i] = nullptr; } -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT _gameSubsFontsFd = nullptr; _subsFont = nullptr; #else _subsFont = nullptr; _subsBgFont = nullptr; -#endif // SUBTITLES_EXTERNAL_FONT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT reset(); // Done - Subtitles Reset // @@ -147,7 +144,7 @@ Subtitles::Subtitles(BladeRunnerEngine *vm) { // Done - Loading text resources // // Initializing/Loading Subtitles' Fonts -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT // Open external fonts file (FON file) and load fonts _gameSubsFontsFd = new Common::File(); _subsFont = new Font(_vm); @@ -172,7 +169,7 @@ Subtitles::Subtitles(BladeRunnerEngine *vm) { } else { _subsFontsLoaded = false; } -#endif // SUBTITLES_EXTERNAL_FONT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT //Done - Initializing/Loading Subtitles' Fonts // // calculate the Screen Y position of the subtitle lines @@ -205,7 +202,7 @@ Subtitles::~Subtitles() { _gameSubsFdEntries[i] = nullptr; } } -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT if (_subsFont != nullptr) { _subsFont->close(); delete _subsFont; @@ -229,7 +226,7 @@ Subtitles::~Subtitles() { delete _subsBgFont; _subsBgFont = nullptr; } -#endif // SUBTITLES_EXTERNAL_FONT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT } /** @@ -334,7 +331,7 @@ Common::SeekableReadStream *Subtitles::createReadStreamForGameSubs(int subTreIdx return new Common::SafeSeekableSubReadStream(_gameSubsFdEntries[subTreIdx], 0, _gameSubsFdEntries[subTreIdx]->size(), DisposeAfterUse::YES); // TODO changed to YES from NO is this ok? } -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT // // EXTERN FONT MANAGEMENT - Font Open/ Create Read Stream / Load / Close methods // @@ -414,7 +411,7 @@ bool Subtitles::loadSubsFont() { // // END OF EXTERNAL FONT MANAGEMENT // -#endif // SUBTITLES_EXTERNAL_FONT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT /** * Get the active subtitle text by searching with actor ID and speech ID @@ -517,11 +514,9 @@ void Subtitles::tickOuttakes(Graphics::Surface &s) { } else { _vm->_subtitles->show(); } -#if BLADERUNNER_RESTORED_CONTENT_GAME - if (!_vm->_extraGameFlagsForRestoredContent->query(kEDSFlagSubtitlesEnable)) { + if (!_vm->isSubtitlesEnabled()) { return; } -#endif if (!_isVisible) { // keep it as a separate if return; } @@ -534,13 +529,10 @@ void Subtitles::tickOuttakes(Graphics::Surface &s) { void Subtitles::tick(Graphics::Surface &s) { if (!_vm->_audioSpeech->isPlaying()) { _vm->_subtitles->hide(); // TODO might need a better system. Don't call it always. - } -#if BLADERUNNER_RESTORED_CONTENT_GAME - if (!_vm->_extraGameFlagsForRestoredContent->query(kEDSFlagSubtitlesEnable)) { + if (!_vm->isSubtitlesEnabled()) { return; } -#endif if (!_isVisible) { // keep it as a separate if return; } @@ -559,7 +551,7 @@ void Subtitles::draw(Graphics::Surface &s) { _subtitlesQuoteChanged = false; } -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT for (int i = 0; i < _currentSubtitleLines; ++i) { _subsFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i]); } @@ -576,7 +568,7 @@ void Subtitles::draw(Graphics::Surface &s) { } _subsFont->draw(_subtitleLineQuote[i], s, _subtitleLineScreenX[i], _subtitleLineScreenY[i]); } -#endif // SUBTITLES_EXTERNAL_FONT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT } /** @@ -745,7 +737,7 @@ void Subtitles::reset() { } } -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT if (_subsFont != nullptr) { _subsFont->close(); delete _subsFont; @@ -770,9 +762,9 @@ void Subtitles::reset() { delete _subsBgFont; _subsBgFont = nullptr; } -#endif // SUBTITLES_EXTERNAL_FONT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT _subsFontsLoaded = false; } } // End of namespace BladeRunner -#endif + diff --git a/engines/bladerunner/subtitles.h b/engines/bladerunner/subtitles.h index 28e970842d..8392b7ab39 100644 --- a/engines/bladerunner/subtitles.h +++ b/engines/bladerunner/subtitles.h @@ -24,7 +24,6 @@ #define BLADERUNNER_SUBTITLES_H #include "bladerunner/bladerunner.h" -#if SUBTITLES_SUPPORT #include "common/str.h" #include "graphics/surface.h" @@ -58,9 +57,9 @@ class Subtitles { TextResource *_vqaSubsTextResourceEntries[kMaxTextResourceEntries]; Font *_subsFont; -#if !SUBTITLES_EXTERNAL_FONT +#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 // SUBTITLES_EXTERNAL_FONT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT bool _isVisible; Common::String _currentSubtitleTextFull; @@ -74,9 +73,9 @@ class Subtitles { Common::File *_gameSubsFdEntries[kMaxTextResourceEntries]; // an array of pointers to TRE FILEs bool _gameSubsFdEntriesFound[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 -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT Common::File *_gameSubsFontsFd; // the file for the external FONT for subtitles -#endif // SUBTITLES_EXTERNAL_FONT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT public: Subtitles(BladeRunnerEngine *vm); @@ -102,13 +101,13 @@ private: bool loadGameSubsText(int subTreIdx); // populate a GAME SUBS TextResource with subtitles // // -#if SUBTITLES_EXTERNAL_FONT +#if BLADERUNNER_SUBTITLES_EXTERNAL_FONT Common::SeekableReadStream *createReadStreamForSubFonts(); bool openSubsFontFile(); void closeSubsFontFile(); bool isOpenSubsFontFile() const; // bool loadSubsFont(); // create a the font object from a FON file (external) -#endif // SUBTITLES_EXTERNAL_FONT +#endif // BLADERUNNER_SUBTITLES_EXTERNAL_FONT void draw(Graphics::Surface &s); @@ -123,6 +122,5 @@ private: }; } // End of namespace BladeRunner -#endif -#endif +#endif // BLADERUNNER_SUBTITLES_H diff --git a/engines/bladerunner/text_resource.cpp b/engines/bladerunner/text_resource.cpp index b7ae136455..1c77baf6f4 100644 --- a/engines/bladerunner/text_resource.cpp +++ b/engines/bladerunner/text_resource.cpp @@ -43,7 +43,6 @@ TextResource::~TextResource() { delete[] _strings; } -#if SUBTITLES_SUPPORT // for TRE subtitles support bool TextResource::openFromStream(Common::ScopedPtr &s) { @@ -85,7 +84,6 @@ bool TextResource::openFromStream(Common::ScopedPtr return true; } -#endif bool TextResource::open(const Common::String &name) { assert(name.size() <= 8); @@ -142,19 +140,17 @@ const char *TextResource::getText(uint32 id) const { return ""; } -#if SUBTITLES_SUPPORT const char *TextResource::getOuttakeTextByFrame(uint32 frame) const { for (uint32 i = 0; i != _count; ++i) { - //debug("Checking %d - so within: %d , %d", _ids[i], (0x0000FFFF & _ids[i]), ((_ids[i] >> 16) & 0x0000FFFF ) ); + //debug("Checking %d - so within: %d , %d", _ids[i], (0x0000FFFF & _ids[i]), ((_ids[i] >> 16) & 0x0000FFFF ) ); if ((frame >= (0x0000FFFF & _ids[i]) ) && (frame < ((_ids[i] >> 16) & 0x0000FFFF ) )){ - // we found an id with lower 16bits smaller or equal to our frame key - // and with higher 16 bits higher than the frame key + // we found an id with lower 16bits smaller or equal to our frame key + // and with higher 16 bits higher than the frame key return _strings + _offsets[i]; } } return ""; } -#endif int TextResource::getCount() const { return _count; diff --git a/engines/bladerunner/text_resource.h b/engines/bladerunner/text_resource.h index be399bf2d8..33a8f98de8 100644 --- a/engines/bladerunner/text_resource.h +++ b/engines/bladerunner/text_resource.h @@ -23,10 +23,8 @@ #ifndef BLADERUNNER_TEXT_RESOURCE_H #define BLADERUNNER_TEXT_RESOURCE_H -#include "bladerunner/bladerunner.h" // needed for definition of Common::ScopedPtr (subtitles font external font file support) -- and for the subtitles relevant macro defines -#if SUBTITLES_SUPPORT +#include "bladerunner/bladerunner.h" // needed for definition of Common::ScopedPtr (subtitles font external font file support) #include "common/util.h" -#endif #include "common/str.h" namespace BladeRunner { @@ -47,14 +45,10 @@ public: ~TextResource(); bool open(const Common::String &name); - #if SUBTITLES_SUPPORT bool openFromStream(Common::ScopedPtr &s); - #endif - + const char *getText(uint32 id) const; - #if SUBTITLES_SUPPORT const char *getOuttakeTextByFrame(uint32 frame) const; - #endif int getCount() const; }; diff --git a/engines/bladerunner/ui/elevator.cpp b/engines/bladerunner/ui/elevator.cpp index 7026f0ea01..759c0e7cb6 100644 --- a/engines/bladerunner/ui/elevator.cpp +++ b/engines/bladerunner/ui/elevator.cpp @@ -32,9 +32,7 @@ #include "bladerunner/time.h" #include "bladerunner/ui/ui_image_picker.h" #include "bladerunner/vqa_player.h" -#if SUBTITLES_SUPPORT #include "bladerunner/subtitles.h" -#endif #include "common/rect.h" #include "common/str.h" @@ -229,9 +227,8 @@ void Elevator::tick() { _imagePicker->draw(_vm->_surfaceFront); _vm->_mouse->draw(_vm->_surfaceFront, p.x, p.y); -#if SUBTITLES_SUPPORT - _vm->_subtitles->tick(_vm->_surfaceFront); -#endif + _vm->_subtitles->tick(_vm->_surfaceFront); + _vm->blitToScreen(_vm->_surfaceFront); tickDescription(); _vm->_system->delayMillis(10); diff --git a/engines/bladerunner/ui/esper.cpp b/engines/bladerunner/ui/esper.cpp index 2a0431f0d8..791dd273ab 100644 --- a/engines/bladerunner/ui/esper.cpp +++ b/engines/bladerunner/ui/esper.cpp @@ -38,9 +38,7 @@ #include "bladerunner/time.h" #include "bladerunner/ui/ui_image_picker.h" #include "bladerunner/vqa_player.h" -#if SUBTITLES_SUPPORT #include "bladerunner/subtitles.h" -#endif #include "common/rect.h" #include "common/str.h" @@ -233,9 +231,7 @@ void ESPER::tick() { drawMouse(_vm->_surfaceFront); tickSound(); -#if SUBTITLES_SUPPORT - _vm->_subtitles->tick(_vm->_surfaceFront); -#endif + _vm->_subtitles->tick(_vm->_surfaceFront); _vm->blitToScreen(_vm->_surfaceFront); // TODO: implement 60hz lock for smoother experience diff --git a/engines/bladerunner/ui/kia.cpp b/engines/bladerunner/ui/kia.cpp index 183bf615d9..d54133a7e4 100644 --- a/engines/bladerunner/ui/kia.cpp +++ b/engines/bladerunner/ui/kia.cpp @@ -53,9 +53,7 @@ #include "bladerunner/ui/kia_shapes.h" #include "bladerunner/ui/ui_image_picker.h" #include "bladerunner/vqa_player.h" -#if SUBTITLES_SUPPORT #include "bladerunner/subtitles.h" -#endif // SUBTITLES_SUPPORT #include "common/str.h" #include "common/keyboard.h" @@ -374,9 +372,7 @@ void KIA::tick() { } _vm->_mouse->draw(_vm->_surfaceFront, mouse.x, mouse.y); -#if SUBTITLES_SUPPORT - _vm->_subtitles->tick(_vm->_surfaceFront); -#endif + _vm->_subtitles->tick(_vm->_surfaceFront); _vm->blitToScreen(_vm->_surfaceFront); _vm->_system->delayMillis(10); diff --git a/engines/bladerunner/ui/kia_section_settings.cpp b/engines/bladerunner/ui/kia_section_settings.cpp index 8ff3c7e7b5..4fd04a9b00 100644 --- a/engines/bladerunner/ui/kia_section_settings.cpp +++ b/engines/bladerunner/ui/kia_section_settings.cpp @@ -55,14 +55,8 @@ KIASectionSettings::KIASectionSettings(BladeRunnerEngine *vm) _ambientSoundVolume = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 210, 460, 220), 101, 0); _speechVolume = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 235, 460, 245), 101, 0); _gammaCorrection = new UISlider(_vm, sliderCallback, this, Common::Rect(180, 260, 460, 270), 101, 0); -#if BLADERUNNER_RESTORED_CONTENT_GAME _directorsCut = new UICheckBox(_vm, checkBoxCallback, this, Common::Rect(180, 364, 270, 374), 0, false); - #if SUBTITLES_SUPPORT - _subtitlesEnable = new UICheckBox(_vm, checkBoxCallback, this, Common::Rect(291, 364, 360, 374), 0, false); - #endif // SUBTITLES_SUPPORT -#else - _directorsCut = new UICheckBox(_vm, checkBoxCallback, this, Common::Rect(180, 364, 460, 374), 0, false); // original -#endif // BLADERUNNER_RESTORED_CONTENT_GAME + _subtitlesEnable = new UICheckBox(_vm, checkBoxCallback, this, Common::Rect(291, 364, 360, 374), 0, false); _playerAgendaSelector = new UIImagePicker(_vm, 5); _uiContainer->add(_musicVolume); @@ -71,11 +65,7 @@ KIASectionSettings::KIASectionSettings(BladeRunnerEngine *vm) _uiContainer->add(_speechVolume); _uiContainer->add(_gammaCorrection); _uiContainer->add(_directorsCut); -#if BLADERUNNER_RESTORED_CONTENT_GAME - #if SUBTITLES_SUPPORT _uiContainer->add(_subtitlesEnable); - #endif // SUBTITLES_SUPPORT -#endif // BLADERUNNER_RESTORED_CONTENT_GAME _learyPos = 0; } @@ -88,11 +78,7 @@ KIASectionSettings::~KIASectionSettings() { delete _speechVolume; delete _gammaCorrection; delete _directorsCut; -#if BLADERUNNER_RESTORED_CONTENT_GAME - #if SUBTITLES_SUPPORT delete _subtitlesEnable; - #endif // SUBTITLES_SUPPORT -#endif // BLADERUNNER_RESTORED_CONTENT_GAME delete _playerAgendaSelector; } @@ -108,11 +94,7 @@ void KIASectionSettings::open() { _playerAgendaSelector->activate(mouseInCallback, nullptr, nullptr, mouseUpCallback, this); _directorsCut->enable(); -#if BLADERUNNER_RESTORED_CONTENT_GAME - #if SUBTITLES_SUPPORT _subtitlesEnable->enable(); - #endif // SUBTITLES_SUPPORT -#endif // BLADERUNNER_RESTORED_CONTENT_GAME } void KIASectionSettings::close() { @@ -126,11 +108,8 @@ void KIASectionSettings::draw(Graphics::Surface &surface) { _speechVolume->setValue(_vm->_audioSpeech->getVolume()); _gammaCorrection->setValue(100.0f); _directorsCut->setChecked(_vm->_gameFlags->query(kFlagDirectorsCut)); -#if BLADERUNNER_RESTORED_CONTENT_GAME - #if SUBTITLES_SUPPORT - _subtitlesEnable->setChecked(_vm->_extraGameFlagsForRestoredContent->query(kEDSFlagSubtitlesEnable)); - #endif // SUBTITLES_SUPPORT -#endif // BLADERUNNER_RESTORED_CONTENT_GAME + + _subtitlesEnable->setChecked(_vm->isSubtitlesEnabled()); const char *textConversationChoices = _vm->_textOptions->getText(0); const char *textMusic = _vm->_textOptions->getText(2); @@ -143,11 +122,8 @@ void KIASectionSettings::draw(Graphics::Surface &surface) { const char *textDark = _vm->_textOptions->getText(14); const char *textLight = _vm->_textOptions->getText(15); const char *textDesignersCut = _vm->_textOptions->getText(18); -#if BLADERUNNER_RESTORED_CONTENT_GAME - #if SUBTITLES_SUPPORT + // TODO REPLACE THIS STRING LITERAL MAYBE WITH A TEXT RESOURCE ITEM? const char *textSubtitles = "Subtitles"; - #endif // SUBTITLES_SUPPORT -#endif // BLADERUNNER_RESTORED_CONTENT_GAME int posConversationChoices = 320 - _vm->_mainFont->getTextWidth(textConversationChoices) / 2; int posMusic = 320 - _vm->_mainFont->getTextWidth(textMusic) / 2; @@ -184,11 +160,7 @@ void KIASectionSettings::draw(Graphics::Surface &surface) { _vm->_mainFont->drawColor(textLight, surface, 462, 261, 0x6EEE); _vm->_mainFont->drawColor(textDesignersCut, surface, 192, 365, 0x7751); -#if BLADERUNNER_RESTORED_CONTENT_GAME - #if SUBTITLES_SUPPORT _vm->_mainFont->drawColor(textSubtitles, surface, 303, 365, 0x7751); - #endif // SUBTITLES_SUPPORT -#endif // BLADERUNNER_RESTORED_CONTENT_GAME _playerAgendaSelector->drawTooltip(surface, _mouseX, _mouseY); } @@ -264,17 +236,9 @@ void KIASectionSettings::checkBoxCallback(void *callbackData, void *source) { self->_vm->_gameFlags->reset(kFlagDirectorsCut); } } - #if BLADERUNNER_RESTORED_CONTENT_GAME - #if SUBTITLES_SUPPORT else if (source == self->_subtitlesEnable) { - if (self->_subtitlesEnable->_isChecked) { - self->_vm->_extraGameFlagsForRestoredContent->set(kEDSFlagSubtitlesEnable); - } else { - self->_vm->_extraGameFlagsForRestoredContent->reset(kEDSFlagSubtitlesEnable); - } + self->_vm->setSubtitlesEnabled(self->_subtitlesEnable->_isChecked); } - #endif // SUBTITLES_SUPPORT - #endif // BLADERUNNER_RESTORED_CONTENT_GAME } void KIASectionSettings::mouseInCallback(int buttonId, void *callbackData) { diff --git a/engines/bladerunner/ui/kia_section_settings.h b/engines/bladerunner/ui/kia_section_settings.h index 4c5452b595..d554087b96 100644 --- a/engines/bladerunner/ui/kia_section_settings.h +++ b/engines/bladerunner/ui/kia_section_settings.h @@ -44,11 +44,7 @@ class KIASectionSettings : public KIASectionBase { UISlider *_speechVolume; UISlider *_gammaCorrection; UICheckBox *_directorsCut; -#if BLADERUNNER_RESTORED_CONTENT_GAME - #if SUBTITLES_SUPPORT UICheckBox *_subtitlesEnable; - #endif -#endif // BLADERUNNER_RESTORED_CONTENT_GAME UIImagePicker *_playerAgendaSelector; int _mouseX; diff --git a/engines/bladerunner/ui/vk.cpp b/engines/bladerunner/ui/vk.cpp index 8565d39a36..031ba3b093 100644 --- a/engines/bladerunner/ui/vk.cpp +++ b/engines/bladerunner/ui/vk.cpp @@ -41,9 +41,7 @@ #include "bladerunner/time.h" #include "bladerunner/ui/ui_image_picker.h" #include "bladerunner/vqa_player.h" -#if SUBTITLES_SUPPORT #include "bladerunner/subtitles.h" -#endif #include "common/str.h" #include "common/keyboard.h" @@ -199,9 +197,7 @@ void VK::tick() { draw(); -#if SUBTITLES_SUPPORT - _vm->_subtitles->tick(_vm->_surfaceFront); -#endif // SUBTITLES_SUPPORT + _vm->_subtitles->tick(_vm->_surfaceFront); _vm->blitToScreen(_vm->_surfaceFront); _vm->_system->delayMillis(10); -- cgit v1.2.3