aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorThanasis Antoniou2019-05-29 12:07:55 +0300
committerThanasis Antoniou2019-05-29 12:08:24 +0300
commitb7e1f8a9ffa0d068536ac5b6319f49ec22a3247d (patch)
tree8b489a2142b7eb301369fd56e43f6950dd31aa65 /engines
parent04d7f72bf79f3acc3975299e79d5b65c24f43f39 (diff)
downloadscummvm-rg350-b7e1f8a9ffa0d068536ac5b6319f49ec22a3247d.tar.gz
scummvm-rg350-b7e1f8a9ffa0d068536ac5b6319f49ec22a3247d.tar.bz2
scummvm-rg350-b7e1f8a9ffa0d068536ac5b6319f49ec22a3247d.zip
BLADERUNNER: Support for displaying subtitles info
Diffstat (limited to 'engines')
-rw-r--r--engines/bladerunner/archive.cpp1
-rw-r--r--engines/bladerunner/debugger.cpp19
-rw-r--r--engines/bladerunner/subtitles.cpp39
-rw-r--r--engines/bladerunner/subtitles.h34
-rw-r--r--engines/bladerunner/text_resource.cpp9
-rw-r--r--engines/bladerunner/text_resource.h2
6 files changed, 83 insertions, 21 deletions
diff --git a/engines/bladerunner/archive.cpp b/engines/bladerunner/archive.cpp
index 7ac2e3e983..8435a9d91d 100644
--- a/engines/bladerunner/archive.cpp
+++ b/engines/bladerunner/archive.cpp
@@ -53,6 +53,7 @@ bool MIXArchive::open(const Common::String &filename) {
_entryCount = _fd.readUint16LE();
_size = _fd.readUint32LE();
+
_entries.resize(_entryCount);
for (uint16 i = 0; i != _entryCount; ++i) {
_entries[i].hash = _fd.readUint32LE();
diff --git a/engines/bladerunner/debugger.cpp b/engines/bladerunner/debugger.cpp
index 633df5eff5..f22f924321 100644
--- a/engines/bladerunner/debugger.cpp
+++ b/engines/bladerunner/debugger.cpp
@@ -1284,8 +1284,21 @@ bool Debugger::cmdSubtitle(int argc, const char **argv) {
if (argc != 2) {
invalidSyntax = true;
} else {
+ if (!_vm->_subtitles->isSystemActive()) {
+ debugPrintf("Subtitles system is currently disabled\n");
+ }
+
Common::String subtitleText = argv[1];
- if (subtitleText == "reset") {
+ if (subtitleText == "info") {
+ debugPrintf("Subtitles version info: v%s (%s) %s by: %s\n",
+ _vm->_subtitles->getSubtitlesInfo().versionStr.c_str(),
+ _vm->_subtitles->getSubtitlesInfo().dateOfCompile.c_str(),
+ _vm->_subtitles->getSubtitlesInfo().languageMode.c_str(),
+ _vm->_subtitles->getSubtitlesInfo().credits.c_str());
+ debugPrintf("Subtitles fonts loaded: %s\n",
+ _vm->_subtitles->isSubsFontsLoaded()? "True":"False");
+
+ } else if (subtitleText == "reset") {
_vm->_subtitles->setGameSubsText("", false);
} else {
debugPrintf("Showing text: %s\n", subtitleText.c_str());
@@ -1295,9 +1308,9 @@ bool Debugger::cmdSubtitle(int argc, const char **argv) {
}
if (invalidSyntax) {
- debugPrintf("Show specified text as subtitle or clear the current subtitle (with the reset option).\n");
+ debugPrintf("Show subtitles info, or display and clear (reset) a specified text as subtitle or clear the current subtitle.\n");
debugPrintf("Use double quotes to encapsulate the text.\n");
- debugPrintf("Usage: %s (\"<text_to_display>\" | reset)\n", argv[0]);
+ debugPrintf("Usage: %s (\"<text_to_display>\" | info | reset)\n", argv[0]);
}
return true;
diff --git a/engines/bladerunner/subtitles.cpp b/engines/bladerunner/subtitles.cpp
index 612091d84f..a9c9af30f5 100644
--- a/engines/bladerunner/subtitles.cpp
+++ b/engines/bladerunner/subtitles.cpp
@@ -25,7 +25,7 @@
#include "bladerunner/font.h"
#include "bladerunner/text_resource.h"
#include "bladerunner/audio_speech.h"
-//#include "common/debug.h"
+#include "common/debug.h"
namespace BladeRunner {
@@ -56,6 +56,7 @@ namespace BladeRunner {
const char *Subtitles::SUBTITLES_FONT_FILENAME_EXTERNAL = "SUBTLS_E.FON";
+const char *Subtitles::SUBTITLES_VERSION_TRENAME = "SBTLVERS"; // addon resource file for Subtitles version info - can only be SBTLVERS.TRE
/*
* All entries need to have the language code appended (after a '_').
* And all entries should get the suffix extension ".TRx"; the last letter in extension "TR*" should also be the language code
@@ -134,14 +135,16 @@ void Subtitles::init(void) {
for (int i = 0; i < kMaxTextResourceEntries; i++) {
_vqaSubsTextResourceEntries[i] = new TextResource(_vm);
Common::String tmpConstructedFileName = "";
+ bool localizedResource = true;
if (!strcmp(SUBTITLES_FILENAME_PREFIXES[i], "WSTLGO") || !strcmp(SUBTITLES_FILENAME_PREFIXES[i], "BRLOGO")) {
tmpConstructedFileName = Common::String(SUBTITLES_FILENAME_PREFIXES[i]) + "_E"; // Only English versions of these exist
+ localizedResource = false;
}
else {
tmpConstructedFileName = Common::String(SUBTITLES_FILENAME_PREFIXES[i]) + "_" + _vm->_languageCode;
}
- if ( _vqaSubsTextResourceEntries[i]->open(tmpConstructedFileName)) {
+ if ( _vqaSubsTextResourceEntries[i]->open(tmpConstructedFileName, localizedResource)) {
_gameSubsResourceEntriesFound[i] = true;
}
}
@@ -168,6 +171,33 @@ void Subtitles::init(void) {
_subtitleLineScreenY[i] = 479 - kSubtitlesBottomYOffsetPx - ((kMaxNumOfSubtitlesLines - i) * (_subsFont->getTextHeight("") + 1));
}
}
+
+ // Loading subtitles versioning info if available
+ TextResource *versionTxtResource = new TextResource(_vm);
+ if ( versionTxtResource->open(SUBTITLES_VERSION_TRENAME, false)) {
+ _subtitlesInfo.credits = versionTxtResource->getText((uint32)0);
+ _subtitlesInfo.versionStr = versionTxtResource->getText((uint32)1);
+ _subtitlesInfo.dateOfCompile = versionTxtResource->getText((uint32)2);
+ _subtitlesInfo.languageMode = versionTxtResource->getText((uint32)3);
+ debug("Subtitles version info: v%s (%s) %s by: %s",
+ _subtitlesInfo.versionStr.c_str(),
+ _subtitlesInfo.dateOfCompile.c_str(),
+ _subtitlesInfo.languageMode.c_str(),
+ _subtitlesInfo.credits.c_str());
+ if (isSubsFontsLoaded()) {
+ debug("Subtitles font was loaded successfully.");
+ } else {
+ debug("Subtitles font could not be loaded.");
+ }
+ delete versionTxtResource;
+ versionTxtResource = nullptr;
+ } else {
+ debug("Subtitles version info: N/A");
+ }
+}
+
+Subtitles::SubtitlesInfo Subtitles::getSubtitlesInfo() const {
+ return _subtitlesInfo;
}
/**
@@ -542,6 +572,11 @@ void Subtitles::clear() {
void Subtitles::reset() {
clear();
+ _subtitlesInfo.credits = "N/A";
+ _subtitlesInfo.versionStr = "N/A";
+ _subtitlesInfo.dateOfCompile = "N/A";
+ _subtitlesInfo.languageMode = "N/A";
+
for (int i = 0; i != kMaxTextResourceEntries; ++i) {
if (_vqaSubsTextResourceEntries[i] != nullptr) {
delete _vqaSubsTextResourceEntries[i];
diff --git a/engines/bladerunner/subtitles.h b/engines/bladerunner/subtitles.h
index e52e19c825..674dde44b1 100644
--- a/engines/bladerunner/subtitles.h
+++ b/engines/bladerunner/subtitles.h
@@ -35,8 +35,6 @@
namespace BladeRunner {
class BladeRunnerEngine;
-//class SaveFileReadStream;
-//class SaveFileWriteStream;
class TextResource;
class Font;
@@ -44,18 +42,26 @@ class Subtitles {
friend class Debugger;
//
// Subtitles could be in 6 possible languages are EN_ANY, DE_DEU, FR_FRA, IT_ITA, RU_RUS, ES_ESP
- // with corresponding _vm->_languageCode values: "E", "G", "F", "I", "E", "S" (Russian version is built on top of English one)
- static const int kMaxNumOfSubtitlesLines = 4; // At least one quote in the game requires 4 lines to be displayed correctly
- static const int kStartFromSubtitleLineFromTop = 2; // Prefer drawing from this line (the top-most of available subtitle lines index is 0) by default
- static const int kSubtitlesBottomYOffsetPx = 12; // In pixels. This is the bottom margin beneath the subtitles space
- static const int kMaxWidthPerLineToAutoSplitThresholdPx = 610; // In pixels
- static const int kMaxTextResourceEntries = 1 + 25; // Support in-game subs (1) and all possible VQAs (25) with spoken dialogue or translatable text!
+ // with corresponding _vm->_languageCode values: "E", "G", "F", "I", "E", "S" (Russian version is built on top of English one)
+ static const int kMaxNumOfSubtitlesLines = 4; // At least one quote in the game requires 4 lines to be displayed correctly
+ static const int kStartFromSubtitleLineFromTop = 2; // Prefer drawing from this line (the top-most of available subtitle lines index is 0) by default
+ static const int kSubtitlesBottomYOffsetPx = 12; // In pixels. This is the bottom margin beneath the subtitles space
+ static const int kMaxWidthPerLineToAutoSplitThresholdPx = 610; // In pixels
+ static const int kMaxTextResourceEntries = 1 + 25; // Support in-game subs (1) and all possible VQAs (25) with spoken dialogue or translatable text
static const char *SUBTITLES_FILENAME_PREFIXES[kMaxTextResourceEntries];
static const char *SUBTITLES_FONT_FILENAME_EXTERNAL;
-
+ static const char *SUBTITLES_VERSION_TRENAME;
BladeRunnerEngine *_vm;
+ struct SubtitlesInfo {
+ Common::String versionStr;
+ Common::String dateOfCompile;
+ Common::String languageMode;
+ Common::String credits;
+ };
+
+ SubtitlesInfo _subtitlesInfo;
TextResource *_vqaSubsTextResourceEntries[kMaxTextResourceEntries];
Font *_subsFont;
@@ -69,21 +75,23 @@ 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
- bool _subtitlesSystemActive; // true if the whole subtitles subsystem should be disabled (due to missing required resources)
+ bool _gameSubsResourceEntriesFound[kMaxTextResourceEntries]; // false if a TRE file did not open successfully
+ bool _subsFontsLoaded; // false if external fonts did not load
+ bool _subtitlesSystemActive; // true if the whole subtitles subsystem should be disabled (due to missing required resources)
public:
Subtitles(BladeRunnerEngine *vm);
~Subtitles();
bool isSystemActive() const { return _subtitlesSystemActive; }
+ bool isSubsFontsLoaded() const { return _subsFontsLoaded; }
void init();
+ SubtitlesInfo getSubtitlesInfo() const;
const char *getInGameSubsText(int actorId, int speech_id); // get the text for actorId, quoteId (in-game subs)
const char *getOuttakeSubsText(const Common::String &outtakesName, int frame); // get the text for this frame if any
- void setGameSubsText(Common::String dbgQuote, bool force); // for debugging - explicit set subs text
+ void setGameSubsText(Common::String dbgQuote, bool force); // for debugging - explicit set subs text
bool show();
bool hide();
bool isVisible() const;
diff --git a/engines/bladerunner/text_resource.cpp b/engines/bladerunner/text_resource.cpp
index 8afc0a3c75..f6d9657376 100644
--- a/engines/bladerunner/text_resource.cpp
+++ b/engines/bladerunner/text_resource.cpp
@@ -43,10 +43,15 @@ TextResource::~TextResource() {
delete[] _strings;
}
-bool TextResource::open(const Common::String &name) {
+bool TextResource::open(const Common::String &name, bool localized) {
assert(name.size() <= 8);
- Common::String resName = Common::String::format("%s.TR%s", name.c_str(), _vm->_languageCode.c_str());
+ Common::String resName;
+ if (localized) {
+ resName = Common::String::format("%s.TR%s", name.c_str(), _vm->_languageCode.c_str());
+ } else {
+ resName = Common::String::format("%s.TRE", name.c_str());
+ }
Common::ScopedPtr<Common::SeekableReadStream> s(_vm->getResourceStream(resName));
if (!s) {
warning("TextResource::open(): Can not open %s", resName.c_str());
diff --git a/engines/bladerunner/text_resource.h b/engines/bladerunner/text_resource.h
index c9706ac397..3c694e38ea 100644
--- a/engines/bladerunner/text_resource.h
+++ b/engines/bladerunner/text_resource.h
@@ -42,7 +42,7 @@ public:
TextResource(BladeRunnerEngine *vm);
~TextResource();
- bool open(const Common::String &name);
+ bool open(const Common::String &name, bool localized = true);
const char *getText(uint32 id) const;
const char *getOuttakeTextByFrame(uint32 frame) const;