[Scummvm-git-logs] scummvm master -> 6ad5245fe49418f732c405843f1fc5ed0989f802
Scorpeg
noreply at scummvm.org
Thu Nov 19 15:11:51 UTC 2026
This automated email contains information about 16 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
fee43a00ca HAROLD: BCB: Load and parse translation packages
7768dea850 HAROLD: BCB: Translate choices, map labels and system dialogs
4f04c739af HAROLD: BCB: Add translation selection to game options
ceaa1f54b3 HAROLD: BCB: Apply translated artwork and render image labels
619a5e39e8 HAROLD: BCB: Format engine sources with clang-format
e483aab12b HAROLD: BCB: Render translated computer cards from translation packages
b8db970022 HAROLD: BCB: Optimize translation rendering and refine computer and movie presentation
18cdcfea87 HAROLD: BCB: Keep ending movie backdrops black during disc transitions
a0c26d1980 HAROLD: BCB: Render translated endings and simplify card text layouts
f16e609672 HAROLD: BCB: Correct ending image order to match LaserActive
5cc35cf4c7 HAROLD: BCB: Add Cinema Disk viewer and Mac image fallbacks
a74ec882c1 HAROLD: BCB: Fix translation rendering and remove HarfBuzz
6b0cb138aa HAROLD: Fix build with BCB subengine disabled
f7150da945 GUI: Expose game options label and spacing in themes
fc9495925a DEVTOOLS: Add Harold engine data resources
6ad5245fe4 HAROLD: BCB: Load shared engine data
Commit: fee43a00ca67992febe1bb9a0a9bc0c475eb0309
https://github.com/scummvm/scummvm/commit/fee43a00ca67992febe1bb9a0a9bc0c475eb0309
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:12+03:00
Commit Message:
HAROLD: BCB: Load and parse translation packages
Changed paths:
A engines/harold/bcb/translation.cpp
A engines/harold/bcb/translation.h
engines/harold/module.mk
diff --git a/engines/harold/bcb/translation.cpp b/engines/harold/bcb/translation.cpp
new file mode 100644
index 00000000000..98fe8b29da3
--- /dev/null
+++ b/engines/harold/bcb/translation.cpp
@@ -0,0 +1,247 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/archive.h"
+#include "common/compression/unzip.h"
+#include "common/fs.h"
+#include "common/language.h"
+#include "common/ptr.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+#include "common/util.h"
+
+#include "harold/bcb/translation.h"
+
+namespace BCB {
+namespace {
+
+Common::String getTranslationStringFileName(const Common::String &code) {
+ return Common::String::format("strings_%s.yml", code.c_str());
+}
+
+bool getTranslationPackageCode(const Common::String &fileName, Common::String &code) {
+ static const char *const prefix = "bcb-translation-";
+ static const char *const suffix = ".dat";
+
+ Common::String lowerFileName = fileName;
+ lowerFileName.toLowercase();
+ if (!lowerFileName.hasPrefix(prefix) || !lowerFileName.hasSuffix(suffix))
+ return false;
+
+ code = lowerFileName.substr(strlen(prefix), lowerFileName.size() - strlen(prefix) - strlen(suffix));
+ return !code.empty();
+}
+
+Common::String getTranslationPackageDisplayName(const Common::String &code) {
+ const Common::Language language = Common::parseLanguage(code);
+ const char *description = Common::getLanguageDescription(language);
+ return description ? Common::String(description) : code;
+}
+
+bool packageHasMatchingStrings(const Common::FSNode &packageNode, const Common::String &code) {
+ Common::Archive *archive = Common::makeZipArchive(packageNode, false);
+ if (!archive)
+ return false;
+
+ const bool hasStrings = archive->hasFile(Common::Path(getTranslationStringFileName(code), '/'));
+ delete archive;
+ return hasStrings;
+}
+
+int parseHexByte(const char *text) {
+ uint value = 0;
+ if (sscanf(text, "%02x", &value) != 1)
+ return -1;
+ return value & 0xff;
+}
+
+Common::String unescapeQuotedString(Common::String value) {
+ if (value.hasPrefix("\"") && value.hasSuffix("\"")) {
+ value.deleteChar(0);
+ value.deleteLastChar();
+ }
+
+ for (uint i = 0; i < value.size(); ++i) {
+ if (value[i] != '\\' || i + 1 >= value.size())
+ continue;
+
+ const char escaped = value[i + 1];
+ if (escaped == 'n' || escaped == 'r') {
+ value.deleteChar(i);
+ value.setChar('\n', i);
+ } else if (escaped == 't') {
+ value.deleteChar(i);
+ value.setChar('\t', i);
+ } else if (escaped == '\\' || escaped == '"') {
+ value.deleteChar(i);
+ } else if (escaped == 'x' && i + 3 < value.size()) {
+ const int byteValue = parseHexByte(value.c_str() + i + 2);
+ if (byteValue < 0)
+ error("BCB translation string has invalid hex escape near \"%s\"", value.c_str() + i);
+ value.deleteChar(i);
+ value.deleteChar(i);
+ value.deleteChar(i);
+ value.setChar((char)byteValue, i);
+ }
+ }
+
+ return value;
+}
+
+} // End of anonymous namespace
+
+bool TextStringTable::load(Common::SeekableReadStream *stream) {
+ Common::ScopedPtr<Common::SeekableReadStream> textStream(stream);
+ if (!textStream)
+ return false;
+
+ clear();
+
+ Common::Array<Common::String> prefixKeys;
+ while (!textStream->eos()) {
+ Common::String line = textStream->readLine();
+ Common::String lineTrimmed = line;
+ lineTrimmed.trim();
+ if (lineTrimmed.empty() || lineTrimmed.hasPrefix("#"))
+ continue;
+
+ size_t indent = 0;
+ while (line.hasPrefix("\t")) {
+ line.deleteChar(0);
+ ++indent;
+ }
+
+ const size_t separator = line.findFirstOf(":");
+ if (separator == Common::String::npos)
+ error("BCB translation string line encountered without colon");
+
+ Common::String key(line.c_str(), line.c_str() + separator);
+ Common::String value(line.c_str() + separator + 1);
+ key.trim();
+ value.trim();
+
+ if (indent > prefixKeys.size())
+ error("BCB translation string table has incorrect indentation");
+ prefixKeys.resize(indent);
+
+ if (value.empty()) {
+ prefixKeys.push_back(key);
+ continue;
+ }
+
+ Common::String fullKey;
+ for (uint i = 0; i < prefixKeys.size(); ++i) {
+ fullKey += prefixKeys[i];
+ fullKey += ".";
+ }
+ fullKey += key;
+
+ (*this)[fullKey] = unescapeQuotedString(value);
+ }
+
+ return true;
+}
+
+const char *TextStringTable::getString(const Common::String &key) const {
+ const_iterator entry = find(key);
+ return entry == end() ? nullptr : entry->_value.c_str();
+}
+
+TextTranslationData::TextTranslationData() : packageArchive(nullptr) {
+}
+
+TextTranslationData::~TextTranslationData() {
+ clear();
+}
+
+void TextTranslationData::clear() {
+ strings.clear();
+ delete packageArchive;
+ packageArchive = nullptr;
+}
+
+Common::String makeTextStringKey(TextTranslationType type, uint primaryId, uint secondaryId) {
+ switch (type) {
+ case kTextTranslationSceneChoice:
+ return Common::String::format("scene_choices.%u.%u", primaryId, secondaryId);
+ case kTextTranslationMapButton:
+ return Common::String::format("map.%u", primaryId);
+ case kTextTranslationGameOver:
+ return Common::String::format("game_over.%u", primaryId);
+ case kTextTranslationSceneChoiceMove:
+ return "system.scene_choice_move";
+ }
+
+ return "";
+}
+
+void listAvailableTranslationPackages(const Common::FSNode &gameDataDir, Common::Array<TranslationPackageDefinition> &packages) {
+ packages.clear();
+
+ Common::FSList children;
+ if (!gameDataDir.getChildren(children, Common::FSNode::kListFilesOnly))
+ return;
+
+ for (Common::FSList::const_iterator it = children.begin(); it != children.end(); ++it) {
+ Common::String code;
+ const Common::String fileName = it->getName();
+ if (!getTranslationPackageCode(fileName, code))
+ continue;
+ if (!packageHasMatchingStrings(*it, code))
+ continue;
+
+ TranslationPackageDefinition definition;
+ definition.code = code;
+ definition.displayName = getTranslationPackageDisplayName(code);
+ definition.fileName = fileName;
+ packages.push_back(definition);
+ }
+}
+
+bool isTranslationPackageAvailable(const Common::FSNode &gameDataDir, const Common::String &code) {
+ return packageHasMatchingStrings(gameDataDir.getChild(Common::String::format("bcb-translation-%s.dat", code.c_str())), code);
+}
+
+bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::String &code, TextTranslationData &translation) {
+ translation.clear();
+
+ const Common::FSNode packageNode = gameDataDir.getChild(Common::String::format("bcb-translation-%s.dat", code.c_str()));
+ translation.packageArchive = Common::makeZipArchive(packageNode, false);
+ if (!translation.packageArchive)
+ return false;
+
+ if (!translation.strings.load(translation.packageArchive->createReadStreamForMember(Common::Path(getTranslationStringFileName(code), '/')))) {
+ translation.clear();
+ return false;
+ }
+
+ return true;
+}
+
+const char *getTextTranslation(const TextTranslationData &translation, TextTranslationType type, uint primaryId, uint secondaryId) {
+ return translation.strings.getString(makeTextStringKey(type, primaryId, secondaryId));
+}
+
+const char *getSystemTextTranslation(const TextTranslationData &translation, const char *key) {
+ return translation.strings.getString(Common::String::format("system.%s", key));
+}
+
+} // End of namespace BCB
diff --git a/engines/harold/bcb/translation.h b/engines/harold/bcb/translation.h
new file mode 100644
index 00000000000..7a1e748f381
--- /dev/null
+++ b/engines/harold/bcb/translation.h
@@ -0,0 +1,82 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef BCB_TRANSLATION_H
+#define BCB_TRANSLATION_H
+
+#include "common/array.h"
+#include "common/hash-str.h"
+#include "common/scummsys.h"
+#include "common/str.h"
+
+namespace Common {
+class Archive;
+class FSNode;
+class SeekableReadStream;
+}
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace BCB {
+
+struct TranslationPackageDefinition {
+ Common::String code;
+ Common::String displayName;
+ Common::String fileName;
+};
+
+enum TextTranslationType {
+ kTextTranslationSceneChoice,
+ kTextTranslationMapButton,
+ kTextTranslationGameOver,
+ kTextTranslationSceneChoiceMove
+};
+
+class TextStringTable : public Common::StringMap {
+public:
+ bool load(Common::SeekableReadStream *stream);
+ const char *getString(const Common::String &key) const;
+};
+
+class TextTranslationData {
+public:
+ TextTranslationData();
+ ~TextTranslationData();
+
+ void clear();
+
+ TextStringTable strings;
+ Common::Archive *packageArchive;
+};
+
+Common::String makeTextStringKey(TextTranslationType type, uint primaryId, uint secondaryId);
+void listAvailableTranslationPackages(const Common::FSNode &gameDataDir, Common::Array<TranslationPackageDefinition> &packages);
+bool isTranslationPackageAvailable(const Common::FSNode &gameDataDir, const Common::String &code);
+bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::String &code, TextTranslationData &translation);
+
+const char *getTextTranslation(const TextTranslationData &translation, TextTranslationType type, uint primaryId, uint secondaryId);
+const char *getSystemTextTranslation(const TextTranslationData &translation, const char *key);
+
+} // End of namespace BCB
+
+#endif
diff --git a/engines/harold/module.mk b/engines/harold/module.mk
index 490fc1a6c38..5a345495745 100644
--- a/engines/harold/module.mk
+++ b/engines/harold/module.mk
@@ -18,6 +18,7 @@ MODULE_OBJS += \
bcb/screens.o \
bcb/script.o \
bcb/static_data.o \
+ bcb/translation.o \
bcb/video.o
endif
Commit: 7768dea85012ce0c1f9b22c7844d33e88f066bdb
https://github.com/scummvm/scummvm/commit/7768dea85012ce0c1f9b22c7844d33e88f066bdb
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:12+03:00
Commit Message:
HAROLD: BCB: Translate choices, map labels and system dialogs
Changed paths:
engines/harold/bcb/bcb.cpp
engines/harold/bcb/bcb.h
engines/harold/bcb/input.cpp
engines/harold/bcb/map.cpp
engines/harold/bcb/saveload.cpp
engines/harold/bcb/scene.cpp
engines/harold/bcb/screens.cpp
engines/harold/bcb/translation.cpp
diff --git a/engines/harold/bcb/bcb.cpp b/engines/harold/bcb/bcb.cpp
index 36edbf08992..e90ac3dfaa8 100644
--- a/engines/harold/bcb/bcb.cpp
+++ b/engines/harold/bcb/bcb.cpp
@@ -126,6 +126,12 @@ Common::Error BCBEngine::run() {
if (!initializeSearchPaths())
return Common::kPathDoesNotExist;
+ const Common::String languageCode = ConfMan.get("bcb_text_language");
+ _selectedTextLanguagePackageAvailable = !languageCode.empty() &&
+ loadTranslationPackage(Common::FSNode(ConfMan.getPath("path")), languageCode, _textTranslation);
+ if (!languageCode.empty() && !_selectedTextLanguagePackageAvailable)
+ warning("BCB: Translation package '%s' is unavailable; using original text", languageCode.c_str());
+
initGraphics(640, 480, &screenFormat);
_screen = new Graphics::Screen(640, 480, g_system->getScreenFormat());
CursorMan.lock(false);
diff --git a/engines/harold/bcb/bcb.h b/engines/harold/bcb/bcb.h
index d3a95d06502..f7c32052106 100644
--- a/engines/harold/bcb/bcb.h
+++ b/engines/harold/bcb/bcb.h
@@ -32,6 +32,7 @@
#include "common/ustr.h"
#include "engines/engine.h"
#include "harold/bcb/ui.h"
+#include "harold/bcb/translation.h"
#include "harold/detection.h"
namespace Graphics {
@@ -227,8 +228,10 @@ private:
void delayWithEventPolling(uint32 millis);
void delayWithEventPolling(uint32 millis, bool handleClicks);
Common::U32String decodeExecutableTextForDisplay(const Common::String &text) const;
- Common::U32String formatSystemTextForDisplay(const Common::String &originalFormat, int slot) const;
- Common::U32String formatSystemClockTextForDisplay(const Common::String &originalFormat, int slot, int savedDay, int savedClockTicks) const;
+ Common::U32String translateTextForDisplay(TextTranslationType type, uint primaryId, uint secondaryId, const Common::U32String &originalText, bool *translated = nullptr) const;
+ Common::U32String translateSystemTextForDisplay(const char *key, const Common::U32String &originalText, bool *translated = nullptr) const;
+ Common::U32String formatSystemTextForDisplay(const char *key, const Common::String &originalSjisFormat, int arg1) const;
+ Common::U32String formatSystemClockTextForDisplay(const char *key, const Common::String &originalSjisFormat, int slot, int savedDay, int savedClockTicks) const;
void mainLoop();
const HaroldGameDescription *_gameDescription;
@@ -255,6 +258,8 @@ private:
Common::String _saveSlotEmptyConfirmTextFormatSjis;
Common::String _noSaveDataMessageSjis;
Common::String _returnToTitleConfirmTextSjis;
+ TextTranslationData _textTranslation;
+ bool _selectedTextLanguagePackageAvailable = false;
Graphics::FontSJIS *_sjisFont = nullptr;
const Graphics::Font *_captionTextFont = nullptr;
const Graphics::Font *_gameOverTextFont = nullptr;
diff --git a/engines/harold/bcb/input.cpp b/engines/harold/bcb/input.cpp
index 7b3712cd32e..2c41866982f 100644
--- a/engines/harold/bcb/input.cpp
+++ b/engines/harold/bcb/input.cpp
@@ -157,7 +157,7 @@ void BCBEngine::handleLeftButtonDown(const Common::Point &mousePosition) {
restoreTitleScreenRegion(Common::Rect(0, 0, 640, 480));
}
drawTitleButton(i, false);
- if (showSystemConfirmationDialog(_titleExitConfirmText, true))
+ if (showSystemConfirmationDialog(translateSystemTextForDisplay("title_exit_confirm", _titleExitConfirmText), true))
quitGame();
break;
default:
diff --git a/engines/harold/bcb/map.cpp b/engines/harold/bcb/map.cpp
index 51943408a13..424d705b1e6 100644
--- a/engines/harold/bcb/map.cpp
+++ b/engines/harold/bcb/map.cpp
@@ -135,7 +135,12 @@ void BCBEngine::composeMapControlsToSurface(Graphics::Surface &surface, const Gr
const int textX = button.x + 0x14;
const int textY = button.y - (_gameDescription->desc.language == Common::KO_KOR ? 5 : 4);
const int textWidth = MAX<int>(0, surface.w - textX - 2);
- if (_gameDescription->desc.language == Common::JA_JPN && _sjisFont) {
+ bool translated = false;
+ const Common::U32String displayText = translateTextForDisplay(kTextTranslationMapButton, i, 0, _mapButtonText[i], &translated);
+ if (translated && _ownerDrawUiTextFont) {
+ _ownerDrawUiTextFont->drawString(&surface, displayText, textX + 1, textY + 1, textWidth, shadowColor, Graphics::kTextAlignLeft);
+ _ownerDrawUiTextFont->drawString(&surface, displayText, textX, textY, textWidth, textColor, Graphics::kTextAlignLeft);
+ } else if (_gameDescription->desc.language == Common::JA_JPN && _sjisFont) {
int x = textX + 1;
for (const byte *text = reinterpret_cast<const byte *>(_mapButtonTextSjis[i].c_str()); *text;) {
const byte firstByte = *text++;
diff --git a/engines/harold/bcb/saveload.cpp b/engines/harold/bcb/saveload.cpp
index 89a76adaa92..184f9402528 100644
--- a/engines/harold/bcb/saveload.cpp
+++ b/engines/harold/bcb/saveload.cpp
@@ -435,9 +435,9 @@ void BCBEngine::drawSystemSaveLoadSlots(bool present) {
int savedClockTicks = 0;
Common::U32String slotText;
if (readSaveSlotHeader(slot, savedDay, savedClockTicks)) {
- slotText = formatSystemClockTextForDisplay(_saveSlotOccupiedTextFormatSjis, slot, savedDay, savedClockTicks);
+ slotText = formatSystemClockTextForDisplay("save_slot_occupied", _saveSlotOccupiedTextFormatSjis, slot, savedDay, savedClockTicks);
} else {
- slotText = formatSystemTextForDisplay(_saveSlotEmptyTextFormatSjis, slot);
+ slotText = formatSystemTextForDisplay("save_slot_empty", _saveSlotEmptyTextFormatSjis, slot);
}
Graphics::Surface *screen = _screen->surfacePtr();
@@ -497,7 +497,7 @@ bool BCBEngine::handleSystemClick(const Common::Point &mousePosition) {
playUiSound();
_systemSaveLoadSlotActionMode = 0;
showSystemScreen();
- if (showSystemConfirmationDialog(decodeExecutableTextForDisplay(_returnToTitleConfirmTextSjis), true)) {
+ if (showSystemConfirmationDialog(translateSystemTextForDisplay("return_to_title_confirm", decodeExecutableTextForDisplay(_returnToTitleConfirmTextSjis)), true)) {
stopMenuBackgroundMusic();
resetGameState();
showTitleScreen();
@@ -539,9 +539,9 @@ bool BCBEngine::handleSaveLoadSlotClick(const Common::Point &mousePosition) {
int savedClockTicks = 0;
Common::U32String message;
if (readSaveSlotHeader(slot, savedDay, savedClockTicks)) {
- message = formatSystemClockTextForDisplay(_saveSlotOverwriteConfirmTextFormatSjis, slot, savedDay, savedClockTicks);
+ message = formatSystemClockTextForDisplay("save_slot_overwrite_confirm", _saveSlotOverwriteConfirmTextFormatSjis, slot, savedDay, savedClockTicks);
} else {
- message = formatSystemTextForDisplay(_saveSlotEmptyConfirmTextFormatSjis, slot);
+ message = formatSystemTextForDisplay("save_slot_empty_confirm", _saveSlotEmptyConfirmTextFormatSjis, slot);
}
if (showSystemConfirmationDialog(message, true)) {
@@ -555,10 +555,10 @@ bool BCBEngine::handleSaveLoadSlotClick(const Common::Point &mousePosition) {
int savedDay = 0;
int savedClockTicks = 0;
if (!readSaveSlotHeader(slot, savedDay, savedClockTicks)) {
- showSystemConfirmationDialog(decodeExecutableTextForDisplay(_noSaveDataMessageSjis), false);
+ showSystemConfirmationDialog(translateSystemTextForDisplay("no_save_data", decodeExecutableTextForDisplay(_noSaveDataMessageSjis)), false);
return true;
}
- Common::U32String message = formatSystemClockTextForDisplay(_loadSlotConfirmTextFormatSjis, slot, savedDay, savedClockTicks);
+ Common::U32String message = formatSystemClockTextForDisplay("load_slot_confirm", _loadSlotConfirmTextFormatSjis, slot, savedDay, savedClockTicks);
if (showSystemConfirmationDialog(message, true)) {
_titleLoadSlotsActive = false;
loadGameState(slot);
@@ -690,16 +690,4 @@ void BCBEngine::returnFromSystemMenuToPreviousState() {
processGameStateDispatcher(false);
}
-Common::U32String BCBEngine::formatSystemTextForDisplay(const Common::String &originalFormat, int slot) const {
- const Common::String formatted = Common::String::format(originalFormat.c_str(), slot);
- return decodeExecutableTextForDisplay(formatted);
-}
-
-Common::U32String BCBEngine::formatSystemClockTextForDisplay(const Common::String &originalFormat, int slot, int savedDay, int savedClockTicks) const {
- const int hour = savedClockTicks / 60;
- const int minute = savedClockTicks % 60;
- const Common::String formatted = Common::String::format(originalFormat.c_str(), slot, savedDay, hour, minute);
- return decodeExecutableTextForDisplay(formatted);
-}
-
} // End of namespace BCB
diff --git a/engines/harold/bcb/scene.cpp b/engines/harold/bcb/scene.cpp
index ec3f4b37850..3235ea9834d 100644
--- a/engines/harold/bcb/scene.cpp
+++ b/engines/harold/bcb/scene.cpp
@@ -190,7 +190,7 @@ void BCBEngine::drawSceneChoiceButtons(int sceneChoiceUiSetToShowId, bool presen
const uint32 pressedTextColor = screen->format.RGBToColor(0x8c, 0x3c, 0x05);
const Common::Array<Common::U32String> &originalLabels = _sceneChoiceText[sceneChoiceUiSetToShowId];
const auto getChoiceLabel = [&](uint choiceIndex) -> Common::U32String {
- return originalLabels[choiceIndex];
+ return translateTextForDisplay(kTextTranslationSceneChoice, sceneChoiceUiSetToShowId, choiceIndex, originalLabels[choiceIndex]);
};
const auto drawChoiceLabel = [&](const Common::U32String &label, int buttonIndex) {
if (!font)
@@ -236,7 +236,7 @@ void BCBEngine::drawSceneChoiceButtons(int sceneChoiceUiSetToShowId, bool presen
stateDword(kStateSceneChoiceExtraButtonFlag) != 0 &&
_sceneChoiceTerminatorButtonIndex > 0 &&
_sceneChoiceTerminatorButtonIndex < (int)ARRAYSIZE(kSceneChoiceButtonTable)) {
- drawChoiceLabel(_sceneChoiceMoveText, _sceneChoiceTerminatorButtonIndex);
+ drawChoiceLabel(translateTextForDisplay(kTextTranslationSceneChoiceMove, 0, 0, _sceneChoiceMoveText), _sceneChoiceTerminatorButtonIndex);
}
if (present)
diff --git a/engines/harold/bcb/screens.cpp b/engines/harold/bcb/screens.cpp
index 819d238faec..986747e9153 100644
--- a/engines/harold/bcb/screens.cpp
+++ b/engines/harold/bcb/screens.cpp
@@ -164,7 +164,7 @@ bool BCBEngine::dispatchGameOverScreen() {
const uint32 white = gameOver->format.RGBToColor(255, 255, 255);
const Common::Rect textRect(100, 200, 540, 400);
if (_gameOverTextFont) {
- const Common::U32String &text = _gameOverText[selectedSceneChoiceValue];
+ const Common::U32String text = translateTextForDisplay(kTextTranslationGameOver, selectedSceneChoiceValue, 0, _gameOverText[selectedSceneChoiceValue]);
int y = textRect.top - (_gameDescription->desc.language == Common::KO_KOR ? 1 : 0);
for (uint lineStart = 0; lineStart < text.size() && y < textRect.bottom;) {
uint lineEnd = lineStart;
diff --git a/engines/harold/bcb/translation.cpp b/engines/harold/bcb/translation.cpp
index 98fe8b29da3..dbc412b77e9 100644
--- a/engines/harold/bcb/translation.cpp
+++ b/engines/harold/bcb/translation.cpp
@@ -29,6 +29,7 @@
#include "common/util.h"
#include "harold/bcb/translation.h"
+#include "harold/bcb/bcb.h"
namespace BCB {
namespace {
@@ -244,4 +245,70 @@ const char *getSystemTextTranslation(const TextTranslationData &translation, con
return translation.strings.getString(Common::String::format("system.%s", key));
}
+Common::U32String BCBEngine::translateTextForDisplay(TextTranslationType type, uint primaryId, uint secondaryId, const Common::U32String &originalText, bool *translated) const {
+ if (translated)
+ *translated = false;
+
+ if (!_selectedTextLanguagePackageAvailable)
+ return originalText;
+
+ const char *translatedText = getTextTranslation(_textTranslation, type, primaryId, secondaryId);
+ if (!translatedText || !translatedText[0])
+ return originalText;
+
+ if (translated)
+ *translated = true;
+ return Common::U32String(translatedText);
+}
+
+Common::U32String BCBEngine::translateSystemTextForDisplay(const char *key, const Common::U32String &originalText, bool *translated) const {
+ if (translated)
+ *translated = false;
+
+ if (!_selectedTextLanguagePackageAvailable)
+ return originalText;
+
+ const char *translatedText = getSystemTextTranslation(_textTranslation, key);
+ if (!translatedText || !translatedText[0])
+ return originalText;
+
+ if (translated)
+ *translated = true;
+ return Common::U32String(translatedText);
+}
+
+Common::U32String BCBEngine::formatSystemTextForDisplay(const char *key, const Common::String &originalSjisFormat, int arg1) const {
+ const char *translatedFormat = _selectedTextLanguagePackageAvailable ? getSystemTextTranslation(_textTranslation, key) : nullptr;
+ if (translatedFormat && translatedFormat[0]) {
+ const Common::String formatted = Common::String::format(translatedFormat, arg1);
+ return Common::U32String(formatted.c_str());
+ }
+
+ const Common::String formatted = Common::String::format(originalSjisFormat.c_str(), arg1);
+ return decodeExecutableTextForDisplay(formatted);
+}
+
+Common::U32String BCBEngine::formatSystemClockTextForDisplay(const char *key, const Common::String &originalSjisFormat, int slot, int savedDay, int savedClockTicks) const {
+ const char *translatedFormat = _selectedTextLanguagePackageAvailable ? getSystemTextTranslation(_textTranslation, key) : nullptr;
+ if (translatedFormat && translatedFormat[0]) {
+ const int clockTicks = savedClockTicks % (24 * 60);
+ const int hour24 = clockTicks / 60;
+ const int minute = clockTicks % 60;
+ const int hour12 = hour24 % 12 == 0 ? 12 : hour24 % 12;
+ Common::String formatted(translatedFormat);
+ Common::replace(formatted, "{slot}", Common::String::format("%d", slot));
+ Common::replace(formatted, "{day}", Common::String::format("%d", 10 + savedDay));
+ Common::replace(formatted, "{hour24}", Common::String::format("%d", hour24));
+ Common::replace(formatted, "{hour12}", Common::String::format("%d", hour12));
+ Common::replace(formatted, "{min}", Common::String::format("%02d", minute));
+ Common::replace(formatted, "{ampm}", hour24 < 12 ? "AM" : "PM");
+ return Common::U32String(formatted.c_str());
+ }
+
+ const int hour = savedClockTicks / 60;
+ const int minute = savedClockTicks % 60;
+ const Common::String formatted = Common::String::format(originalSjisFormat.c_str(), slot, savedDay, hour, minute);
+ return decodeExecutableTextForDisplay(formatted);
+}
+
} // End of namespace BCB
Commit: 4f04c739af05fd5d13c42735089a7da07272fcab
https://github.com/scummvm/scummvm/commit/4f04c739af05fd5d13c42735089a7da07272fcab
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:12+03:00
Commit Message:
HAROLD: BCB: Add translation selection to game options
Changed paths:
A engines/harold/bcb/options.cpp
A engines/harold/bcb/options.h
engines/harold/metaengine.cpp
engines/harold/module.mk
diff --git a/engines/harold/bcb/options.cpp b/engines/harold/bcb/options.cpp
new file mode 100644
index 00000000000..54313700472
--- /dev/null
+++ b/engines/harold/bcb/options.cpp
@@ -0,0 +1,125 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/config-manager.h"
+#include "common/fs.h"
+#include "common/str-array.h"
+#include "common/translation.h"
+#include "gui/ThemeEval.h"
+#include "gui/gui-manager.h"
+#include "gui/widget.h"
+#include "gui/widgets/popup.h"
+#include "harold/bcb/options.h"
+#include "harold/bcb/translation.h"
+
+namespace BCB {
+
+static const char *const kTextLanguageConfigKey = "bcb_text_language";
+
+class BCBOptionsWidget : public GUI::OptionsContainerWidget {
+public:
+ BCBOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &domain);
+
+ void load() override;
+ bool save() override;
+
+private:
+ void defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const override;
+
+ Common::StringArray _languageCodes;
+ GUI::PopUpWidget *_textLanguagePopUp;
+};
+
+BCBOptionsWidget::BCBOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &domain) :
+ OptionsContainerWidget(boss, name, "BCBGameOptionsDialog", domain),
+ _textLanguagePopUp(nullptr) {
+
+ GUI::StaticTextWidget *languageLabel = new GUI::StaticTextWidget(
+ widgetsBoss(),
+ _dialogLayout + ".text_language_desc",
+ _("Translation:"),
+ _("Select a text translation package. Original language is used when no package is selected."));
+ languageLabel->setAlign(Graphics::kTextAlignRight);
+
+ _textLanguagePopUp = new GUI::PopUpWidget(
+ widgetsBoss(),
+ _dialogLayout + ".text_language",
+ _("Select a text translation package. Original language is used when no package is selected."));
+
+ _languageCodes.push_back("");
+ _textLanguagePopUp->appendEntry(_("Original"), 0);
+
+ const Common::FSNode gameDataDir(ConfMan.getPath("path", domain));
+ Common::Array<TranslationPackageDefinition> packages;
+ listAvailableTranslationPackages(gameDataDir, packages);
+ for (uint i = 0; i < packages.size(); ++i) {
+ const TranslationPackageDefinition &package = packages[i];
+ _languageCodes.push_back(package.code);
+ _textLanguagePopUp->appendEntry(package.displayName.c_str(), _languageCodes.size() - 1);
+ }
+}
+
+void BCBOptionsWidget::load() {
+ uint32 selectedTag = 0;
+ Common::ConfigManager::Domain *gameConfig = ConfMan.getDomain(_domain);
+ if (gameConfig) {
+ Common::String selectedCode;
+ gameConfig->tryGetVal(kTextLanguageConfigKey, selectedCode);
+ for (uint i = 0; i < _languageCodes.size(); ++i) {
+ if (_languageCodes[i].equalsIgnoreCase(selectedCode)) {
+ selectedTag = i;
+ break;
+ }
+ }
+ }
+
+ _textLanguagePopUp->setSelectedTag(selectedTag);
+}
+
+bool BCBOptionsWidget::save() {
+ const uint32 selectedTag = _textLanguagePopUp->getSelectedTag();
+ if (selectedTag > 0 && selectedTag < _languageCodes.size())
+ ConfMan.set(kTextLanguageConfigKey, _languageCodes[selectedTag], _domain);
+ else
+ ConfMan.removeKey(kTextLanguageConfigKey, _domain);
+
+ return true;
+}
+
+void BCBOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {
+ layouts.addDialog(layoutName, overlayedLayout);
+ const bool lowResGui = g_gui.useLowResGUI();
+ const int labelWidth = lowResGui ? 125 : 115;
+ const int leftInset = 1;
+ const int rowSpacing = lowResGui ? 6 : 10;
+ const int lineHeight = layouts.getVar("Globals.Line.Height");
+ layouts.addLayout(GUI::ThemeLayout::kLayoutVertical).addPadding(leftInset, 0, 0, 0);
+ layouts.addLayout(GUI::ThemeLayout::kLayoutHorizontal, rowSpacing, GUI::ThemeLayout::kItemAlignCenter).addPadding(0, 0, 0, 0);
+ layouts.addWidget("text_language_desc", "", labelWidth, lineHeight, Graphics::kTextAlignEnd);
+ layouts.addWidget("text_language", "PopUp").closeLayout();
+ layouts.closeLayout().closeDialog();
+}
+
+GUI::OptionsContainerWidget *createTranslationOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) {
+ return new BCBOptionsWidget(boss, name, target);
+}
+
+} // End of namespace BCB
diff --git a/engines/harold/bcb/options.h b/engines/harold/bcb/options.h
new file mode 100644
index 00000000000..ec3253f5d05
--- /dev/null
+++ b/engines/harold/bcb/options.h
@@ -0,0 +1,36 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef HAROLD_BCB_OPTIONS_H
+#define HAROLD_BCB_OPTIONS_H
+
+#include "common/str.h"
+
+namespace GUI {
+class GuiObject;
+class OptionsContainerWidget;
+}
+
+namespace BCB {
+GUI::OptionsContainerWidget *createTranslationOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target);
+}
+
+#endif
diff --git a/engines/harold/metaengine.cpp b/engines/harold/metaengine.cpp
index 1c82ff590db..f85faa11d9c 100644
--- a/engines/harold/metaengine.cpp
+++ b/engines/harold/metaengine.cpp
@@ -20,6 +20,7 @@
*/
#include "common/events.h"
+#include "common/config-manager.h"
#include "common/translation.h"
#include "backends/keymapper/action.h"
@@ -29,6 +30,7 @@
#include "engines/advancedDetector.h"
#include "harold/bcb/bcb.h"
+#include "harold/bcb/options.h"
#include "harold/detection.h"
class HaroldMetaEngine : public AdvancedMetaEngine<BCB::HaroldGameDescription> {
@@ -39,6 +41,7 @@ public:
int getMaximumSaveSlot() const override { return 8; }
bool hasFeature(MetaEngineFeature f) const override;
+ GUI::OptionsContainerWidget *buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
Common::KeymapArray initKeymaps(const char *target) const override;
Common::Error createInstance(OSystem *syst, Engine **engine, const BCB::HaroldGameDescription *gd) const override;
};
@@ -47,6 +50,12 @@ bool HaroldMetaEngine::hasFeature(MetaEngineFeature f) const {
return checkExtendedSaves(f);
}
+GUI::OptionsContainerWidget *HaroldMetaEngine::buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
+ if (!ConfMan.get("gameid", target).equalsIgnoreCase("bcb"))
+ return nullptr;
+ return BCB::createTranslationOptionsWidget(boss, name, target);
+}
+
Common::KeymapArray HaroldMetaEngine::initKeymaps(const char *target) const {
using namespace Common;
using namespace BCB;
diff --git a/engines/harold/module.mk b/engines/harold/module.mk
index 5a345495745..6b20062c6c6 100644
--- a/engines/harold/module.mk
+++ b/engines/harold/module.mk
@@ -12,6 +12,7 @@ MODULE_OBJS += \
bcb/executable_data.o \
bcb/input.o \
bcb/map.o \
+ bcb/options.o \
bcb/resources.o \
bcb/saveload.o \
bcb/scene.o \
Commit: ceaa1f54b35c1e2d098610027b9c930a581aae1e
https://github.com/scummvm/scummvm/commit/ceaa1f54b35c1e2d098610027b9c930a581aae1e
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:12+03:00
Commit Message:
HAROLD: BCB: Apply translated artwork and render image labels
Changed paths:
A engines/harold/bcb/text_renderer.cpp
A engines/harold/bcb/text_renderer.h
A engines/harold/bcb/translation_images.cpp
engines/harold/bcb/computer.cpp
engines/harold/bcb/screens.cpp
engines/harold/bcb/translation.h
engines/harold/module.mk
diff --git a/engines/harold/bcb/computer.cpp b/engines/harold/bcb/computer.cpp
index 0ca4f44a1eb..4dafbbd747c 100644
--- a/engines/harold/bcb/computer.cpp
+++ b/engines/harold/bcb/computer.cpp
@@ -40,6 +40,8 @@ static const int kComputerCompositeTransitionBottom = 444;
const Graphics::Surface *BCBEngine::getComputerBitmap() {
if (!_computerBitmap) {
_computerBitmap = loadBitmap("256com.bmp");
+ if (_computerBitmap && _selectedTextLanguagePackageAvailable)
+ applyTranslatedComputerButtons(*_computerBitmap, _textTranslation);
}
return _computerBitmap;
}
diff --git a/engines/harold/bcb/screens.cpp b/engines/harold/bcb/screens.cpp
index 986747e9153..528ba3a9e05 100644
--- a/engines/harold/bcb/screens.cpp
+++ b/engines/harold/bcb/screens.cpp
@@ -57,8 +57,11 @@ bool BCBEngine::showTitleScreen() {
_titleBitmap = nullptr;
}
- if (!_titleBitmap)
+ if (!_titleBitmap) {
_titleBitmap = loadBitmap("16mtitle.bmp");
+ if (_titleBitmap && _selectedTextLanguagePackageAvailable)
+ applyTranslatedTitleMenu(*_titleBitmap, _textTranslation);
+ }
if (!_titleBitmap)
return false;
@@ -124,6 +127,9 @@ bool BCBEngine::showPendingStillImageScreen() {
if (!still)
return false;
+ if (_gameDescription->desc.language == Common::JA_JPN && _selectedTextLanguagePackageAvailable)
+ applyTranslatedStillImage(*still, stillIndex, _textTranslation);
+
_screen->copyRectToSurface(still->getPixels(), still->pitch, 0, 0, MIN<int>(still->w, 640), MIN<int>(still->h, 480));
_screen->update();
still->free();
diff --git a/engines/harold/bcb/text_renderer.cpp b/engines/harold/bcb/text_renderer.cpp
new file mode 100644
index 00000000000..7d7b0dc8557
--- /dev/null
+++ b/engines/harold/bcb/text_renderer.cpp
@@ -0,0 +1,649 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#define FORBIDDEN_SYMBOL_ALLOW_ALL
+
+#include "common/archive.h"
+#include "common/compression/unzip.h"
+#include "common/config-manager.h"
+#include "common/fs.h"
+#include "common/ptr.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+#include "common/util.h"
+#include "graphics/fonts/freetype.h"
+#include "graphics/surface.h"
+
+#include <math.h>
+
+#include "harold/bcb/text_renderer.h"
+
+#ifdef USE_FREETYPE2
+#include <ft2build.h>
+#include FT_FREETYPE_H
+#include FT_GLYPH_H
+#include FT_STROKER_H
+#if __has_include(<hb.h>) && __has_include(<hb-ft.h>)
+#include <hb-ft.h>
+#include <hb.h>
+#define BCB_USE_HARFBUZZ_TEXT_LAYOUT
+#endif
+#endif
+
+namespace BCB {
+namespace {
+
+static inline uint pillowShiftForDiv255(uint value) {
+ return (((value >> 8) + value) >> 8);
+}
+
+static inline uint pillowDiv255(uint value) {
+ return pillowShiftForDiv255(value + 128);
+}
+
+static inline uint pillowMulDiv255(uint a, uint b) {
+ return pillowShiftForDiv255(a * b + 128);
+}
+
+static inline uint pillowBlend(uint mask, uint destination, uint source) {
+ return pillowDiv255(destination * (255 - mask) + source * mask);
+}
+
+#ifdef USE_FREETYPE2
+static int ftPixel(FT_Pos value) {
+ return (int)((value + 32) >> 6);
+}
+
+bool loadFontArchiveMember(const Common::String &fontName, const char *archiveName, Common::Array<byte> &fontData) {
+ Common::SeekableReadStream *archiveStream = nullptr;
+ if (ConfMan.hasKey("extrapath")) {
+ Common::FSDirectory extrapath(ConfMan.getPath("extrapath"));
+ archiveStream = extrapath.createReadStreamForMember(Common::Path(archiveName, Common::Path::kNoSeparator));
+ }
+
+ if (!archiveStream)
+ archiveStream = SearchMan.createReadStreamForMember(Common::Path(archiveName, Common::Path::kNoSeparator));
+
+ Common::ScopedPtr<Common::Archive> archive(Common::makeZipArchive(archiveStream));
+ if (!archive)
+ return false;
+
+ Common::ScopedPtr<Common::SeekableReadStream> stream(archive->createReadStreamForMember(Common::Path(fontName, Common::Path::kNoSeparator)));
+ if (!stream)
+ return false;
+
+ fontData.resize(stream->size());
+ return stream->read(fontData.data(), fontData.size()) == fontData.size();
+}
+
+bool loadFontDataFromArchives(const Common::String &fontName, Common::Array<byte> &fontData) {
+ return loadFontArchiveMember(fontName, "fonts.dat", fontData) || loadFontArchiveMember(fontName, "fonts-cjk.dat", fontData);
+}
+
+struct PillowGlyphInfo {
+ FT_UInt index;
+ FT_Pos xAdvance;
+ FT_Pos xOffset;
+};
+
+#ifdef BCB_USE_HARFBUZZ_TEXT_LAYOUT
+bool layoutPillowGlyphsWithHarfBuzz(FT_Face face, const Common::U32String &text, Common::Array<PillowGlyphInfo> &glyphs) {
+ glyphs.clear();
+ if (text.empty())
+ return true;
+
+ hb_font_t *font = hb_ft_font_create_referenced(face);
+ if (!font)
+ return false;
+ hb_buffer_t *buffer = hb_buffer_create();
+ if (!buffer) {
+ hb_font_destroy(font);
+ return false;
+ }
+
+ Common::Array<uint32> codepoints;
+ codepoints.resize(text.size());
+ for (uint i = 0; i < text.size(); ++i)
+ codepoints[i] = text[i];
+
+ hb_buffer_add_utf32(buffer, codepoints.data(), codepoints.size(), 0, codepoints.size());
+ hb_buffer_guess_segment_properties(buffer);
+ hb_shape(font, buffer, nullptr, 0);
+
+ uint glyphCount = 0;
+ hb_glyph_info_t *glyphInfo = hb_buffer_get_glyph_infos(buffer, &glyphCount);
+ hb_glyph_position_t *glyphPosition = hb_buffer_get_glyph_positions(buffer, &glyphCount);
+ if (!glyphInfo || !glyphPosition) {
+ hb_buffer_destroy(buffer);
+ hb_font_destroy(font);
+ return false;
+ }
+
+ for (uint i = 0; i < glyphCount; ++i) {
+ PillowGlyphInfo glyph;
+ glyph.index = glyphInfo[i].codepoint;
+ glyph.xOffset = glyphPosition[i].x_offset;
+ glyph.xAdvance = glyphPosition[i].x_advance;
+ glyphs.push_back(glyph);
+ }
+
+ hb_buffer_destroy(buffer);
+ hb_font_destroy(font);
+ return true;
+}
+#endif
+
+bool layoutPillowGlyphs(FT_Face face, const Common::U32String &text, Common::Array<PillowGlyphInfo> &glyphs) {
+#ifdef BCB_USE_HARFBUZZ_TEXT_LAYOUT
+ if (layoutPillowGlyphsWithHarfBuzz(face, text, glyphs))
+ return true;
+#endif
+
+ glyphs.clear();
+ FT_UInt previousIndex = 0;
+ for (uint i = 0; i < text.size(); ++i) {
+ const FT_UInt glyphIndex = Graphics::FreeType::Get_Char_Index(face, text[i]);
+ if (!glyphIndex)
+ continue;
+
+ FT_Vector kerning;
+ FT_Pos xOffset = 0;
+ if (previousIndex && FT_HAS_KERNING(face) && !Graphics::FreeType::Get_Kerning(face, previousIndex, glyphIndex, FT_KERNING_DEFAULT, &kerning))
+ xOffset = kerning.x;
+
+ if (Graphics::FreeType::Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT))
+ return false;
+
+ PillowGlyphInfo glyph;
+ glyph.index = glyphIndex;
+ glyph.xOffset = xOffset;
+ glyph.xAdvance = face->glyph->advance.x;
+ glyphs.push_back(glyph);
+ previousIndex = glyphIndex;
+ }
+
+ return true;
+}
+
+bool getPillowTextMaskMetrics(FT_Face face, const Common::Array<PillowGlyphInfo> &glyphs, int strokeWidth,
+ int &xOffset, int &yOffset, int &xMin, int &yMax, int &maskWidth, int &maskHeight, int loadFlags) {
+ int bboxXMin = 0;
+ int bboxXMax = 0;
+ int yMin = 0;
+ int bboxYMax = 0;
+ FT_Pos penX = 0;
+
+ for (uint i = 0; i < glyphs.size(); ++i) {
+ const int px = ftPixel(penX + glyphs[i].xOffset);
+ penX += glyphs[i].xOffset + glyphs[i].xAdvance;
+ const int advanced = ftPixel(penX);
+ if (advanced > bboxXMax)
+ bboxXMax = advanced;
+
+ if (Graphics::FreeType::Load_Glyph(face, glyphs[i].index, loadFlags))
+ return false;
+
+ FT_Glyph glyph;
+ if (Graphics::FreeType::Get_Glyph(face->glyph, &glyph))
+ return false;
+
+ FT_BBox bbox;
+ FT_Glyph_Get_CBox(glyph, FT_GLYPH_BBOX_PIXELS, &bbox);
+ Graphics::FreeType::Done_Glyph(glyph);
+
+ bboxXMin = MIN<int>(bboxXMin, bbox.xMin + px);
+ bboxXMax = MAX<int>(bboxXMax, bbox.xMax + px);
+ yMin = MIN<int>(yMin, bbox.yMin);
+ bboxYMax = MAX<int>(bboxYMax, bbox.yMax);
+ }
+
+ if (glyphs.empty()) {
+ xOffset = 0;
+ yOffset = 0;
+ xMin = 0;
+ yMax = 0;
+ maskWidth = 0;
+ maskHeight = 0;
+ return true;
+ }
+
+ const int ascender = ftPixel(face->size->metrics.ascender);
+ xMin = bboxXMin;
+ yMax = bboxYMax;
+ maskWidth = bboxXMax - bboxXMin + strokeWidth * 2;
+ maskHeight = bboxYMax - yMin + strokeWidth * 2;
+ xOffset = (int)round((double)bboxXMin - strokeWidth);
+ yOffset = (int)round((double)(ascender - bboxYMax) - strokeWidth);
+ return true;
+}
+
+void renderPillowGlyphBitmapToSurface(Graphics::Surface &surface, const FT_Bitmap &bitmap, int destX, int destY, uint32 color) {
+ uint8 inkA, inkR, inkG, inkB;
+ surface.format.colorToARGB(color, inkA, inkR, inkG, inkB);
+
+ for (uint row = 0; row < bitmap.rows; ++row) {
+ const byte *source = bitmap.buffer + row * bitmap.pitch;
+ const int y = destY + row;
+ if (y < 0 || y >= surface.h)
+ continue;
+ byte *targetRow = (byte *)surface.getBasePtr(0, y);
+ for (uint col = 0; col < bitmap.width; ++col) {
+ const int x = destX + col;
+ if (x < 0 || x >= surface.w)
+ continue;
+
+ const uint sourceAlpha = source[col];
+ if (sourceAlpha == 0)
+ continue;
+
+ byte *target = targetRow + x * 4;
+ if (target[3] > 0) {
+ target[0] = pillowBlend(sourceAlpha, target[0], inkR);
+ target[1] = pillowBlend(sourceAlpha, target[1], inkG);
+ target[2] = pillowBlend(sourceAlpha, target[2], inkB);
+ target[3] = CLIP<uint>(sourceAlpha + pillowMulDiv255(target[3], 255 - sourceAlpha), 0, 255);
+ } else {
+ target[0] = inkR;
+ target[1] = inkG;
+ target[2] = inkB;
+ target[3] = sourceAlpha;
+ }
+ }
+ }
+}
+
+bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common::Array<PillowGlyphInfo> &glyphs,
+ int x, int y, uint32 color, int strokeWidth, bool strokeOnly) {
+ const int loadFlags = strokeOnly ? FT_LOAD_NO_BITMAP : (FT_LOAD_DEFAULT | FT_LOAD_RENDER);
+ int xOffset = 0;
+ int yOffset = 0;
+ int xMin = 0;
+ int yMax = 0;
+ int maskWidth = 0;
+ int maskHeight = 0;
+ if (!getPillowTextMaskMetrics(face, glyphs, strokeOnly ? strokeWidth : 0, xOffset, yOffset, xMin, yMax, maskWidth, maskHeight, strokeOnly ? FT_LOAD_NO_BITMAP : FT_LOAD_DEFAULT))
+ return false;
+ if (maskWidth == 0 || maskHeight == 0)
+ return true;
+
+ FT_Stroker stroker = nullptr;
+ if (strokeOnly) {
+ if (FT_Stroker_New(face->glyph->library, &stroker))
+ return false;
+ FT_Stroker_Set(stroker, (FT_Fixed)round(strokeWidth * 64.0), FT_STROKER_LINECAP_ROUND, FT_STROKER_LINEJOIN_ROUND, 0);
+ }
+
+ FT_Pos penX = 0;
+ const FT_Pos originX = (FT_Pos)round((-xMin + (strokeOnly ? strokeWidth : 0)) * 64.0);
+ const FT_Pos originY = (FT_Pos)round((-yMax - (strokeOnly ? strokeWidth : 0)) * 64.0);
+ for (uint i = 0; i < glyphs.size(); ++i) {
+ const int px = ftPixel(originX + penX + glyphs[i].xOffset);
+ const int py = ftPixel(originY);
+ if (Graphics::FreeType::Load_Glyph(face, glyphs[i].index, loadFlags)) {
+ if (stroker)
+ FT_Stroker_Done(stroker);
+ return false;
+ }
+
+ if (strokeOnly) {
+ FT_Glyph glyph;
+ if (Graphics::FreeType::Get_Glyph(face->glyph, &glyph)) {
+ FT_Stroker_Done(stroker);
+ return false;
+ }
+ if (FT_Glyph_StrokeBorder(&glyph, stroker, 0, 1) ||
+ Graphics::FreeType::Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, nullptr, 1)) {
+ Graphics::FreeType::Done_Glyph(glyph);
+ FT_Stroker_Done(stroker);
+ return false;
+ }
+ FT_BitmapGlyph bitmapGlyph = (FT_BitmapGlyph)glyph;
+ const int destX = x + xOffset + px + bitmapGlyph->left;
+ const int destY = y + yOffset - (py + bitmapGlyph->top);
+ renderPillowGlyphBitmapToSurface(surface, bitmapGlyph->bitmap, destX, destY, color);
+ Graphics::FreeType::Done_Glyph(glyph);
+ } else {
+ const FT_GlyphSlot slot = face->glyph;
+ const int destX = x + xOffset + px + slot->bitmap_left;
+ const int destY = y + yOffset - (py + slot->bitmap_top);
+ renderPillowGlyphBitmapToSurface(surface, slot->bitmap, destX, destY, color);
+ }
+
+ penX += glyphs[i].xOffset + glyphs[i].xAdvance;
+ }
+
+ if (stroker)
+ FT_Stroker_Done(stroker);
+ return true;
+}
+
+bool drawFreeTypeTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
+ const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
+ Common::Array<byte> fontData;
+ if (!loadFontDataFromArchives(fontName, fontData))
+ return false;
+
+ FT_Library library = nullptr;
+ if (Graphics::FreeType::Init_FreeType(&library))
+ return false;
+
+ FT_Face face = nullptr;
+ bool ok = !Graphics::FreeType::New_Memory_Face(library, fontData.data(), fontData.size(), 0, &face);
+ if (ok) {
+ FT_Size_RequestRec request;
+ memset(&request, 0, sizeof(request));
+ request.type = FT_SIZE_REQUEST_TYPE_NOMINAL;
+ request.width = size * 64;
+ request.height = size * 64;
+ ok = !FT_Request_Size(face, &request);
+ }
+
+ Common::Array<PillowGlyphInfo> glyphs;
+ if (ok)
+ ok = layoutPillowGlyphs(face, text, glyphs);
+
+ if (ok) {
+ for (uint i = 0; i < shadowOffsets.size(); ++i)
+ ok = drawFreeTypeTextPass(surface, face, glyphs, x + shadowOffsets[i].x, y + shadowOffsets[i].y, shadowColor, 0, false) && ok;
+ if (strokeWidth > 0)
+ ok = drawFreeTypeTextPass(surface, face, glyphs, x, y, shadowColor, strokeWidth, true) && ok;
+ ok = drawFreeTypeTextPass(surface, face, glyphs, x, y, textColor, 0, false) && ok;
+ }
+
+ if (face)
+ Graphics::FreeType::Done_Face(face);
+ Graphics::FreeType::Done_FreeType(library);
+ return ok;
+}
+#endif
+
+void alphaCompositeRgbaLayerInternal(Graphics::Surface &target, const Graphics::Surface &layer) {
+ const int width = MIN<int>(target.w, layer.w);
+ const int height = MIN<int>(target.h, layer.h);
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ uint8 srcA, srcR, srcG, srcB;
+ layer.format.colorToARGB(layer.getPixel(x, y), srcA, srcR, srcG, srcB);
+ if (srcA == 0)
+ continue;
+
+ uint8 dstA, dstR, dstG, dstB;
+ target.format.colorToARGB(target.getPixel(x, y), dstA, dstR, dstG, dstB);
+ const uint32 blend = dstA * (255 - srcA);
+ const uint32 outA255 = srcA * 255 + blend;
+ const uint32 coef1 = srcA * 255 * 255 * 128 / outA255;
+ const uint32 coef2 = 255 * 128 - coef1;
+ const uint8 outR = pillowShiftForDiv255(srcR * coef1 + dstR * coef2 + (0x80 << 7)) >> 7;
+ const uint8 outG = pillowShiftForDiv255(srcG * coef1 + dstG * coef2 + (0x80 << 7)) >> 7;
+ const uint8 outB = pillowShiftForDiv255(srcB * coef1 + dstB * coef2 + (0x80 << 7)) >> 7;
+ const uint8 outA = pillowShiftForDiv255(outA255 + 0x80);
+ target.setPixel(x, y, target.format.ARGBToColor(outA, outR, outG, outB));
+ }
+ }
+}
+
+static double cubicWeight(double value) {
+ value = fabs(value);
+ if (value < 1.0)
+ return (1.5 * value - 2.5) * value * value + 1.0;
+ if (value < 2.0)
+ return (((value - 5.0) * value + 8.0) * value - 4.0) * -0.5;
+ return 0.0;
+}
+
+static const int kPillowResamplePrecisionBits = 22;
+
+static uint8 pillowResampleClip8(int value) {
+ value >>= kPillowResamplePrecisionBits;
+ return CLIP<int>(value, 0, 255);
+}
+
+int precomputePillowCoefficients(int inputSize, float inputStart, float inputEnd, int outputSize,
+ Common::Array<int> &bounds, Common::Array<int> &coefficients) {
+ const double scale = (double)(inputEnd - inputStart) / outputSize;
+ const double filterScale = MAX<double>(scale, 1.0);
+ const double support = 2.0 * filterScale;
+ const int kernelSize = (int)ceil(support) * 2 + 1;
+
+ bounds.resize(outputSize * 2);
+ Common::Array<double> precomputed;
+ precomputed.resize(outputSize * kernelSize);
+ const double invFilterScale = 1.0 / filterScale;
+ for (int outX = 0; outX < outputSize; ++outX) {
+ const double center = inputStart + (outX + 0.5) * scale;
+ int xmin = (int)(center - support + 0.5);
+ if (xmin < 0)
+ xmin = 0;
+ int xmax = (int)(center + support + 0.5);
+ if (xmax > inputSize)
+ xmax = inputSize;
+ xmax -= xmin;
+
+ double weightSum = 0.0;
+ for (int x = 0; x < xmax; ++x) {
+ const double weight = cubicWeight((x + xmin - center + 0.5) * invFilterScale);
+ precomputed[outX * kernelSize + x] = weight;
+ weightSum += weight;
+ }
+ if (weightSum != 0.0) {
+ for (int x = 0; x < xmax; ++x)
+ precomputed[outX * kernelSize + x] /= weightSum;
+ }
+ for (int x = xmax; x < kernelSize; ++x)
+ precomputed[outX * kernelSize + x] = 0.0;
+
+ bounds[outX * 2 + 0] = xmin;
+ bounds[outX * 2 + 1] = xmax;
+ }
+
+ coefficients.resize(outputSize * kernelSize);
+ for (int i = 0; i < outputSize * kernelSize; ++i) {
+ if (precomputed[i] < 0.0)
+ coefficients[i] = (int)(-0.5 + precomputed[i] * (1 << kPillowResamplePrecisionBits));
+ else
+ coefficients[i] = (int)(0.5 + precomputed[i] * (1 << kPillowResamplePrecisionBits));
+ }
+
+ return kernelSize;
+}
+
+static inline void premultiplyPillowRgba(uint8 a, uint8 &r, uint8 &g, uint8 &b) {
+ r = pillowMulDiv255(r, a);
+ g = pillowMulDiv255(g, a);
+ b = pillowMulDiv255(b, a);
+}
+
+static inline void unpremultiplyPillowRgba(uint8 a, uint8 &r, uint8 &g, uint8 &b) {
+ if (a == 0 || a == 0xff)
+ return;
+
+ r = CLIP<int>((255 * r) / a, 0, 255);
+ g = CLIP<int>((255 * g) / a, 0, 255);
+ b = CLIP<int>((255 * b) / a, 0, 255);
+}
+
+Common::Rect findSurfaceAlphaBounds(const Graphics::Surface &surface) {
+ Common::Rect bounds;
+ bool found = false;
+ for (int y = 0; y < surface.h; ++y) {
+ const byte *row = (const byte *)surface.getBasePtr(0, y);
+ for (int x = 0; x < surface.w; ++x) {
+ if (row[x * 4 + 3] == 0)
+ continue;
+
+ if (!found) {
+ bounds.left = x;
+ bounds.right = x + 1;
+ bounds.top = y;
+ bounds.bottom = y + 1;
+ found = true;
+ } else {
+ if (x < bounds.left)
+ bounds.left = x;
+ if (x + 1 > bounds.right)
+ bounds.right = x + 1;
+ if (y < bounds.top)
+ bounds.top = y;
+ if (y + 1 > bounds.bottom)
+ bounds.bottom = y + 1;
+ }
+ }
+ }
+
+ return found ? bounds : Common::Rect();
+}
+
+void findOutputBoundsForSourceBounds(const Common::Array<int> &bounds, int outputSize, const Common::Rect &sourceBounds,
+ bool horizontal, int &first, int &last) {
+ first = outputSize;
+ last = 0;
+ const int sourceMin = horizontal ? sourceBounds.left : sourceBounds.top;
+ const int sourceMax = horizontal ? sourceBounds.right : sourceBounds.bottom;
+ for (int out = 0; out < outputSize; ++out) {
+ const int inputMin = bounds[out * 2 + 0];
+ const int inputMax = inputMin + bounds[out * 2 + 1];
+ if (inputMin >= sourceMax || inputMax <= sourceMin)
+ continue;
+
+ first = MIN(first, out);
+ last = MAX(last, out + 1);
+ }
+}
+
+Graphics::Surface *downscaleRgbaLayerBicubicInternal(const Graphics::Surface &source, int width, int height) {
+ Graphics::Surface *target = new Graphics::Surface();
+ target->create(width, height, source.format);
+ target->fillRect(Common::Rect(width, height), 0);
+
+ const Common::Rect sourceAlphaBounds = findSurfaceAlphaBounds(source);
+ if (sourceAlphaBounds.isEmpty())
+ return target;
+
+ Common::Array<int> horizontalBounds;
+ Common::Array<int> horizontalCoefficients;
+ const int horizontalKernelSize = precomputePillowCoefficients(source.w, 0.0f, (float)source.w, width,
+ horizontalBounds, horizontalCoefficients);
+ Common::Array<int> verticalBounds;
+ Common::Array<int> verticalCoefficients;
+ const int verticalKernelSize = precomputePillowCoefficients(source.h, 0.0f, (float)source.h, height,
+ verticalBounds, verticalCoefficients);
+
+ int firstOutX = 0;
+ int lastOutX = 0;
+ findOutputBoundsForSourceBounds(horizontalBounds, width, sourceAlphaBounds, true, firstOutX, lastOutX);
+ int firstOutY = 0;
+ int lastOutY = 0;
+ findOutputBoundsForSourceBounds(verticalBounds, height, sourceAlphaBounds, false, firstOutY, lastOutY);
+ if (firstOutX >= lastOutX || firstOutY >= lastOutY)
+ return target;
+
+ Graphics::Surface temp;
+ temp.create(width, source.h, source.format);
+ temp.fillRect(Common::Rect(width, source.h), 0);
+ for (int y = sourceAlphaBounds.top; y < sourceAlphaBounds.bottom; ++y) {
+ const byte *sourceRow = (const byte *)source.getBasePtr(0, y);
+ byte *tempRow = (byte *)temp.getBasePtr(0, y);
+ for (int outX = firstOutX; outX < lastOutX; ++outX) {
+ const int xmin = horizontalBounds[outX * 2 + 0];
+ const int xmax = horizontalBounds[outX * 2 + 1];
+ const int *kernel = &horizontalCoefficients[outX * horizontalKernelSize];
+ int sumA = 1 << (kPillowResamplePrecisionBits - 1);
+ int sumR = 1 << (kPillowResamplePrecisionBits - 1);
+ int sumG = 1 << (kPillowResamplePrecisionBits - 1);
+ int sumB = 1 << (kPillowResamplePrecisionBits - 1);
+ for (int x = 0; x < xmax; ++x) {
+ const byte *sourcePixel = sourceRow + (x + xmin) * 4;
+ uint8 r = sourcePixel[0];
+ uint8 g = sourcePixel[1];
+ uint8 b = sourcePixel[2];
+ const uint8 a = sourcePixel[3];
+ premultiplyPillowRgba(a, r, g, b);
+ sumR += r * kernel[x];
+ sumG += g * kernel[x];
+ sumB += b * kernel[x];
+ sumA += a * kernel[x];
+ }
+ byte *tempPixel = tempRow + outX * 4;
+ tempPixel[0] = pillowResampleClip8(sumR);
+ tempPixel[1] = pillowResampleClip8(sumG);
+ tempPixel[2] = pillowResampleClip8(sumB);
+ tempPixel[3] = pillowResampleClip8(sumA);
+ }
+ }
+
+ for (int outY = firstOutY; outY < lastOutY; ++outY) {
+ const int ymin = verticalBounds[outY * 2 + 0];
+ const int ymax = verticalBounds[outY * 2 + 1];
+ const int *kernel = &verticalCoefficients[outY * verticalKernelSize];
+ byte *targetRow = (byte *)target->getBasePtr(0, outY);
+ for (int x = firstOutX; x < lastOutX; ++x) {
+ int sumA = 1 << (kPillowResamplePrecisionBits - 1);
+ int sumR = 1 << (kPillowResamplePrecisionBits - 1);
+ int sumG = 1 << (kPillowResamplePrecisionBits - 1);
+ int sumB = 1 << (kPillowResamplePrecisionBits - 1);
+ for (int y = 0; y < ymax; ++y) {
+ const byte *tempPixel = (const byte *)temp.getBasePtr(x, y + ymin);
+ const uint8 r = tempPixel[0];
+ const uint8 g = tempPixel[1];
+ const uint8 b = tempPixel[2];
+ const uint8 a = tempPixel[3];
+ sumR += r * kernel[y];
+ sumG += g * kernel[y];
+ sumB += b * kernel[y];
+ sumA += a * kernel[y];
+ }
+ uint8 a = pillowResampleClip8(sumA);
+ uint8 r = pillowResampleClip8(sumR);
+ uint8 g = pillowResampleClip8(sumG);
+ uint8 b = pillowResampleClip8(sumB);
+ unpremultiplyPillowRgba(a, r, g, b);
+ byte *targetPixel = targetRow + x * 4;
+ targetPixel[0] = r;
+ targetPixel[1] = g;
+ targetPixel[2] = b;
+ targetPixel[3] = a;
+ }
+ }
+
+ temp.free();
+ return target;
+}
+
+} // End of anonymous namespace
+
+Graphics::Surface *downscaleRgbaLayerBicubic(const Graphics::Surface &source, int width, int height) {
+ return downscaleRgbaLayerBicubicInternal(source, width, height);
+}
+
+void alphaCompositeRgbaLayer(Graphics::Surface &target, const Graphics::Surface &layer) {
+ alphaCompositeRgbaLayerInternal(target, layer);
+}
+
+void drawHighQualityTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
+ const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
+#ifdef USE_FREETYPE2
+ drawFreeTypeTextLine(surface, fontName, size, shadowOffsets, text, x, y, textColor, shadowColor, strokeWidth);
+#endif
+}
+
+} // End of namespace BCB
diff --git a/engines/harold/bcb/text_renderer.h b/engines/harold/bcb/text_renderer.h
new file mode 100644
index 00000000000..19a2979c37e
--- /dev/null
+++ b/engines/harold/bcb/text_renderer.h
@@ -0,0 +1,45 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#ifndef BCB_TEXT_RENDERER_H
+#define BCB_TEXT_RENDERER_H
+
+#include "common/array.h"
+#include "common/rect.h"
+#include "common/str.h"
+#include "common/ustr.h"
+#include "graphics/pixelformat.h"
+
+namespace Graphics {
+struct Surface;
+}
+
+namespace BCB {
+
+void drawHighQualityTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
+ const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth);
+Graphics::Surface *downscaleRgbaLayerBicubic(const Graphics::Surface &source, int width, int height);
+void alphaCompositeRgbaLayer(Graphics::Surface &target, const Graphics::Surface &layer);
+
+} // End of namespace BCB
+
+#endif
diff --git a/engines/harold/bcb/translation.h b/engines/harold/bcb/translation.h
index 7a1e748f381..65b6c545318 100644
--- a/engines/harold/bcb/translation.h
+++ b/engines/harold/bcb/translation.h
@@ -31,7 +31,7 @@ namespace Common {
class Archive;
class FSNode;
class SeekableReadStream;
-}
+} // namespace Common
namespace Graphics {
struct Surface;
@@ -73,6 +73,9 @@ Common::String makeTextStringKey(TextTranslationType type, uint primaryId, uint
void listAvailableTranslationPackages(const Common::FSNode &gameDataDir, Common::Array<TranslationPackageDefinition> &packages);
bool isTranslationPackageAvailable(const Common::FSNode &gameDataDir, const Common::String &code);
bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::String &code, TextTranslationData &translation);
+void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const TextTranslationData &translation);
+void applyTranslatedTitleMenu(Graphics::Surface &title, const TextTranslationData &translation);
+void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTranslationData &translation);
const char *getTextTranslation(const TextTranslationData &translation, TextTranslationType type, uint primaryId, uint secondaryId);
const char *getSystemTextTranslation(const TextTranslationData &translation, const char *key);
diff --git a/engines/harold/bcb/translation_images.cpp b/engines/harold/bcb/translation_images.cpp
new file mode 100644
index 00000000000..1c06cb872e7
--- /dev/null
+++ b/engines/harold/bcb/translation_images.cpp
@@ -0,0 +1,263 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+#include "common/archive.h"
+#include "common/ptr.h"
+#include "common/stream.h"
+#include "common/textconsole.h"
+#include "common/util.h"
+#include "graphics/surface.h"
+#include "harold/bcb/text_renderer.h"
+#include "harold/bcb/translation.h"
+#include "image/png.h"
+
+namespace BCB {
+namespace {
+
+bool parseTranslationInt(const char *text, int &value) {
+ if (!text || !text[0])
+ return false;
+ return sscanf(text, "%d", &value) == 1;
+}
+
+int getTranslationInt(const TextStringTable &strings, const Common::String &key, int defaultValue) {
+ int value = defaultValue;
+ parseTranslationInt(strings.getString(key), value);
+ return value;
+}
+
+uint32 getTranslationColor(const TextStringTable &strings, const Common::String &key, const Graphics::PixelFormat &format, uint8 defaultR, uint8 defaultG, uint8 defaultB) {
+ const char *text = strings.getString(key);
+ uint r = defaultR;
+ uint g = defaultG;
+ uint b = defaultB;
+ if (text && text[0])
+ sscanf(text, "%u,%u,%u", &r, &g, &b);
+ return format.ARGBToColor(0xff, CLIP<uint>(r, 0, 255), CLIP<uint>(g, 0, 255), CLIP<uint>(b, 0, 255));
+}
+
+Common::Array<Common::Point> getTranslationShadowOffsets(const TextStringTable &strings, const Common::String &key) {
+ Common::Array<Common::Point> offsets;
+ const char *text = strings.getString(key);
+ if (!text || !text[0]) {
+ offsets.push_back(Common::Point(0, 2));
+ offsets.push_back(Common::Point(0, 3));
+ offsets.push_back(Common::Point(0, 4));
+ offsets.push_back(Common::Point(1, 4));
+ offsets.push_back(Common::Point(-1, 4));
+ offsets.push_back(Common::Point(0, 5));
+ return offsets;
+ }
+
+ Common::String offsetsText(text);
+ while (!offsetsText.empty()) {
+ Common::String item = offsetsText;
+ const uint separator = offsetsText.findFirstOf(";");
+ if (separator != Common::String::npos) {
+ item = offsetsText.substr(0, separator);
+ offsetsText = offsetsText.substr(separator + 1);
+ } else {
+ offsetsText.clear();
+ }
+
+ int x = 0;
+ int y = 0;
+ if (sscanf(item.c_str(), "%d,%d", &x, &y) == 2)
+ offsets.push_back(Common::Point(x, y));
+ }
+
+ return offsets;
+}
+
+bool parseStillHeadingLine(const char *definition, Common::U32String &text, int &x, int &y, int &size, int &strokeWidth) {
+ if (!definition || !definition[0])
+ return false;
+
+ Common::String fields[5];
+ Common::String remaining(definition);
+ for (int i = 0; i < 5; ++i) {
+ const uint separator = remaining.findFirstOf(";");
+ if (separator == Common::String::npos) {
+ fields[i] = remaining;
+ remaining.clear();
+ } else {
+ fields[i] = remaining.substr(0, separator);
+ remaining = remaining.substr(separator + 1);
+ }
+ fields[i].trim();
+ }
+
+ if (fields[0].empty())
+ return false;
+
+ text = Common::U32String(fields[0]);
+ parseTranslationInt(fields[1].c_str(), x);
+ parseTranslationInt(fields[2].c_str(), y);
+ parseTranslationInt(fields[3].c_str(), size);
+ parseTranslationInt(fields[4].c_str(), strokeWidth);
+ return true;
+}
+
+void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextStringTable &strings, const Common::String &prefix,
+ const char *defaultFont, uint8 defaultTextR, uint8 defaultTextG, uint8 defaultTextB,
+ uint8 defaultShadowR, uint8 defaultShadowG, uint8 defaultShadowB) {
+ const char *fontName = strings.getString(prefix + "font");
+ if (!fontName || !fontName[0])
+ fontName = defaultFont;
+
+ const Common::Array<Common::Point> shadowOffsets = getTranslationShadowOffsets(strings, prefix + "shadow_offsets");
+ const bool drawShadowWithoutStroke = getTranslationInt(strings, prefix + "shadow_without_stroke", 0) != 0;
+ const int scale = CLIP<int>(getTranslationInt(strings, prefix + "scale", 4), 1, 8);
+ Graphics::Surface layer;
+ layer.create(surface.w * scale, surface.h * scale, Graphics::PixelFormat::createFormatRGBA32());
+ layer.fillRect(Common::Rect(layer.w, layer.h), 0);
+ const uint32 scaledTextColor = getTranslationColor(strings, prefix + "text_color", layer.format, defaultTextR, defaultTextG, defaultTextB);
+ const uint32 scaledShadowColor = getTranslationColor(strings, prefix + "shadow_color", layer.format, defaultShadowR, defaultShadowG, defaultShadowB);
+ Common::Array<Common::Point> scaledShadowOffsets;
+ for (uint i = 0; i < shadowOffsets.size(); ++i)
+ scaledShadowOffsets.push_back(Common::Point(shadowOffsets[i].x * scale, shadowOffsets[i].y * scale));
+
+ for (int i = 1; i <= 16; ++i) {
+ Common::U32String text;
+ int x = 0;
+ int y = 0;
+ int size = 44;
+ int strokeWidth = 0;
+ if (!parseStillHeadingLine(strings.getString(Common::String::format("%sline%d", prefix.c_str(), i)), text, x, y, size, strokeWidth))
+ continue;
+
+ const Common::Array<Common::Point> emptyShadowOffsets;
+ drawHighQualityTextLine(layer, fontName, size * scale, (strokeWidth == 0 && !drawShadowWithoutStroke) ? emptyShadowOffsets : scaledShadowOffsets,
+ text, x * scale, y * scale, scaledTextColor, scaledShadowColor, strokeWidth * scale);
+ }
+
+ Graphics::Surface *downscaledLayer = downscaleRgbaLayerBicubic(layer, surface.w, surface.h);
+ layer.free();
+ if (!downscaledLayer)
+ return;
+
+ alphaCompositeRgbaLayer(surface, *downscaledLayer);
+ downscaledLayer->free();
+ delete downscaledLayer;
+}
+
+void drawTranslatedStillHeading(Graphics::Surface &still, int stillIndex, const TextStringTable &strings) {
+ if (stillIndex < 0 || stillIndex >= 5)
+ return;
+
+ const int stillNumber = stillIndex + 1;
+ const Common::String prefix = Common::String::format("still_headings.%d.", stillNumber);
+ drawConfiguredHighQualityTextLines(still, strings, prefix, "LiberationSerif-BoldItalic.ttf", 255, 255, 255, 0, 0, 0);
+}
+
+void applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *stream, const char *debugName) {
+ Common::ScopedPtr<Common::SeekableReadStream> patchStream(stream);
+ if (!patchStream)
+ return;
+
+ Image::PNGDecoder decoder;
+ if (!decoder.loadStream(*patchStream) || !decoder.getSurface()) {
+ warning("%s: Could not decode translated patch", debugName);
+ return;
+ }
+
+ const Graphics::Surface *patch = decoder.getSurface();
+ const int width = MIN<int>(surface.w, patch->w);
+ const int height = MIN<int>(surface.h, patch->h);
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ uint8 srcA, srcR, srcG, srcB;
+ patch->format.colorToARGB(patch->getPixel(x, y), srcA, srcR, srcG, srcB);
+ if (srcA == 0)
+ continue;
+
+ if (srcA == 0xff) {
+ surface.setPixel(x, y, surface.format.ARGBToColor(0xff, srcR, srcG, srcB));
+ continue;
+ }
+
+ uint8 dstA, dstR, dstG, dstB;
+ surface.format.colorToARGB(surface.getPixel(x, y), dstA, dstR, dstG, dstB);
+ const uint invA = 255 - srcA;
+ const uint8 outR = (srcR * srcA + dstR * invA) / 255;
+ const uint8 outG = (srcG * srcA + dstG * invA) / 255;
+ const uint8 outB = (srcB * srcA + dstB * invA) / 255;
+ surface.setPixel(x, y, surface.format.ARGBToColor(0xff, outR, outG, outB));
+ }
+ }
+}
+
+} // End of anonymous namespace
+
+void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const TextTranslationData &translation) {
+ if (translation.packageArchive && stillIndex >= 0 && stillIndex < 5) {
+ applyPatchImage(still, translation.packageArchive->createReadStreamForMember(Common::Path(Common::String::format("patches/pstill_%d_patch.png", stillIndex + 1), '/')), "applyTranslatedStillImage");
+ }
+
+ drawTranslatedStillHeading(still, stillIndex, translation.strings);
+}
+
+void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTranslationData &translation) {
+ if (!translation.packageArchive)
+ return;
+
+ Common::ScopedPtr<Common::SeekableReadStream> stream(translation.packageArchive->createReadStreamForMember(Common::Path("256com_buttons.png")));
+ if (!stream)
+ return;
+ Image::PNGDecoder decoder;
+ if (!decoder.loadStream(*stream) || !decoder.getSurface()) {
+ warning("Could not decode translated computer buttons");
+ return;
+ }
+ const Graphics::Surface *atlas = decoder.getSurface();
+ if (atlas->w != 234 || atlas->h != 265 || computer.w < 640 || computer.h < 738) {
+ warning("Invalid translated computer button atlas or computer bitmap dimensions");
+ return;
+ }
+ Graphics::Surface *converted = atlas->convertTo(computer.format, decoder.getPalette().data(), decoder.getPalette().size());
+ if (!converted)
+ return;
+
+ // The compact atlas has shared one-pixel borders, excluded from every copy.
+ for (int state = 0; state < 3; ++state)
+ computer.copyRectToSurface(*converted, 0, 672 + state * 22, Common::Rect(1, 1 + state * 23, 233, 23 + state * 23));
+ for (int page = 0; page < 2; ++page)
+ computer.copyRectToSurface(*converted, 392 + page * 160, 672, Common::Rect(1 + page * 81, 70, 81 + page * 81, 94));
+ // Captions follow the sheet's 29 populated icons; the unused choice has no cell.
+ for (int icon = 0; icon < 29; ++icon) {
+ const int x = 1 + (icon % 3) * 65;
+ const int y = 95 + (icon / 3) * 17;
+ computer.copyRectToSurface(*converted, (icon % 10) * 64, 528 + (icon / 10) * 64, Common::Rect(x, y, x + 64, y + 16));
+ }
+ converted->free();
+ delete converted;
+}
+
+void applyTranslatedTitleMenu(Graphics::Surface &title, const TextTranslationData &translation) {
+ if (!translation.packageArchive)
+ return;
+
+ applyPatchImage(title, translation.packageArchive->createReadStreamForMember(Common::Path("patches/16mtitle_patch.png", '/')), "applyTranslatedTitleMenu");
+ drawConfiguredHighQualityTextLines(title, translation.strings, "title_menu.", "LiberationSans-BoldItalic.ttf", 53, 55, 106, 142, 146, 232);
+ drawConfiguredHighQualityTextLines(title, translation.strings, "title_menu_pressed.", "LiberationSans-BoldItalic.ttf", 136, 90, 155, 183, 169, 211);
+}
+
+} // End of namespace BCB
diff --git a/engines/harold/module.mk b/engines/harold/module.mk
index 6b20062c6c6..925e8109202 100644
--- a/engines/harold/module.mk
+++ b/engines/harold/module.mk
@@ -19,7 +19,9 @@ MODULE_OBJS += \
bcb/screens.o \
bcb/script.o \
bcb/static_data.o \
+ bcb/text_renderer.o \
bcb/translation.o \
+ bcb/translation_images.o \
bcb/video.o
endif
Commit: 619a5e39e8b03108ec33c0cced87d7faeab28986
https://github.com/scummvm/scummvm/commit/619a5e39e8b03108ec33c0cced87d7faeab28986
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:12+03:00
Commit Message:
HAROLD: BCB: Format engine sources with clang-format
Changed paths:
.pre-commit-config.yaml
engines/harold/bcb/bcb.cpp
engines/harold/bcb/bcb.h
engines/harold/bcb/captions.cpp
engines/harold/bcb/debugger.cpp
engines/harold/bcb/input.cpp
engines/harold/bcb/options.cpp
engines/harold/bcb/options.h
engines/harold/bcb/resources.cpp
engines/harold/bcb/saveload.cpp
engines/harold/bcb/scene.cpp
engines/harold/bcb/screens.cpp
engines/harold/bcb/static_data.cpp
engines/harold/bcb/text_renderer.cpp
engines/harold/bcb/text_renderer.h
engines/harold/bcb/translation.cpp
engines/harold/bcb/translation_images.cpp
engines/harold/bcb/video.cpp
engines/harold/detection.cpp
engines/harold/detection_tables.h
engines/harold/metaengine.cpp
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index f54bb88c56b..0031755f95c 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -9,6 +9,7 @@ repos:
rev: v21.1.2
hooks:
- id: clang-format
+ exclude: ^engines/harold/(detection_tables\.h|bcb/static_data\.cpp)$
- repo: local
hooks:
- id: check-commit-msg
diff --git a/engines/harold/bcb/bcb.cpp b/engines/harold/bcb/bcb.cpp
index e90ac3dfaa8..44c16933772 100644
--- a/engines/harold/bcb/bcb.cpp
+++ b/engines/harold/bcb/bcb.cpp
@@ -81,7 +81,8 @@ void BCBEngine::loadFonts() {
}
BCBEngine::BCBEngine(OSystem *syst, const HaroldGameDescription *desc)
- : Engine(syst), _gameDescription(desc) {
+ : Engine(syst),
+ _gameDescription(desc) {
}
BCBEngine::~BCBEngine() {
diff --git a/engines/harold/bcb/bcb.h b/engines/harold/bcb/bcb.h
index f7c32052106..e964347965b 100644
--- a/engines/harold/bcb/bcb.h
+++ b/engines/harold/bcb/bcb.h
@@ -31,8 +31,8 @@
#include "common/str-enc.h"
#include "common/ustr.h"
#include "engines/engine.h"
-#include "harold/bcb/ui.h"
#include "harold/bcb/translation.h"
+#include "harold/bcb/ui.h"
#include "harold/detection.h"
namespace Graphics {
diff --git a/engines/harold/bcb/captions.cpp b/engines/harold/bcb/captions.cpp
index 0866c348a0e..e8750de2bff 100644
--- a/engines/harold/bcb/captions.cpp
+++ b/engines/harold/bcb/captions.cpp
@@ -122,8 +122,7 @@ static void trimTimedCaptionLine(Common::String &line) {
while (start < end) {
if (isCaptionEdgeSpace(text[start])) {
++start;
- } else if (start + 1 < end && ((text[start] == 0x81 && text[start + 1] == 0x40) ||
- (text[start] == 0xa1 && text[start + 1] == 0xa1))) {
+ } else if (start + 1 < end && ((text[start] == 0x81 && text[start + 1] == 0x40) || (text[start] == 0xa1 && text[start + 1] == 0xa1))) {
start += 2;
} else {
break;
@@ -133,8 +132,7 @@ static void trimTimedCaptionLine(Common::String &line) {
while (end > start) {
if (isCaptionEdgeSpace(text[end - 1])) {
--end;
- } else if (end >= start + 2 && ((text[end - 2] == 0x81 && text[end - 1] == 0x40) ||
- (text[end - 2] == 0xa1 && text[end - 1] == 0xa1))) {
+ } else if (end >= start + 2 && ((text[end - 2] == 0x81 && text[end - 1] == 0x40) || (text[end - 2] == 0xa1 && text[end - 1] == 0xa1))) {
end -= 2;
} else {
break;
diff --git a/engines/harold/bcb/debugger.cpp b/engines/harold/bcb/debugger.cpp
index ffcf8fe89eb..4390671b7ba 100644
--- a/engines/harold/bcb/debugger.cpp
+++ b/engines/harold/bcb/debugger.cpp
@@ -27,7 +27,9 @@
namespace BCB {
-Debugger::Debugger(BCBEngine *vm) : GUI::Debugger(), _vm(vm) {
+Debugger::Debugger(BCBEngine *vm)
+ : GUI::Debugger(),
+ _vm(vm) {
registerCmd("time", WRAP_METHOD(Debugger, cmdTime));
registerCmd("add_time", WRAP_METHOD(Debugger, cmdAddTime));
registerCmd("seq", WRAP_METHOD(Debugger, cmdSequence));
@@ -56,9 +58,9 @@ bool Debugger::cmdTime(int argc, const char **argv) {
if (argc > 2) {
debugPrintf("Format: time [ticks]\n");
debugPrintf("Current: %s, ticks=%u / 0x%04x\n",
- formatGameClock(_vm->stateDword(kStateGameClockTicks)).c_str(),
- _vm->stateDword(kStateGameClockTicks),
- _vm->stateDword(kStateGameClockTicks));
+ formatGameClock(_vm->stateDword(kStateGameClockTicks)).c_str(),
+ _vm->stateDword(kStateGameClockTicks),
+ _vm->stateDword(kStateGameClockTicks));
return true;
}
@@ -76,9 +78,9 @@ bool Debugger::cmdTime(int argc, const char **argv) {
}
debugPrintf("Current: %s, ticks=%u / 0x%04x\n",
- formatGameClock(_vm->stateDword(kStateGameClockTicks)).c_str(),
- _vm->stateDword(kStateGameClockTicks),
- _vm->stateDword(kStateGameClockTicks));
+ formatGameClock(_vm->stateDword(kStateGameClockTicks)).c_str(),
+ _vm->stateDword(kStateGameClockTicks),
+ _vm->stateDword(kStateGameClockTicks));
return true;
}
@@ -96,9 +98,9 @@ bool Debugger::cmdAddTime(int argc, const char **argv) {
_vm->addCheatTime((int)minutes);
debugPrintf("Current: %s, ticks=%u / 0x%04x\n",
- formatGameClock(_vm->stateDword(kStateGameClockTicks)).c_str(),
- _vm->stateDword(kStateGameClockTicks),
- _vm->stateDword(kStateGameClockTicks));
+ formatGameClock(_vm->stateDword(kStateGameClockTicks)).c_str(),
+ _vm->stateDword(kStateGameClockTicks),
+ _vm->stateDword(kStateGameClockTicks));
return true;
}
@@ -166,7 +168,7 @@ bool Debugger::cmdFlag(int argc, const char **argv) {
}
debugPrintf("secondary[%u] state[0x%04x] = %u / 0x%08x\n",
- flagIndex, byteOffset, _vm->stateDword(byteOffset), _vm->stateDword(byteOffset));
+ flagIndex, byteOffset, _vm->stateDword(byteOffset), _vm->stateDword(byteOffset));
return true;
}
@@ -186,8 +188,8 @@ bool Debugger::cmdChoice(int argc, const char **argv) {
}
debugPrintf("selectedSceneChoiceValue = %u / 0x%02x\n",
- _vm->stateDword(kStateSelectedSceneChoiceValue),
- _vm->stateDword(kStateSelectedSceneChoiceValue));
+ _vm->stateDword(kStateSelectedSceneChoiceValue),
+ _vm->stateDword(kStateSelectedSceneChoiceValue));
return true;
}
@@ -228,7 +230,7 @@ bool Debugger::cmdClockChip(int argc, const char **argv) {
}
debugPrintf("clock/chip state index = %u (state[0x%04x])\n",
- _vm->stateDword(kStateRequiredDiscIndex), kStateRequiredDiscIndex);
+ _vm->stateDword(kStateRequiredDiscIndex), kStateRequiredDiscIndex);
return true;
}
diff --git a/engines/harold/bcb/input.cpp b/engines/harold/bcb/input.cpp
index 2c41866982f..a817f98f461 100644
--- a/engines/harold/bcb/input.cpp
+++ b/engines/harold/bcb/input.cpp
@@ -198,12 +198,12 @@ bool BCBEngine::pollEvents(bool handleClicks) {
} else if (event.kbd.keycode == Common::KEYCODE_SPACE) {
handleSkipKey();
} else if (_sceneChoiceActive &&
- event.kbd.keycode >= Common::KEYCODE_1 &&
- event.kbd.keycode <= Common::KEYCODE_9) {
+ event.kbd.keycode >= Common::KEYCODE_1 &&
+ event.kbd.keycode <= Common::KEYCODE_9) {
handleSceneChoiceKeyboardSelection(event.kbd.keycode - Common::KEYCODE_1 + 1);
} else if (_sceneChoiceActive &&
- event.kbd.keycode >= Common::KEYCODE_KP1 &&
- event.kbd.keycode <= Common::KEYCODE_KP9) {
+ event.kbd.keycode >= Common::KEYCODE_KP1 &&
+ event.kbd.keycode <= Common::KEYCODE_KP9) {
handleSceneChoiceKeyboardSelection(event.kbd.keycode - Common::KEYCODE_KP1 + 1);
}
}
diff --git a/engines/harold/bcb/options.cpp b/engines/harold/bcb/options.cpp
index 54313700472..f712d67b71b 100644
--- a/engines/harold/bcb/options.cpp
+++ b/engines/harold/bcb/options.cpp
@@ -19,6 +19,7 @@
*
*/
+#include "harold/bcb/options.h"
#include "common/config-manager.h"
#include "common/fs.h"
#include "common/str-array.h"
@@ -27,7 +28,6 @@
#include "gui/gui-manager.h"
#include "gui/widget.h"
#include "gui/widgets/popup.h"
-#include "harold/bcb/options.h"
#include "harold/bcb/translation.h"
namespace BCB {
@@ -48,9 +48,9 @@ private:
GUI::PopUpWidget *_textLanguagePopUp;
};
-BCBOptionsWidget::BCBOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &domain) :
- OptionsContainerWidget(boss, name, "BCBGameOptionsDialog", domain),
- _textLanguagePopUp(nullptr) {
+BCBOptionsWidget::BCBOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &domain)
+ : OptionsContainerWidget(boss, name, "BCBGameOptionsDialog", domain),
+ _textLanguagePopUp(nullptr) {
GUI::StaticTextWidget *languageLabel = new GUI::StaticTextWidget(
widgetsBoss(),
@@ -112,9 +112,9 @@ void BCBOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::Strin
const int rowSpacing = lowResGui ? 6 : 10;
const int lineHeight = layouts.getVar("Globals.Line.Height");
layouts.addLayout(GUI::ThemeLayout::kLayoutVertical).addPadding(leftInset, 0, 0, 0);
- layouts.addLayout(GUI::ThemeLayout::kLayoutHorizontal, rowSpacing, GUI::ThemeLayout::kItemAlignCenter).addPadding(0, 0, 0, 0);
- layouts.addWidget("text_language_desc", "", labelWidth, lineHeight, Graphics::kTextAlignEnd);
- layouts.addWidget("text_language", "PopUp").closeLayout();
+ layouts.addLayout(GUI::ThemeLayout::kLayoutHorizontal, rowSpacing, GUI::ThemeLayout::kItemAlignCenter).addPadding(0, 0, 0, 0);
+ layouts.addWidget("text_language_desc", "", labelWidth, lineHeight, Graphics::kTextAlignEnd);
+ layouts.addWidget("text_language", "PopUp").closeLayout();
layouts.closeLayout().closeDialog();
}
diff --git a/engines/harold/bcb/options.h b/engines/harold/bcb/options.h
index ec3253f5d05..f34f5f3a250 100644
--- a/engines/harold/bcb/options.h
+++ b/engines/harold/bcb/options.h
@@ -27,7 +27,7 @@
namespace GUI {
class GuiObject;
class OptionsContainerWidget;
-}
+} // namespace GUI
namespace BCB {
GUI::OptionsContainerWidget *createTranslationOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target);
diff --git a/engines/harold/bcb/resources.cpp b/engines/harold/bcb/resources.cpp
index 65da108503f..e13d9b7176d 100644
--- a/engines/harold/bcb/resources.cpp
+++ b/engines/harold/bcb/resources.cpp
@@ -170,7 +170,7 @@ void BCBEngine::checkCurrentMediaPathReady() {
if (requiredDiscNumber < 1 || requiredDiscNumber > 5) {
warning("BCBEngine::checkCurrentMediaPathReady(): Invalid required media index %d from script state %u",
- requiredDiscNumber, stateDword(kStateRequiredDiscIndex));
+ requiredDiscNumber, stateDword(kStateRequiredDiscIndex));
_scriptStopFlag = true;
return;
}
@@ -178,10 +178,10 @@ void BCBEngine::checkCurrentMediaPathReady() {
Common::ArchiveMemberList requiredDiscMembers;
if (_discFiles[requiredDiscNumber - 1].listMembers(requiredDiscMembers) == 0) {
warning("BCBEngine::checkCurrentMediaPathReady(): Missing installed media directory bcb%d",
- requiredDiscNumber);
+ requiredDiscNumber);
debugC(1, kBCBDebugGeneral,
- "BCB required media dump: active=bcb%d required=bcb%d scriptRequiredDiscIndex=%u",
- _activeMediaDiscNumber, requiredDiscNumber, stateDword(kStateRequiredDiscIndex));
+ "BCB required media dump: active=bcb%d required=bcb%d scriptRequiredDiscIndex=%u",
+ _activeMediaDiscNumber, requiredDiscNumber, stateDword(kStateRequiredDiscIndex));
_scriptStopFlag = true;
return;
}
diff --git a/engines/harold/bcb/saveload.cpp b/engines/harold/bcb/saveload.cpp
index 184f9402528..f22389aafbe 100644
--- a/engines/harold/bcb/saveload.cpp
+++ b/engines/harold/bcb/saveload.cpp
@@ -75,7 +75,7 @@ static Common::String formatEnglishSaveDescription(int savedDay, int savedClockT
const Common::String chapterName = discIndex == 0 ? Common::String("Prologue") : Common::String::format("Chapter %d", discIndex);
return Common::String::format("%s: November %d, %d:%02d %s",
- chapterName.c_str(), dayOfMonth, hour12, minute, period);
+ chapterName.c_str(), dayOfMonth, hour12, minute, period);
}
static bool isValidBCBSaveSlot(int slot) {
@@ -84,8 +84,8 @@ static bool isValidBCBSaveSlot(int slot) {
bool BCBEngine::hasFeature(EngineFeature f) const {
return f == kSupportsLoadingDuringRuntime ||
- f == kSupportsSavingDuringRuntime ||
- f == kSupportsReturnToLauncher;
+ f == kSupportsSavingDuringRuntime ||
+ f == kSupportsReturnToLauncher;
}
bool BCBEngine::canLoadGameStateCurrently(Common::U32String *msg) {
@@ -235,7 +235,7 @@ bool BCBEngine::showSystemScreen() {
const int fillWidth = (_systemWaveVolume * kSystemWaveVolumeIndicatorRect.width()) / 0xffff;
if (fillWidth > 0) {
const Common::Rect fillRect(kSystemWaveVolumeIndicatorRect.left, kSystemWaveVolumeIndicatorRect.top,
- kSystemWaveVolumeIndicatorRect.left + fillWidth, kSystemWaveVolumeIndicatorRect.bottom);
+ kSystemWaveVolumeIndicatorRect.left + fillWidth, kSystemWaveVolumeIndicatorRect.bottom);
system->fillRect(fillRect, system->format.RGBToColor(255, 255, 255));
}
_screen->copyRectToSurface(system->getPixels(), system->pitch, 0, 0, MIN<int>(system->w, 640), MIN<int>(system->h, 480));
@@ -261,7 +261,7 @@ void BCBEngine::drawSystemSubmodeButtons(bool present) {
source = kSystemSubmodeSelectedSources[i];
if (source.x + button.width <= system->w && source.y + button.height <= system->h)
_screen->copyRectToSurface(system->getBasePtr(source.x, source.y), system->pitch,
- button.x, button.y, button.width, button.height);
+ button.x, button.y, button.width, button.height);
}
if (present)
@@ -313,8 +313,8 @@ void BCBEngine::drawSystemWaveVolumeIndicator(bool present) {
if (kSystemWaveVolumeIndicatorRect.right <= system->w && kSystemWaveVolumeIndicatorRect.bottom <= system->h) {
_screen->copyRectToSurface(system->getBasePtr(kSystemWaveVolumeIndicatorRect.left, kSystemWaveVolumeIndicatorRect.top),
- system->pitch, kSystemWaveVolumeIndicatorRect.left, kSystemWaveVolumeIndicatorRect.top,
- kSystemWaveVolumeIndicatorRect.width(), kSystemWaveVolumeIndicatorRect.height());
+ system->pitch, kSystemWaveVolumeIndicatorRect.left, kSystemWaveVolumeIndicatorRect.top,
+ kSystemWaveVolumeIndicatorRect.width(), kSystemWaveVolumeIndicatorRect.height());
}
Graphics::Surface *screen = _screen->surfacePtr();
@@ -322,7 +322,7 @@ void BCBEngine::drawSystemWaveVolumeIndicator(bool present) {
const int fillWidth = (_systemWaveVolume * kSystemWaveVolumeIndicatorRect.width()) / 0xffff;
if (fillWidth > 0) {
const Common::Rect fillRect(kSystemWaveVolumeIndicatorRect.left, kSystemWaveVolumeIndicatorRect.top,
- kSystemWaveVolumeIndicatorRect.left + fillWidth, kSystemWaveVolumeIndicatorRect.bottom);
+ kSystemWaveVolumeIndicatorRect.left + fillWidth, kSystemWaveVolumeIndicatorRect.bottom);
_screen->fillRect(fillRect, screen->format.RGBToColor(255, 255, 255));
}
}
@@ -462,17 +462,17 @@ bool BCBEngine::handleSystemClick(const Common::Point &mousePosition) {
return false;
const Common::Rect saveRect(kSystemSubmodeButtonTable[1].x, kSystemSubmodeButtonTable[1].y,
- kSystemSubmodeButtonTable[1].x + kSystemSubmodeButtonTable[1].width,
- kSystemSubmodeButtonTable[1].y + kSystemSubmodeButtonTable[1].height);
+ kSystemSubmodeButtonTable[1].x + kSystemSubmodeButtonTable[1].width,
+ kSystemSubmodeButtonTable[1].y + kSystemSubmodeButtonTable[1].height);
const Common::Rect loadRect(kSystemSubmodeButtonTable[2].x, kSystemSubmodeButtonTable[2].y,
- kSystemSubmodeButtonTable[2].x + kSystemSubmodeButtonTable[2].width,
- kSystemSubmodeButtonTable[2].y + kSystemSubmodeButtonTable[2].height);
+ kSystemSubmodeButtonTable[2].x + kSystemSubmodeButtonTable[2].width,
+ kSystemSubmodeButtonTable[2].y + kSystemSubmodeButtonTable[2].height);
const Common::Rect titleRect(kSystemSubmodeButtonTable[3].x, kSystemSubmodeButtonTable[3].y,
- kSystemSubmodeButtonTable[3].x + kSystemSubmodeButtonTable[3].width,
- kSystemSubmodeButtonTable[3].y + kSystemSubmodeButtonTable[3].height);
+ kSystemSubmodeButtonTable[3].x + kSystemSubmodeButtonTable[3].width,
+ kSystemSubmodeButtonTable[3].y + kSystemSubmodeButtonTable[3].height);
const Common::Rect exitRect(kSystemSubmodeButtonTable[4].x, kSystemSubmodeButtonTable[4].y,
- kSystemSubmodeButtonTable[4].x + kSystemSubmodeButtonTable[4].width,
- kSystemSubmodeButtonTable[4].y + kSystemSubmodeButtonTable[4].height);
+ kSystemSubmodeButtonTable[4].x + kSystemSubmodeButtonTable[4].width,
+ kSystemSubmodeButtonTable[4].y + kSystemSubmodeButtonTable[4].height);
if (handleSystemWaveVolumeClick(mousePosition))
return true;
@@ -596,7 +596,7 @@ bool BCBEngine::showSystemConfirmationDialog(const Common::U32String &message, b
auto drawDialogButton = [&](const Common::Rect &rect, int sourceX, bool present) {
if (sourceX + rect.width() <= chip->w && chip->h >= buttonSourceY + rect.height())
_screen->copyRectToSurface(chip->getBasePtr(sourceX, buttonSourceY), chip->pitch,
- rect.left, rect.top, rect.width(), rect.height());
+ rect.left, rect.top, rect.width(), rect.height());
if (present)
_screen->update();
};
@@ -668,7 +668,7 @@ bool BCBEngine::showSystemConfirmationDialog(const Common::U32String &message, b
}
_screen->copyRectToSurface(dialogBacking.getPixels(), dialogBacking.pitch, dialogRect.left, dialogRect.top,
- dialogBacking.w, dialogBacking.h);
+ dialogBacking.w, dialogBacking.h);
dialogBacking.free();
_screen->update();
return result;
diff --git a/engines/harold/bcb/scene.cpp b/engines/harold/bcb/scene.cpp
index 3235ea9834d..60faa07a155 100644
--- a/engines/harold/bcb/scene.cpp
+++ b/engines/harold/bcb/scene.cpp
@@ -163,7 +163,7 @@ bool BCBEngine::isSceneChoiceButtonVisible(int buttonIndex) const {
const int choiceCount = (sceneChoiceUiSetToShowId >= 0 && sceneChoiceUiSetToShowId < (int)_sceneChoiceText.size()) ? MIN<int>(_sceneChoiceText[sceneChoiceUiSetToShowId].size(), 8) : 0;
return buttonIndex <= choiceCount ||
- (buttonIndex == _sceneChoiceTerminatorButtonIndex && stateDword(kStateSceneChoiceExtraButtonFlag) != 0);
+ (buttonIndex == _sceneChoiceTerminatorButtonIndex && stateDword(kStateSceneChoiceExtraButtonFlag) != 0);
}
void BCBEngine::drawSceneChoiceButtons(int sceneChoiceUiSetToShowId, bool present, int pressedButtonIndex) {
diff --git a/engines/harold/bcb/screens.cpp b/engines/harold/bcb/screens.cpp
index 528ba3a9e05..48f1c2756f7 100644
--- a/engines/harold/bcb/screens.cpp
+++ b/engines/harold/bcb/screens.cpp
@@ -85,7 +85,7 @@ void BCBEngine::restoreTitleScreenRegion(const Common::Rect &rect, bool present)
return;
_screen->copyRectToSurface(_titleBitmap->getBasePtr(clippedRect.left, clippedRect.top), _titleBitmap->pitch,
- clippedRect.left, clippedRect.top, clippedRect.width(), clippedRect.height());
+ clippedRect.left, clippedRect.top, clippedRect.width(), clippedRect.height());
if (present)
_screen->update();
}
diff --git a/engines/harold/bcb/static_data.cpp b/engines/harold/bcb/static_data.cpp
index 29300854e33..88a2691bf3a 100644
--- a/engines/harold/bcb/static_data.cpp
+++ b/engines/harold/bcb/static_data.cpp
@@ -33,14 +33,16 @@ const ButtonControlRecord kTitleButtonTable[5] = {
{51, 429, 263, 162, 32},
{52, 429, 302, 162, 32},
{53, 429, 341, 162, 32},
- {54, 429, 386, 162, 32}};
+ {54, 429, 386, 162, 32}
+};
const ButtonControlRecord kSystemSubmodeButtonTable[5] = {
{500, 0, 0, 0, 0},
{501, 380, 53, 240, 44},
{502, 380, 120, 240, 44},
{503, 380, 216, 240, 44},
- {504, 505, 404, 96, 48}};
+ {504, 505, 404, 96, 48}
+};
const ButtonControlRecord kSystemButtonTable[9] = {
{550, 0, 0, 0, 0},
@@ -51,7 +53,8 @@ const ButtonControlRecord kSystemButtonTable[9] = {
{555, 41, 174, 288, 32},
{556, 41, 206, 288, 32},
{557, 41, 238, 288, 32},
- {558, 41, 270, 288, 32}};
+ {558, 41, 270, 288, 32}
+};
const ButtonControlRecord kSceneChoiceButtonTable[10] = {
{100, 0, 0, 0, 0},
@@ -63,7 +66,8 @@ const ButtonControlRecord kSceneChoiceButtonTable[10] = {
{106, 432, 278, 192, 40},
{107, 432, 324, 192, 40},
{108, 432, 370, 192, 40},
- {109, 432, 416, 192, 40}};
+ {109, 432, 416, 192, 40}
+};
const ButtonControlRecord kMapButtonTable[19] = {
{200, 0, 0, 0, 0},
@@ -84,19 +88,23 @@ const ButtonControlRecord kMapButtonTable[19] = {
{215, 234, 115, 16, 16},
{216, 270, 225, 16, 16},
{217, 317, 392, 16, 16},
- {218, 393, 375, 16, 16}};
+ {218, 393, 375, 16, 16}
+};
const int kMapButtonSecondaryStateIndexTable[19] = {
- 0, 0, 0, 41, 42, 0, 42, 44, 0, 0, 40, 0, 0, 39, 45, 46, 43, 47, 48};
+ 0, 0, 0, 41, 42, 0, 42, 44, 0, 0, 40, 0, 0, 39, 45, 46, 43, 47, 48
+};
const ButtonControlRecord kComputerPrimaryButtonTable[2] = {
{600, 0, 0, 0, 0},
- {601, 49, 40, 16, 16}};
+ {601, 49, 40, 16, 16}
+};
const ButtonControlRecord kComputerDetailButtonTable[3] = {
{750, 0, 0, 0, 0},
{751, 54, 50, 17, 17},
- {752, 508, 402, 80, 24}};
+ {752, 508, 402, 80, 24}
+};
const ButtonControlRecord kComputerChoiceLayoutSlots[21] = {
{0, 0, 0, 0, 0},
@@ -119,7 +127,8 @@ const ButtonControlRecord kComputerChoiceLayoutSlots[21] = {
{0, 171, 335, 64, 64},
{0, 259, 335, 64, 64},
{0, 347, 335, 64, 64},
- {0, 435, 335, 64, 64}};
+ {0, 435, 335, 64, 64}
+};
const ButtonControlRecord kComputerChoiceButtonTable[30] = {
{701, 0, 480, 64, 64},
@@ -151,17 +160,20 @@ const ButtonControlRecord kComputerChoiceButtonTable[30] = {
{727, 320, 608, 64, 64},
{728, 384, 608, 64, 64},
{729, 448, 608, 64, 64},
- {730, 512, 608, 64, 64}};
+ {730, 512, 608, 64, 64}
+};
const StaticHitRect kComputerChoiceGroupHitRects[3] = {
{60, 67, 131, 89},
{137, 67, 208, 89},
- {214, 67, 285, 89}};
+ {214, 67, 285, 89}
+};
const byte kComputerChoiceDependencyStateIndex[30] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 30,
31, 32, 33, 34, 0, 0, 0, 0, 35, 0,
- 37, 0, 0, 0, 0, 0, 0, 0, 0, 0};
+ 37, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
const CompositeBitmapVariantSet kComputerDetailBitmapVariantsBySelectedValue[31] = {
{0, {}},
@@ -194,7 +206,8 @@ const CompositeBitmapVariantSet kComputerDetailBitmapVariantsBySelectedValue[31]
{1, {"bmp/comp/pcom_27a.bmp"}},
{3, {"bmp/comp/pcom_28a.bmp", "bmp/comp/pcom_28b.bmp", "bmp/comp/pcom_28c.bmp"}},
{3, {"bmp/comp/pcom_29a.bmp", "bmp/comp/pcom_29b.bmp", "bmp/comp/pcom_29c.bmp"}},
- {1, {"bmp/comp/pcom_30a.bmp"}}};
+ {1, {"bmp/comp/pcom_30a.bmp"}}
+};
const byte kSceneChoiceValueByButtonIndex[10] = {0, 1, 2, 4, 8, 16, 32, 64, 128, 255};
@@ -208,6 +221,7 @@ const char *const kStillImageHighColorPaths[8] = {
"bmp/still/16m/pstill_5.bmp",
"bmp/still/16m/pbad.bmp",
"bmp/still/16m/pgood.bmp",
- "bmp/still/16m/pstaff.bmp"};
+ "bmp/still/16m/pstaff.bmp"
+};
} // End of namespace BCB
diff --git a/engines/harold/bcb/text_renderer.cpp b/engines/harold/bcb/text_renderer.cpp
index 7d7b0dc8557..cd2d6ba00c5 100644
--- a/engines/harold/bcb/text_renderer.cpp
+++ b/engines/harold/bcb/text_renderer.cpp
@@ -184,7 +184,7 @@ bool layoutPillowGlyphs(FT_Face face, const Common::U32String &text, Common::Arr
}
bool getPillowTextMaskMetrics(FT_Face face, const Common::Array<PillowGlyphInfo> &glyphs, int strokeWidth,
- int &xOffset, int &yOffset, int &xMin, int &yMax, int &maskWidth, int &maskHeight, int loadFlags) {
+ int &xOffset, int &yOffset, int &xMin, int &yMax, int &maskWidth, int &maskHeight, int loadFlags) {
int bboxXMin = 0;
int bboxXMax = 0;
int yMin = 0;
@@ -271,7 +271,7 @@ void renderPillowGlyphBitmapToSurface(Graphics::Surface &surface, const FT_Bitma
}
bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common::Array<PillowGlyphInfo> &glyphs,
- int x, int y, uint32 color, int strokeWidth, bool strokeOnly) {
+ int x, int y, uint32 color, int strokeWidth, bool strokeOnly) {
const int loadFlags = strokeOnly ? FT_LOAD_NO_BITMAP : (FT_LOAD_DEFAULT | FT_LOAD_RENDER);
int xOffset = 0;
int yOffset = 0;
@@ -336,8 +336,8 @@ bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common
}
bool drawFreeTypeTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
- const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
- int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
+ const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
Common::Array<byte> fontData;
if (!loadFontDataFromArchives(fontName, fontData))
return false;
@@ -418,7 +418,7 @@ static uint8 pillowResampleClip8(int value) {
}
int precomputePillowCoefficients(int inputSize, float inputStart, float inputEnd, int outputSize,
- Common::Array<int> &bounds, Common::Array<int> &coefficients) {
+ Common::Array<int> &bounds, Common::Array<int> &coefficients) {
const double scale = (double)(inputEnd - inputStart) / outputSize;
const double filterScale = MAX<double>(scale, 1.0);
const double support = 2.0 * filterScale;
@@ -513,7 +513,7 @@ Common::Rect findSurfaceAlphaBounds(const Graphics::Surface &surface) {
}
void findOutputBoundsForSourceBounds(const Common::Array<int> &bounds, int outputSize, const Common::Rect &sourceBounds,
- bool horizontal, int &first, int &last) {
+ bool horizontal, int &first, int &last) {
first = outputSize;
last = 0;
const int sourceMin = horizontal ? sourceBounds.left : sourceBounds.top;
@@ -541,11 +541,11 @@ Graphics::Surface *downscaleRgbaLayerBicubicInternal(const Graphics::Surface &so
Common::Array<int> horizontalBounds;
Common::Array<int> horizontalCoefficients;
const int horizontalKernelSize = precomputePillowCoefficients(source.w, 0.0f, (float)source.w, width,
- horizontalBounds, horizontalCoefficients);
+ horizontalBounds, horizontalCoefficients);
Common::Array<int> verticalBounds;
Common::Array<int> verticalCoefficients;
const int verticalKernelSize = precomputePillowCoefficients(source.h, 0.0f, (float)source.h, height,
- verticalBounds, verticalCoefficients);
+ verticalBounds, verticalCoefficients);
int firstOutX = 0;
int lastOutX = 0;
@@ -639,8 +639,8 @@ void alphaCompositeRgbaLayer(Graphics::Surface &target, const Graphics::Surface
}
void drawHighQualityTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
- const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
- int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
+ const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
#ifdef USE_FREETYPE2
drawFreeTypeTextLine(surface, fontName, size, shadowOffsets, text, x, y, textColor, shadowColor, strokeWidth);
#endif
diff --git a/engines/harold/bcb/text_renderer.h b/engines/harold/bcb/text_renderer.h
index 19a2979c37e..0e2ec334e72 100644
--- a/engines/harold/bcb/text_renderer.h
+++ b/engines/harold/bcb/text_renderer.h
@@ -35,8 +35,8 @@ struct Surface;
namespace BCB {
void drawHighQualityTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
- const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
- int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth);
+ const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth);
Graphics::Surface *downscaleRgbaLayerBicubic(const Graphics::Surface &source, int width, int height);
void alphaCompositeRgbaLayer(Graphics::Surface &target, const Graphics::Surface &layer);
diff --git a/engines/harold/bcb/translation.cpp b/engines/harold/bcb/translation.cpp
index dbc412b77e9..2df18ad0d3e 100644
--- a/engines/harold/bcb/translation.cpp
+++ b/engines/harold/bcb/translation.cpp
@@ -28,8 +28,8 @@
#include "common/textconsole.h"
#include "common/util.h"
-#include "harold/bcb/translation.h"
#include "harold/bcb/bcb.h"
+#include "harold/bcb/translation.h"
namespace BCB {
namespace {
@@ -166,7 +166,8 @@ const char *TextStringTable::getString(const Common::String &key) const {
return entry == end() ? nullptr : entry->_value.c_str();
}
-TextTranslationData::TextTranslationData() : packageArchive(nullptr) {
+TextTranslationData::TextTranslationData()
+ : packageArchive(nullptr) {
}
TextTranslationData::~TextTranslationData() {
diff --git a/engines/harold/bcb/translation_images.cpp b/engines/harold/bcb/translation_images.cpp
index 1c06cb872e7..a539541e5e5 100644
--- a/engines/harold/bcb/translation_images.cpp
+++ b/engines/harold/bcb/translation_images.cpp
@@ -117,8 +117,8 @@ bool parseStillHeadingLine(const char *definition, Common::U32String &text, int
}
void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextStringTable &strings, const Common::String &prefix,
- const char *defaultFont, uint8 defaultTextR, uint8 defaultTextG, uint8 defaultTextB,
- uint8 defaultShadowR, uint8 defaultShadowG, uint8 defaultShadowB) {
+ const char *defaultFont, uint8 defaultTextR, uint8 defaultTextG, uint8 defaultTextB,
+ uint8 defaultShadowR, uint8 defaultShadowG, uint8 defaultShadowB) {
const char *fontName = strings.getString(prefix + "font");
if (!fontName || !fontName[0])
fontName = defaultFont;
@@ -146,7 +146,7 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextSt
const Common::Array<Common::Point> emptyShadowOffsets;
drawHighQualityTextLine(layer, fontName, size * scale, (strokeWidth == 0 && !drawShadowWithoutStroke) ? emptyShadowOffsets : scaledShadowOffsets,
- text, x * scale, y * scale, scaledTextColor, scaledShadowColor, strokeWidth * scale);
+ text, x * scale, y * scale, scaledTextColor, scaledShadowColor, strokeWidth * scale);
}
Graphics::Surface *downscaledLayer = downscaleRgbaLayerBicubic(layer, surface.w, surface.h);
diff --git a/engines/harold/bcb/video.cpp b/engines/harold/bcb/video.cpp
index ed8946dd0ee..e5ea5d0e75e 100644
--- a/engines/harold/bcb/video.cpp
+++ b/engines/harold/bcb/video.cpp
@@ -82,11 +82,11 @@ void BCBEngine::drawMapSubmodeMovieBackdrop(bool present) {
const Graphics::Surface *map = getUiBitmap("16mmap.bmp");
if (map) {
const Common::Rect sourceRect(kMapSubmodeMovieBackdropSourceX, kMapSubmodeMovieBackdropSourceY,
- kMapSubmodeMovieBackdropSourceX + 0x1a4, kMapSubmodeMovieBackdropSourceY + 0x11e);
+ kMapSubmodeMovieBackdropSourceX + 0x1a4, kMapSubmodeMovieBackdropSourceY + 0x11e);
if (sourceRect.right <= map->w && sourceRect.bottom <= map->h)
_screen->copyRectToSurface(map->getBasePtr(sourceRect.left, sourceRect.top), map->pitch,
- kMapSubmodeMovieBackdropRect.left, kMapSubmodeMovieBackdropRect.top,
- sourceRect.width(), sourceRect.height());
+ kMapSubmodeMovieBackdropRect.left, kMapSubmodeMovieBackdropRect.top,
+ sourceRect.width(), sourceRect.height());
} else {
Graphics::Surface *screen = _screen->surfacePtr();
if (!screen)
diff --git a/engines/harold/detection.cpp b/engines/harold/detection.cpp
index 478587301ac..44a10aa5772 100644
--- a/engines/harold/detection.cpp
+++ b/engines/harold/detection.cpp
@@ -36,7 +36,8 @@ static const DebugChannelDef debugFlagList[] = {
class HaroldMetaEngineDetection : public AdvancedMetaEngineDetection<BCB::HaroldGameDescription> {
public:
- HaroldMetaEngineDetection() : AdvancedMetaEngineDetection(BCB::gameDescriptions, haroldGames) {
+ HaroldMetaEngineDetection()
+ : AdvancedMetaEngineDetection(BCB::gameDescriptions, haroldGames) {
_guiOptions = GUIO2(GUIO_NOMIDI, GUIO_NOSUBTITLES);
_maxScanDepth = 3;
_directoryGlobs = directoryGlobs;
diff --git a/engines/harold/detection_tables.h b/engines/harold/detection_tables.h
index 483c0501661..953dfd62212 100644
--- a/engines/harold/detection_tables.h
+++ b/engines/harold/detection_tables.h
@@ -36,7 +36,8 @@ static const HaroldGameDescription gameDescriptions[] = {
Common::JA_JPN,
Common::kPlatformWindows,
ADGF_UNSTABLE,
- GUIO0()},
+ GUIO0()
+ },
kHaroldGameBCB
},
@@ -54,10 +55,12 @@ static const HaroldGameDescription gameDescriptions[] = {
Common::KO_KOR,
Common::kPlatformWindows,
ADGF_UNSTABLE,
- GUIO0()},
+ GUIO0()
+ },
kHaroldGameBCB
},
- {AD_TABLE_END_MARKER, kHaroldGameBCB}};
+ {AD_TABLE_END_MARKER, kHaroldGameBCB}
+};
} // End of namespace BCB
diff --git a/engines/harold/metaengine.cpp b/engines/harold/metaengine.cpp
index f85faa11d9c..4f3d5a4fa0f 100644
--- a/engines/harold/metaengine.cpp
+++ b/engines/harold/metaengine.cpp
@@ -19,8 +19,8 @@
*
*/
-#include "common/events.h"
#include "common/config-manager.h"
+#include "common/events.h"
#include "common/translation.h"
#include "backends/keymapper/action.h"
Commit: e483aab12bcd61ca0630dc1e6a925d3a861a79a6
https://github.com/scummvm/scummvm/commit/e483aab12bcd61ca0630dc1e6a925d3a861a79a6
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:13+03:00
Commit Message:
HAROLD: BCB: Render translated computer cards from translation packages
Changed paths:
engines/harold/bcb/computer.cpp
engines/harold/bcb/text_renderer.cpp
engines/harold/bcb/text_renderer.h
engines/harold/bcb/translation.h
engines/harold/bcb/translation_images.cpp
diff --git a/engines/harold/bcb/computer.cpp b/engines/harold/bcb/computer.cpp
index 4dafbbd747c..f2fd8dad1ee 100644
--- a/engines/harold/bcb/computer.cpp
+++ b/engines/harold/bcb/computer.cpp
@@ -297,6 +297,8 @@ bool BCBEngine::showComputerDetailScreen(int compositeIndex) {
Graphics::Surface *composite = loadDiscBitmap(compositePath);
if (!composite)
return false;
+ if (_gameDescription->desc.language == Common::JA_JPN && _selectedTextLanguagePackageAvailable)
+ applyTranslatedComputerCard(*composite, compositePath, _textTranslation);
Graphics::Surface *screen = _screen->surfacePtr();
if (screen) {
diff --git a/engines/harold/bcb/text_renderer.cpp b/engines/harold/bcb/text_renderer.cpp
index cd2d6ba00c5..4797a45afa1 100644
--- a/engines/harold/bcb/text_renderer.cpp
+++ b/engines/harold/bcb/text_renderer.cpp
@@ -184,7 +184,7 @@ bool layoutPillowGlyphs(FT_Face face, const Common::U32String &text, Common::Arr
}
bool getPillowTextMaskMetrics(FT_Face face, const Common::Array<PillowGlyphInfo> &glyphs, int strokeWidth,
- int &xOffset, int &yOffset, int &xMin, int &yMax, int &maskWidth, int &maskHeight, int loadFlags) {
+ int &xOffset, int &yOffset, int &xMin, int &yMax, int &maskWidth, int &maskHeight, int loadFlags) {
int bboxXMin = 0;
int bboxXMax = 0;
int yMin = 0;
@@ -271,7 +271,7 @@ void renderPillowGlyphBitmapToSurface(Graphics::Surface &surface, const FT_Bitma
}
bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common::Array<PillowGlyphInfo> &glyphs,
- int x, int y, uint32 color, int strokeWidth, bool strokeOnly) {
+ int x, int y, uint32 color, int strokeWidth, bool strokeOnly) {
const int loadFlags = strokeOnly ? FT_LOAD_NO_BITMAP : (FT_LOAD_DEFAULT | FT_LOAD_RENDER);
int xOffset = 0;
int yOffset = 0;
@@ -336,8 +336,8 @@ bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common
}
bool drawFreeTypeTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
- const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
- int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
+ const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
Common::Array<byte> fontData;
if (!loadFontDataFromArchives(fontName, fontData))
return false;
@@ -412,16 +412,25 @@ static double cubicWeight(double value) {
static const int kPillowResamplePrecisionBits = 22;
+static double lanczosWeight(double value) {
+ if (value == 0.0)
+ return 1.0;
+ if (fabs(value) >= 3.0)
+ return 0.0;
+ const double angle = value * 3.14159265358979323846;
+ return (sin(angle) / angle) * (sin(angle / 3.0) / (angle / 3.0));
+}
+
static uint8 pillowResampleClip8(int value) {
value >>= kPillowResamplePrecisionBits;
return CLIP<int>(value, 0, 255);
}
-int precomputePillowCoefficients(int inputSize, float inputStart, float inputEnd, int outputSize,
- Common::Array<int> &bounds, Common::Array<int> &coefficients) {
+int precomputePillowCoefficients(int inputSize, float inputStart, float inputEnd, int outputSize, bool lanczos,
+ Common::Array<int> &bounds, Common::Array<int> &coefficients) {
const double scale = (double)(inputEnd - inputStart) / outputSize;
const double filterScale = MAX<double>(scale, 1.0);
- const double support = 2.0 * filterScale;
+ const double support = (lanczos ? 3.0 : 2.0) * filterScale;
const int kernelSize = (int)ceil(support) * 2 + 1;
bounds.resize(outputSize * 2);
@@ -440,7 +449,8 @@ int precomputePillowCoefficients(int inputSize, float inputStart, float inputEnd
double weightSum = 0.0;
for (int x = 0; x < xmax; ++x) {
- const double weight = cubicWeight((x + xmin - center + 0.5) * invFilterScale);
+ const double distance = (x + xmin - center + 0.5) * invFilterScale;
+ const double weight = lanczos ? lanczosWeight(distance) : cubicWeight(distance);
precomputed[outX * kernelSize + x] = weight;
weightSum += weight;
}
@@ -513,7 +523,7 @@ Common::Rect findSurfaceAlphaBounds(const Graphics::Surface &surface) {
}
void findOutputBoundsForSourceBounds(const Common::Array<int> &bounds, int outputSize, const Common::Rect &sourceBounds,
- bool horizontal, int &first, int &last) {
+ bool horizontal, int &first, int &last) {
first = outputSize;
last = 0;
const int sourceMin = horizontal ? sourceBounds.left : sourceBounds.top;
@@ -529,7 +539,7 @@ void findOutputBoundsForSourceBounds(const Common::Array<int> &bounds, int outpu
}
}
-Graphics::Surface *downscaleRgbaLayerBicubicInternal(const Graphics::Surface &source, int width, int height) {
+Graphics::Surface *downscaleRgbaLayerInternal(const Graphics::Surface &source, int width, int height, bool lanczos) {
Graphics::Surface *target = new Graphics::Surface();
target->create(width, height, source.format);
target->fillRect(Common::Rect(width, height), 0);
@@ -540,12 +550,12 @@ Graphics::Surface *downscaleRgbaLayerBicubicInternal(const Graphics::Surface &so
Common::Array<int> horizontalBounds;
Common::Array<int> horizontalCoefficients;
- const int horizontalKernelSize = precomputePillowCoefficients(source.w, 0.0f, (float)source.w, width,
- horizontalBounds, horizontalCoefficients);
+ const int horizontalKernelSize = precomputePillowCoefficients(source.w, 0.0f, (float)source.w, width, lanczos,
+ horizontalBounds, horizontalCoefficients);
Common::Array<int> verticalBounds;
Common::Array<int> verticalCoefficients;
- const int verticalKernelSize = precomputePillowCoefficients(source.h, 0.0f, (float)source.h, height,
- verticalBounds, verticalCoefficients);
+ const int verticalKernelSize = precomputePillowCoefficients(source.h, 0.0f, (float)source.h, height, lanczos,
+ verticalBounds, verticalCoefficients);
int firstOutX = 0;
int lastOutX = 0;
@@ -631,7 +641,11 @@ Graphics::Surface *downscaleRgbaLayerBicubicInternal(const Graphics::Surface &so
} // End of anonymous namespace
Graphics::Surface *downscaleRgbaLayerBicubic(const Graphics::Surface &source, int width, int height) {
- return downscaleRgbaLayerBicubicInternal(source, width, height);
+ return downscaleRgbaLayerInternal(source, width, height, false);
+}
+
+Graphics::Surface *downscaleRgbaLayerLanczos(const Graphics::Surface &source, int width, int height) {
+ return downscaleRgbaLayerInternal(source, width, height, true);
}
void alphaCompositeRgbaLayer(Graphics::Surface &target, const Graphics::Surface &layer) {
@@ -639,8 +653,8 @@ void alphaCompositeRgbaLayer(Graphics::Surface &target, const Graphics::Surface
}
void drawHighQualityTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
- const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
- int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
+ const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
#ifdef USE_FREETYPE2
drawFreeTypeTextLine(surface, fontName, size, shadowOffsets, text, x, y, textColor, shadowColor, strokeWidth);
#endif
diff --git a/engines/harold/bcb/text_renderer.h b/engines/harold/bcb/text_renderer.h
index 0e2ec334e72..6fedb383ffc 100644
--- a/engines/harold/bcb/text_renderer.h
+++ b/engines/harold/bcb/text_renderer.h
@@ -35,9 +35,10 @@ struct Surface;
namespace BCB {
void drawHighQualityTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
- const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
- int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth);
+ const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth);
Graphics::Surface *downscaleRgbaLayerBicubic(const Graphics::Surface &source, int width, int height);
+Graphics::Surface *downscaleRgbaLayerLanczos(const Graphics::Surface &source, int width, int height);
void alphaCompositeRgbaLayer(Graphics::Surface &target, const Graphics::Surface &layer);
} // End of namespace BCB
diff --git a/engines/harold/bcb/translation.h b/engines/harold/bcb/translation.h
index 65b6c545318..ab957be34b3 100644
--- a/engines/harold/bcb/translation.h
+++ b/engines/harold/bcb/translation.h
@@ -76,6 +76,7 @@ bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::Str
void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const TextTranslationData &translation);
void applyTranslatedTitleMenu(Graphics::Surface &title, const TextTranslationData &translation);
void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTranslationData &translation);
+void applyTranslatedComputerCard(Graphics::Surface &card, const char *path, const TextTranslationData &translation);
const char *getTextTranslation(const TextTranslationData &translation, TextTranslationType type, uint primaryId, uint secondaryId);
const char *getSystemTextTranslation(const TextTranslationData &translation, const char *key);
diff --git a/engines/harold/bcb/translation_images.cpp b/engines/harold/bcb/translation_images.cpp
index a539541e5e5..4f082d84c65 100644
--- a/engines/harold/bcb/translation_images.cpp
+++ b/engines/harold/bcb/translation_images.cpp
@@ -87,13 +87,14 @@ Common::Array<Common::Point> getTranslationShadowOffsets(const TextStringTable &
return offsets;
}
-bool parseStillHeadingLine(const char *definition, Common::U32String &text, int &x, int &y, int &size, int &strokeWidth) {
+bool parseImageTextLine(const char *definition, Common::U32String &text, int &x, int &y, int &size, int &strokeWidth,
+ uint32 &color, const Graphics::PixelFormat &format) {
if (!definition || !definition[0])
return false;
- Common::String fields[5];
+ Common::String fields[6];
Common::String remaining(definition);
- for (int i = 0; i < 5; ++i) {
+ for (int i = 0; i < 6; ++i) {
const uint separator = remaining.findFirstOf(";");
if (separator == Common::String::npos) {
fields[i] = remaining;
@@ -113,12 +114,15 @@ bool parseStillHeadingLine(const char *definition, Common::U32String &text, int
parseTranslationInt(fields[2].c_str(), y);
parseTranslationInt(fields[3].c_str(), size);
parseTranslationInt(fields[4].c_str(), strokeWidth);
+ uint r, g, b;
+ if (sscanf(fields[5].c_str(), "%u,%u,%u", &r, &g, &b) == 3)
+ color = format.ARGBToColor(255, MIN(r, 255U), MIN(g, 255U), MIN(b, 255U));
return true;
}
void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextStringTable &strings, const Common::String &prefix,
- const char *defaultFont, uint8 defaultTextR, uint8 defaultTextG, uint8 defaultTextB,
- uint8 defaultShadowR, uint8 defaultShadowG, uint8 defaultShadowB) {
+ const char *defaultFont, uint8 defaultTextR, uint8 defaultTextG, uint8 defaultTextB,
+ uint8 defaultShadowR, uint8 defaultShadowG, uint8 defaultShadowB, bool resampleBackground = false) {
const char *fontName = strings.getString(prefix + "font");
if (!fontName || !fontName[0])
fontName = defaultFont;
@@ -129,27 +133,40 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextSt
Graphics::Surface layer;
layer.create(surface.w * scale, surface.h * scale, Graphics::PixelFormat::createFormatRGBA32());
layer.fillRect(Common::Rect(layer.w, layer.h), 0);
+ if (resampleBackground) {
+ for (int y = 0; y < surface.h; ++y) {
+ for (int x = 0; x < surface.w; ++x) {
+ uint8 r, g, b;
+ surface.format.colorToRGB(surface.getPixel(x, y), r, g, b);
+ layer.fillRect(Common::Rect(x * scale, y * scale, (x + 1) * scale, (y + 1) * scale), layer.format.RGBToColor(r, g, b));
+ }
+ }
+ }
const uint32 scaledTextColor = getTranslationColor(strings, prefix + "text_color", layer.format, defaultTextR, defaultTextG, defaultTextB);
const uint32 scaledShadowColor = getTranslationColor(strings, prefix + "shadow_color", layer.format, defaultShadowR, defaultShadowG, defaultShadowB);
Common::Array<Common::Point> scaledShadowOffsets;
for (uint i = 0; i < shadowOffsets.size(); ++i)
scaledShadowOffsets.push_back(Common::Point(shadowOffsets[i].x * scale, shadowOffsets[i].y * scale));
- for (int i = 1; i <= 16; ++i) {
+ const int lineCount = CLIP(getTranslationInt(strings, prefix + "line_count", 16), 0, 256);
+ for (int i = 1; i <= lineCount; ++i) {
Common::U32String text;
int x = 0;
int y = 0;
int size = 44;
int strokeWidth = 0;
- if (!parseStillHeadingLine(strings.getString(Common::String::format("%sline%d", prefix.c_str(), i)), text, x, y, size, strokeWidth))
+ uint32 textColor = scaledTextColor;
+ if (!parseImageTextLine(strings.getString(Common::String::format("%sline%d", prefix.c_str(), i)), text, x, y, size, strokeWidth, textColor, layer.format))
continue;
+ size = CLIP(size, 1, 128);
+ strokeWidth = CLIP(strokeWidth, 0, 16);
const Common::Array<Common::Point> emptyShadowOffsets;
drawHighQualityTextLine(layer, fontName, size * scale, (strokeWidth == 0 && !drawShadowWithoutStroke) ? emptyShadowOffsets : scaledShadowOffsets,
- text, x * scale, y * scale, scaledTextColor, scaledShadowColor, strokeWidth * scale);
+ text, x * scale, y * scale, textColor, scaledShadowColor, strokeWidth * scale);
}
- Graphics::Surface *downscaledLayer = downscaleRgbaLayerBicubic(layer, surface.w, surface.h);
+ Graphics::Surface *downscaledLayer = resampleBackground ? downscaleRgbaLayerLanczos(layer, surface.w, surface.h) : downscaleRgbaLayerBicubic(layer, surface.w, surface.h);
layer.free();
if (!downscaledLayer)
return;
@@ -168,15 +185,15 @@ void drawTranslatedStillHeading(Graphics::Surface &still, int stillIndex, const
drawConfiguredHighQualityTextLines(still, strings, prefix, "LiberationSerif-BoldItalic.ttf", 255, 255, 255, 0, 0, 0);
}
-void applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *stream, const char *debugName) {
+bool applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *stream, const char *debugName) {
Common::ScopedPtr<Common::SeekableReadStream> patchStream(stream);
if (!patchStream)
- return;
+ return false;
Image::PNGDecoder decoder;
if (!decoder.loadStream(*patchStream) || !decoder.getSurface()) {
warning("%s: Could not decode translated patch", debugName);
- return;
+ return false;
}
const Graphics::Surface *patch = decoder.getSurface();
@@ -203,10 +220,30 @@ void applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *str
surface.setPixel(x, y, surface.format.ARGBToColor(0xff, outR, outG, outB));
}
}
+ return true;
}
} // End of anonymous namespace
+void applyTranslatedComputerCard(Graphics::Surface &card, const char *path, const TextTranslationData &translation) {
+#ifdef USE_FREETYPE2
+ if (!translation.packageArchive)
+ return;
+ Common::String name = Common::Path(path, '/').getLastComponent().toString();
+ name.toLowercase();
+ const uint dot = name.findLastOf('.');
+ if (dot != Common::String::npos)
+ name = name.substr(0, dot);
+ const Common::String prefix = "computer_cards." + name + ".";
+ const char *patch = translation.strings.getString(prefix + "patch");
+ if (!patch || !translation.strings.getString(prefix + "line1"))
+ return;
+ if (!applyPatchImage(card, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "applyTranslatedComputerCard"))
+ return;
+ drawConfiguredHighQualityTextLines(card, translation.strings, prefix, "LiberationSans-Regular.ttf", 218, 218, 236, 0, 0, 0, true);
+#endif
+}
+
void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const TextTranslationData &translation) {
if (translation.packageArchive && stillIndex >= 0 && stillIndex < 5) {
applyPatchImage(still, translation.packageArchive->createReadStreamForMember(Common::Path(Common::String::format("patches/pstill_%d_patch.png", stillIndex + 1), '/')), "applyTranslatedStillImage");
Commit: b8db9700226f3be653a592acfc3b8fe10e9f951b
https://github.com/scummvm/scummvm/commit/b8db9700226f3be653a592acfc3b8fe10e9f951b
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:13+03:00
Commit Message:
HAROLD: BCB: Optimize translation rendering and refine computer and movie presentation
Changed paths:
engines/harold/POTFILES
engines/harold/bcb/bcb.cpp
engines/harold/bcb/bcb.h
engines/harold/bcb/computer.cpp
engines/harold/bcb/text_renderer.cpp
engines/harold/bcb/text_renderer.h
engines/harold/bcb/translation.cpp
engines/harold/bcb/translation.h
engines/harold/bcb/translation_images.cpp
engines/harold/bcb/video.cpp
diff --git a/engines/harold/POTFILES b/engines/harold/POTFILES
index 10f9e1eb1e2..e243e6e8551 100644
--- a/engines/harold/POTFILES
+++ b/engines/harold/POTFILES
@@ -1 +1,2 @@
+engines/harold/bcb/options.cpp
engines/harold/metaengine.cpp
diff --git a/engines/harold/bcb/bcb.cpp b/engines/harold/bcb/bcb.cpp
index 44c16933772..12e36e3284a 100644
--- a/engines/harold/bcb/bcb.cpp
+++ b/engines/harold/bcb/bcb.cpp
@@ -99,7 +99,7 @@ BCBEngine::~BCBEngine() {
_computerBitmap->free();
delete _computerBitmap;
}
- delete _activeMovieVideo;
+ stopActiveMovie();
delete _mapMoveVideo;
delete _sceneIdleVideo;
delete _gameOverVideo;
diff --git a/engines/harold/bcb/bcb.h b/engines/harold/bcb/bcb.h
index e964347965b..a62019ab05c 100644
--- a/engines/harold/bcb/bcb.h
+++ b/engines/harold/bcb/bcb.h
@@ -149,6 +149,7 @@ private:
void drawXorRectangleBorder(const Common::Rect &rect);
void processXorRectangleBorderAnimation(bool expand, const Common::Rect &sourceRect, const Common::Rect &targetRect);
bool showComputerDetailScreen(int compositeIndex);
+ Graphics::Surface *loadComputerDetailBitmap(const char *path);
void checkCurrentMediaPathReady();
void clearDisplayAndResetState();
void executeCurrentScriptSequence();
@@ -277,6 +278,8 @@ private:
Common::Rect _sceneChoiceBackingRect;
Graphics::Surface *_computerBitmap = nullptr;
Graphics::Surface *_computerDetailBacking = nullptr;
+ struct PreparedComputerCard;
+ PreparedComputerCard *_preparedComputerCard = nullptr;
Audio::SoundHandle _uiSoundHandle;
uint32 _gameState[0x100] = {};
uint32 _scriptValueStack[0x100] = {};
@@ -313,6 +316,8 @@ private:
Common::Point _mousePosition;
bool _activeMovieDispatchOnFinish = false;
bool _activeMovieOnBlankScreen = false;
+ bool _activeMovieCursorHidden = false;
+ bool _activeMovieCursorWasVisible = false;
bool _activeMoviePaused = false;
bool _sceneChoiceActive = false;
bool _mapControlsActive = false;
diff --git a/engines/harold/bcb/computer.cpp b/engines/harold/bcb/computer.cpp
index f2fd8dad1ee..765a1119d07 100644
--- a/engines/harold/bcb/computer.cpp
+++ b/engines/harold/bcb/computer.cpp
@@ -22,6 +22,7 @@
#include "common/algorithm.h"
#include "common/endian.h"
#include "common/events.h"
+#include "common/ptr.h"
#include "common/system.h"
#include "graphics/screen.h"
#include "graphics/surface.h"
@@ -37,6 +38,12 @@ static const int kComputerCompositeTransitionTop = 36;
static const int kComputerCompositeTransitionRight = 606;
static const int kComputerCompositeTransitionBottom = 444;
+struct BCBEngine::PreparedComputerCard {
+ const char *path = nullptr;
+ int disc = 0;
+ Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> bitmap;
+};
+
const Graphics::Surface *BCBEngine::getComputerBitmap() {
if (!_computerBitmap) {
_computerBitmap = loadBitmap("256com.bmp");
@@ -280,6 +287,17 @@ void BCBEngine::drawComputerConditionalChoiceControls(const ButtonControlRecord
}
}
+Graphics::Surface *BCBEngine::loadComputerDetailBitmap(const char *path) {
+ if (_preparedComputerCard && _preparedComputerCard->bitmap &&
+ _preparedComputerCard->disc == _activeMediaDiscNumber && !strcmp(_preparedComputerCard->path, path))
+ return _preparedComputerCard->bitmap.release();
+
+ Graphics::Surface *bitmap = loadDiscBitmap(path);
+ if (bitmap && _gameDescription->desc.language == Common::JA_JPN && _selectedTextLanguagePackageAvailable)
+ applyTranslatedComputerCard(*bitmap, path, _textTranslation);
+ return bitmap;
+}
+
bool BCBEngine::showComputerDetailScreen(int compositeIndex) {
if (compositeIndex < 0 || compositeIndex >= (int)ARRAYSIZE(kComputerDetailBitmapVariantsBySelectedValue))
return false;
@@ -294,11 +312,19 @@ bool BCBEngine::showComputerDetailScreen(int compositeIndex) {
if (!computer)
return false;
- Graphics::Surface *composite = loadDiscBitmap(compositePath);
+ Graphics::Surface *composite = loadComputerDetailBitmap(compositePath);
if (!composite)
return false;
- if (_gameDescription->desc.language == Common::JA_JPN && _selectedTextLanguagePackageAvailable)
- applyTranslatedComputerCard(*composite, compositePath, _textTranslation);
+
+ if (_gameDescription->desc.language == Common::JA_JPN && _selectedTextLanguagePackageAvailable && variantSet.pathCount > 1) {
+ const ButtonControlRecord &button = kComputerDetailButtonTable[2];
+ const int sourceX = displayedVariantIndex + 1 < (int)variantSet.pathCount ? 312 : 472;
+ const int x = button.x - 0x24;
+ const int y = button.y - 0x23;
+ if (x + button.width <= composite->w && y + button.height <= composite->h &&
+ sourceX + button.width <= computer->w && 672 + button.height <= computer->h)
+ composite->copyRectToSurface(*computer, x, y, Common::Rect(sourceX, 672, sourceX + button.width, 672 + button.height));
+ }
Graphics::Surface *screen = _screen->surfacePtr();
if (screen) {
@@ -359,13 +385,25 @@ bool BCBEngine::handleComputerClick(const Common::Point &mousePosition) {
continue;
playUiSound();
+ const int compositeIndex = _computerActiveChoiceIds[i] - 700;
+ PreparedComputerCard prepared;
+ if (compositeIndex >= 0 && compositeIndex < (int)ARRAYSIZE(kComputerDetailBitmapVariantsBySelectedValue)) {
+ const CompositeBitmapVariantSet &variants = kComputerDetailBitmapVariantsBySelectedValue[compositeIndex];
+ if (variants.pathCount > 0) {
+ prepared.path = variants.paths[0];
+ prepared.disc = _activeMediaDiscNumber;
+ prepared.bitmap.reset(loadComputerDetailBitmap(prepared.path));
+ }
+ }
+ _preparedComputerCard = &prepared;
_computerSelectionXorRect = _computerActiveChoiceRects[i];
processXorRectangleBorderAnimation(true, _computerSelectionXorRect, Common::Rect(kComputerCompositeTransitionLeft, kComputerCompositeTransitionTop, kComputerCompositeTransitionRight, kComputerCompositeTransitionBottom));
_computerControlsActive = false;
- stateDword(kStateSelectedSceneChoiceValue) = _computerActiveChoiceIds[i] - 700;
+ stateDword(kStateSelectedSceneChoiceValue) = compositeIndex;
_computerActiveChoiceIds.clear();
_computerActiveChoiceRects.clear();
processGameStateDispatcher(true);
+ _preparedComputerCard = nullptr;
return true;
}
}
diff --git a/engines/harold/bcb/text_renderer.cpp b/engines/harold/bcb/text_renderer.cpp
index 4797a45afa1..aaac2736cf1 100644
--- a/engines/harold/bcb/text_renderer.cpp
+++ b/engines/harold/bcb/text_renderer.cpp
@@ -19,7 +19,9 @@
*
*/
-#define FORBIDDEN_SYMBOL_ALLOW_ALL
+// FreeType includes setjmp declarations in its public headers.
+#define FORBIDDEN_SYMBOL_EXCEPTION_setjmp
+#define FORBIDDEN_SYMBOL_EXCEPTION_longjmp
#include "common/archive.h"
#include "common/compression/unzip.h"
@@ -32,8 +34,6 @@
#include "graphics/fonts/freetype.h"
#include "graphics/surface.h"
-#include <math.h>
-
#include "harold/bcb/text_renderer.h"
#ifdef USE_FREETYPE2
@@ -335,19 +335,13 @@ bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common
return true;
}
-bool drawFreeTypeTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
+bool drawFreeTypeTextLine(Graphics::Surface &surface, FT_Face face, int size,
const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
- Common::Array<byte> fontData;
- if (!loadFontDataFromArchives(fontName, fontData))
+ if (!face)
return false;
- FT_Library library = nullptr;
- if (Graphics::FreeType::Init_FreeType(&library))
- return false;
-
- FT_Face face = nullptr;
- bool ok = !Graphics::FreeType::New_Memory_Face(library, fontData.data(), fontData.size(), 0, &face);
+ bool ok = true;
if (ok) {
FT_Size_RequestRec request;
memset(&request, 0, sizeof(request));
@@ -369,9 +363,6 @@ bool drawFreeTypeTextLine(Graphics::Surface &surface, const Common::String &font
ok = drawFreeTypeTextPass(surface, face, glyphs, x, y, textColor, 0, false) && ok;
}
- if (face)
- Graphics::FreeType::Done_Face(face);
- Graphics::FreeType::Done_FreeType(library);
return ok;
}
#endif
@@ -385,6 +376,10 @@ void alphaCompositeRgbaLayerInternal(Graphics::Surface &target, const Graphics::
layer.format.colorToARGB(layer.getPixel(x, y), srcA, srcR, srcG, srcB);
if (srcA == 0)
continue;
+ if (srcA == 255) {
+ target.setPixel(x, y, target.format.ARGBToColor(255, srcR, srcG, srcB));
+ continue;
+ }
uint8 dstA, dstR, dstG, dstB;
target.format.colorToARGB(target.getPixel(x, y), dstA, dstR, dstG, dstB);
@@ -491,9 +486,22 @@ static inline void unpremultiplyPillowRgba(uint8 a, uint8 &r, uint8 &g, uint8 &b
b = CLIP<int>((255 * b) / a, 0, 255);
}
-Common::Rect findSurfaceAlphaBounds(const Graphics::Surface &surface) {
+Common::Rect findSurfaceAlphaBounds(const Graphics::Surface &surface, bool &opaque) {
Common::Rect bounds;
bool found = false;
+ opaque = true;
+ for (int y = 0; y < surface.h && opaque; ++y) {
+ const byte *row = static_cast<const byte *>(surface.getBasePtr(0, y));
+ for (int x = 0; x < surface.w; ++x) {
+ if (row[x * 4 + 3] != 255) {
+ opaque = false;
+ break;
+ }
+ }
+ }
+ if (opaque)
+ return Common::Rect(surface.w, surface.h);
+
for (int y = 0; y < surface.h; ++y) {
const byte *row = (const byte *)surface.getBasePtr(0, y);
for (int x = 0; x < surface.w; ++x) {
@@ -539,12 +547,42 @@ void findOutputBoundsForSourceBounds(const Common::Array<int> &bounds, int outpu
}
}
+template<bool opaque, bool horizontal>
+void resampleRgbaPixel(const byte *source, int stride, const int *kernel, int count, byte *target) {
+ int sumR = 1 << (kPillowResamplePrecisionBits - 1);
+ int sumG = sumR;
+ int sumB = sumR;
+ int sumA = sumR;
+ for (int i = 0; i < count; ++i, source += stride) {
+ uint8 r = source[0], g = source[1], b = source[2];
+ if (!opaque && horizontal)
+ premultiplyPillowRgba(source[3], r, g, b);
+ const int weight = kernel[i];
+ sumR += r * weight;
+ sumG += g * weight;
+ sumB += b * weight;
+ if (!opaque)
+ sumA += source[3] * weight;
+ }
+ uint8 r = pillowResampleClip8(sumR);
+ uint8 g = pillowResampleClip8(sumG);
+ uint8 b = pillowResampleClip8(sumB);
+ const uint8 a = opaque ? 255 : pillowResampleClip8(sumA);
+ if (!opaque && !horizontal)
+ unpremultiplyPillowRgba(a, r, g, b);
+ target[0] = r;
+ target[1] = g;
+ target[2] = b;
+ target[3] = a;
+}
+
Graphics::Surface *downscaleRgbaLayerInternal(const Graphics::Surface &source, int width, int height, bool lanczos) {
Graphics::Surface *target = new Graphics::Surface();
target->create(width, height, source.format);
target->fillRect(Common::Rect(width, height), 0);
- const Common::Rect sourceAlphaBounds = findSurfaceAlphaBounds(source);
+ bool opaque;
+ const Common::Rect sourceAlphaBounds = findSurfaceAlphaBounds(source, opaque);
if (sourceAlphaBounds.isEmpty())
return target;
@@ -552,6 +590,18 @@ Graphics::Surface *downscaleRgbaLayerInternal(const Graphics::Surface &source, i
Common::Array<int> horizontalCoefficients;
const int horizontalKernelSize = precomputePillowCoefficients(source.w, 0.0f, (float)source.w, width, lanczos,
horizontalBounds, horizontalCoefficients);
+ Common::Array<int> horizontalWeightSums;
+ Common::Array<int> runEnds;
+ if (opaque) {
+ runEnds.resize(source.w);
+ horizontalWeightSums.resize(width * (horizontalKernelSize + 1));
+ for (int x = 0; x < width; ++x) {
+ int *sums = &horizontalWeightSums[x * (horizontalKernelSize + 1)];
+ sums[0] = 0;
+ for (int i = 0; i < horizontalKernelSize; ++i)
+ sums[i + 1] = sums[i] + horizontalCoefficients[x * horizontalKernelSize + i];
+ }
+ }
Common::Array<int> verticalBounds;
Common::Array<int> verticalCoefficients;
const int verticalKernelSize = precomputePillowCoefficients(source.h, 0.0f, (float)source.h, height, lanczos,
@@ -572,31 +622,41 @@ Graphics::Surface *downscaleRgbaLayerInternal(const Graphics::Surface &source, i
for (int y = sourceAlphaBounds.top; y < sourceAlphaBounds.bottom; ++y) {
const byte *sourceRow = (const byte *)source.getBasePtr(0, y);
byte *tempRow = (byte *)temp.getBasePtr(0, y);
+ if (y > sourceAlphaBounds.top && !memcmp(sourceRow, sourceRow - source.pitch, source.w * 4)) {
+ memcpy(tempRow, tempRow - temp.pitch, width * 4);
+ continue;
+ }
+ if (opaque) {
+ const uint32 *pixels = reinterpret_cast<const uint32 *>(sourceRow);
+ runEnds[source.w - 1] = source.w;
+ for (int x = source.w - 2; x >= 0; --x)
+ runEnds[x] = pixels[x] == pixels[x + 1] ? runEnds[x + 1] : x + 1;
+ }
for (int outX = firstOutX; outX < lastOutX; ++outX) {
const int xmin = horizontalBounds[outX * 2 + 0];
const int xmax = horizontalBounds[outX * 2 + 1];
const int *kernel = &horizontalCoefficients[outX * horizontalKernelSize];
- int sumA = 1 << (kPillowResamplePrecisionBits - 1);
- int sumR = 1 << (kPillowResamplePrecisionBits - 1);
- int sumG = 1 << (kPillowResamplePrecisionBits - 1);
- int sumB = 1 << (kPillowResamplePrecisionBits - 1);
- for (int x = 0; x < xmax; ++x) {
- const byte *sourcePixel = sourceRow + (x + xmin) * 4;
- uint8 r = sourcePixel[0];
- uint8 g = sourcePixel[1];
- uint8 b = sourcePixel[2];
- const uint8 a = sourcePixel[3];
- premultiplyPillowRgba(a, r, g, b);
- sumR += r * kernel[x];
- sumG += g * kernel[x];
- sumB += b * kernel[x];
- sumA += a * kernel[x];
- }
byte *tempPixel = tempRow + outX * 4;
- tempPixel[0] = pillowResampleClip8(sumR);
- tempPixel[1] = pillowResampleClip8(sumG);
- tempPixel[2] = pillowResampleClip8(sumB);
- tempPixel[3] = pillowResampleClip8(sumA);
+ if (opaque) {
+ const int *sums = &horizontalWeightSums[outX * (horizontalKernelSize + 1)];
+ int sumR = 1 << (kPillowResamplePrecisionBits - 1);
+ int sumG = sumR;
+ int sumB = sumR;
+ for (int x = xmin; x < xmin + xmax;) {
+ const int end = MIN(runEnds[x], xmin + xmax);
+ const int weight = sums[end - xmin] - sums[x - xmin];
+ const byte *pixel = sourceRow + x * 4;
+ sumR += pixel[0] * weight;
+ sumG += pixel[1] * weight;
+ sumB += pixel[2] * weight;
+ x = end;
+ }
+ tempPixel[0] = pillowResampleClip8(sumR);
+ tempPixel[1] = pillowResampleClip8(sumG);
+ tempPixel[2] = pillowResampleClip8(sumB);
+ tempPixel[3] = 255;
+ } else
+ resampleRgbaPixel<false, true>(sourceRow + xmin * 4, 4, kernel, xmax, tempPixel);
}
}
@@ -605,32 +665,13 @@ Graphics::Surface *downscaleRgbaLayerInternal(const Graphics::Surface &source, i
const int ymax = verticalBounds[outY * 2 + 1];
const int *kernel = &verticalCoefficients[outY * verticalKernelSize];
byte *targetRow = (byte *)target->getBasePtr(0, outY);
+ const byte *tempRow = static_cast<const byte *>(temp.getBasePtr(0, ymin));
for (int x = firstOutX; x < lastOutX; ++x) {
- int sumA = 1 << (kPillowResamplePrecisionBits - 1);
- int sumR = 1 << (kPillowResamplePrecisionBits - 1);
- int sumG = 1 << (kPillowResamplePrecisionBits - 1);
- int sumB = 1 << (kPillowResamplePrecisionBits - 1);
- for (int y = 0; y < ymax; ++y) {
- const byte *tempPixel = (const byte *)temp.getBasePtr(x, y + ymin);
- const uint8 r = tempPixel[0];
- const uint8 g = tempPixel[1];
- const uint8 b = tempPixel[2];
- const uint8 a = tempPixel[3];
- sumR += r * kernel[y];
- sumG += g * kernel[y];
- sumB += b * kernel[y];
- sumA += a * kernel[y];
- }
- uint8 a = pillowResampleClip8(sumA);
- uint8 r = pillowResampleClip8(sumR);
- uint8 g = pillowResampleClip8(sumG);
- uint8 b = pillowResampleClip8(sumB);
- unpremultiplyPillowRgba(a, r, g, b);
byte *targetPixel = targetRow + x * 4;
- targetPixel[0] = r;
- targetPixel[1] = g;
- targetPixel[2] = b;
- targetPixel[3] = a;
+ if (opaque)
+ resampleRgbaPixel<true, false>(tempRow + x * 4, temp.pitch, kernel, ymax, targetPixel);
+ else
+ resampleRgbaPixel<false, false>(tempRow + x * 4, temp.pitch, kernel, ymax, targetPixel);
}
}
@@ -652,11 +693,37 @@ void alphaCompositeRgbaLayer(Graphics::Surface &target, const Graphics::Surface
alphaCompositeRgbaLayerInternal(target, layer);
}
-void drawHighQualityTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
+struct HighQualityTextRenderer::FontData {
+#ifdef USE_FREETYPE2
+ Common::Array<byte> bytes;
+ FT_Library library = nullptr;
+ FT_Face face = nullptr;
+
+ ~FontData() {
+ if (face)
+ Graphics::FreeType::Done_Face(face);
+ if (library)
+ Graphics::FreeType::Done_FreeType(library);
+ }
+#endif
+};
+
+HighQualityTextRenderer::HighQualityTextRenderer(const Common::String &fontName) : _font(new FontData()) {
+#ifdef USE_FREETYPE2
+ if (loadFontDataFromArchives(fontName, _font->bytes) && !Graphics::FreeType::Init_FreeType(&_font->library))
+ Graphics::FreeType::New_Memory_Face(_font->library, _font->bytes.data(), _font->bytes.size(), 0, &_font->face);
+#endif
+}
+
+HighQualityTextRenderer::~HighQualityTextRenderer() {
+ delete _font;
+}
+
+void HighQualityTextRenderer::drawLine(Graphics::Surface &surface, int size,
const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
#ifdef USE_FREETYPE2
- drawFreeTypeTextLine(surface, fontName, size, shadowOffsets, text, x, y, textColor, shadowColor, strokeWidth);
+ drawFreeTypeTextLine(surface, _font->face, size, shadowOffsets, text, x, y, textColor, shadowColor, strokeWidth);
#endif
}
diff --git a/engines/harold/bcb/text_renderer.h b/engines/harold/bcb/text_renderer.h
index 6fedb383ffc..6a5e725f456 100644
--- a/engines/harold/bcb/text_renderer.h
+++ b/engines/harold/bcb/text_renderer.h
@@ -34,9 +34,20 @@ struct Surface;
namespace BCB {
-void drawHighQualityTextLine(Graphics::Surface &surface, const Common::String &fontName, int size,
+class HighQualityTextRenderer {
+public:
+ explicit HighQualityTextRenderer(const Common::String &fontName);
+ ~HighQualityTextRenderer();
+ void drawLine(Graphics::Surface &surface, int size,
const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth);
+
+private:
+ struct FontData;
+ FontData *_font;
+ HighQualityTextRenderer(const HighQualityTextRenderer &) = delete;
+ HighQualityTextRenderer &operator=(const HighQualityTextRenderer &) = delete;
+};
Graphics::Surface *downscaleRgbaLayerBicubic(const Graphics::Surface &source, int width, int height);
Graphics::Surface *downscaleRgbaLayerLanczos(const Graphics::Surface &source, int width, int height);
void alphaCompositeRgbaLayer(Graphics::Surface &target, const Graphics::Surface &layer);
diff --git a/engines/harold/bcb/translation.cpp b/engines/harold/bcb/translation.cpp
index 2df18ad0d3e..8d4f79db9d5 100644
--- a/engines/harold/bcb/translation.cpp
+++ b/engines/harold/bcb/translation.cpp
@@ -29,6 +29,7 @@
#include "common/util.h"
#include "harold/bcb/bcb.h"
+#include "harold/bcb/text_renderer.h"
#include "harold/bcb/translation.h"
namespace BCB {
@@ -175,6 +176,9 @@ TextTranslationData::~TextTranslationData() {
}
void TextTranslationData::clear() {
+ for (auto &entry : imageFonts)
+ delete entry._value;
+ imageFonts.clear();
strings.clear();
delete packageArchive;
packageArchive = nullptr;
@@ -234,6 +238,10 @@ bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::Str
translation.clear();
return false;
}
+ for (const auto &entry : translation.strings) {
+ if (entry._key.hasSuffix(".font") && !entry._value.empty() && !translation.imageFonts.contains(entry._value))
+ translation.imageFonts[entry._value] = new HighQualityTextRenderer(entry._value);
+ }
return true;
}
diff --git a/engines/harold/bcb/translation.h b/engines/harold/bcb/translation.h
index ab957be34b3..f1ae55af0d1 100644
--- a/engines/harold/bcb/translation.h
+++ b/engines/harold/bcb/translation.h
@@ -39,6 +39,8 @@ struct Surface;
namespace BCB {
+class HighQualityTextRenderer;
+
struct TranslationPackageDefinition {
Common::String code;
Common::String displayName;
@@ -66,6 +68,7 @@ public:
void clear();
TextStringTable strings;
+ Common::HashMap<Common::String, HighQualityTextRenderer *> imageFonts;
Common::Archive *packageArchive;
};
diff --git a/engines/harold/bcb/translation_images.cpp b/engines/harold/bcb/translation_images.cpp
index 4f082d84c65..aed50190fd6 100644
--- a/engines/harold/bcb/translation_images.cpp
+++ b/engines/harold/bcb/translation_images.cpp
@@ -120,9 +120,10 @@ bool parseImageTextLine(const char *definition, Common::U32String &text, int &x,
return true;
}
-void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextStringTable &strings, const Common::String &prefix,
+void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextTranslationData &translation, const Common::String &prefix,
const char *defaultFont, uint8 defaultTextR, uint8 defaultTextG, uint8 defaultTextB,
uint8 defaultShadowR, uint8 defaultShadowG, uint8 defaultShadowB, bool resampleBackground = false) {
+ const TextStringTable &strings = translation.strings;
const char *fontName = strings.getString(prefix + "font");
if (!fontName || !fontName[0])
fontName = defaultFont;
@@ -132,15 +133,21 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextSt
const int scale = CLIP<int>(getTranslationInt(strings, prefix + "scale", 4), 1, 8);
Graphics::Surface layer;
layer.create(surface.w * scale, surface.h * scale, Graphics::PixelFormat::createFormatRGBA32());
- layer.fillRect(Common::Rect(layer.w, layer.h), 0);
if (resampleBackground) {
for (int y = 0; y < surface.h; ++y) {
+ uint32 *row = static_cast<uint32 *>(layer.getBasePtr(0, y * scale));
for (int x = 0; x < surface.w; ++x) {
uint8 r, g, b;
surface.format.colorToRGB(surface.getPixel(x, y), r, g, b);
- layer.fillRect(Common::Rect(x * scale, y * scale, (x + 1) * scale, (y + 1) * scale), layer.format.RGBToColor(r, g, b));
+ const uint32 pixel = layer.format.RGBToColor(r, g, b);
+ for (int i = 0; i < scale; ++i)
+ row[x * scale + i] = pixel;
}
+ for (int i = 1; i < scale; ++i)
+ memcpy(layer.getBasePtr(0, y * scale + i), row, layer.w * 4);
}
+ } else {
+ layer.fillRect(Common::Rect(layer.w, layer.h), 0);
}
const uint32 scaledTextColor = getTranslationColor(strings, prefix + "text_color", layer.format, defaultTextR, defaultTextG, defaultTextB);
const uint32 scaledShadowColor = getTranslationColor(strings, prefix + "shadow_color", layer.format, defaultShadowR, defaultShadowG, defaultShadowB);
@@ -149,6 +156,12 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextSt
scaledShadowOffsets.push_back(Common::Point(shadowOffsets[i].x * scale, shadowOffsets[i].y * scale));
const int lineCount = CLIP(getTranslationInt(strings, prefix + "line_count", 16), 0, 256);
+ HighQualityTextRenderer *renderer = translation.imageFonts.getValOrDefault(fontName, nullptr);
+ Common::ScopedPtr<HighQualityTextRenderer> fallbackRenderer;
+ if (!renderer) {
+ fallbackRenderer.reset(new HighQualityTextRenderer(fontName));
+ renderer = fallbackRenderer.get();
+ }
for (int i = 1; i <= lineCount; ++i) {
Common::U32String text;
int x = 0;
@@ -162,7 +175,7 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextSt
strokeWidth = CLIP(strokeWidth, 0, 16);
const Common::Array<Common::Point> emptyShadowOffsets;
- drawHighQualityTextLine(layer, fontName, size * scale, (strokeWidth == 0 && !drawShadowWithoutStroke) ? emptyShadowOffsets : scaledShadowOffsets,
+ renderer->drawLine(layer, size * scale, (strokeWidth == 0 && !drawShadowWithoutStroke) ? emptyShadowOffsets : scaledShadowOffsets,
text, x * scale, y * scale, textColor, scaledShadowColor, strokeWidth * scale);
}
@@ -176,13 +189,13 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextSt
delete downscaledLayer;
}
-void drawTranslatedStillHeading(Graphics::Surface &still, int stillIndex, const TextStringTable &strings) {
+void drawTranslatedStillHeading(Graphics::Surface &still, int stillIndex, const TextTranslationData &translation) {
if (stillIndex < 0 || stillIndex >= 5)
return;
const int stillNumber = stillIndex + 1;
const Common::String prefix = Common::String::format("still_headings.%d.", stillNumber);
- drawConfiguredHighQualityTextLines(still, strings, prefix, "LiberationSerif-BoldItalic.ttf", 255, 255, 255, 0, 0, 0);
+ drawConfiguredHighQualityTextLines(still, translation, prefix, "LiberationSerif-BoldItalic.ttf", 255, 255, 255, 0, 0, 0);
}
bool applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *stream, const char *debugName) {
@@ -240,7 +253,7 @@ void applyTranslatedComputerCard(Graphics::Surface &card, const char *path, cons
return;
if (!applyPatchImage(card, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "applyTranslatedComputerCard"))
return;
- drawConfiguredHighQualityTextLines(card, translation.strings, prefix, "LiberationSans-Regular.ttf", 218, 218, 236, 0, 0, 0, true);
+ drawConfiguredHighQualityTextLines(card, translation, prefix, "LiberationSans-Regular.ttf", 218, 218, 236, 0, 0, 0, true);
#endif
}
@@ -249,7 +262,7 @@ void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const T
applyPatchImage(still, translation.packageArchive->createReadStreamForMember(Common::Path(Common::String::format("patches/pstill_%d_patch.png", stillIndex + 1), '/')), "applyTranslatedStillImage");
}
- drawTranslatedStillHeading(still, stillIndex, translation.strings);
+ drawTranslatedStillHeading(still, stillIndex, translation);
}
void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTranslationData &translation) {
@@ -265,7 +278,7 @@ void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTrans
return;
}
const Graphics::Surface *atlas = decoder.getSurface();
- if (atlas->w != 234 || atlas->h != 265 || computer.w < 640 || computer.h < 738) {
+ if (atlas->w != 234 || atlas->h != 290 || computer.w < 640 || computer.h < 738) {
warning("Invalid translated computer button atlas or computer bitmap dimensions");
return;
}
@@ -276,14 +289,17 @@ void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTrans
// The compact atlas has shared one-pixel borders, excluded from every copy.
for (int state = 0; state < 3; ++state)
computer.copyRectToSurface(*converted, 0, 672 + state * 22, Common::Rect(1, 1 + state * 23, 233, 23 + state * 23));
- for (int page = 0; page < 2; ++page)
+ for (int page = 0; page < 2; ++page) {
computer.copyRectToSurface(*converted, 392 + page * 160, 672, Common::Rect(1 + page * 81, 70, 81 + page * 81, 94));
+ computer.copyRectToSurface(*converted, 312 + page * 160, 672, Common::Rect(1 + page * 81, 95, 81 + page * 81, 119));
+ }
// Captions follow the sheet's 29 populated icons; the unused choice has no cell.
for (int icon = 0; icon < 29; ++icon) {
const int x = 1 + (icon % 3) * 65;
- const int y = 95 + (icon / 3) * 17;
+ const int y = 120 + (icon / 3) * 17;
computer.copyRectToSurface(*converted, (icon % 10) * 64, 528 + (icon / 10) * 64, Common::Rect(x, y, x + 64, y + 16));
}
+ computer.copyRectToSurface(*converted, 576, 608, Common::Rect(163, 70, 217, 94));
converted->free();
delete converted;
}
@@ -293,8 +309,8 @@ void applyTranslatedTitleMenu(Graphics::Surface &title, const TextTranslationDat
return;
applyPatchImage(title, translation.packageArchive->createReadStreamForMember(Common::Path("patches/16mtitle_patch.png", '/')), "applyTranslatedTitleMenu");
- drawConfiguredHighQualityTextLines(title, translation.strings, "title_menu.", "LiberationSans-BoldItalic.ttf", 53, 55, 106, 142, 146, 232);
- drawConfiguredHighQualityTextLines(title, translation.strings, "title_menu_pressed.", "LiberationSans-BoldItalic.ttf", 136, 90, 155, 183, 169, 211);
+ drawConfiguredHighQualityTextLines(title, translation, "title_menu.", "LiberationSans-BoldItalic.ttf", 53, 55, 106, 142, 146, 232);
+ drawConfiguredHighQualityTextLines(title, translation, "title_menu_pressed.", "LiberationSans-BoldItalic.ttf", 136, 90, 155, 183, 169, 211);
}
} // End of namespace BCB
diff --git a/engines/harold/bcb/video.cpp b/engines/harold/bcb/video.cpp
index e5ea5d0e75e..446db556bd9 100644
--- a/engines/harold/bcb/video.cpp
+++ b/engines/harold/bcb/video.cpp
@@ -23,6 +23,7 @@
#include "audio/decoders/wave.h"
#include "common/system.h"
#include "common/textconsole.h"
+#include "graphics/cursorman.h"
#include "graphics/screen.h"
#include "graphics/surface.h"
#include "harold/bcb/bcb.h"
@@ -62,6 +63,10 @@ bool BCBEngine::playNumberedMovie(int movieId, bool blankScreenMovie) {
_activeMovieVideo->start();
_activeMoviePaused = false;
_activeMovieDispatchOnFinish = true;
+ if (blankScreenMovie || _currentDisplayState == 0) {
+ _activeMovieCursorWasVisible = CursorMan.showMouse(false);
+ _activeMovieCursorHidden = true;
+ }
drawMovieControlStrip();
return true;
}
@@ -152,6 +157,10 @@ void BCBEngine::processQueuedMovieSequence() {
}
void BCBEngine::stopActiveMovie() {
+ if (_activeMovieCursorHidden) {
+ CursorMan.showMouse(_activeMovieCursorWasVisible);
+ _activeMovieCursorHidden = false;
+ }
if (!_activeMovieVideo)
return;
Commit: 18cdcfea879f6e46537ce5b942f3388908b70403
https://github.com/scummvm/scummvm/commit/18cdcfea879f6e46537ce5b942f3388908b70403
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:14+03:00
Commit Message:
HAROLD: BCB: Keep ending movie backdrops black during disc transitions
Changed paths:
engines/harold/bcb/captions.cpp
engines/harold/bcb/video.cpp
diff --git a/engines/harold/bcb/captions.cpp b/engines/harold/bcb/captions.cpp
index e8750de2bff..d87234d660e 100644
--- a/engines/harold/bcb/captions.cpp
+++ b/engines/harold/bcb/captions.cpp
@@ -178,7 +178,7 @@ void BCBEngine::loadNextTimedCaptionText() {
}
void BCBEngine::restoreCaptionBackingRect(const Common::Rect &rect) {
- if (_activeMovieOnBlankScreen) {
+ if (_activeMovieOnBlankScreen || stateDword(kStateClearDisplayBeforeMediaCheckFlag) != 0) {
Graphics::Surface *screen = _screen->surfacePtr();
if (screen) {
_screen->fillRect(rect, screen->format.RGBToColor(0, 0, 0));
diff --git a/engines/harold/bcb/video.cpp b/engines/harold/bcb/video.cpp
index 446db556bd9..8f8ae4d6891 100644
--- a/engines/harold/bcb/video.cpp
+++ b/engines/harold/bcb/video.cpp
@@ -39,7 +39,7 @@ bool BCBEngine::playNumberedMovie(int movieId, bool blankScreenMovie) {
stopActiveMovie();
_sceneChoiceActive = false;
_mapControlsActive = false;
- _activeMovieOnBlankScreen = blankScreenMovie;
+ _activeMovieOnBlankScreen = blankScreenMovie || stateDword(kStateClearDisplayBeforeMediaCheckFlag) != 0;
loadTimedCaptionRecord(movieId);
const Common::String movieName = Common::String::format("mov%04d.avi", movieId);
Commit: a0c26d19802b32b0918ee8a6d03637e129e81d5f
https://github.com/scummvm/scummvm/commit/a0c26d19802b32b0918ee8a6d03637e129e81d5f
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:14+03:00
Commit Message:
HAROLD: BCB: Render translated endings and simplify card text layouts
Changed paths:
engines/harold/bcb/text_renderer.cpp
engines/harold/bcb/text_renderer.h
engines/harold/bcb/translation_images.cpp
diff --git a/engines/harold/bcb/text_renderer.cpp b/engines/harold/bcb/text_renderer.cpp
index aaac2736cf1..f678114b1e5 100644
--- a/engines/harold/bcb/text_renderer.cpp
+++ b/engines/harold/bcb/text_renderer.cpp
@@ -337,7 +337,7 @@ bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common
bool drawFreeTypeTextLine(Graphics::Surface &surface, FT_Face face, int size,
const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
- int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth, bool baseline) {
if (!face)
return false;
@@ -356,6 +356,8 @@ bool drawFreeTypeTextLine(Graphics::Surface &surface, FT_Face face, int size,
ok = layoutPillowGlyphs(face, text, glyphs);
if (ok) {
+ if (baseline)
+ y -= ftPixel(face->size->metrics.ascender);
for (uint i = 0; i < shadowOffsets.size(); ++i)
ok = drawFreeTypeTextPass(surface, face, glyphs, x + shadowOffsets[i].x, y + shadowOffsets[i].y, shadowColor, 0, false) && ok;
if (strokeWidth > 0)
@@ -721,9 +723,9 @@ HighQualityTextRenderer::~HighQualityTextRenderer() {
void HighQualityTextRenderer::drawLine(Graphics::Surface &surface, int size,
const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
- int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth) {
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth, bool baseline) {
#ifdef USE_FREETYPE2
- drawFreeTypeTextLine(surface, _font->face, size, shadowOffsets, text, x, y, textColor, shadowColor, strokeWidth);
+ drawFreeTypeTextLine(surface, _font->face, size, shadowOffsets, text, x, y, textColor, shadowColor, strokeWidth, baseline);
#endif
}
diff --git a/engines/harold/bcb/text_renderer.h b/engines/harold/bcb/text_renderer.h
index 6a5e725f456..f5f02974177 100644
--- a/engines/harold/bcb/text_renderer.h
+++ b/engines/harold/bcb/text_renderer.h
@@ -40,7 +40,7 @@ public:
~HighQualityTextRenderer();
void drawLine(Graphics::Surface &surface, int size,
const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
- int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth);
+ int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth, bool baseline = false);
private:
struct FontData;
diff --git a/engines/harold/bcb/translation_images.cpp b/engines/harold/bcb/translation_images.cpp
index aed50190fd6..35f1a86c345 100644
--- a/engines/harold/bcb/translation_images.cpp
+++ b/engines/harold/bcb/translation_images.cpp
@@ -130,7 +130,7 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextTr
const Common::Array<Common::Point> shadowOffsets = getTranslationShadowOffsets(strings, prefix + "shadow_offsets");
const bool drawShadowWithoutStroke = getTranslationInt(strings, prefix + "shadow_without_stroke", 0) != 0;
- const int scale = CLIP<int>(getTranslationInt(strings, prefix + "scale", 4), 1, 8);
+ const int scale = resampleBackground ? 4 : CLIP<int>(getTranslationInt(strings, prefix + "scale", 4), 1, 8);
Graphics::Surface layer;
layer.create(surface.w * scale, surface.h * scale, Graphics::PixelFormat::createFormatRGBA32());
if (resampleBackground) {
@@ -155,21 +155,23 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextTr
for (uint i = 0; i < shadowOffsets.size(); ++i)
scaledShadowOffsets.push_back(Common::Point(shadowOffsets[i].x * scale, shadowOffsets[i].y * scale));
- const int lineCount = CLIP(getTranslationInt(strings, prefix + "line_count", 16), 0, 256);
HighQualityTextRenderer *renderer = translation.imageFonts.getValOrDefault(fontName, nullptr);
Common::ScopedPtr<HighQualityTextRenderer> fallbackRenderer;
if (!renderer) {
fallbackRenderer.reset(new HighQualityTextRenderer(fontName));
renderer = fallbackRenderer.get();
}
- for (int i = 1; i <= lineCount; ++i) {
+ for (int i = 1; ; ++i) {
+ const char *definition = strings.getString(Common::String::format("%sline%d", prefix.c_str(), i));
+ if (!definition)
+ break;
Common::U32String text;
int x = 0;
int y = 0;
int size = 44;
int strokeWidth = 0;
uint32 textColor = scaledTextColor;
- if (!parseImageTextLine(strings.getString(Common::String::format("%sline%d", prefix.c_str(), i)), text, x, y, size, strokeWidth, textColor, layer.format))
+ if (!parseImageTextLine(definition, text, x, y, size, strokeWidth, textColor, layer.format))
continue;
size = CLIP(size, 1, 128);
strokeWidth = CLIP(strokeWidth, 0, 16);
@@ -236,6 +238,87 @@ bool applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *str
return true;
}
+void drawTranslatedEnding(Graphics::Surface &surface, const TextTranslationData &translation, const Common::String &prefix) {
+#ifdef USE_FREETYPE2
+ const TextStringTable &strings = translation.strings;
+ const char *patch = strings.getString(prefix + "patch");
+ const char *font = strings.getString(prefix + "font");
+ HighQualityTextRenderer *renderer = font ? translation.imageFonts.getValOrDefault(font, nullptr) : nullptr;
+ if (!translation.packageArchive || !patch || !renderer || !strings.getString(prefix + "line1"))
+ return;
+ if (!applyPatchImage(surface, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "drawTranslatedEnding"))
+ return;
+
+ const int scale = 4;
+ const int widthPercent = CLIP(getTranslationInt(strings, prefix + "width_percent", 100), 1, 100);
+ const int shadowX = getTranslationInt(strings, prefix + "shadow_x", 2);
+ const int shadowY = getTranslationInt(strings, prefix + "shadow_y", 2);
+ const int opacity = CLIP(getTranslationInt(strings, prefix + "shadow_opacity", 100), 0, 100);
+ const Graphics::PixelFormat format = Graphics::PixelFormat::createFormatRGBA32();
+ const uint32 black = format.RGBToColor(0, 0, 0);
+ const uint32 white = format.RGBToColor(255, 255, 255);
+ Graphics::Surface mask, line;
+ mask.create(surface.w * scale, surface.h * scale, format);
+ mask.fillRect(Common::Rect(mask.w, mask.h), black);
+ line.create(mask.w, 60 * scale, format);
+ const Common::Array<Common::Point> noShadow;
+ for (int i = 1; ; ++i) {
+ const char *definition = strings.getString(Common::String::format("%sline%d", prefix.c_str(), i));
+ if (!definition)
+ break;
+ Common::U32String text;
+ int x = 0, y = 0, size = 23, stroke = 0;
+ uint32 color = white;
+ if (!parseImageTextLine(definition, text, x, y, size, stroke, color, format))
+ continue;
+ line.fillRect(Common::Rect(line.w, line.h), black);
+ renderer->drawLine(line, CLIP(size, 1, 128) * scale, noShadow, text, 0, 40 * scale, white, black, 0, true);
+ Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> narrowed(
+ downscaleRgbaLayerBicubic(line, MAX(1, (line.w * widthPercent + 50) / 100), line.h));
+ for (int row = 0; row < narrowed->h; ++row) {
+ const int destY = (y - 40) * scale + row;
+ if (destY < 0 || destY >= mask.h)
+ continue;
+ for (int col = 0; col < narrowed->w; ++col) {
+ const int destX = x * scale + col;
+ if (destX < 0 || destX >= mask.w)
+ continue;
+ const byte value = *static_cast<const byte *>(narrowed->getBasePtr(col, row));
+ byte *dest = static_cast<byte *>(mask.getBasePtr(destX, destY));
+ dest[0] = dest[1] = dest[2] = MAX(dest[0], value);
+ }
+ }
+ }
+ Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> reduced(downscaleRgbaLayerBicubic(mask, surface.w, surface.h));
+ mask.free();
+ line.free();
+ uint8 textR, textG, textB, shadowR, shadowG, shadowB;
+ format.colorToRGB(getTranslationColor(strings, prefix + "text_color", format, 255, 237, 214), textR, textG, textB);
+ format.colorToRGB(getTranslationColor(strings, prefix + "shadow_color", format, 77, 0, 18), shadowR, shadowG, shadowB);
+ for (int y = 0; y < surface.h; ++y) {
+ for (int x = 0; x < surface.w; ++x) {
+ const int sx = x - shadowX, sy = y - shadowY;
+ const byte ink = *static_cast<const byte *>(reduced->getBasePtr(x, y));
+ const byte shade = sx >= 0 && sx < reduced->w && sy >= 0 && sy < reduced->h ?
+ *static_cast<const byte *>(reduced->getBasePtr(sx, sy)) : 0;
+ if (!ink && !shade)
+ continue;
+ uint8 r, g, b;
+ surface.format.colorToRGB(surface.getPixel(x, y), r, g, b);
+ const double alpha = ink / 255.0;
+ const double shadow = shade / 255.0 * (opacity / 100.0);
+ const auto blend = [&](uint8 background, uint8 tint, uint8 foreground) {
+ const double under = background * (1 - shadow) + MIN(background, tint) * shadow;
+ const double value = under * (1 - alpha) + foreground * alpha;
+ const int integral = (int)value;
+ return (uint8)(integral + (value - integral > 0.5 || (value - integral == 0.5 && (integral & 1))));
+ };
+ surface.setPixel(x, y, surface.format.RGBToColor(blend(r, shadowR, textR), blend(g, shadowG, textG), blend(b, shadowB, textB)));
+ }
+ }
+#endif
+}
+
} // End of anonymous namespace
void applyTranslatedComputerCard(Graphics::Surface &card, const char *path, const TextTranslationData &translation) {
@@ -263,6 +346,8 @@ void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const T
}
drawTranslatedStillHeading(still, stillIndex, translation);
+ if (stillIndex == 5 || stillIndex == 6)
+ drawTranslatedEnding(still, translation, stillIndex == 5 ? "endings.pbad." : "endings.pgood.");
}
void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTranslationData &translation) {
Commit: f16e6096722d285aa569d9f75f7648223a5b0691
https://github.com/scummvm/scummvm/commit/f16e6096722d285aa569d9f75f7648223a5b0691
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:14+03:00
Commit Message:
HAROLD: BCB: Correct ending image order to match LaserActive
Changed paths:
engines/harold/bcb/static_data.cpp
engines/harold/bcb/translation_images.cpp
diff --git a/engines/harold/bcb/static_data.cpp b/engines/harold/bcb/static_data.cpp
index 88a2691bf3a..57c049a6d91 100644
--- a/engines/harold/bcb/static_data.cpp
+++ b/engines/harold/bcb/static_data.cpp
@@ -219,8 +219,9 @@ const char *const kStillImageHighColorPaths[8] = {
"bmp/still/16m/pstill_3.bmp",
"bmp/still/16m/pstill_4.bmp",
"bmp/still/16m/pstill_5.bmp",
- "bmp/still/16m/pbad.bmp",
+ // Correct the Windows ending order to match LaserActive.
"bmp/still/16m/pgood.bmp",
+ "bmp/still/16m/pbad.bmp",
"bmp/still/16m/pstaff.bmp"
};
diff --git a/engines/harold/bcb/translation_images.cpp b/engines/harold/bcb/translation_images.cpp
index 35f1a86c345..d6062409d65 100644
--- a/engines/harold/bcb/translation_images.cpp
+++ b/engines/harold/bcb/translation_images.cpp
@@ -347,7 +347,7 @@ void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const T
drawTranslatedStillHeading(still, stillIndex, translation);
if (stillIndex == 5 || stillIndex == 6)
- drawTranslatedEnding(still, translation, stillIndex == 5 ? "endings.pbad." : "endings.pgood.");
+ drawTranslatedEnding(still, translation, stillIndex == 5 ? "endings.pgood." : "endings.pbad.");
}
void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTranslationData &translation) {
Commit: 5cc35cf4c7c0e8e612cdd73bda69ee27cb89ae4f
https://github.com/scummvm/scummvm/commit/5cc35cf4c7c0e8e612cdd73bda69ee27cb89ae4f
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:14+03:00
Commit Message:
HAROLD: BCB: Add Cinema Disk viewer and Mac image fallbacks
Changed paths:
A engines/harold/bcb/cinema.cpp
A engines/harold/bcb/cinema.h
A engines/harold/bcb/cinema_data.cpp
A engines/harold/bcb/cinema_tables.cpp
A engines/harold/bcb/cinema_tables.h
A engines/harold/bcb/cinema_video.cpp
engines/harold/bcb/bcb.cpp
engines/harold/bcb/bcb.h
engines/harold/bcb/input.cpp
engines/harold/bcb/resources.cpp
engines/harold/bcb/saveload.cpp
engines/harold/bcb/screens.cpp
engines/harold/bcb/text_renderer.cpp
engines/harold/bcb/translation.h
engines/harold/bcb/translation_images.cpp
engines/harold/module.mk
diff --git a/engines/harold/bcb/bcb.cpp b/engines/harold/bcb/bcb.cpp
index 12e36e3284a..44963ce81a3 100644
--- a/engines/harold/bcb/bcb.cpp
+++ b/engines/harold/bcb/bcb.cpp
@@ -31,6 +31,7 @@
#include "graphics/sjis.h"
#include "graphics/surface.h"
#include "harold/bcb/debugger.h"
+#include "harold/bcb/cinema.h"
#include "harold/bcb/script.h"
#include "harold/bcb/static_data.h"
#include "video/avi_decoder.h"
@@ -86,6 +87,7 @@ BCBEngine::BCBEngine(OSystem *syst, const HaroldGameDescription *desc)
}
BCBEngine::~BCBEngine() {
+ delete _cinemaMenu;
delete _screen;
if (_uiBitmap) {
_uiBitmap->free();
diff --git a/engines/harold/bcb/bcb.h b/engines/harold/bcb/bcb.h
index a62019ab05c..84f2bd1ef8f 100644
--- a/engines/harold/bcb/bcb.h
+++ b/engines/harold/bcb/bcb.h
@@ -68,9 +68,11 @@ enum BCBAction {
};
class Debugger;
+class CinemaViewer;
class BCBEngine : public Engine {
friend class Debugger;
+ friend class CinemaViewer;
public:
BCBEngine(OSystem *syst, const HaroldGameDescription *desc);
@@ -85,6 +87,8 @@ public:
bool canSaveAutosaveCurrently() override;
private:
+ void runCinemaViewer();
+ void pauseEngineIntern(bool paused) override;
void loadFonts();
bool initializeSearchPaths();
bool showInitialLogoScreen();
@@ -205,14 +209,15 @@ private:
void drawAnalogClockAndChip(int baseHourOffset, int gameClockTicks, bool present = true);
void renderClockAndChipToSurface(Graphics::Surface &surface, int baseHourOffset, int gameClockTicks);
Graphics::Surface *loadBitmap(const char *fileName);
+ Graphics::Surface *loadProgramBitmap(const char *fileName) const;
const Graphics::Surface *getUiBitmap(const char *fileName);
- Graphics::Surface *loadBitmapFromStream(Common::SeekableReadStream *stream, const char *debugName) const;
+ Graphics::Surface *loadImageFromStream(Common::SeekableReadStream *stream, const char *fileName) const;
Graphics::Surface *loadDiscBitmap(const char *relativePath) const;
Graphics::Surface *loadDiscBitmapFromAnyDisc(const char *relativePath) const;
Common::SeekableReadStream *createProgramReadStream(const char *relativePath) const;
Common::SeekableReadStream *createDiscReadStream(int discNumber, const char *relativePath) const;
Common::SeekableReadStream *createActiveDiscReadStream(const char *relativePath) const;
- Common::SeekableReadStream *createActiveDiscHighColorReadStream(const char *relativePath) const;
+ Common::SeekableReadStream *createDiscImageReadStream(int discNumber, const char *relativePath, Common::String &resolvedPath, bool searchAllDiscs = false) const;
void blitScreenWithLineReveal(const Graphics::Surface &surface, bool presentFinalFrame = true);
void drawTitleButton(uint buttonIndex, bool pressed);
void handleLeftButtonDown(const Common::Point &mousePosition);
@@ -271,6 +276,9 @@ private:
Video::AVIDecoder *_mapMoveVideo = nullptr;
Video::AVIDecoder *_activeMovieVideo = nullptr;
Graphics::Surface *_titleBitmap = nullptr;
+ CinemaViewer *_cinemaViewer = nullptr;
+ CinemaViewer *_cinemaMenu = nullptr;
+ bool _cinemaAvailable = false;
Graphics::Surface *_uiBitmap = nullptr;
Common::String _uiBitmapName;
Graphics::Surface *_chipBitmap = nullptr;
diff --git a/engines/harold/bcb/cinema.cpp b/engines/harold/bcb/cinema.cpp
new file mode 100644
index 00000000000..4c439689c0b
--- /dev/null
+++ b/engines/harold/bcb/cinema.cpp
@@ -0,0 +1,432 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/archive.h"
+#include "common/events.h"
+#include "common/system.h"
+#include "common/textconsole.h"
+#include "graphics/font.h"
+#include "graphics/fontman.h"
+#include "graphics/screen.h"
+#include "harold/bcb/bcb.h"
+#include "harold/bcb/cinema.h"
+#include "harold/bcb/static_data.h"
+#include "harold/bcb/translation.h"
+#include "video/avi_decoder.h"
+
+namespace BCB {
+
+CinemaViewer::CinemaViewer(BCBEngine &engine) : _engine(engine) {
+}
+
+CinemaViewer::~CinemaViewer() {
+ _video.reset();
+}
+
+Common::Rect CinemaViewer::titleButtonRect() {
+ const ButtonControlRecord &button = kTitleButtonTable[4];
+ return Common::Rect(24, button.y, 24 + button.width, button.y + button.height);
+}
+
+void CinemaViewer::drawTitleButton(BCBEngine &engine, Graphics::Surface &surface) {
+ const Common::Rect rect = titleButtonRect();
+ Graphics::Surface buttons;
+ buttons.create(rect.width(), rect.height() * 2, surface.format);
+ for (int state = 0; state < 2; ++state) {
+ buttons.copyRectToSurface(surface, 0, state * rect.height(),
+ Common::Rect(state * rect.width(), 736, (state + 1) * rect.width(), 736 + rect.height()));
+ for (int y = 3; y < rect.height() - 3; ++y) {
+ const int row = state * rect.height() + y;
+ buttons.fillRect(Common::Rect(3, row, rect.width() - 3, row + 1), buttons.getPixel(3, row));
+ }
+ }
+ if (!applyTranslatedCinemaTitleButton(buttons, engine._textTranslation)) {
+ const Graphics::Font *font = engine._ownerDrawUiTextFont;
+ if (!font)
+ font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+ const Common::U32String name = engine.translateSystemTextForDisplay("cinema_title",
+ Common::String("\x83\x56\x83\x6c\x83\x7d" "DISK").decode(Common::kWindows932));
+ for (int state = 0; state < 2; ++state) {
+ const int y = state * rect.height() + (rect.height() - font->getFontHeight()) / 2;
+ const uint32 ink = state ? surface.format.RGBToColor(136, 90, 155) : surface.format.RGBToColor(53, 55, 106);
+ const uint32 highlight = state ? surface.format.RGBToColor(183, 169, 211) : surface.format.RGBToColor(142, 146, 232);
+ font->drawString(&buttons, name, 5, y - 1, rect.width() - 8, highlight, Graphics::kTextAlignCenter);
+ font->drawString(&buttons, name, 4, y, rect.width() - 8, ink, Graphics::kTextAlignCenter);
+ }
+ }
+ surface.copyRectToSurface(buttons, rect.left, rect.top, Common::Rect(rect.width(), rect.height()));
+ // Cache the pressed state in the unused right-hand title atlas area.
+ surface.copyRectToSurface(buttons, 324, 736, Common::Rect(0, rect.height(), rect.width(), rect.height() * 2));
+ buttons.free();
+}
+
+void CinemaViewer::pressTitleButton(BCBEngine &engine) {
+ const Common::Rect rect = titleButtonRect();
+ engine._screen->copyRectToSurface(engine._titleBitmap->getBasePtr(324, 736), engine._titleBitmap->pitch,
+ rect.left, rect.top, rect.width(), rect.height());
+ engine._screen->update();
+}
+
+void BCBEngine::runCinemaViewer() {
+ if (!_cinemaMenu) {
+ warning("BCB: Unable to load bcb-cinema.dat");
+ restoreTitleScreenRegion(CinemaViewer::titleButtonRect());
+ return;
+ }
+ const uint32 playTime = getTotalPlayTime();
+ _cinemaViewer = _cinemaMenu;
+ _titleButtonsActive = false;
+ stopMenuBackgroundMusic();
+ _cinemaMenu->run();
+ _cinemaViewer = nullptr;
+ setTotalPlayTime(playTime);
+ _lastTimerTick = g_system->getMillis();
+ if (!shouldQuit()) {
+ showTitleScreen();
+ startMenuBackgroundMusic();
+ }
+}
+
+void BCBEngine::pauseEngineIntern(bool paused) {
+ Engine::pauseEngineIntern(paused);
+ if (_cinemaViewer)
+ _cinemaViewer->pause(paused);
+}
+
+void CinemaViewer::pause(bool paused) {
+ _enginePaused = paused;
+ syncMoviePause();
+}
+
+Common::Point CinemaViewer::dialogOrigin() const {
+ if (_page == kPlayback)
+ return Common::Point(189, 400);
+ // ScummVM uses the same 640x480 canvas in windowed and fullscreen modes.
+ const uint16 *size = kCinemaDialogSizes[_page == kBackground ? 3 : 1];
+ return Common::Point((640 - size[0]) / 2, (480 - size[1]) / 2);
+}
+
+Common::Point CinemaViewer::movieOrigin() const {
+ return _backgroundIndex == 5 ? Common::Point(46, 51) : Common::Point(120, 72);
+}
+
+void CinemaViewer::drawButton(int index) {
+ const CinemaButton &button = kCinemaButtons[index];
+ const Graphics::ManagedSurface &sheet = _sheets[index < 12 ? 0 : index < 20 ? 1 : 2];
+ _canvas.blitFrom(sheet, button.source, Common::Point(button.destinationX, button.destinationY) + dialogOrigin());
+}
+
+void CinemaViewer::drawSelection(bool reveal) {
+ if (_engine._titleBitmap)
+ _canvas.blitFrom(*_engine._titleBitmap, Common::Rect(640, 480), Common::Point(0, 0));
+ else
+ _canvas.clear(0);
+ if (_canvas.format.bytesPerPixel == 4) {
+ const uint32 keepMask = ~_canvas.format.ARGBToColor(0, 255, 255, 255);
+ const uint32 halfMask = _canvas.format.ARGBToColor(0, 127, 127, 127);
+ for (int y = 0; y < _canvas.h; ++y) {
+ uint32 *row = static_cast<uint32 *>(_canvas.getBasePtr(0, y));
+ for (int x = 0; x < _canvas.w; ++x)
+ row[x] = (row[x] & keepMask) | ((row[x] >> 1) & halfMask);
+ }
+ } else {
+ for (int y = 0; y < _canvas.h; ++y) {
+ for (int x = 0; x < _canvas.w; ++x) {
+ byte a, r, g, b;
+ _canvas.format.colorToARGB(_canvas.getPixel(x, y), a, r, g, b);
+ _canvas.setPixel(x, y, _canvas.format.ARGBToColor(a, r / 2, g / 2, b / 2));
+ }
+ }
+ }
+ const int sheet = _page == kBackground ? 0 : 1;
+ const Common::Rect rect = _page == kBackground ? Common::Rect(420, 199) : Common::Rect(260, 192);
+ _canvas.blitFrom(_sheets[sheet], rect, dialogOrigin());
+ if (_page == kPlaylist)
+ drawRows();
+ if (reveal) {
+ _engine.blitScreenWithLineReveal(_canvas);
+ _canvas.clearDirtyRects();
+ } else
+ present();
+}
+
+void CinemaViewer::drawRows() {
+ const Common::Point origin = dialogOrigin();
+ const Graphics::Font *font = _listFont ? _listFont.get() : _engine._ownerDrawUiTextFont;
+ if (!font)
+ font = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+ Common::Rect area(15, 15, 195, 127);
+ area.translate(origin.x, origin.y);
+ _canvas.fillRect(area, _canvas.format.RGBToColor(255, 255, 255));
+ for (int row = 0; row < 4; ++row) {
+ Common::Rect bounds(15, 15 + row * 28, 195, 43 + row * 28);
+ bounds.translate(origin.x, origin.y);
+ const bool selected = row == _selectedRow;
+ if (selected)
+ _canvas.fillRect(bounds, _canvas.format.RGBToColor(0, 0, 0));
+ font->drawString(&_canvas, _labels[_scrollOffset + row], origin.x + 16,
+ origin.y + 33 + row * 28 - font->getFontAscent(), 178,
+ selected ? _canvas.format.RGBToColor(255, 255, 255) : _canvas.format.RGBToColor(0, 0, 0));
+ }
+}
+
+void CinemaViewer::scroll(int delta) {
+ _scrollOffset = CLIP<int>(_scrollOffset + delta, 0, ARRAYSIZE(kCinemaPlaylists) - 4);
+ _selectedRow = -1;
+ drawRows();
+}
+
+void CinemaViewer::Canvas::addDirtyRect(const Common::Rect &rect) {
+ Common::Rect clipped = rect;
+ clipped.clip(getBounds());
+ if (!clipped.isEmpty())
+ _dirtyRects.push_back(clipped);
+}
+
+void CinemaViewer::Canvas::presentTo(Graphics::Screen &screen) {
+ _dirtyRects.merge();
+ for (const Common::Rect &rect : _dirtyRects)
+ screen.copyRectToSurface(getBasePtr(rect.left, rect.top), pitch, rect.left, rect.top, rect.width(), rect.height());
+ _dirtyRects.clear();
+ screen.update();
+}
+
+void CinemaViewer::present() {
+ _canvas.presentTo(*_engine._screen);
+}
+
+void CinemaViewer::back() {
+ _releaseAction = 0;
+ _dragging = false;
+ release();
+ if (_page == kPlayback) {
+ stopPlayback();
+ } else if (_page == kPlaylist) {
+ _page = kBackground;
+ drawSelection(true);
+ } else {
+ _running = false;
+ }
+}
+
+void CinemaViewer::release() {
+ _heldScroll = 0;
+ if (_dragging) {
+ _dragging = false;
+ seekMovie(_seekEntry);
+ }
+ if (_pressedButton >= 0) {
+ drawButton(_pressedButton - 1);
+ _pressedButton = -1;
+ present();
+ }
+ const int action = _releaseAction;
+ _releaseAction = 0;
+ if (action == 1 && _selectedPlaylist)
+ showPlayback();
+ else if (action == 2)
+ stopPlayback();
+ else if (action == 3)
+ _running = false;
+}
+
+void CinemaViewer::click(Common::Point mouse) {
+ const Common::Point local = mouse - dialogOrigin();
+ if (_page == kPlayback && Common::Rect(0, 40, 262, 56).contains(local)) {
+ if (_playlistEndTime)
+ return;
+ const Common::Rect thumb = thumbRect();
+ if (thumb.contains(mouse)) {
+ _dragging = true;
+ _seekEntry = _entry;
+ _thumbOffset = mouse.x - thumb.left;
+ syncMoviePause();
+ } else {
+ const int step = local.x < 16 ? -1 : local.x >= 246 ? 1 : mouse.x < thumb.left ? -4 : 4;
+ seekMovie(_entry + step);
+ }
+ return;
+ }
+ const Common::Span<const StaticRect> items = _page == kBackground ?
+ Common::Span<const StaticRect>(kCinemaBackgroundItems, ARRAYSIZE(kCinemaBackgroundItems) - 1) :
+ _page == kPlaylist ? Common::Span<const StaticRect>(kCinemaPlaylistItems, ARRAYSIZE(kCinemaPlaylistItems)) :
+ Common::Span<const StaticRect>(kCinemaPlaybackItems, ARRAYSIZE(kCinemaPlaybackItems));
+ for (uint item = 0; item < items.size(); ++item) {
+ if (!items[item].contains(local))
+ continue;
+ if (_page == kBackground) {
+ if (item < 4) {
+ drawButton(item * 2 + 1);
+ present();
+ const int background = item ? item + 2 : 0;
+ if (background && !loadPicture(background, _background)) {
+ drawSelection();
+ return;
+ }
+ _backgroundIndex = background;
+ _page = kPlaylist;
+ drawSelection(true);
+ } else if (item == 4) {
+ _pressedButton = 9;
+ _releaseAction = 3;
+ drawButton(9);
+ present();
+ }
+ } else if (_page == kPlaylist) {
+ if (item < 2) {
+ _heldScroll = item ? 1 : -1;
+ _pressedButton = item ? 15 : 13;
+ drawButton(_pressedButton);
+ scroll(_heldScroll);
+ _repeatTime = g_system->getMillis() + 117;
+ present();
+ } else if (item == 2) {
+ _pressedButton = 17;
+ _releaseAction = 1;
+ drawButton(17);
+ present();
+ } else if (item == 3) {
+ back();
+ } else {
+ _selectedRow = item - 4;
+ _selectedPlaylist = _scrollOffset + _selectedRow + 1;
+ drawRows();
+ present();
+ }
+ } else if (!_playlistEndTime) {
+ if (item == 0)
+ seekMovie(_entry + 1);
+ else if (item == 1)
+ togglePause();
+ else {
+ _pressedButton = 25;
+ _releaseAction = 2;
+ syncMoviePause();
+ drawButton(25);
+ present();
+ }
+ }
+ return;
+ }
+}
+
+bool CinemaViewer::pumpEvents(bool interactive) {
+ Common::Event event;
+ while (g_system->getEventManager()->pollEvent(event)) {
+ if (event.type == Common::EVENT_QUIT || event.type == Common::EVENT_RETURN_TO_LAUNCHER) {
+ _engine.quitGame();
+ _running = false;
+ return false;
+ }
+ if (!interactive)
+ continue;
+ switch (event.type) {
+ case Common::EVENT_MOUSEMOVE:
+ _engine._mousePosition = event.mouse;
+ if (_dragging) {
+ const int x = CLIP<int>(event.mouse.x - 189 - 16 - _thumbOffset, 0, 214);
+ _seekEntry = (x * _movies.size() + 107) / 214;
+ drawScrollbar();
+ present();
+ }
+ break;
+ case Common::EVENT_LBUTTONDOWN:
+ _engine._mousePosition = event.mouse;
+ click(event.mouse);
+ break;
+ case Common::EVENT_LBUTTONUP:
+ release();
+ break;
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+ if (event.customType == kBCBActionInteract)
+ click(_engine._mousePosition);
+ else if (event.customType == kBCBActionEscape)
+ back();
+ else if (event.customType == kBCBActionSkip && _page == kPlayback)
+ seekMovie(_entry + 1);
+ break;
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
+ if (event.customType == kBCBActionInteract)
+ release();
+ break;
+ case Common::EVENT_WHEELUP:
+ case Common::EVENT_WHEELDOWN:
+ if (_page == kPlaylist) {
+ scroll(event.type == Common::EVENT_WHEELUP ? -1 : 1);
+ present();
+ }
+ break;
+ case Common::EVENT_KEYDOWN:
+ if (event.kbd.keycode == Common::KEYCODE_ESCAPE)
+ back();
+ else if (event.kbd.keycode == Common::KEYCODE_SPACE && _page == kPlayback)
+ seekMovie(_entry + 1);
+ else if (event.kbd.keycode == Common::KEYCODE_p && _page == kPlayback)
+ togglePause();
+ break;
+ default:
+ break;
+ }
+ }
+ return _running && !_engine.shouldQuit();
+}
+
+void CinemaViewer::wait(uint millis) {
+ const uint32 start = g_system->getMillis();
+ while (_running && !_engine.shouldQuit() && g_system->getMillis() - start < millis) {
+ pumpEvents(false);
+ _engine._screen->update();
+ g_system->delayMillis(5);
+ }
+}
+
+void CinemaViewer::run() {
+ _page = kBackground;
+ _backgroundIndex = 0;
+ _scrollOffset = 0;
+ _selectedPlaylist = 0;
+ _selectedRow = -1;
+ _entry = 0;
+ _nextCaption = 0;
+ _pressedButton = -1;
+ _releaseAction = 0;
+ _heldScroll = 0;
+ _playlistEndTime = 0;
+ _paused = _enginePaused = _dragging = false;
+ _running = true;
+ drawSelection(true);
+ while (pumpEvents()) {
+ if (_heldScroll && static_cast<int32>(g_system->getMillis() - _repeatTime) >= 0) {
+ scroll(_heldScroll);
+ _repeatTime = g_system->getMillis() + 117;
+ present();
+ }
+ if (_page == kPlayback)
+ updatePlayback();
+ _engine._screen->update();
+ g_system->delayMillis(5);
+ }
+ _video.reset();
+ _background.free();
+ _movies.clear();
+ _captions.clear();
+}
+
+} // namespace BCB
diff --git a/engines/harold/bcb/cinema.h b/engines/harold/bcb/cinema.h
new file mode 100644
index 00000000000..932903232c0
--- /dev/null
+++ b/engines/harold/bcb/cinema.h
@@ -0,0 +1,141 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef HAROLD_BCB_CINEMA_H
+#define HAROLD_BCB_CINEMA_H
+
+#include "common/array.h"
+#include "common/ptr.h"
+#include "common/rect.h"
+#include "common/span.h"
+#include "common/ustr.h"
+#include "graphics/dirtyrects.h"
+#include "graphics/managed_surface.h"
+#include "harold/bcb/cinema_tables.h"
+
+namespace Common {
+class Archive;
+class SeekableReadStream;
+}
+namespace Graphics {
+class Font;
+class Screen;
+}
+namespace Video {
+class AVIDecoder;
+}
+
+namespace BCB {
+
+class BCBEngine;
+
+class CinemaViewer {
+public:
+ explicit CinemaViewer(BCBEngine &engine);
+ ~CinemaViewer();
+ bool load();
+ void run();
+ void pause(bool paused);
+ static Common::SeekableReadStream *openPackage(BCBEngine &engine);
+ static Common::Rect titleButtonRect();
+ static void drawTitleButton(BCBEngine &engine, Graphics::Surface &surface);
+ static void pressTitleButton(BCBEngine &engine);
+
+private:
+ enum Page { kBackground, kPlaylist, kPlayback };
+ class Canvas : public Graphics::ManagedSurface {
+ public:
+ void addDirtyRect(const Common::Rect &rect) override;
+ void clearDirtyRects() override { _dirtyRects.clear(); }
+ void presentTo(Graphics::Screen &screen);
+ private:
+ Graphics::DirtyRectList _dirtyRects;
+ };
+ struct Caption {
+ int frame;
+ Common::U32String lines[2];
+ };
+
+ bool loadLabels();
+ bool loadPicture(uint index, Graphics::ManagedSurface &surface);
+ bool loadPlaylist();
+ void loadCaptions(uint movie);
+ void drawSelection(bool reveal = false);
+ void drawRows();
+ void drawButton(int index);
+ void drawControls();
+ void drawScrollbar();
+ Common::Rect thumbRect() const;
+ void drawCaptions();
+ void clearCaptions();
+ void showPlayback();
+ bool startMovie();
+ void stopPlayback();
+ void seekMovie(int entry);
+ void updatePlayback();
+ void click(Common::Point mouse);
+ void release();
+ void back();
+ void togglePause();
+ void syncMoviePause();
+ void scroll(int delta);
+ void present();
+ bool pumpEvents(bool interactive = true);
+ void wait(uint millis);
+ void revealBackground();
+ Common::Point dialogOrigin() const;
+ Common::Point movieOrigin() const;
+ Common::U32String translate(const Common::String &key, const Common::U32String &original) const;
+
+ BCBEngine &_engine;
+ Common::ScopedPtr<Common::Archive> _archive;
+ Graphics::ManagedSurface _sheets[3];
+ Graphics::ManagedSurface _background;
+ Canvas _canvas;
+ Common::ScopedPtr<Graphics::Font> _listFont;
+ Common::ScopedPtr<Graphics::Font> _captionFont;
+ Common::ScopedPtr<Video::AVIDecoder> _video;
+ Common::Array<Common::U32String> _labels;
+ Common::Span<const CinemaMovie> _movies;
+ Common::Array<Caption> _captions;
+ Page _page = kBackground;
+ int _backgroundIndex = 0;
+ int _scrollOffset = 0;
+ int _selectedPlaylist = 0;
+ int _selectedRow = -1;
+ int _entry = 0;
+ uint _nextCaption = 0;
+ int _captionSize = 12;
+ int _pressedButton = -1;
+ int _releaseAction = 0;
+ int _heldScroll = 0;
+ uint32 _repeatTime = 0;
+ uint32 _playlistEndTime = 0;
+ bool _running = false;
+ bool _paused = false;
+ bool _enginePaused = false;
+ bool _dragging = false;
+ int _seekEntry = 0;
+ int _thumbOffset = 0;
+};
+
+} // namespace BCB
+
+#endif
diff --git a/engines/harold/bcb/cinema_data.cpp b/engines/harold/bcb/cinema_data.cpp
new file mode 100644
index 00000000000..3c064cef1e8
--- /dev/null
+++ b/engines/harold/bcb/cinema_data.cpp
@@ -0,0 +1,149 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/archive.h"
+#include "common/compression/unzip.h"
+#include "common/memstream.h"
+#include "common/str-enc.h"
+#include "common/system.h"
+#include "common/textconsole.h"
+#include "graphics/font.h"
+#include "graphics/fonts/ttf.h"
+#include "harold/bcb/bcb.h"
+#include "harold/bcb/cinema.h"
+#include "harold/bcb/translation.h"
+
+namespace BCB {
+
+Common::SeekableReadStream *CinemaViewer::openPackage(BCBEngine &engine) {
+ Common::SeekableReadStream *stream = engine.createProgramReadStream("bcb-cinema.dat");
+ return stream ? stream : SearchMan.createReadStreamForMember("bcb-cinema.dat");
+}
+
+bool CinemaViewer::loadLabels() {
+ TextStringTable labels;
+ if (!labels.load(_archive->createReadStreamForMember("cinema.yml")))
+ return false;
+ for (uint i = 0; i < ARRAYSIZE(kCinemaPlaylists); ++i) {
+ const Common::String key = Common::String::format("cinema.playlist.%u", i + 1);
+ const char *name = labels.getString(key);
+ if (!name || !*name)
+ return false;
+ _labels.push_back(translate(key, Common::U32String(name, Common::kUtf8)));
+ }
+ return true;
+}
+
+bool CinemaViewer::loadPicture(uint index, Graphics::ManagedSurface &surface) {
+ if (index >= 3) {
+ const Common::String path = Common::String::format("bmp/still/16m/pcin%u.bmp", index - 2);
+ Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> bitmap(
+ _engine.loadDiscBitmapFromAnyDisc(path.c_str()));
+ if (!bitmap) {
+ warning("BCB Cinema: Missing picture %s", path.c_str());
+ return false;
+ }
+ surface.copyFrom(*bitmap);
+ return true;
+ }
+ const char *path = kCinemaPicturePaths[index];
+ Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> picture(
+ _engine.loadImageFromStream(_archive->createReadStreamForMember(Common::Path(path)), path));
+ if (!picture) {
+ warning("BCB Cinema: Missing picture %s", path);
+ return false;
+ }
+ if (index == 0) {
+ if (!applyPatchImage(*picture, _archive->createReadStreamForMember("patches/pcinm_patch.png"), "BCB Cinema")) {
+ warning("BCB Cinema: Missing or invalid menu patch");
+ return false;
+ }
+ applyTranslatedCinemaMenu(*picture, _engine._textTranslation);
+ }
+ surface.copyFrom(*picture);
+ return true;
+}
+
+bool CinemaViewer::load() {
+ Common::SeekableReadStream *stream = openPackage(_engine);
+ if (!stream)
+ return false;
+ _archive.reset(Common::makeZipArchive(stream));
+ if (!_archive)
+ return false;
+ if (!loadLabels()) {
+ warning("BCB Cinema: Missing or invalid cinema.yml");
+ return false;
+ }
+ _canvas.create(640, 480, g_system->getScreenFormat());
+ for (uint i = 0; i < 3; ++i)
+ if (!loadPicture(i, _sheets[i]))
+ return false;
+ for (uint i = 0; i < ARRAYSIZE(kCinemaButtons); ++i) {
+ const Graphics::ManagedSurface &sheet = _sheets[i < 12 ? 0 : i < 20 ? 1 : 2];
+ if (!Common::Rect(sheet.w, sheet.h).contains(kCinemaButtons[i].source))
+ return false;
+ }
+#ifdef USE_FREETYPE2
+ _listFont.reset(Graphics::loadTTFFontFromArchive("NotoSansJP-Regular.otf", 12, Graphics::kTTFSizeModeCharacter));
+ _captionFont.reset(Graphics::loadTTFFontFromArchive("NotoSansJP-Regular.otf", 14, Graphics::kTTFSizeModeCharacter));
+ if (!_listFont)
+ _listFont.reset(Graphics::loadTTFFontFromArchive("VL-Gothic-Regular.ttf", 12, Graphics::kTTFSizeModeCharacter));
+ if (!_captionFont)
+ _captionFont.reset(Graphics::loadTTFFontFromArchive("VL-Gothic-Regular.ttf", 14, Graphics::kTTFSizeModeCharacter));
+#endif
+ return true;
+}
+
+bool CinemaViewer::loadPlaylist() {
+ _movies.clear();
+ if (_selectedPlaylist < 1 || _selectedPlaylist > static_cast<int>(ARRAYSIZE(kCinemaPlaylists)))
+ return false;
+ const CinemaPlaylist &playlist = kCinemaPlaylists[_selectedPlaylist - 1];
+ _movies = Common::Span<const CinemaMovie>(kCinemaMovies + playlist.firstMovie, playlist.movieCount);
+ return _movies.size() != 0;
+}
+
+void CinemaViewer::loadCaptions(uint movie) {
+ _captions.clear();
+ _nextCaption = 0;
+ uint32 size = 0;
+ const byte *data = _engine.findAllBinRecordData(Common::String::format("MES%04u.TXT", movie), size);
+ if (!data || !size)
+ return;
+ Common::MemoryReadStream text(data, size);
+ while (!text.eos()) {
+ Common::String time = text.readLine();
+ if (time.empty())
+ break;
+ Caption caption;
+ caption.frame = atoi(time.c_str());
+ caption.lines[0] = text.readLine().decode(_engine._executableTextEncoding);
+ caption.lines[1] = text.readLine().decode(_engine._executableTextEncoding);
+ _captions.push_back(caption);
+ }
+}
+
+Common::U32String CinemaViewer::translate(const Common::String &key, const Common::U32String &original) const {
+ const char *text = _engine._textTranslation.strings.getString(key);
+ return text ? Common::U32String(text, Common::kUtf8) : original;
+}
+
+} // namespace BCB
diff --git a/engines/harold/bcb/cinema_tables.cpp b/engines/harold/bcb/cinema_tables.cpp
new file mode 100644
index 00000000000..e4d6c1c2922
--- /dev/null
+++ b/engines/harold/bcb/cinema_tables.cpp
@@ -0,0 +1,381 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "harold/bcb/cinema_tables.h"
+
+namespace BCB {
+
+const char *const kCinemaPicturePaths[3] = {
+ "Cinepict/PCINM.PIC",
+ "Cinepict/PCINM2.pic",
+ "Cinepict/PCINM3.PIC"
+};
+
+const CinemaButton kCinemaButtons[26] = {
+ {{0, 199, 138, 227}, 271, 14},
+ {{0, 227, 138, 255}, 271, 14},
+ {{138, 199, 276, 227}, 271, 49},
+ {{138, 227, 276, 255}, 271, 49},
+ {{138, 255, 276, 283}, 271, 84},
+ {{138, 283, 276, 311}, 271, 84},
+ {{0, 255, 138, 283}, 271, 119},
+ {{0, 283, 138, 311}, 271, 119},
+ {{276, 255, 356, 283}, 329, 160},
+ {{276, 283, 356, 311}, 329, 160},
+ {{356, 255, 391, 283}, 280, 160},
+ {{356, 283, 391, 311}, 280, 160},
+ {{0, 247, 24, 269}, 216, 31},
+ {{24, 247, 48, 269}, 216, 31},
+ {{48, 247, 72, 269}, 216, 87},
+ {{72, 247, 96, 269}, 216, 87},
+ {{0, 192, 138, 220}, 16, 154},
+ {{0, 220, 138, 248}, 16, 154},
+ {{138, 192, 218, 220}, 167, 154},
+ {{138, 220, 218, 248}, 167, 154},
+ {{0, 160, 70, 185}, 16, 8},
+ {{0, 185, 70, 210}, 16, 8},
+ {{70, 160, 140, 185}, 96, 8},
+ {{70, 185, 140, 210}, 96, 8},
+ {{140, 160, 210, 185}, 176, 8},
+ {{140, 185, 210, 210}, 176, 8}
+};
+
+const uint16 kCinemaDialogSizes[4][2] = {
+ {259, 192},
+ {260, 192},
+ {420, 199},
+ {420, 199}
+};
+
+const StaticRect kCinemaBackgroundItems[6] = {
+ {271, 14, 409, 42},
+ {271, 49, 409, 77},
+ {271, 84, 409, 112},
+ {271, 119, 409, 147},
+ {329, 160, 409, 188},
+ {280, 160, 315, 188}
+};
+
+const StaticRect kCinemaPlaylistItems[8] = {
+ {216, 31, 240, 53},
+ {216, 87, 240, 109},
+ {16, 154, 154, 182},
+ {167, 154, 247, 182},
+ {15, 15, 195, 43},
+ {15, 43, 195, 71},
+ {15, 71, 195, 99},
+ {15, 99, 195, 127}
+};
+
+const StaticRect kCinemaPlaybackItems[3] = {
+ {16, 8, 86, 32},
+ {96, 8, 166, 32},
+ {176, 8, 246, 32}
+};
+
+const CinemaMovie kCinemaMovies[] = {
+ {1, 6}, {1, 453}, {1, 456}, {1, 279}, {1, 280}, {1, 283},
+ {1, 285}, {1, 286}, {1, 287}, {1, 311}, {1, 313}, {1, 321},
+ {2, 337}, {2, 316}, {2, 62}, {2, 7}, {2, 9}, {2, 10},
+ {2, 11}, {2, 470}, {2, 125}, {2, 65}, {2, 66}, {2, 68},
+ {2, 69}, {2, 70}, {2, 71}, {2, 72}, {2, 73}, {2, 76},
+ {2, 81}, {2, 82}, {2, 83}, {2, 86}, {2, 88}, {2, 95},
+ {2, 103}, {2, 106}, {2, 354}, {2, 340}, {2, 342}, {2, 343},
+ {2, 344}, {2, 345}, {2, 372}, {2, 356}, {2, 358}, {2, 359},
+ {2, 360}, {2, 361}, {2, 362}, {2, 396}, {2, 373}, {2, 375},
+ {2, 376}, {2, 377}, {2, 378}, {2, 379}, {2, 410}, {2, 398},
+ {2, 400}, {2, 401}, {2, 402}, {2, 403}, {2, 404}, {2, 174},
+ {2, 129}, {2, 130}, {2, 132}, {2, 133}, {2, 134}, {2, 135},
+ {2, 148}, {2, 137}, {2, 141}, {2, 144}, {2, 145}, {2, 149},
+ {2, 150}, {2, 152}, {2, 155}, {2, 156}, {2, 157}, {2, 158},
+ {2, 202}, {2, 176}, {2, 178}, {2, 179}, {2, 180}, {2, 181},
+ {2, 182}, {2, 183}, {2, 184}, {2, 232}, {2, 207}, {2, 209},
+ {2, 210}, {2, 211}, {2, 212}, {2, 213}, {2, 215}, {2, 218},
+ {2, 220}, {2, 24}, {2, 26}, {2, 27}, {2, 28}, {2, 30},
+ {2, 34}, {2, 35}, {2, 36}, {2, 257}, {2, 236}, {2, 237},
+ {2, 239}, {2, 241}, {2, 243}, {2, 307}, {2, 289}, {2, 291},
+ {2, 292}, {2, 293}, {2, 295}, {2, 338}, {2, 311}, {2, 320},
+ {2, 322}, {3, 337}, {3, 316}, {3, 62}, {3, 40}, {3, 44},
+ {3, 45}, {3, 46}, {3, 47}, {3, 49}, {3, 50}, {3, 52},
+ {3, 53}, {3, 54}, {3, 55}, {3, 125}, {3, 116}, {3, 117},
+ {3, 119}, {3, 120}, {3, 122}, {3, 174}, {3, 164}, {3, 166},
+ {3, 167}, {3, 168}, {3, 169}, {3, 422}, {3, 412}, {3, 413},
+ {3, 415}, {3, 416}, {3, 417}, {3, 418}, {3, 202}, {3, 189},
+ {3, 192}, {3, 193}, {3, 194}, {3, 195}, {3, 196}, {3, 197},
+ {3, 435}, {3, 424}, {3, 426}, {3, 427}, {3, 428}, {3, 429},
+ {3, 430}, {3, 431}, {3, 451}, {3, 439}, {3, 440}, {3, 442},
+ {3, 444}, {3, 445}, {3, 446}, {3, 256}, {3, 245}, {3, 247},
+ {3, 248}, {3, 249}, {3, 250}, {3, 251}, {3, 396}, {3, 385},
+ {3, 387}, {3, 388}, {3, 389}, {3, 390}, {3, 464}, {3, 465},
+ {3, 466}, {3, 261}, {3, 263}, {3, 264}, {3, 266}, {3, 267},
+ {3, 268}, {3, 269}, {3, 62}, {3, 56}, {3, 58}, {3, 59},
+ {3, 233}, {3, 222}, {3, 225}, {3, 227}, {3, 229}, {3, 307},
+ {3, 298}, {3, 299}, {3, 301}, {3, 302}, {3, 304}, {3, 338},
+ {3, 311}, {3, 324}, {3, 325}, {3, 326}, {3, 328}, {3, 329},
+ {3, 334}, {3, 336}, {4, 627}, {4, 619}, {4, 618}, {4, 476},
+ {4, 477}, {4, 482}, {4, 483}, {4, 484}, {4, 485}, {4, 486},
+ {4, 696}, {4, 686}, {4, 688}, {4, 689}, {4, 690}, {4, 691},
+ {4, 683}, {4, 672}, {4, 674}, {4, 675}, {4, 676}, {4, 677},
+ {4, 569}, {4, 553}, {4, 555}, {4, 556}, {4, 557}, {4, 560},
+ {4, 563}, {4, 559}, {4, 566}, {4, 521}, {4, 514}, {4, 516},
+ {4, 517}, {4, 518}, {4, 519}, {4, 520}, {4, 639}, {4, 630},
+ {4, 632}, {4, 633}, {4, 604}, {4, 597}, {4, 598}, {4, 600},
+ {4, 601}, {4, 549}, {4, 540}, {4, 542}, {4, 543}, {4, 545},
+ {4, 546}, {4, 537}, {4, 525}, {4, 526}, {4, 528}, {4, 529},
+ {4, 530}, {4, 531}, {4, 533}, {4, 534}, {4, 535}, {4, 510},
+ {4, 487}, {4, 490}, {4, 491}, {4, 492}, {4, 593}, {4, 575},
+ {4, 576}, {4, 580}, {4, 581}, {4, 583}, {4, 584}, {4, 586},
+ {4, 587}, {4, 588}, {4, 589}, {4, 609}, {4, 610}, {4, 611},
+ {4, 612}, {4, 628}, {4, 621}, {4, 623}, {4, 625}, {5, 627},
+ {5, 618}, {5, 510}, {5, 494}, {5, 497}, {5, 502}, {5, 710},
+ {5, 712}, {5, 713}, {5, 714}, {5, 715}, {5, 718}, {5, 506},
+ {5, 741}, {5, 743}, {5, 744}, {5, 745}, {5, 746}, {5, 827},
+ {5, 719}, {5, 721}, {5, 722}, {5, 725}, {5, 726}, {5, 728},
+ {5, 729}, {5, 732}, {5, 733}, {5, 735}, {5, 736}, {5, 737},
+ {5, 740}, {5, 505}, {5, 749}, {5, 751}, {5, 752}, {5, 754},
+ {5, 755}, {5, 756}, {5, 758}, {5, 759}, {5, 760}, {5, 761},
+ {5, 762}, {5, 764}, {5, 823}, {5, 765}, {5, 768}, {5, 769},
+ {5, 771}, {5, 772}, {5, 773}, {5, 774}, {5, 776}, {5, 777},
+ {5, 778}, {5, 779}, {5, 781}, {5, 824}, {5, 782}, {5, 785},
+ {5, 786}, {5, 788}, {5, 789}, {5, 790}, {5, 791}, {5, 792},
+ {5, 793}, {5, 794}, {5, 795}, {5, 798}, {5, 825}, {5, 799},
+ {5, 802}, {5, 803}, {5, 805}, {5, 806}, {5, 807}, {5, 808},
+ {5, 809}, {5, 810}, {5, 811}, {5, 813}, {5, 815}, {5, 816},
+ {5, 817}, {5, 819}, {5, 821}, {5, 567}, {5, 507}, {1, 641},
+ {1, 828}, {1, 6}, {1, 453}, {1, 456}, {1, 279}, {1, 280},
+ {1, 283}, {1, 285}, {1, 286}, {1, 287}, {1, 311}, {1, 313},
+ {1, 321}, {2, 337}, {2, 316}, {2, 62}, {2, 7}, {2, 9},
+ {2, 10}, {2, 11}, {2, 470}, {2, 125}, {2, 65}, {2, 66},
+ {2, 68}, {2, 69}, {2, 70}, {2, 71}, {2, 72}, {2, 73},
+ {2, 76}, {2, 81}, {2, 82}, {2, 83}, {2, 86}, {2, 88},
+ {2, 95}, {2, 103}, {2, 106}, {2, 354}, {2, 340}, {2, 342},
+ {2, 343}, {2, 344}, {2, 345}, {2, 372}, {2, 356}, {2, 358},
+ {2, 359}, {2, 360}, {2, 361}, {2, 362}, {2, 396}, {2, 373},
+ {2, 375}, {2, 376}, {2, 377}, {2, 378}, {2, 379}, {2, 410},
+ {2, 398}, {2, 400}, {2, 401}, {2, 402}, {2, 403}, {2, 404},
+ {2, 174}, {2, 129}, {2, 130}, {2, 132}, {2, 133}, {2, 134},
+ {2, 135}, {2, 148}, {2, 137}, {2, 141}, {2, 144}, {2, 145},
+ {2, 149}, {2, 150}, {2, 152}, {2, 155}, {2, 156}, {2, 157},
+ {2, 158}, {2, 202}, {2, 176}, {2, 178}, {2, 179}, {2, 180},
+ {2, 181}, {2, 182}, {2, 183}, {2, 184}, {2, 232}, {2, 207},
+ {2, 209}, {2, 210}, {2, 211}, {2, 212}, {2, 213}, {2, 215},
+ {2, 218}, {2, 220}, {2, 24}, {2, 26}, {2, 27}, {2, 28},
+ {2, 30}, {2, 34}, {2, 35}, {2, 36}, {2, 257}, {2, 236},
+ {2, 237}, {2, 239}, {2, 241}, {2, 243}, {2, 307}, {2, 289},
+ {2, 291}, {2, 292}, {2, 293}, {2, 295}, {2, 338}, {2, 311},
+ {2, 320}, {2, 322}, {3, 337}, {3, 316}, {3, 62}, {3, 40},
+ {3, 44}, {3, 45}, {3, 46}, {3, 47}, {3, 49}, {3, 50},
+ {3, 52}, {3, 53}, {3, 54}, {3, 55}, {3, 125}, {3, 116},
+ {3, 117}, {3, 119}, {3, 120}, {3, 122}, {3, 174}, {3, 164},
+ {3, 166}, {3, 167}, {3, 168}, {3, 169}, {3, 422}, {3, 412},
+ {3, 413}, {3, 415}, {3, 416}, {3, 417}, {3, 418}, {3, 202},
+ {3, 189}, {3, 192}, {3, 193}, {3, 194}, {3, 195}, {3, 196},
+ {3, 197}, {3, 435}, {3, 424}, {3, 426}, {3, 427}, {3, 428},
+ {3, 429}, {3, 430}, {3, 431}, {3, 451}, {3, 439}, {3, 440},
+ {3, 442}, {3, 444}, {3, 445}, {3, 446}, {3, 256}, {3, 245},
+ {3, 247}, {3, 248}, {3, 249}, {3, 250}, {3, 251}, {3, 396},
+ {3, 385}, {3, 387}, {3, 388}, {3, 389}, {3, 390}, {3, 464},
+ {3, 465}, {3, 466}, {3, 261}, {3, 263}, {3, 264}, {3, 266},
+ {3, 267}, {3, 268}, {3, 269}, {3, 62}, {3, 56}, {3, 58},
+ {3, 59}, {3, 233}, {3, 222}, {3, 225}, {3, 227}, {3, 229},
+ {3, 307}, {3, 298}, {3, 299}, {3, 301}, {3, 302}, {3, 304},
+ {3, 338}, {3, 311}, {3, 324}, {3, 325}, {3, 326}, {3, 328},
+ {3, 329}, {3, 334}, {3, 336}, {4, 627}, {4, 619}, {4, 618},
+ {4, 476}, {4, 477}, {4, 482}, {4, 483}, {4, 484}, {4, 485},
+ {4, 486}, {4, 696}, {4, 686}, {4, 688}, {4, 689}, {4, 690},
+ {4, 691}, {4, 683}, {4, 672}, {4, 674}, {4, 675}, {4, 676},
+ {4, 677}, {4, 569}, {4, 553}, {4, 555}, {4, 556}, {4, 557},
+ {4, 560}, {4, 563}, {4, 559}, {4, 566}, {4, 521}, {4, 514},
+ {4, 516}, {4, 517}, {4, 518}, {4, 519}, {4, 520}, {4, 639},
+ {4, 630}, {4, 632}, {4, 633}, {4, 604}, {4, 597}, {4, 598},
+ {4, 600}, {4, 601}, {4, 549}, {4, 540}, {4, 542}, {4, 543},
+ {4, 545}, {4, 546}, {4, 537}, {4, 525}, {4, 526}, {4, 528},
+ {4, 529}, {4, 530}, {4, 531}, {4, 533}, {4, 534}, {4, 535},
+ {4, 510}, {4, 487}, {4, 490}, {4, 491}, {4, 492}, {4, 593},
+ {4, 575}, {4, 576}, {4, 580}, {4, 581}, {4, 583}, {4, 584},
+ {4, 586}, {4, 587}, {4, 588}, {4, 589}, {4, 609}, {4, 610},
+ {4, 611}, {4, 612}, {4, 628}, {4, 621}, {4, 623}, {4, 625},
+ {5, 627}, {5, 618}, {5, 510}, {5, 494}, {5, 497}, {5, 502},
+ {5, 710}, {5, 712}, {5, 713}, {5, 714}, {5, 715}, {5, 718},
+ {5, 506}, {5, 741}, {5, 743}, {5, 744}, {5, 745}, {5, 746},
+ {5, 827}, {5, 719}, {5, 721}, {5, 722}, {5, 725}, {5, 726},
+ {5, 728}, {5, 729}, {5, 732}, {5, 733}, {5, 735}, {5, 736},
+ {5, 737}, {5, 740}, {5, 505}, {5, 749}, {5, 751}, {5, 752},
+ {5, 754}, {5, 755}, {5, 756}, {5, 758}, {5, 759}, {5, 760},
+ {5, 761}, {5, 762}, {5, 764}, {5, 823}, {5, 765}, {5, 768},
+ {5, 769}, {5, 771}, {5, 772}, {5, 773}, {5, 774}, {5, 776},
+ {5, 777}, {5, 778}, {5, 779}, {5, 781}, {5, 824}, {5, 782},
+ {5, 785}, {5, 786}, {5, 788}, {5, 789}, {5, 790}, {5, 791},
+ {5, 792}, {5, 793}, {5, 794}, {5, 795}, {5, 798}, {5, 825},
+ {5, 799}, {5, 802}, {5, 803}, {5, 805}, {5, 806}, {5, 807},
+ {5, 808}, {5, 809}, {5, 810}, {5, 811}, {5, 813}, {5, 815},
+ {5, 816}, {5, 817}, {5, 819}, {5, 821}, {5, 567}, {5, 507},
+ {1, 641}, {1, 828}, {1, 453}, {1, 456}, {1, 279}, {1, 280},
+ {1, 283}, {1, 285}, {1, 286}, {1, 287}, {1, 311}, {1, 313},
+ {1, 321}, {2, 337}, {2, 316}, {2, 62}, {2, 7}, {2, 9},
+ {2, 10}, {2, 11}, {2, 470}, {2, 125}, {2, 65}, {2, 66},
+ {2, 68}, {2, 69}, {2, 70}, {2, 71}, {2, 72}, {2, 73},
+ {2, 76}, {2, 81}, {2, 82}, {2, 83}, {2, 86}, {2, 88},
+ {2, 95}, {2, 103}, {2, 106}, {2, 354}, {2, 340}, {2, 342},
+ {2, 343}, {2, 344}, {2, 345}, {2, 372}, {2, 356}, {2, 358},
+ {2, 359}, {2, 360}, {2, 361}, {2, 362}, {2, 396}, {2, 373},
+ {2, 375}, {2, 376}, {2, 377}, {2, 378}, {2, 379}, {2, 410},
+ {2, 398}, {2, 400}, {2, 401}, {2, 402}, {2, 403}, {2, 404},
+ {2, 174}, {2, 129}, {2, 130}, {2, 132}, {2, 133}, {2, 134},
+ {2, 135}, {2, 148}, {2, 137}, {2, 141}, {2, 144}, {2, 145},
+ {2, 149}, {2, 150}, {2, 152}, {2, 155}, {2, 156}, {2, 157},
+ {2, 158}, {2, 202}, {2, 176}, {2, 178}, {2, 179}, {2, 180},
+ {2, 181}, {2, 182}, {2, 183}, {2, 184}, {2, 232}, {2, 207},
+ {2, 209}, {2, 210}, {2, 211}, {2, 212}, {2, 213}, {2, 215},
+ {2, 218}, {2, 220}, {2, 24}, {2, 26}, {2, 27}, {2, 28},
+ {2, 30}, {2, 34}, {2, 35}, {2, 36}, {2, 257}, {2, 236},
+ {2, 237}, {2, 239}, {2, 241}, {2, 243}, {2, 307}, {2, 289},
+ {2, 291}, {2, 292}, {2, 293}, {2, 295}, {2, 338}, {2, 311},
+ {2, 320}, {2, 322}, {3, 337}, {3, 316}, {3, 62}, {3, 40},
+ {3, 44}, {3, 45}, {3, 46}, {3, 47}, {3, 49}, {3, 50},
+ {3, 52}, {3, 53}, {3, 54}, {3, 55}, {3, 125}, {3, 116},
+ {3, 117}, {3, 119}, {3, 120}, {3, 122}, {3, 174}, {3, 164},
+ {3, 166}, {3, 167}, {3, 168}, {3, 169}, {3, 422}, {3, 412},
+ {3, 413}, {3, 415}, {3, 416}, {3, 417}, {3, 418}, {3, 202},
+ {3, 189}, {3, 192}, {3, 193}, {3, 194}, {3, 195}, {3, 196},
+ {3, 197}, {3, 435}, {3, 424}, {3, 426}, {3, 427}, {3, 428},
+ {3, 429}, {3, 430}, {3, 431}, {3, 451}, {3, 439}, {3, 440},
+ {3, 442}, {3, 444}, {3, 445}, {3, 446}, {3, 256}, {3, 245},
+ {3, 247}, {3, 248}, {3, 249}, {3, 250}, {3, 251}, {3, 396},
+ {3, 385}, {3, 387}, {3, 388}, {3, 389}, {3, 390}, {3, 464},
+ {3, 465}, {3, 466}, {3, 261}, {3, 263}, {3, 264}, {3, 266},
+ {3, 267}, {3, 268}, {3, 269}, {3, 62}, {3, 56}, {3, 58},
+ {3, 59}, {3, 233}, {3, 222}, {3, 225}, {3, 227}, {3, 229},
+ {3, 307}, {3, 298}, {3, 299}, {3, 301}, {3, 302}, {3, 304},
+ {3, 338}, {3, 311}, {3, 324}, {3, 325}, {3, 326}, {3, 328},
+ {3, 329}, {3, 334}, {3, 336}, {4, 627}, {4, 619}, {4, 618},
+ {4, 476}, {4, 477}, {4, 482}, {4, 483}, {4, 484}, {4, 485},
+ {4, 486}, {4, 696}, {4, 686}, {4, 688}, {4, 689}, {4, 690},
+ {4, 691}, {4, 683}, {4, 672}, {4, 674}, {4, 675}, {4, 676},
+ {4, 677}, {4, 569}, {4, 553}, {4, 555}, {4, 556}, {4, 557},
+ {4, 560}, {4, 563}, {4, 559}, {4, 566}, {4, 521}, {4, 514},
+ {4, 516}, {4, 517}, {4, 518}, {4, 519}, {4, 520}, {4, 639},
+ {4, 630}, {4, 632}, {4, 633}, {4, 604}, {4, 597}, {4, 598},
+ {4, 600}, {4, 601}, {4, 549}, {4, 540}, {4, 542}, {4, 543},
+ {4, 545}, {4, 546}, {4, 537}, {4, 525}, {4, 526}, {4, 528},
+ {4, 529}, {4, 530}, {4, 531}, {4, 533}, {4, 534}, {4, 535},
+ {4, 510}, {4, 487}, {4, 490}, {4, 491}, {4, 492}, {4, 593},
+ {4, 575}, {4, 576}, {4, 580}, {4, 581}, {4, 583}, {4, 584},
+ {4, 586}, {4, 587}, {4, 588}, {4, 589}, {4, 609}, {4, 610},
+ {4, 611}, {4, 612}, {4, 628}, {4, 621}, {4, 623}, {4, 625},
+ {5, 627}, {5, 618}, {5, 510}, {5, 494}, {5, 497}, {5, 710},
+ {5, 712}, {5, 713}, {5, 714}, {5, 715}, {5, 718}, {5, 506},
+ {5, 741}, {5, 743}, {5, 744}, {5, 745}, {5, 746}, {5, 827},
+ {5, 719}, {5, 721}, {5, 722}, {5, 725}, {5, 726}, {5, 728},
+ {5, 729}, {5, 732}, {5, 733}, {5, 735}, {5, 736}, {5, 737},
+ {5, 740}, {5, 505}, {5, 749}, {5, 751}, {5, 752}, {5, 754},
+ {5, 755}, {5, 756}, {5, 758}, {5, 759}, {5, 760}, {5, 761},
+ {5, 762}, {5, 764}, {5, 823}, {5, 765}, {5, 768}, {5, 769},
+ {5, 771}, {5, 772}, {5, 773}, {5, 774}, {5, 776}, {5, 777},
+ {5, 778}, {5, 779}, {5, 781}, {5, 824}, {5, 782}, {5, 785},
+ {5, 786}, {5, 788}, {5, 789}, {5, 790}, {5, 791}, {5, 792},
+ {5, 793}, {5, 794}, {5, 795}, {5, 798}, {5, 825}, {5, 799},
+ {5, 802}, {5, 803}, {5, 805}, {5, 806}, {5, 807}, {5, 808},
+ {5, 809}, {5, 810}, {5, 811}, {5, 813}, {5, 815}, {5, 816},
+ {5, 817}, {5, 819}, {5, 821}, {5, 567}, {5, 507}, {1, 641}
+};
+
+const CinemaPlaylist kCinemaPlaylists[78] = {
+ {0, 409},
+ {409, 1},
+ {410, 11},
+ {421, 115},
+ {536, 103},
+ {639, 87},
+ {726, 91},
+ {817, 1},
+ {818, 8},
+ {826, 3},
+ {829, 8},
+ {837, 9},
+ {846, 4},
+ {850, 5},
+ {855, 6},
+ {861, 7},
+ {868, 7},
+ {875, 7},
+ {882, 8},
+ {890, 4},
+ {894, 7},
+ {901, 9},
+ {910, 7},
+ {917, 3},
+ {920, 5},
+ {925, 3},
+ {928, 6},
+ {934, 6},
+ {940, 4},
+ {944, 6},
+ {950, 8},
+ {958, 6},
+ {964, 6},
+ {970, 7},
+ {977, 8},
+ {985, 8},
+ {993, 7},
+ {1000, 7},
+ {1007, 6},
+ {1013, 10},
+ {1023, 4},
+ {1027, 5},
+ {1032, 6},
+ {1038, 3},
+ {1041, 6},
+ {1047, 2},
+ {1049, 8},
+ {1057, 6},
+ {1063, 6},
+ {1069, 3},
+ {1072, 6},
+ {1078, 7},
+ {1085, 4},
+ {1089, 5},
+ {1094, 6},
+ {1100, 10},
+ {1110, 5},
+ {1115, 2},
+ {1117, 3},
+ {1120, 6},
+ {1126, 4},
+ {1130, 4},
+ {1134, 5},
+ {1139, 6},
+ {1145, 7},
+ {1152, 4},
+ {1156, 4},
+ {1160, 5},
+ {1165, 1},
+ {1166, 13},
+ {1179, 13},
+ {1192, 13},
+ {1205, 13},
+ {1218, 1},
+ {1219, 1},
+ {1220, 1},
+ {1221, 2},
+ {1223, 1}
+};
+
+} // namespace BCB
diff --git a/engines/harold/bcb/cinema_tables.h b/engines/harold/bcb/cinema_tables.h
new file mode 100644
index 00000000000..8ef7c47773c
--- /dev/null
+++ b/engines/harold/bcb/cinema_tables.h
@@ -0,0 +1,55 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef HAROLD_BCB_CINEMA_TABLES_H
+#define HAROLD_BCB_CINEMA_TABLES_H
+
+#include "harold/bcb/ui.h"
+
+namespace BCB {
+
+struct CinemaButton {
+ StaticRect source;
+ int16 destinationX;
+ int16 destinationY;
+};
+
+struct CinemaMovie {
+ uint16 disc;
+ uint16 number;
+};
+
+struct CinemaPlaylist {
+ uint16 firstMovie;
+ uint16 movieCount;
+};
+
+extern const char *const kCinemaPicturePaths[3];
+extern const CinemaButton kCinemaButtons[26];
+extern const uint16 kCinemaDialogSizes[4][2];
+extern const StaticRect kCinemaBackgroundItems[6];
+extern const StaticRect kCinemaPlaylistItems[8];
+extern const StaticRect kCinemaPlaybackItems[3];
+extern const CinemaMovie kCinemaMovies[];
+extern const CinemaPlaylist kCinemaPlaylists[78];
+
+} // namespace BCB
+
+#endif
diff --git a/engines/harold/bcb/cinema_video.cpp b/engines/harold/bcb/cinema_video.cpp
new file mode 100644
index 00000000000..1f741e5c650
--- /dev/null
+++ b/engines/harold/bcb/cinema_video.cpp
@@ -0,0 +1,233 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "common/system.h"
+#include "common/textconsole.h"
+#include "graphics/font.h"
+#include "graphics/screen.h"
+#include "harold/bcb/bcb.h"
+#include "harold/bcb/cinema.h"
+#include "video/avi_decoder.h"
+
+namespace BCB {
+
+void CinemaViewer::revealBackground() {
+ const uint32 start = g_system->getMillis();
+ for (int step = 0; step < 160 && _running && !_engine.shouldQuit(); ++step) {
+ const uint32 elapsed = g_system->getMillis() - start;
+ const uint32 deadline = (step + 1) * 1000 / 60;
+ if (elapsed < deadline)
+ wait(deadline - elapsed);
+ const Common::Rect right(320 + step * 2, 0, 322 + step * 2, 480);
+ const Common::Rect left(318 - step * 2, 0, 320 - step * 2, 480);
+ _canvas.blitFrom(_background, right, Common::Point(right.left, 0));
+ _canvas.blitFrom(_background, left, Common::Point(left.left, 0));
+ present();
+ }
+}
+
+void CinemaViewer::showPlayback() {
+ if (!loadPlaylist())
+ return;
+ _heldScroll = 0;
+ _pressedButton = -1;
+ _releaseAction = 0;
+ _page = kPlayback;
+ _entry = 0;
+ _captionSize = 12;
+ _playlistEndTime = 0;
+ _canvas.clear(0);
+ present();
+ if (_backgroundIndex)
+ revealBackground();
+ if (!_running || _engine.shouldQuit())
+ return;
+ drawControls();
+ if (!startMovie())
+ stopPlayback();
+}
+
+bool CinemaViewer::startMovie() {
+ _video.reset();
+ _paused = false;
+ if (_entry >= static_cast<int>(_movies.size())) {
+ _playlistEndTime = g_system->getMillis() + 1000;
+ drawControls();
+ present();
+ return true;
+ }
+ const CinemaMovie &movie = _movies[_entry];
+ const Common::String path = Common::String::format("movie/mov%04u.avi", movie.number);
+ Common::SeekableReadStream *stream = _engine.createDiscReadStream(movie.disc, path.c_str());
+ if (!stream) {
+ warning("BCB Cinema: Missing disc %u file %s", movie.disc, path.c_str());
+ return false;
+ }
+ _video.reset(new Video::AVIDecoder());
+ _video->setSoundType(Audio::Mixer::kSFXSoundType);
+ if (!_video->loadStream(stream)) {
+ warning("BCB Cinema: Unable to decode disc %u file %s", movie.disc, path.c_str());
+ _video.reset();
+ return false;
+ }
+ _video->setOutputPixelFormat(_canvas.format);
+ loadCaptions(movie.number);
+ drawControls();
+ _video->start();
+ syncMoviePause();
+ present();
+ return true;
+}
+
+void CinemaViewer::stopPlayback() {
+ _video.reset();
+ _playlistEndTime = 0;
+ _dragging = false;
+ _paused = false;
+ _pressedButton = -1;
+ _releaseAction = 0;
+ _page = kPlaylist;
+ _entry = 0;
+ drawSelection();
+}
+
+void CinemaViewer::seekMovie(int entry) {
+ if (_page != kPlayback)
+ return;
+ clearCaptions();
+ _dragging = false;
+ _playlistEndTime = 0;
+ _entry = CLIP<int>(entry, 0, _movies.size());
+ if (!startMovie())
+ stopPlayback();
+}
+
+void CinemaViewer::togglePause() {
+ if (!_video)
+ return;
+ _paused = !_paused;
+ syncMoviePause();
+ drawButton(_paused ? 23 : 22);
+ present();
+}
+
+void CinemaViewer::syncMoviePause() {
+ const bool paused = _paused || _enginePaused || _dragging || _releaseAction == 2;
+ if (_video && _video->isPaused() != paused)
+ _video->pauseVideo(paused);
+}
+
+Common::Rect CinemaViewer::thumbRect() const {
+ const int entry = _dragging ? _seekEntry : _entry;
+ const int x = 189 + 16 + (_movies.size() == 0 ? 0 : 214 * entry / _movies.size());
+ return Common::Rect(x, 440, x + 16, 456);
+}
+
+void CinemaViewer::drawScrollbar() {
+ const uint32 black = _canvas.format.RGBToColor(0, 0, 0);
+ const uint32 white = _canvas.format.RGBToColor(255, 255, 255);
+ const Common::Rect track(189, 440, 451, 456);
+ _canvas.fillRect(track, _canvas.format.RGBToColor(190, 190, 190));
+ _canvas.frameRect(track, black);
+ const Common::Rect left(189, 440, 205, 456), right(435, 440, 451, 456);
+ _canvas.fillRect(left, white);
+ _canvas.fillRect(right, white);
+ _canvas.frameRect(left, black);
+ _canvas.frameRect(right, black);
+ for (int i = 0; i < 4; ++i) {
+ _canvas.vLine(194 + i, 448 - i, 448 + i, black);
+ _canvas.vLine(445 - i, 448 - i, 448 + i, black);
+ }
+ const Common::Rect thumb = thumbRect();
+ _canvas.fillRect(thumb, white);
+ _canvas.frameRect(thumb, black);
+ for (int i = 4; i <= 10; i += 3)
+ _canvas.vLine(thumb.left + i, thumb.top + 4, thumb.bottom - 5, black);
+}
+
+void CinemaViewer::drawControls() {
+ _canvas.blitFrom(_sheets[2], Common::Rect(0, 120, 262, 160), dialogOrigin());
+ drawButton(20);
+ drawButton(_paused ? 23 : 22);
+ drawButton(24);
+ drawScrollbar();
+}
+
+void CinemaViewer::clearCaptions() {
+ const Common::Point movie = movieOrigin();
+ const int width = 18 * _captionSize;
+ const int x = movie.x + (400 - width) / 2;
+ const Common::Rect area(x, movie.y + 208, x + width, movie.y + 208 + 2 * (_captionSize + 2) + 4);
+ if (_backgroundIndex)
+ _canvas.blitFrom(_background, area, Common::Point(area.left, area.top));
+ else
+ _canvas.fillRect(area, _canvas.format.RGBToColor(0, 0, 0));
+}
+
+void CinemaViewer::drawCaptions() {
+ if (!_video || _nextCaption >= _captions.size())
+ return;
+ const int frame = static_cast<int>(_video->getTime() * 15 / 1000) - 1;
+ if (_captions[_nextCaption].frame > frame)
+ return;
+ clearCaptions();
+ const int lineStep = _captionSize + 2;
+ _captionSize = 14;
+ const Caption &caption = _captions[_nextCaption++];
+ const Graphics::Font *font = _captionFont ? _captionFont.get() : _engine._captionTextFont;
+ if (!font)
+ return;
+ const Common::Point movie = movieOrigin();
+ const int left = movie.x + (400 - 252) / 2 - 1;
+ const int top = movie.y + 210 + 14 - 1 - font->getFontAscent();
+ const uint32 color = _canvas.format.RGBToColor(255, 255, 255);
+ font->drawString(&_canvas, caption.lines[0], left, top, 252, color, Graphics::kTextAlignCenter);
+ font->drawString(&_canvas, caption.lines[1], left, top + lineStep, 252, color, Graphics::kTextAlignCenter);
+}
+
+void CinemaViewer::updatePlayback() {
+ if (_playlistEndTime) {
+ if (static_cast<int32>(g_system->getMillis() - _playlistEndTime) >= 0)
+ stopPlayback();
+ return;
+ }
+ if (!_video || _paused || _enginePaused || _dragging || _releaseAction == 2)
+ return;
+ if (_video->endOfVideo()) {
+ seekMovie(_entry + 1);
+ return;
+ }
+ bool changed = false;
+ if (_video->needsUpdate()) {
+ const Graphics::Surface *frame = _video->decodeNextFrame();
+ if (frame) {
+ const Common::Point origin = movieOrigin();
+ _canvas.blitFrom(*frame, Common::Rect(frame->w, frame->h),
+ Common::Rect(origin.x, origin.y, origin.x + 400, origin.y + 200));
+ changed = true;
+ }
+ }
+ const uint previousCaption = _nextCaption;
+ drawCaptions();
+ if (changed || previousCaption != _nextCaption)
+ present();
+}
+
+} // namespace BCB
diff --git a/engines/harold/bcb/input.cpp b/engines/harold/bcb/input.cpp
index a817f98f461..a205b38819f 100644
--- a/engines/harold/bcb/input.cpp
+++ b/engines/harold/bcb/input.cpp
@@ -23,6 +23,7 @@
#include "common/system.h"
#include "graphics/screen.h"
#include "harold/bcb/bcb.h"
+#include "harold/bcb/cinema.h"
#include "harold/bcb/script.h"
#include "harold/bcb/static_data.h"
#include "video/avi_decoder.h"
@@ -123,6 +124,13 @@ void BCBEngine::handleLeftButtonDown(const Common::Point &mousePosition) {
if (_currentDisplayState != 0 || !_titleButtonsActive)
return;
+ if (_cinemaAvailable && !_titleLoadSlotsActive && CinemaViewer::titleButtonRect().contains(mousePosition)) {
+ CinemaViewer::pressTitleButton(*this);
+ delayWithEventPolling(80);
+ runCinemaViewer();
+ return;
+ }
+
for (uint i = 1; i < ARRAYSIZE(kTitleButtonTable); ++i) {
const ButtonControlRecord &button = kTitleButtonTable[i];
const Common::Rect rect(button.x, button.y, button.x + button.width, button.y + button.height);
diff --git a/engines/harold/bcb/resources.cpp b/engines/harold/bcb/resources.cpp
index e13d9b7176d..27e27df0636 100644
--- a/engines/harold/bcb/resources.cpp
+++ b/engines/harold/bcb/resources.cpp
@@ -29,6 +29,7 @@
#include "harold/bcb/script.h"
#include "harold/bcb/static_data.h"
#include "image/bmp.h"
+#include "image/pict.h"
namespace BCB {
@@ -37,6 +38,8 @@ bool BCBEngine::initializeSearchPaths() {
_programFiles.addDirectory(gameDataDir, 0, 1, false);
_programFiles.addSubDirectoryMatching(gameDataDir, "program", 0, 1, false);
_programFiles.addSubDirectoryMatching(gameDataDir, "bcb/program", 0, 2, false);
+ _programFiles.addSubDirectoryMatching(gameDataDir, "pict", 0, 1, false);
+ _programFiles.addSubDirectoryMatching(gameDataDir, "BLUE CHICAGO BLUES/pict", 0, 1, false);
for (int i = 0; i < 5; ++i)
_discFiles[i].addSubDirectoryMatching(gameDataDir, Common::String::format("bcb%d", i + 1), 0, 8);
@@ -58,36 +61,99 @@ Common::SeekableReadStream *BCBEngine::createActiveDiscReadStream(const char *re
return createDiscReadStream(CLIP<int>(_activeMediaDiscNumber, 1, 5), relativePath);
}
-Common::SeekableReadStream *BCBEngine::createActiveDiscHighColorReadStream(const char *relativePath) const {
- Common::SeekableReadStream *stream = createActiveDiscReadStream(relativePath);
- if (stream)
- return stream;
+Common::SeekableReadStream *BCBEngine::createDiscImageReadStream(int discNumber, const char *relativePath, Common::String &resolvedPath, bool searchAllDiscs) const {
+ resolvedPath = relativePath;
+ if (discNumber < 1 || discNumber > 5)
+ return nullptr;
Common::String fallbackPath(relativePath);
- int marker = fallbackPath.find("/16m/");
- if (marker < 0)
+ fallbackPath.toLowercase();
+ if (!fallbackPath.hasPrefix("bmp/") || !fallbackPath.hasSuffix(".bmp")) {
+ for (int offset = 0; offset < (searchAllDiscs ? 5 : 1); ++offset) {
+ Common::SeekableReadStream *stream = createDiscReadStream((discNumber - 1 + offset) % 5 + 1, relativePath);
+ if (stream)
+ return stream;
+ }
return nullptr;
+ }
- fallbackPath = fallbackPath.substr(0, marker) + "/256/" + fallbackPath.substr(marker + 5);
- return createActiveDiscReadStream(fallbackPath.c_str());
+ const int marker = fallbackPath.find("/16m/");
+ Common::String pictPath = fallbackPath;
+ if (marker >= 0)
+ pictPath = pictPath.substr(0, marker) + pictPath.substr(marker + 4);
+ pictPath = "pict/" + pictPath.substr(4, pictPath.size() - 8) + ".pic";
+ Common::String paths[3] = {relativePath, pictPath, ""};
+ const int pathCount = marker >= 0 ? 3 : 2;
+ const int discCount = marker >= 0 || searchAllDiscs ? 5 : 1;
+ if (marker >= 0)
+ paths[2] = fallbackPath.substr(0, marker) + "/256/" + fallbackPath.substr(marker + 5);
+
+ for (int pathIndex = 0; pathIndex < pathCount; ++pathIndex) {
+ resolvedPath = paths[pathIndex];
+ for (int offset = 0; offset < discCount; ++offset) {
+ const int sourceDisc = (discNumber - 1 + offset) % 5 + 1;
+ Common::SeekableReadStream *stream = createDiscReadStream(sourceDisc, resolvedPath.c_str());
+ if (stream)
+ return stream;
+ }
+ }
+ return nullptr;
}
-Graphics::Surface *BCBEngine::loadBitmapFromStream(Common::SeekableReadStream *stream, const char *debugName) const {
+Graphics::Surface *BCBEngine::loadImageFromStream(Common::SeekableReadStream *stream, const char *fileName) const {
Common::ScopedPtr<Common::SeekableReadStream> file(stream);
if (!file)
return nullptr;
- Image::BitmapDecoder decoder;
- if (!decoder.loadStream(*file)) {
- warning("BCBEngine::loadBitmapFromStream(): Could not decode %s", debugName);
+ Common::String name(fileName);
+ name.toLowercase();
+ Common::ScopedPtr<Image::ImageDecoder> decoder;
+ if (name.hasSuffix(".pic") || name.hasSuffix(".pict"))
+ decoder.reset(new Image::PICTDecoder());
+ else
+ decoder.reset(new Image::BitmapDecoder());
+ if (!decoder->loadStream(*file)) {
+ warning("BCBEngine::loadImageFromStream(): Could not decode %s", fileName);
return nullptr;
}
- const Graphics::Surface *source = decoder.getSurface();
+ const Graphics::Surface *source = decoder->getSurface();
if (!source)
return nullptr;
- return source->convertTo(g_system->getScreenFormat(), decoder.getPalette().data(), decoder.getPalette().size());
+ return source->convertTo(g_system->getScreenFormat(), decoder->getPalette().data(), decoder->getPalette().size());
+}
+
+Graphics::Surface *BCBEngine::loadProgramBitmap(const char *fileName) const {
+ Common::SeekableReadStream *stream = createProgramReadStream(fileName);
+ if (stream)
+ return loadImageFromStream(stream, fileName);
+
+ static const struct {
+ const char *bitmap;
+ const char *picture;
+ } imageNames[] = {
+ {"16mchip.bmp", "PCHIP.PIC"},
+ {"16mlogo.bmp", "PRSLOGO.PIC"},
+ {"16mmain.bmp", "PMAIN.PIC"},
+ {"16mmainn.bmp", "PMAIN_N.PIC"},
+ {"16mmap.bmp", "PMAP.PIC"},
+ {"16msys.bmp", "PSYSTEM.PIC"},
+ {"16mtitle.bmp", "PTITLE.PIC"},
+ {"256com.bmp", "PCOM.PIC"}
+ };
+ const Common::String requestedName(fileName);
+ for (uint i = 0; i < ARRAYSIZE(imageNames); ++i) {
+ if (!requestedName.equalsIgnoreCase(imageNames[i].bitmap))
+ continue;
+ stream = createProgramReadStream(imageNames[i].picture);
+ if (!stream && requestedName.equalsIgnoreCase("256com.bmp")) {
+ for (int disc = 1; disc <= 5 && !stream; ++disc)
+ stream = createDiscReadStream(disc, "pict/comp/pcom.pic");
+ }
+ return loadImageFromStream(stream, imageNames[i].picture);
+ }
+ return nullptr;
}
const Graphics::Surface *BCBEngine::getUiBitmap(const char *fileName) {
@@ -99,7 +165,7 @@ const Graphics::Surface *BCBEngine::getUiBitmap(const char *fileName) {
bitmap = nullptr;
}
if (!bitmap) {
- bitmap = loadBitmapFromStream(createProgramReadStream(fileName), fileName);
+ bitmap = loadProgramBitmap(fileName);
if (!isChip)
_uiBitmapName = fileName;
}
@@ -116,30 +182,19 @@ Graphics::Surface *BCBEngine::loadBitmap(const char *fileName) {
copy->copyFrom(*source);
return copy;
}
- return loadBitmapFromStream(createProgramReadStream(fileName), fileName);
+ return loadProgramBitmap(fileName);
}
Graphics::Surface *BCBEngine::loadDiscBitmap(const char *relativePath) const {
- return loadBitmapFromStream(createActiveDiscHighColorReadStream(relativePath), relativePath);
+ Common::String resolvedPath;
+ Common::SeekableReadStream *stream = createDiscImageReadStream(CLIP<int>(_activeMediaDiscNumber, 1, 5), relativePath, resolvedPath);
+ return loadImageFromStream(stream, resolvedPath.c_str());
}
Graphics::Surface *BCBEngine::loadDiscBitmapFromAnyDisc(const char *relativePath) const {
- for (int discNumber = 1; discNumber <= 5; ++discNumber) {
- Common::SeekableReadStream *stream = createDiscReadStream(discNumber, relativePath);
- if (stream)
- return loadBitmapFromStream(stream, relativePath);
-
- Common::String fallbackPath(relativePath);
- const int marker = fallbackPath.find("/16m/");
- if (marker >= 0) {
- fallbackPath = fallbackPath.substr(0, marker) + "/256/" + fallbackPath.substr(marker + 5);
- stream = createDiscReadStream(discNumber, fallbackPath.c_str());
- if (stream)
- return loadBitmapFromStream(stream, fallbackPath.c_str());
- }
- }
-
- return nullptr;
+ Common::String resolvedPath;
+ Common::SeekableReadStream *stream = createDiscImageReadStream(CLIP<int>(_activeMediaDiscNumber, 1, 5), relativePath, resolvedPath, true);
+ return loadImageFromStream(stream, resolvedPath.c_str());
}
Common::SeekableReadStream *BCBEngine::createMovieReadStream(int movieId) const {
diff --git a/engines/harold/bcb/saveload.cpp b/engines/harold/bcb/saveload.cpp
index f22389aafbe..4cfb9b6e052 100644
--- a/engines/harold/bcb/saveload.cpp
+++ b/engines/harold/bcb/saveload.cpp
@@ -33,6 +33,7 @@
#include "graphics/surface.h"
#include "harold/bcb/bcb.h"
+#include "harold/bcb/cinema.h"
#include "harold/bcb/script.h"
#include "harold/bcb/static_data.h"
@@ -89,11 +90,11 @@ bool BCBEngine::hasFeature(EngineFeature f) const {
}
bool BCBEngine::canLoadGameStateCurrently(Common::U32String *msg) {
- return true;
+ return !_cinemaViewer;
}
bool BCBEngine::canSaveGameStateCurrently(Common::U32String *msg) {
- return true;
+ return !_cinemaViewer;
}
bool BCBEngine::canSaveAutosaveCurrently() {
@@ -154,6 +155,8 @@ Common::Error BCBEngine::loadGameState(int slot) {
if (!validSave)
return Common::kReadingFailed;
+ delete _cinemaMenu;
+ _cinemaMenu = nullptr;
resetTransientRuntimeStateAfterLoad();
processGameStateDispatcher(false);
return Common::kNoError;
diff --git a/engines/harold/bcb/screens.cpp b/engines/harold/bcb/screens.cpp
index 48f1c2756f7..838ee442c31 100644
--- a/engines/harold/bcb/screens.cpp
+++ b/engines/harold/bcb/screens.cpp
@@ -19,11 +19,13 @@
*
*/
+#include "common/config-manager.h"
#include "common/system.h"
#include "graphics/font.h"
#include "graphics/screen.h"
#include "graphics/surface.h"
#include "harold/bcb/bcb.h"
+#include "harold/bcb/cinema.h"
#include "harold/bcb/script.h"
#include "harold/bcb/static_data.h"
@@ -52,15 +54,35 @@ bool BCBEngine::showInitialLogoScreen() {
bool BCBEngine::showTitleScreen() {
stopGameOverMusic();
if (_titleBitmap && _titleBitmap->format != g_system->getScreenFormat()) {
+ delete _cinemaMenu;
+ _cinemaMenu = nullptr;
_titleBitmap->free();
delete _titleBitmap;
_titleBitmap = nullptr;
}
+ const Common::String &target = ConfMan.getActiveDomainName();
+ const bool completed = ConfMan.hasKey("bcb_completed", target) && ConfMan.getBool("bcb_completed", target);
+ if (completed && !_cinemaMenu) {
+ _cinemaMenu = new CinemaViewer(*this);
+ if (!_cinemaMenu->load()) {
+ delete _cinemaMenu;
+ _cinemaMenu = nullptr;
+ }
+ }
+ const bool cinemaAvailable = completed && _cinemaMenu;
+ if (_titleBitmap && _cinemaAvailable != cinemaAvailable) {
+ _titleBitmap->free();
+ delete _titleBitmap;
+ _titleBitmap = nullptr;
+ }
+ _cinemaAvailable = cinemaAvailable;
if (!_titleBitmap) {
_titleBitmap = loadBitmap("16mtitle.bmp");
if (_titleBitmap && _selectedTextLanguagePackageAvailable)
applyTranslatedTitleMenu(*_titleBitmap, _textTranslation);
+ if (_titleBitmap && _cinemaAvailable)
+ CinemaViewer::drawTitleButton(*this, *_titleBitmap);
}
if (!_titleBitmap)
return false;
@@ -99,6 +121,8 @@ bool BCBEngine::transitionFromLogoToTitle() {
}
bool BCBEngine::startNewGameFromTitle() {
+ delete _cinemaMenu;
+ _cinemaMenu = nullptr;
_titleButtonsActive = false;
_systemButtonsVisible = false;
stopMenuBackgroundMusic();
@@ -135,6 +159,19 @@ bool BCBEngine::showPendingStillImageScreen() {
still->free();
delete still;
+ if (stillImageToShowId == 0x39 || stillImageToShowId == 0x3a) {
+ const Common::String &target = ConfMan.getActiveDomainName();
+ if (!ConfMan.hasKey("bcb_completed", target) || !ConfMan.getBool("bcb_completed", target)) {
+ ConfMan.setBool("bcb_completed", true, target);
+ ConfMan.flushToDisk();
+ if (_titleBitmap) {
+ _titleBitmap->free();
+ delete _titleBitmap;
+ _titleBitmap = nullptr;
+ }
+ }
+ }
+
_currentDisplayState = 6;
_pendingStillElapsedTimerTicks = 0;
_lastTimerTick = g_system->getMillis();
diff --git a/engines/harold/bcb/text_renderer.cpp b/engines/harold/bcb/text_renderer.cpp
index f678114b1e5..7f13403ab0c 100644
--- a/engines/harold/bcb/text_renderer.cpp
+++ b/engines/harold/bcb/text_renderer.cpp
@@ -621,20 +621,46 @@ Graphics::Surface *downscaleRgbaLayerInternal(const Graphics::Surface &source, i
Graphics::Surface temp;
temp.create(width, source.h, source.format);
temp.fillRect(Common::Rect(width, source.h), 0);
+ Common::Array<int> rowStarts, rowEnds;
+ if (!opaque) {
+ rowStarts.resize(source.h);
+ rowEnds.resize(source.h);
+ for (int y = 0; y < source.h; ++y) {
+ rowStarts[y] = width;
+ rowEnds[y] = 0;
+ }
+ }
for (int y = sourceAlphaBounds.top; y < sourceAlphaBounds.bottom; ++y) {
const byte *sourceRow = (const byte *)source.getBasePtr(0, y);
byte *tempRow = (byte *)temp.getBasePtr(0, y);
if (y > sourceAlphaBounds.top && !memcmp(sourceRow, sourceRow - source.pitch, source.w * 4)) {
memcpy(tempRow, tempRow - temp.pitch, width * 4);
+ if (!opaque) {
+ rowStarts[y] = rowStarts[y - 1];
+ rowEnds[y] = rowEnds[y - 1];
+ }
continue;
}
+ int rowFirst = firstOutX, rowLast = lastOutX;
+ if (!opaque) {
+ int left = sourceAlphaBounds.left, right = sourceAlphaBounds.right;
+ while (left < right && !sourceRow[left * 4 + 3])
+ ++left;
+ if (left == right)
+ continue;
+ while (!sourceRow[(right - 1) * 4 + 3])
+ --right;
+ findOutputBoundsForSourceBounds(horizontalBounds, width, Common::Rect(left, 0, right, 1), true, rowFirst, rowLast);
+ rowStarts[y] = rowFirst;
+ rowEnds[y] = rowLast;
+ }
if (opaque) {
const uint32 *pixels = reinterpret_cast<const uint32 *>(sourceRow);
runEnds[source.w - 1] = source.w;
for (int x = source.w - 2; x >= 0; --x)
runEnds[x] = pixels[x] == pixels[x + 1] ? runEnds[x + 1] : x + 1;
}
- for (int outX = firstOutX; outX < lastOutX; ++outX) {
+ for (int outX = rowFirst; outX < rowLast; ++outX) {
const int xmin = horizontalBounds[outX * 2 + 0];
const int xmax = horizontalBounds[outX * 2 + 1];
const int *kernel = &horizontalCoefficients[outX * horizontalKernelSize];
@@ -668,7 +694,16 @@ Graphics::Surface *downscaleRgbaLayerInternal(const Graphics::Surface &source, i
const int *kernel = &verticalCoefficients[outY * verticalKernelSize];
byte *targetRow = (byte *)target->getBasePtr(0, outY);
const byte *tempRow = static_cast<const byte *>(temp.getBasePtr(0, ymin));
- for (int x = firstOutX; x < lastOutX; ++x) {
+ int rowFirst = firstOutX, rowLast = lastOutX;
+ if (!opaque) {
+ rowFirst = width;
+ rowLast = 0;
+ for (int y = ymin; y < ymin + ymax; ++y) {
+ rowFirst = MIN(rowFirst, rowStarts[y]);
+ rowLast = MAX(rowLast, rowEnds[y]);
+ }
+ }
+ for (int x = rowFirst; x < rowLast; ++x) {
byte *targetPixel = targetRow + x * 4;
if (opaque)
resampleRgbaPixel<true, false>(tempRow + x * 4, temp.pitch, kernel, ymax, targetPixel);
diff --git a/engines/harold/bcb/translation.h b/engines/harold/bcb/translation.h
index f1ae55af0d1..f40c5e0c98e 100644
--- a/engines/harold/bcb/translation.h
+++ b/engines/harold/bcb/translation.h
@@ -76,8 +76,11 @@ Common::String makeTextStringKey(TextTranslationType type, uint primaryId, uint
void listAvailableTranslationPackages(const Common::FSNode &gameDataDir, Common::Array<TranslationPackageDefinition> &packages);
bool isTranslationPackageAvailable(const Common::FSNode &gameDataDir, const Common::String &code);
bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::String &code, TextTranslationData &translation);
+bool applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *stream, const char *debugName);
void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const TextTranslationData &translation);
void applyTranslatedTitleMenu(Graphics::Surface &title, const TextTranslationData &translation);
+void applyTranslatedCinemaMenu(Graphics::Surface &menu, const TextTranslationData &translation);
+bool applyTranslatedCinemaTitleButton(Graphics::Surface &buttons, const TextTranslationData &translation);
void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTranslationData &translation);
void applyTranslatedComputerCard(Graphics::Surface &card, const char *path, const TextTranslationData &translation);
diff --git a/engines/harold/bcb/translation_images.cpp b/engines/harold/bcb/translation_images.cpp
index d6062409d65..78841e45421 100644
--- a/engines/harold/bcb/translation_images.cpp
+++ b/engines/harold/bcb/translation_images.cpp
@@ -200,44 +200,6 @@ void drawTranslatedStillHeading(Graphics::Surface &still, int stillIndex, const
drawConfiguredHighQualityTextLines(still, translation, prefix, "LiberationSerif-BoldItalic.ttf", 255, 255, 255, 0, 0, 0);
}
-bool applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *stream, const char *debugName) {
- Common::ScopedPtr<Common::SeekableReadStream> patchStream(stream);
- if (!patchStream)
- return false;
-
- Image::PNGDecoder decoder;
- if (!decoder.loadStream(*patchStream) || !decoder.getSurface()) {
- warning("%s: Could not decode translated patch", debugName);
- return false;
- }
-
- const Graphics::Surface *patch = decoder.getSurface();
- const int width = MIN<int>(surface.w, patch->w);
- const int height = MIN<int>(surface.h, patch->h);
- for (int y = 0; y < height; ++y) {
- for (int x = 0; x < width; ++x) {
- uint8 srcA, srcR, srcG, srcB;
- patch->format.colorToARGB(patch->getPixel(x, y), srcA, srcR, srcG, srcB);
- if (srcA == 0)
- continue;
-
- if (srcA == 0xff) {
- surface.setPixel(x, y, surface.format.ARGBToColor(0xff, srcR, srcG, srcB));
- continue;
- }
-
- uint8 dstA, dstR, dstG, dstB;
- surface.format.colorToARGB(surface.getPixel(x, y), dstA, dstR, dstG, dstB);
- const uint invA = 255 - srcA;
- const uint8 outR = (srcR * srcA + dstR * invA) / 255;
- const uint8 outG = (srcG * srcA + dstG * invA) / 255;
- const uint8 outB = (srcB * srcA + dstB * invA) / 255;
- surface.setPixel(x, y, surface.format.ARGBToColor(0xff, outR, outG, outB));
- }
- }
- return true;
-}
-
void drawTranslatedEnding(Graphics::Surface &surface, const TextTranslationData &translation, const Common::String &prefix) {
#ifdef USE_FREETYPE2
const TextStringTable &strings = translation.strings;
@@ -321,6 +283,44 @@ void drawTranslatedEnding(Graphics::Surface &surface, const TextTranslationData
} // End of anonymous namespace
+bool applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *stream, const char *debugName) {
+ Common::ScopedPtr<Common::SeekableReadStream> patchStream(stream);
+ if (!patchStream)
+ return false;
+
+ Image::PNGDecoder decoder;
+ if (!decoder.loadStream(*patchStream) || !decoder.getSurface()) {
+ warning("%s: Could not decode image patch", debugName);
+ return false;
+ }
+
+ const Graphics::Surface *patch = decoder.getSurface();
+ const int width = MIN<int>(surface.w, patch->w);
+ const int height = MIN<int>(surface.h, patch->h);
+ for (int y = 0; y < height; ++y) {
+ for (int x = 0; x < width; ++x) {
+ uint8 srcA, srcR, srcG, srcB;
+ patch->format.colorToARGB(patch->getPixel(x, y), srcA, srcR, srcG, srcB);
+ if (srcA == 0)
+ continue;
+
+ if (srcA == 0xff) {
+ surface.setPixel(x, y, surface.format.ARGBToColor(0xff, srcR, srcG, srcB));
+ continue;
+ }
+
+ uint8 dstA, dstR, dstG, dstB;
+ surface.format.colorToARGB(surface.getPixel(x, y), dstA, dstR, dstG, dstB);
+ const uint invA = 255 - srcA;
+ const uint8 outR = (srcR * srcA + dstR * invA) / 255;
+ const uint8 outG = (srcG * srcA + dstG * invA) / 255;
+ const uint8 outB = (srcB * srcA + dstB * invA) / 255;
+ surface.setPixel(x, y, surface.format.ARGBToColor(0xff, outR, outG, outB));
+ }
+ }
+ return true;
+}
+
void applyTranslatedComputerCard(Graphics::Surface &card, const char *path, const TextTranslationData &translation) {
#ifdef USE_FREETYPE2
if (!translation.packageArchive)
@@ -389,6 +389,34 @@ void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTrans
delete converted;
}
+bool applyTranslatedCinemaTitleButton(Graphics::Surface &buttons, const TextTranslationData &translation) {
+#ifdef USE_FREETYPE2
+ if (translation.strings.getString("cinema_title_button.line1") &&
+ translation.strings.getString("cinema_title_button_pressed.line1")) {
+ drawConfiguredHighQualityTextLines(buttons, translation, "cinema_title_button.", "LiberationSans-BoldItalic.ttf", 53, 55, 106, 142, 146, 232);
+ drawConfiguredHighQualityTextLines(buttons, translation, "cinema_title_button_pressed.", "LiberationSans-BoldItalic.ttf", 136, 90, 155, 183, 169, 211);
+ return true;
+ }
+#endif
+ return false;
+}
+
+void applyTranslatedCinemaMenu(Graphics::Surface &menu, const TextTranslationData &translation) {
+#ifdef USE_FREETYPE2
+ if (!translation.packageArchive)
+ return;
+ const char *patch = translation.strings.getString("cinema_menu.patch");
+ if (!patch || !translation.strings.getString("cinema_menu.buttons.line1") ||
+ !translation.strings.getString("cinema_menu.instruction.line1"))
+ return;
+ if (!applyPatchImage(menu, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "applyTranslatedCinemaMenu"))
+ return;
+
+ drawConfiguredHighQualityTextLines(menu, translation, "cinema_menu.buttons.", "LiberationSans-BoldItalic.ttf", 32, 40, 48, 0, 0, 0);
+ drawConfiguredHighQualityTextLines(menu, translation, "cinema_menu.instruction.", "LiberationSerif-Regular.ttf", 216, 176, 32, 0, 0, 0);
+#endif
+}
+
void applyTranslatedTitleMenu(Graphics::Surface &title, const TextTranslationData &translation) {
if (!translation.packageArchive)
return;
diff --git a/engines/harold/module.mk b/engines/harold/module.mk
index 925e8109202..5977618b75d 100644
--- a/engines/harold/module.mk
+++ b/engines/harold/module.mk
@@ -7,6 +7,10 @@ ifdef ENABLE_BCB
MODULE_OBJS += \
bcb/bcb.o \
bcb/captions.o \
+ bcb/cinema.o \
+ bcb/cinema_data.o \
+ bcb/cinema_tables.o \
+ bcb/cinema_video.o \
bcb/computer.o \
bcb/debugger.o \
bcb/executable_data.o \
Commit: a74ec882c120d5ce7bb42acd424a06bbab7be61c
https://github.com/scummvm/scummvm/commit/a74ec882c120d5ce7bb42acd424a06bbab7be61c
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:14+03:00
Commit Message:
HAROLD: BCB: Fix translation rendering and remove HarfBuzz
Changed paths:
engines/harold/bcb/text_renderer.cpp
engines/harold/bcb/text_renderer.h
engines/harold/bcb/translation.cpp
engines/harold/bcb/translation.h
engines/harold/bcb/translation_images.cpp
diff --git a/engines/harold/bcb/text_renderer.cpp b/engines/harold/bcb/text_renderer.cpp
index 7f13403ab0c..0b7d2316244 100644
--- a/engines/harold/bcb/text_renderer.cpp
+++ b/engines/harold/bcb/text_renderer.cpp
@@ -41,11 +41,6 @@
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include FT_STROKER_H
-#if __has_include(<hb.h>) && __has_include(<hb-ft.h>)
-#include <hb-ft.h>
-#include <hb.h>
-#define BCB_USE_HARFBUZZ_TEXT_LAYOUT
-#endif
#endif
namespace BCB {
@@ -104,65 +99,13 @@ struct PillowGlyphInfo {
FT_Pos xOffset;
};
-#ifdef BCB_USE_HARFBUZZ_TEXT_LAYOUT
-bool layoutPillowGlyphsWithHarfBuzz(FT_Face face, const Common::U32String &text, Common::Array<PillowGlyphInfo> &glyphs) {
- glyphs.clear();
- if (text.empty())
- return true;
-
- hb_font_t *font = hb_ft_font_create_referenced(face);
- if (!font)
- return false;
- hb_buffer_t *buffer = hb_buffer_create();
- if (!buffer) {
- hb_font_destroy(font);
- return false;
- }
-
- Common::Array<uint32> codepoints;
- codepoints.resize(text.size());
- for (uint i = 0; i < text.size(); ++i)
- codepoints[i] = text[i];
-
- hb_buffer_add_utf32(buffer, codepoints.data(), codepoints.size(), 0, codepoints.size());
- hb_buffer_guess_segment_properties(buffer);
- hb_shape(font, buffer, nullptr, 0);
-
- uint glyphCount = 0;
- hb_glyph_info_t *glyphInfo = hb_buffer_get_glyph_infos(buffer, &glyphCount);
- hb_glyph_position_t *glyphPosition = hb_buffer_get_glyph_positions(buffer, &glyphCount);
- if (!glyphInfo || !glyphPosition) {
- hb_buffer_destroy(buffer);
- hb_font_destroy(font);
- return false;
- }
-
- for (uint i = 0; i < glyphCount; ++i) {
- PillowGlyphInfo glyph;
- glyph.index = glyphInfo[i].codepoint;
- glyph.xOffset = glyphPosition[i].x_offset;
- glyph.xAdvance = glyphPosition[i].x_advance;
- glyphs.push_back(glyph);
- }
-
- hb_buffer_destroy(buffer);
- hb_font_destroy(font);
- return true;
-}
-#endif
-
bool layoutPillowGlyphs(FT_Face face, const Common::U32String &text, Common::Array<PillowGlyphInfo> &glyphs) {
-#ifdef BCB_USE_HARFBUZZ_TEXT_LAYOUT
- if (layoutPillowGlyphsWithHarfBuzz(face, text, glyphs))
- return true;
-#endif
-
glyphs.clear();
FT_UInt previousIndex = 0;
for (uint i = 0; i < text.size(); ++i) {
const FT_UInt glyphIndex = Graphics::FreeType::Get_Char_Index(face, text[i]);
if (!glyphIndex)
- continue;
+ return false;
FT_Vector kerning;
FT_Pos xOffset = 0;
@@ -175,7 +118,7 @@ bool layoutPillowGlyphs(FT_Face face, const Common::U32String &text, Common::Arr
PillowGlyphInfo glyph;
glyph.index = glyphIndex;
glyph.xOffset = xOffset;
- glyph.xAdvance = face->glyph->advance.x;
+ glyph.xAdvance = face->glyph->advance.x + xOffset;
glyphs.push_back(glyph);
previousIndex = glyphIndex;
}
@@ -193,7 +136,7 @@ bool getPillowTextMaskMetrics(FT_Face face, const Common::Array<PillowGlyphInfo>
for (uint i = 0; i < glyphs.size(); ++i) {
const int px = ftPixel(penX + glyphs[i].xOffset);
- penX += glyphs[i].xOffset + glyphs[i].xAdvance;
+ penX += glyphs[i].xAdvance;
const int advanced = ftPixel(penX);
if (advanced > bboxXMax)
bboxXMax = advanced;
@@ -327,7 +270,7 @@ bool drawFreeTypeTextPass(Graphics::Surface &surface, FT_Face face, const Common
renderPillowGlyphBitmapToSurface(surface, slot->bitmap, destX, destY, color);
}
- penX += glyphs[i].xOffset + glyphs[i].xAdvance;
+ penX += glyphs[i].xAdvance;
}
if (stroker)
@@ -756,11 +699,21 @@ HighQualityTextRenderer::~HighQualityTextRenderer() {
delete _font;
}
-void HighQualityTextRenderer::drawLine(Graphics::Surface &surface, int size,
+bool HighQualityTextRenderer::isValid() const {
+#ifdef USE_FREETYPE2
+ return _font->face != nullptr;
+#else
+ return false;
+#endif
+}
+
+bool HighQualityTextRenderer::drawLine(Graphics::Surface &surface, int size,
const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth, bool baseline) {
#ifdef USE_FREETYPE2
- drawFreeTypeTextLine(surface, _font->face, size, shadowOffsets, text, x, y, textColor, shadowColor, strokeWidth, baseline);
+ return drawFreeTypeTextLine(surface, _font->face, size, shadowOffsets, text, x, y, textColor, shadowColor, strokeWidth, baseline);
+#else
+ return false;
#endif
}
diff --git a/engines/harold/bcb/text_renderer.h b/engines/harold/bcb/text_renderer.h
index f5f02974177..5ef226a4379 100644
--- a/engines/harold/bcb/text_renderer.h
+++ b/engines/harold/bcb/text_renderer.h
@@ -38,7 +38,8 @@ class HighQualityTextRenderer {
public:
explicit HighQualityTextRenderer(const Common::String &fontName);
~HighQualityTextRenderer();
- void drawLine(Graphics::Surface &surface, int size,
+ bool isValid() const;
+ bool drawLine(Graphics::Surface &surface, int size,
const Common::Array<Common::Point> &shadowOffsets, const Common::U32String &text,
int x, int y, uint32 textColor, uint32 shadowColor, int strokeWidth, bool baseline = false);
diff --git a/engines/harold/bcb/translation.cpp b/engines/harold/bcb/translation.cpp
index 8d4f79db9d5..f687e90f656 100644
--- a/engines/harold/bcb/translation.cpp
+++ b/engines/harold/bcb/translation.cpp
@@ -184,6 +184,17 @@ void TextTranslationData::clear() {
packageArchive = nullptr;
}
+HighQualityTextRenderer *TextTranslationData::getImageFont(const Common::String &name) const {
+ HighQualityTextRenderer *renderer = imageFonts.getValOrDefault(name, nullptr);
+ if (!renderer) {
+ renderer = new HighQualityTextRenderer(name);
+ imageFonts[name] = renderer;
+ if (!renderer->isValid())
+ warning("BCB: Could not load translation font '%s'", name.c_str());
+ }
+ return renderer;
+}
+
Common::String makeTextStringKey(TextTranslationType type, uint primaryId, uint secondaryId) {
switch (type) {
case kTextTranslationSceneChoice:
@@ -223,13 +234,29 @@ void listAvailableTranslationPackages(const Common::FSNode &gameDataDir, Common:
}
bool isTranslationPackageAvailable(const Common::FSNode &gameDataDir, const Common::String &code) {
- return packageHasMatchingStrings(gameDataDir.getChild(Common::String::format("bcb-translation-%s.dat", code.c_str())), code);
+ Common::Array<TranslationPackageDefinition> packages;
+ listAvailableTranslationPackages(gameDataDir, packages);
+ for (const auto &package : packages)
+ if (package.code.equalsIgnoreCase(code))
+ return true;
+ return false;
}
bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::String &code, TextTranslationData &translation) {
translation.clear();
- const Common::FSNode packageNode = gameDataDir.getChild(Common::String::format("bcb-translation-%s.dat", code.c_str()));
+ Common::Array<TranslationPackageDefinition> packages;
+ listAvailableTranslationPackages(gameDataDir, packages);
+ Common::String fileName;
+ for (const auto &package : packages) {
+ if (package.code.equalsIgnoreCase(code)) {
+ fileName = package.fileName;
+ break;
+ }
+ }
+ if (fileName.empty())
+ return false;
+ const Common::FSNode packageNode = gameDataDir.getChild(fileName);
translation.packageArchive = Common::makeZipArchive(packageNode, false);
if (!translation.packageArchive)
return false;
@@ -238,11 +265,18 @@ bool loadTranslationPackage(const Common::FSNode &gameDataDir, const Common::Str
translation.clear();
return false;
}
+ static const char *const defaultFonts[] = {
+ "LiberationSerif-BoldItalic.ttf",
+ "LiberationSans-Regular.ttf",
+ "LiberationSans-BoldItalic.ttf",
+ "LiberationSerif-Regular.ttf"
+ };
+ for (const char *font : defaultFonts)
+ translation.getImageFont(font);
for (const auto &entry : translation.strings) {
- if (entry._key.hasSuffix(".font") && !entry._value.empty() && !translation.imageFonts.contains(entry._value))
- translation.imageFonts[entry._value] = new HighQualityTextRenderer(entry._value);
+ if (entry._key.hasSuffix(".font") && !entry._value.empty())
+ translation.getImageFont(entry._value);
}
-
return true;
}
diff --git a/engines/harold/bcb/translation.h b/engines/harold/bcb/translation.h
index f40c5e0c98e..d098c8008ea 100644
--- a/engines/harold/bcb/translation.h
+++ b/engines/harold/bcb/translation.h
@@ -66,9 +66,10 @@ public:
~TextTranslationData();
void clear();
+ HighQualityTextRenderer *getImageFont(const Common::String &name) const;
TextStringTable strings;
- Common::HashMap<Common::String, HighQualityTextRenderer *> imageFonts;
+ mutable Common::HashMap<Common::String, HighQualityTextRenderer *> imageFonts;
Common::Archive *packageArchive;
};
diff --git a/engines/harold/bcb/translation_images.cpp b/engines/harold/bcb/translation_images.cpp
index 78841e45421..fdaed461211 100644
--- a/engines/harold/bcb/translation_images.cpp
+++ b/engines/harold/bcb/translation_images.cpp
@@ -120,13 +120,16 @@ bool parseImageTextLine(const char *definition, Common::U32String &text, int &x,
return true;
}
-void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextTranslationData &translation, const Common::String &prefix,
+bool drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextTranslationData &translation, const Common::String &prefix,
const char *defaultFont, uint8 defaultTextR, uint8 defaultTextG, uint8 defaultTextB,
uint8 defaultShadowR, uint8 defaultShadowG, uint8 defaultShadowB, bool resampleBackground = false) {
const TextStringTable &strings = translation.strings;
const char *fontName = strings.getString(prefix + "font");
if (!fontName || !fontName[0])
fontName = defaultFont;
+ HighQualityTextRenderer *renderer = translation.getImageFont(fontName);
+ if (!renderer->isValid() || !strings.getString(prefix + "line1"))
+ return false;
const Common::Array<Common::Point> shadowOffsets = getTranslationShadowOffsets(strings, prefix + "shadow_offsets");
const bool drawShadowWithoutStroke = getTranslationInt(strings, prefix + "shadow_without_stroke", 0) != 0;
@@ -155,12 +158,7 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextTr
for (uint i = 0; i < shadowOffsets.size(); ++i)
scaledShadowOffsets.push_back(Common::Point(shadowOffsets[i].x * scale, shadowOffsets[i].y * scale));
- HighQualityTextRenderer *renderer = translation.imageFonts.getValOrDefault(fontName, nullptr);
- Common::ScopedPtr<HighQualityTextRenderer> fallbackRenderer;
- if (!renderer) {
- fallbackRenderer.reset(new HighQualityTextRenderer(fontName));
- renderer = fallbackRenderer.get();
- }
+ bool valid = true;
for (int i = 1; ; ++i) {
const char *definition = strings.getString(Common::String::format("%sline%d", prefix.c_str(), i));
if (!definition)
@@ -171,45 +169,55 @@ void drawConfiguredHighQualityTextLines(Graphics::Surface &surface, const TextTr
int size = 44;
int strokeWidth = 0;
uint32 textColor = scaledTextColor;
- if (!parseImageTextLine(definition, text, x, y, size, strokeWidth, textColor, layer.format))
- continue;
+ if (!parseImageTextLine(definition, text, x, y, size, strokeWidth, textColor, layer.format)) {
+ valid = false;
+ break;
+ }
size = CLIP(size, 1, 128);
strokeWidth = CLIP(strokeWidth, 0, 16);
const Common::Array<Common::Point> emptyShadowOffsets;
- renderer->drawLine(layer, size * scale, (strokeWidth == 0 && !drawShadowWithoutStroke) ? emptyShadowOffsets : scaledShadowOffsets,
- text, x * scale, y * scale, textColor, scaledShadowColor, strokeWidth * scale);
+ if (!renderer->drawLine(layer, size * scale, (strokeWidth == 0 && !drawShadowWithoutStroke) ? emptyShadowOffsets : scaledShadowOffsets,
+ text, x * scale, y * scale, textColor, scaledShadowColor, strokeWidth * scale)) {
+ valid = false;
+ break;
+ }
+ }
+ if (!valid) {
+ layer.free();
+ return false;
}
Graphics::Surface *downscaledLayer = resampleBackground ? downscaleRgbaLayerLanczos(layer, surface.w, surface.h) : downscaleRgbaLayerBicubic(layer, surface.w, surface.h);
layer.free();
if (!downscaledLayer)
- return;
+ return false;
alphaCompositeRgbaLayer(surface, *downscaledLayer);
downscaledLayer->free();
delete downscaledLayer;
+ return true;
}
-void drawTranslatedStillHeading(Graphics::Surface &still, int stillIndex, const TextTranslationData &translation) {
+bool drawTranslatedStillHeading(Graphics::Surface &still, int stillIndex, const TextTranslationData &translation) {
if (stillIndex < 0 || stillIndex >= 5)
- return;
+ return false;
const int stillNumber = stillIndex + 1;
const Common::String prefix = Common::String::format("still_headings.%d.", stillNumber);
- drawConfiguredHighQualityTextLines(still, translation, prefix, "LiberationSerif-BoldItalic.ttf", 255, 255, 255, 0, 0, 0);
+ return drawConfiguredHighQualityTextLines(still, translation, prefix, "LiberationSerif-BoldItalic.ttf", 255, 255, 255, 0, 0, 0);
}
-void drawTranslatedEnding(Graphics::Surface &surface, const TextTranslationData &translation, const Common::String &prefix) {
+bool drawTranslatedEnding(Graphics::Surface &surface, const TextTranslationData &translation, const Common::String &prefix) {
#ifdef USE_FREETYPE2
const TextStringTable &strings = translation.strings;
const char *patch = strings.getString(prefix + "patch");
const char *font = strings.getString(prefix + "font");
- HighQualityTextRenderer *renderer = font ? translation.imageFonts.getValOrDefault(font, nullptr) : nullptr;
- if (!translation.packageArchive || !patch || !renderer || !strings.getString(prefix + "line1"))
- return;
+ HighQualityTextRenderer *renderer = font ? translation.getImageFont(font) : nullptr;
+ if (!translation.packageArchive || !patch || !renderer || !renderer->isValid() || !strings.getString(prefix + "line1"))
+ return false;
if (!applyPatchImage(surface, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "drawTranslatedEnding"))
- return;
+ return false;
const int scale = 4;
const int widthPercent = CLIP(getTranslationInt(strings, prefix + "width_percent", 100), 1, 100);
@@ -231,10 +239,17 @@ void drawTranslatedEnding(Graphics::Surface &surface, const TextTranslationData
Common::U32String text;
int x = 0, y = 0, size = 23, stroke = 0;
uint32 color = white;
- if (!parseImageTextLine(definition, text, x, y, size, stroke, color, format))
- continue;
+ if (!parseImageTextLine(definition, text, x, y, size, stroke, color, format)) {
+ mask.free();
+ line.free();
+ return false;
+ }
line.fillRect(Common::Rect(line.w, line.h), black);
- renderer->drawLine(line, CLIP(size, 1, 128) * scale, noShadow, text, 0, 40 * scale, white, black, 0, true);
+ if (!renderer->drawLine(line, CLIP(size, 1, 128) * scale, noShadow, text, 0, 40 * scale, white, black, 0, true)) {
+ mask.free();
+ line.free();
+ return false;
+ }
Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> narrowed(
downscaleRgbaLayerBicubic(line, MAX(1, (line.w * widthPercent + 50) / 100), line.h));
for (int row = 0; row < narrowed->h; ++row) {
@@ -278,6 +293,9 @@ void drawTranslatedEnding(Graphics::Surface &surface, const TextTranslationData
surface.setPixel(x, y, surface.format.RGBToColor(blend(r, shadowR, textR), blend(g, shadowG, textG), blend(b, shadowB, textB)));
}
}
+ return true;
+#else
+ return false;
#endif
}
@@ -295,6 +313,13 @@ bool applyPatchImage(Graphics::Surface &surface, Common::SeekableReadStream *str
}
const Graphics::Surface *patch = decoder.getSurface();
+ Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> converted;
+ if (patch->format.bytesPerPixel == 1) {
+ converted.reset(patch->convertTo(Graphics::PixelFormat::createFormatRGBA32(), decoder.getPalette().data(), decoder.getPalette().size()));
+ if (!converted)
+ return false;
+ patch = converted.get();
+ }
const int width = MIN<int>(surface.w, patch->w);
const int height = MIN<int>(surface.h, patch->h);
for (int y = 0; y < height; ++y) {
@@ -334,20 +359,31 @@ void applyTranslatedComputerCard(Graphics::Surface &card, const char *path, cons
const char *patch = translation.strings.getString(prefix + "patch");
if (!patch || !translation.strings.getString(prefix + "line1"))
return;
- if (!applyPatchImage(card, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "applyTranslatedComputerCard"))
- return;
- drawConfiguredHighQualityTextLines(card, translation, prefix, "LiberationSans-Regular.ttf", 218, 218, 236, 0, 0, 0, true);
+ Graphics::Surface result;
+ result.copyFrom(card);
+ if (applyPatchImage(result, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "applyTranslatedComputerCard") &&
+ drawConfiguredHighQualityTextLines(result, translation, prefix, "LiberationSans-Regular.ttf", 218, 218, 236, 0, 0, 0, true))
+ card.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
+ result.free();
#endif
}
void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const TextTranslationData &translation) {
if (translation.packageArchive && stillIndex >= 0 && stillIndex < 5) {
- applyPatchImage(still, translation.packageArchive->createReadStreamForMember(Common::Path(Common::String::format("patches/pstill_%d_patch.png", stillIndex + 1), '/')), "applyTranslatedStillImage");
+ Graphics::Surface result;
+ result.copyFrom(still);
+ if (applyPatchImage(result, translation.packageArchive->createReadStreamForMember(Common::Path(Common::String::format("patches/pstill_%d_patch.png", stillIndex + 1), '/')), "applyTranslatedStillImage") &&
+ drawTranslatedStillHeading(result, stillIndex, translation))
+ still.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
+ result.free();
+ }
+ if (stillIndex == 5 || stillIndex == 6) {
+ Graphics::Surface result;
+ result.copyFrom(still);
+ if (drawTranslatedEnding(result, translation, stillIndex == 5 ? "endings.pgood." : "endings.pbad."))
+ still.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
+ result.free();
}
-
- drawTranslatedStillHeading(still, stillIndex, translation);
- if (stillIndex == 5 || stillIndex == 6)
- drawTranslatedEnding(still, translation, stillIndex == 5 ? "endings.pgood." : "endings.pbad.");
}
void applyTranslatedComputerButtons(Graphics::Surface &computer, const TextTranslationData &translation) {
@@ -393,9 +429,14 @@ bool applyTranslatedCinemaTitleButton(Graphics::Surface &buttons, const TextTran
#ifdef USE_FREETYPE2
if (translation.strings.getString("cinema_title_button.line1") &&
translation.strings.getString("cinema_title_button_pressed.line1")) {
- drawConfiguredHighQualityTextLines(buttons, translation, "cinema_title_button.", "LiberationSans-BoldItalic.ttf", 53, 55, 106, 142, 146, 232);
- drawConfiguredHighQualityTextLines(buttons, translation, "cinema_title_button_pressed.", "LiberationSans-BoldItalic.ttf", 136, 90, 155, 183, 169, 211);
- return true;
+ Graphics::Surface result;
+ result.copyFrom(buttons);
+ const bool ok = drawConfiguredHighQualityTextLines(result, translation, "cinema_title_button.", "LiberationSans-BoldItalic.ttf", 53, 55, 106, 142, 146, 232) &&
+ drawConfiguredHighQualityTextLines(result, translation, "cinema_title_button_pressed.", "LiberationSans-BoldItalic.ttf", 136, 90, 155, 183, 169, 211);
+ if (ok)
+ buttons.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
+ result.free();
+ return ok;
}
#endif
return false;
@@ -409,11 +450,13 @@ void applyTranslatedCinemaMenu(Graphics::Surface &menu, const TextTranslationDat
if (!patch || !translation.strings.getString("cinema_menu.buttons.line1") ||
!translation.strings.getString("cinema_menu.instruction.line1"))
return;
- if (!applyPatchImage(menu, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "applyTranslatedCinemaMenu"))
- return;
-
- drawConfiguredHighQualityTextLines(menu, translation, "cinema_menu.buttons.", "LiberationSans-BoldItalic.ttf", 32, 40, 48, 0, 0, 0);
- drawConfiguredHighQualityTextLines(menu, translation, "cinema_menu.instruction.", "LiberationSerif-Regular.ttf", 216, 176, 32, 0, 0, 0);
+ Graphics::Surface result;
+ result.copyFrom(menu);
+ if (applyPatchImage(result, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "applyTranslatedCinemaMenu") &&
+ drawConfiguredHighQualityTextLines(result, translation, "cinema_menu.buttons.", "LiberationSans-BoldItalic.ttf", 32, 40, 48, 0, 0, 0) &&
+ drawConfiguredHighQualityTextLines(result, translation, "cinema_menu.instruction.", "LiberationSerif-Regular.ttf", 216, 176, 32, 0, 0, 0))
+ menu.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
+ result.free();
#endif
}
@@ -421,9 +464,13 @@ void applyTranslatedTitleMenu(Graphics::Surface &title, const TextTranslationDat
if (!translation.packageArchive)
return;
- applyPatchImage(title, translation.packageArchive->createReadStreamForMember(Common::Path("patches/16mtitle_patch.png", '/')), "applyTranslatedTitleMenu");
- drawConfiguredHighQualityTextLines(title, translation, "title_menu.", "LiberationSans-BoldItalic.ttf", 53, 55, 106, 142, 146, 232);
- drawConfiguredHighQualityTextLines(title, translation, "title_menu_pressed.", "LiberationSans-BoldItalic.ttf", 136, 90, 155, 183, 169, 211);
+ Graphics::Surface result;
+ result.copyFrom(title);
+ if (applyPatchImage(result, translation.packageArchive->createReadStreamForMember(Common::Path("patches/16mtitle_patch.png", '/')), "applyTranslatedTitleMenu") &&
+ drawConfiguredHighQualityTextLines(result, translation, "title_menu.", "LiberationSans-BoldItalic.ttf", 53, 55, 106, 142, 146, 232) &&
+ drawConfiguredHighQualityTextLines(result, translation, "title_menu_pressed.", "LiberationSans-BoldItalic.ttf", 136, 90, 155, 183, 169, 211))
+ title.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
+ result.free();
}
} // End of namespace BCB
Commit: 6b0cb138aaa3cfbac73f8495ba06d8c90cbc6fb0
https://github.com/scummvm/scummvm/commit/6b0cb138aaa3cfbac73f8495ba06d8c90cbc6fb0
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T14:39:14+03:00
Commit Message:
HAROLD: Fix build with BCB subengine disabled
Changed paths:
engines/harold/metaengine.cpp
diff --git a/engines/harold/metaengine.cpp b/engines/harold/metaengine.cpp
index 4f3d5a4fa0f..453db83a0a9 100644
--- a/engines/harold/metaengine.cpp
+++ b/engines/harold/metaengine.cpp
@@ -41,7 +41,9 @@ public:
int getMaximumSaveSlot() const override { return 8; }
bool hasFeature(MetaEngineFeature f) const override;
+#ifdef ENABLE_BCB
GUI::OptionsContainerWidget *buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const override;
+#endif
Common::KeymapArray initKeymaps(const char *target) const override;
Common::Error createInstance(OSystem *syst, Engine **engine, const BCB::HaroldGameDescription *gd) const override;
};
@@ -50,11 +52,13 @@ bool HaroldMetaEngine::hasFeature(MetaEngineFeature f) const {
return checkExtendedSaves(f);
}
+#ifdef ENABLE_BCB
GUI::OptionsContainerWidget *HaroldMetaEngine::buildEngineOptionsWidget(GUI::GuiObject *boss, const Common::String &name, const Common::String &target) const {
if (!ConfMan.get("gameid", target).equalsIgnoreCase("bcb"))
return nullptr;
return BCB::createTranslationOptionsWidget(boss, name, target);
}
+#endif
Common::KeymapArray HaroldMetaEngine::initKeymaps(const char *target) const {
using namespace Common;
Commit: f7150da945d8c509398ead793d49ae4e1f27c149
https://github.com/scummvm/scummvm/commit/f7150da945d8c509398ead793d49ae4e1f27c149
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T18:10:33+03:00
Commit Message:
GUI: Expose game options label and spacing in themes
Changed paths:
gui/ThemeParser.cpp
gui/themes/common/highres_layout.stx
gui/themes/common/lowres_layout.stx
gui/themes/default.inc
gui/themes/residualvm.zip
gui/themes/scummclassic.zip
gui/themes/scummclassic/classic_layout.stx
gui/themes/scummclassic/classic_layout_lowres.stx
gui/themes/scummmodern.zip
gui/themes/scummremastered.zip
diff --git a/gui/ThemeParser.cpp b/gui/ThemeParser.cpp
index e0e8cdc7065..61da765460b 100644
--- a/gui/ThemeParser.cpp
+++ b/gui/ThemeParser.cpp
@@ -896,7 +896,9 @@ bool ThemeParser::parserCallback_layout(ParserNode *node) {
int spacing = -1;
if (node->values.contains("spacing")) {
- if (parseList(node->values["spacing"], 1, &spacing))
+ if (_theme->getEvaluator()->hasVar(node->values["spacing"]))
+ spacing = _theme->getEvaluator()->getVar(node->values["spacing"]);
+ else if (parseList(node->values["spacing"], 1, &spacing))
spacing = SCALEVALUE(spacing);
else
return false;
diff --git a/gui/themes/common/highres_layout.stx b/gui/themes/common/highres_layout.stx
index 7ad1ea5563e..276dd06303c 100644
--- a/gui/themes/common/highres_layout.stx
+++ b/gui/themes/common/highres_layout.stx
@@ -36,6 +36,7 @@
<def var = 'RichTextWidget.InnerMargin' value = '10' scalable = 'yes'/>
<def var = 'Layout.Spacing' value = '4' scalable = 'yes'/>
+ <def var = 'GameOptions.Spacing' value = '10' scalable = 'yes'/>
<def var = 'ListWidget.hlLeftPadding' value = '0'/>
<def var = 'ListWidget.hlRightPadding' value = '0'/>
@@ -93,6 +94,10 @@
size = '115, Globals.Line.Height'
textalign = 'end'
/>
+ <widget name = 'GameOptionsLabel'
+ size = 'Globals.OptionsLabel.Width, Globals.Line.Height'
+ textalign = 'end'
+ />
<widget name = 'ShortOptionsLabel'
size = '60, Globals.Line.Height'
/>
@@ -1814,17 +1819,17 @@
type = 'PopUp'
/>
</layout>
- <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = 'Globals.GameOptions.Spacing' align = 'center'>
<widget name = 'LangPopupDesc'
- type = 'OptionsLabel'
+ type = 'GameOptionsLabel'
/>
<widget name = 'LangPopup'
type = 'PopUp'
/>
</layout>
- <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = 'Globals.GameOptions.Spacing' align = 'center'>
<widget name = 'PlatformPopupDesc'
- type = 'OptionsLabel'
+ type = 'GameOptionsLabel'
/>
<widget name = 'PlatformPopup'
type = 'PopUp'
diff --git a/gui/themes/common/lowres_layout.stx b/gui/themes/common/lowres_layout.stx
index 3a711232390..9ef8047015e 100644
--- a/gui/themes/common/lowres_layout.stx
+++ b/gui/themes/common/lowres_layout.stx
@@ -31,6 +31,7 @@
<def var = 'RichTextWidget.InnerMargin' value = '10' scalable = 'yes'/>
<def var = 'Layout.Spacing' value = '4' scalable = 'yes'/>
+ <def var = 'GameOptions.Spacing' value = '6' scalable = 'yes'/>
<def var = 'ShowLauncherLogo' value = '0'/>
<def var = 'ShowGlobalMenuLogo' value = '0'/>
@@ -80,6 +81,10 @@
size = '100, Globals.Line.Height'
textalign = 'end'
/>
+ <widget name = 'GameOptionsLabel'
+ size = '60, Globals.Line.Height'
+ textalign = 'end'
+ />
<widget name = 'ShortOptionsLabel'
size = '50, Globals.Line.Height'
/>
@@ -1637,21 +1642,17 @@
/>
</layout>
<space size = '8'/>
- <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = 'Globals.GameOptions.Spacing' align = 'center'>
<widget name = 'LangPopupDesc'
- width = '60'
- height = 'Globals.Line.Height'
- textalign = 'end'
+ type = 'GameOptionsLabel'
/>
<widget name = 'LangPopup'
type = 'PopUp'
/>
</layout>
- <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = 'Globals.GameOptions.Spacing' align = 'center'>
<widget name = 'PlatformPopupDesc'
- width = '60'
- height = 'Globals.Line.Height'
- textalign = 'end'
+ type = 'GameOptionsLabel'
/>
<widget name = 'PlatformPopup'
type = 'PopUp'
diff --git a/gui/themes/default.inc b/gui/themes/default.inc
index 67c0d07d37d..563186f68c3 100644
--- a/gui/themes/default.inc
+++ b/gui/themes/default.inc
@@ -1448,6 +1448,7 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"<def var='TabWidget.TitleSpacing' value='10' scalable='yes'/>"
"<def var='RichTextWidget.InnerMargin' value='10' scalable='yes'/>"
"<def var='Layout.Spacing' value='8' scalable='yes'/>"
+"<def var='GameOptions.Spacing' value='10' scalable='yes'/>"
"<def var='GlkOptionsDialog.HeadingMinGap' value='2'/>"
"<def var='ShowLauncherLogo' value='0'/>"
"<def var='ShowGlobalMenuLogo' value='0'/>"
@@ -1477,6 +1478,10 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"size='120,Globals.Line.Height' "
"textalign='end' "
"/>"
+"<widget name='GameOptionsLabel' "
+"size='Globals.OptionsLabel.Width,Globals.Line.Height' "
+"textalign='end' "
+"/>"
"<widget name='ShortOptionsLabel' "
"size='60,Globals.Line.Height' "
"/>"
@@ -2782,17 +2787,17 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"type='PopUp' "
"/>"
"</layout>"
-"<layout type='horizontal' padding='0,0,0,0' spacing='10' align='center'>"
+"<layout type='horizontal' padding='0,0,0,0' spacing='Globals.GameOptions.Spacing' align='center'>"
"<widget name='LangPopupDesc' "
-"type='OptionsLabel' "
+"type='GameOptionsLabel' "
"/>"
"<widget name='LangPopup' "
"type='PopUp' "
"/>"
"</layout>"
-"<layout type='horizontal' padding='0,0,0,0' spacing='10' align='center'>"
+"<layout type='horizontal' padding='0,0,0,0' spacing='Globals.GameOptions.Spacing' align='center'>"
"<widget name='PlatformPopupDesc' "
-"type='OptionsLabel' "
+"type='GameOptionsLabel' "
"/>"
"<widget name='PlatformPopup' "
"type='PopUp' "
@@ -3942,6 +3947,7 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"<def var='TabWidget.TitleSpacing' value='10' scalable='yes'/>"
"<def var='RichTextWidget.InnerMargin' value='10' scalable='yes'/>"
"<def var='Layout.Spacing' value='8' scalable='yes'/>"
+"<def var='GameOptions.Spacing' value='6' scalable='yes'/>"
"<def var='GlkOptionsDialog.HeadingMinGap' value='2'/>"
"<def var='ShowLauncherLogo' value='0'/>"
"<def var='ShowGlobalMenuLogo' value='0'/>"
@@ -3971,6 +3977,10 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"size='120,Globals.Line.Height' "
"textalign='end' "
"/>"
+"<widget name='GameOptionsLabel' "
+"size='60,Globals.Line.Height' "
+"textalign='end' "
+"/>"
"<widget name='ShortOptionsLabel' "
"size='60,Globals.Line.Height' "
"/>"
@@ -5294,21 +5304,17 @@ const char *defaultXML1 = "<?xml version = '1.0'?>"
"/>"
"</layout>"
"<space size='8'/>"
-"<layout type='horizontal' padding='0,0,0,0' spacing='6' align='center'>"
+"<layout type='horizontal' padding='0,0,0,0' spacing='Globals.GameOptions.Spacing' align='center'>"
"<widget name='LangPopupDesc' "
-"width='60' "
-"height='Globals.Line.Height' "
-"textalign='end' "
+"type='GameOptionsLabel' "
"/>"
"<widget name='LangPopup' "
"type='PopUp' "
"/>"
"</layout>"
-"<layout type='horizontal' padding='0,0,0,0' spacing='6' align='center'>"
+"<layout type='horizontal' padding='0,0,0,0' spacing='Globals.GameOptions.Spacing' align='center'>"
"<widget name='PlatformPopupDesc' "
-"width='60' "
-"height='Globals.Line.Height' "
-"textalign='end' "
+"type='GameOptionsLabel' "
"/>"
"<widget name='PlatformPopup' "
"type='PopUp' "
diff --git a/gui/themes/residualvm.zip b/gui/themes/residualvm.zip
index 35542620d56..295f97dfec4 100644
Binary files a/gui/themes/residualvm.zip and b/gui/themes/residualvm.zip differ
diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip
index 11be309f413..462bde42b3c 100644
Binary files a/gui/themes/scummclassic.zip and b/gui/themes/scummclassic.zip differ
diff --git a/gui/themes/scummclassic/classic_layout.stx b/gui/themes/scummclassic/classic_layout.stx
index 83d1298b688..7a6d62a2b0d 100644
--- a/gui/themes/scummclassic/classic_layout.stx
+++ b/gui/themes/scummclassic/classic_layout.stx
@@ -31,6 +31,7 @@
<def var = 'RichTextWidget.InnerMargin' value = '10' scalable = 'yes'/>
<def var = 'Layout.Spacing' value = '8' scalable = 'yes'/>
+ <def var = 'GameOptions.Spacing' value = '10' scalable = 'yes'/>
<def var = 'GlkOptionsDialog.HeadingMinGap' value = '2'/>
@@ -72,6 +73,10 @@
size = '120, Globals.Line.Height'
textalign = 'end'
/>
+ <widget name = 'GameOptionsLabel'
+ size = 'Globals.OptionsLabel.Width, Globals.Line.Height'
+ textalign = 'end'
+ />
<widget name = 'ShortOptionsLabel'
size = '60, Globals.Line.Height'
/>
@@ -1449,17 +1454,17 @@
type = 'PopUp'
/>
</layout>
- <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = 'Globals.GameOptions.Spacing' align = 'center'>
<widget name = 'LangPopupDesc'
- type = 'OptionsLabel'
+ type = 'GameOptionsLabel'
/>
<widget name = 'LangPopup'
type = 'PopUp'
/>
</layout>
- <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '10' align = 'center'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = 'Globals.GameOptions.Spacing' align = 'center'>
<widget name = 'PlatformPopupDesc'
- type = 'OptionsLabel'
+ type = 'GameOptionsLabel'
/>
<widget name = 'PlatformPopup'
type = 'PopUp'
diff --git a/gui/themes/scummclassic/classic_layout_lowres.stx b/gui/themes/scummclassic/classic_layout_lowres.stx
index 04b5d2629ff..675b809b0f3 100644
--- a/gui/themes/scummclassic/classic_layout_lowres.stx
+++ b/gui/themes/scummclassic/classic_layout_lowres.stx
@@ -31,6 +31,7 @@
<def var = 'RichTextWidget.InnerMargin' value = '10' scalable = 'yes'/>
<def var = 'Layout.Spacing' value = '8' scalable = 'yes'/>
+ <def var = 'GameOptions.Spacing' value = '6' scalable = 'yes'/>
<def var = 'GlkOptionsDialog.HeadingMinGap' value = '2'/>
@@ -72,6 +73,10 @@
size = '120, Globals.Line.Height'
textalign = 'end'
/>
+ <widget name = 'GameOptionsLabel'
+ size = '60, Globals.Line.Height'
+ textalign = 'end'
+ />
<widget name = 'ShortOptionsLabel'
size = '60, Globals.Line.Height'
/>
@@ -1466,21 +1471,17 @@
/>
</layout>
<space size = '8'/>
- <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = 'Globals.GameOptions.Spacing' align = 'center'>
<widget name = 'LangPopupDesc'
- width = '60'
- height = 'Globals.Line.Height'
- textalign = 'end'
+ type = 'GameOptionsLabel'
/>
<widget name = 'LangPopup'
type = 'PopUp'
/>
</layout>
- <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = '6' align = 'center'>
+ <layout type = 'horizontal' padding = '0, 0, 0, 0' spacing = 'Globals.GameOptions.Spacing' align = 'center'>
<widget name = 'PlatformPopupDesc'
- width = '60'
- height = 'Globals.Line.Height'
- textalign = 'end'
+ type = 'GameOptionsLabel'
/>
<widget name = 'PlatformPopup'
type = 'PopUp'
diff --git a/gui/themes/scummmodern.zip b/gui/themes/scummmodern.zip
index 1c8796bc21a..418c3114da4 100644
Binary files a/gui/themes/scummmodern.zip and b/gui/themes/scummmodern.zip differ
diff --git a/gui/themes/scummremastered.zip b/gui/themes/scummremastered.zip
index 841720cb354..8bd47f4f0f0 100644
Binary files a/gui/themes/scummremastered.zip and b/gui/themes/scummremastered.zip differ
Commit: fc9495925a0484de9ebf28c34584294585ecdcd9
https://github.com/scummvm/scummvm/commit/fc9495925a0484de9ebf28c34584294585ecdcd9
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T18:10:33+03:00
Commit Message:
DEVTOOLS: Add Harold engine data resources
Changed paths:
A devtools/create_harold/README.md
A devtools/create_harold/files/bcb/cinema/cinema.yml
A devtools/create_harold/files/bcb/cinema/patches/pcinm_patch.png
A devtools/create_harold/files/bcb/cinema/pcinm.png
A devtools/create_harold/files/bcb/cinema/pcinm2.png
A devtools/create_harold/files/bcb/cinema/pcinm3.png
A devtools/create_harold/files/bcb/computer_cards/card_1_2.png
A devtools/create_harold/files/bcb/computer_cards/card_1_3.png
A devtools/create_harold/files/bcb/computer_cards/card_1_4.png
A devtools/create_harold/files/bcb/computer_cards/card_2_2.png
A devtools/create_harold/files/bcb/computer_cards/card_2_3.png
A devtools/create_harold/files/bcb/computer_cards/card_2_4.png
A devtools/create_harold/files/bcb/computer_cards/card_3_3.png
A devtools/create_harold/files/bcb/computer_cards/card_3_4.png
A devtools/create_harold/files/bcb/computer_cards/card_4_4.png
A devtools/create_harold/files/bcb/computer_cards/card_plain.png
A devtools/create_harold/files/bcb/computer_cards/id_required.png
A devtools/create_harold/files/bcb/computer_cards/text_1_3.png
A devtools/create_harold/files/bcb/computer_cards/text_2_3.png
A devtools/create_harold/files/bcb/computer_cards/text_3_3.png
A devtools/create_harold/files/bcb/patches/16mtitle_patch.png
A devtools/create_harold/files/bcb/patches/256com_clean.png
A devtools/create_harold/files/bcb/patches/ending_clean.png
A devtools/create_harold/files/bcb/patches/pcinm_patch.png
A devtools/create_harold/files/bcb/patches/pstill_1_patch.png
A devtools/create_harold/files/bcb/patches/pstill_2_patch.png
A devtools/create_harold/files/bcb/patches/pstill_3_patch.png
A devtools/create_harold/files/bcb/patches/pstill_4_patch.png
A devtools/create_harold/files/bcb/patches/pstill_5_patch.png
A devtools/create_harold/files/bcb/version.txt
A devtools/create_harold/module.mk
diff --git a/devtools/create_harold/README.md b/devtools/create_harold/README.md
new file mode 100644
index 00000000000..1b220a7924d
--- /dev/null
+++ b/devtools/create_harold/README.md
@@ -0,0 +1,8 @@
+# Harold engine data
+
+`files/bcb` contains shared Blue Chicago Blues assets, including Cinema Disk
+menu graphics, Japanese playlist names, and image patches used by translations.
+
+Run `make harold.dat` from the ScummVM root to rebuild
+`dists/engine-data/harold.dat`. In debug builds, set the game's Extra Path to
+`devtools/create_harold` to load these files directly.
diff --git a/devtools/create_harold/files/bcb/cinema/cinema.yml b/devtools/create_harold/files/bcb/cinema/cinema.yml
new file mode 100644
index 00000000000..65d3427752d
--- /dev/null
+++ b/devtools/create_harold/files/bcb/cinema/cinema.yml
@@ -0,0 +1,81 @@
+# Original Japanese Cinema playlist names, UTF-8. IDs 1-78 follow the native menu order.
+# Duplicate names are intentional. Translation packages use these same keys in
+# strings_<language>.yml; only names are translatable, not playlist contents or order.
+cinema.playlist.1: "å
¨ç·¨"
+cinema.playlist.2: "ãªã¼ããã³ã°"
+cinema.playlist.3: "ãããã¼ã°"
+cinema.playlist.4: "ï¼ç« ãç ããªã女"
+cinema.playlist.5: "ï¼ç« ã17æã®å¾®ç±"
+cinema.playlist.6: "ï¼ç« ãã¬ã©ã¹ã®éµ"
+cinema.playlist.7: "ï¼ç« ãæ®ºæã®é¸æ"
+cinema.playlist.8: "ã¨ã³ãã£ã³ã°"
+cinema.playlist.9: "[10æ¥ å¤ ]ï¾ï¾ï½°ï½±ï½¹ï¾ï½²ï¾ï½¥é£²ã¿ããã¹"
+cinema.playlist.10: "[10æ¥ å¤ ]ï¾ï¾ï¾ï½¼ï½¶ï½ºï¾"
+cinema.playlist.11: "[11æ¥ æ ]å¸è¦ï½¥ï¾ï½¯ï½¾ï¾"
+cinema.playlist.12: "[11æ¥åå]ï¾ï½°ï¾å®¶ï½¥ï½¼ï¾ï½ªï½°ï¾ï½½"
+cinema.playlist.13: "[11æ¥åå]ï¾ï½°ï¾å®¶ï½¥ï¾ï¾ï¾ï½°"
+cinema.playlist.14: "[11æ¥åå]ï¾ï½°ï¾å®¶ï½¥ï½±ï¾ï½¼ï¾ï½°ã®é¨å±"
+cinema.playlist.15: "[11æ¥åå]ï¾ï½²ï½½ï¾å®¶"
+cinema.playlist.16: "[11æ¥åå]ï¾ï¾ï¾ï¾ï¾ï¾ï½³ï¾"
+cinema.playlist.17: "[11æ¥åå]ï¾ï½²ï½½ï½¸ï½°ï¾ï½¥ï½¾ï½²ï¾ï½°"
+cinema.playlist.18: "[11æ¥åå]ï¾ï½¼ï½¶ï¾ï¾ï½¼ï¾ï½¬ï½°ï¾
ï¾"
+cinema.playlist.19: "[11æ¥åå¾]BRï½¶ï¾ï¾ï¾ï¾ï½°ï½¥ï¾ï½¯ï¾"
+cinema.playlist.20: "[11æ¥åå¾]BRï½¶ï¾ï¾ï¾ï¾ï½°ï½¥æç´¢"
+cinema.playlist.21: "[11æ¥åå¾]BRï½¶ï¾ï¾ï¾ï¾ï½°ï½¥ï½¼ï¾ï½ï¾ï½±"
+cinema.playlist.22: "[11æ¥åå¾]ï¾ï¾ï½ï½°ï¾ï½¨ï½³ï¾ï½«ï½°ï½¸ï¾ï½¥ï¾ï¾ï½²ï½¼ï¾"
+cinema.playlist.23: "[11æ¥åå¾]ï¾ï¾ï½²ï¾ï½¸ï¾ï¾ï½¯ï½¸"
+cinema.playlist.24: "[11æ¥åå¾]ï¾ï¾ï½²ï¾ï½¸ï¾ï¾ï½¯ï½¸"
+cinema.playlist.25: "[11æ¥å¤æ¹]å¸è¦ï½¥ï¾ï½¨ï¾ï¾"
+cinema.playlist.26: "[11æ¥å¤æ¹]å¸è¦ï½¥ï¾ï½¯ï½¾ï¾"
+cinema.playlist.27: "[11æ¥ å¤ ]ï½»ï¾ï¾ï½²ï¾ï½¥ï½¼ï¾ï½ï¾ï½±"
+cinema.playlist.28: "[11æ¥ å¤ ]ï¾ï¾ï½°ï½±ï½¹ï¾ï½²ï¾ï½¥ï½¼ï¾ï¾ï¾ï½¨"
+cinema.playlist.29: "[11æ¥ å¤ ]ï¾ï¾ï¾ï½¼ï½¶ï½ºï¾"
+cinema.playlist.30: "[12æ¥ æ ]å¸è¦ï½¥ï¾ï½¯ï½¾ï¾"
+cinema.playlist.31: "[12æ¥ æ ]å¸è¦ï½¥ï¾ï½ªï¾ï½¯ï½¸ï½½"
+cinema.playlist.32: "[12æ¥åå]ï¾ï½°ï¾å®¶ï½¥ï¾ï¾ï¾ï½°"
+cinema.playlist.33: "[12æ¥åå]BRï½¶ï¾ï¾ï¾ï¾ï½°ï½¥ï½´ï¾ï¾ï½±"
+cinema.playlist.34: "[12æ¥åå]オーï¾ï¾ï¾ï¾ï½±25"
+cinema.playlist.35: "[12æ¥åå]ï¾ï¾ï½ï½°ï¾ï½¨ï½³ï¾ï½«ï½°ï½¸ï¾ï½¥ï¾ï¾ï¾ï¾"
+cinema.playlist.36: "[12æ¥åå¾]アーï¾ï¾ï¾ï¾ï¾ï¾ï¾"
+cinema.playlist.37: "[12æ¥åå¾]ï½½ï¾ï¾ï½°ï¾ï¾ï¾ï¾ï½°ï¾ï½°"
+cinema.playlist.38: "[12æ¥åå¾]ï½»ï¾ï¾ï½²ï¾ï½¥ï½¼ï¾ï½®ï½°"
+cinema.playlist.39: "[12æ¥åå¾]ï¾ï½²ï½½ï½¸ï½°ï¾ï½¥ï¾ï¾ï¾ï½°ï½½"
+cinema.playlist.40: "[12æ¥åå¾]ï¾ï¾ï¾ï½¯ï¾ï¾ï½¨ï¾ï¾ï½°"
+cinema.playlist.41: "[12æ¥å¤æ¹]å¸è¦"
+cinema.playlist.42: "[12æ¥ å¤ ]ï¾ï¾ï½²ï¾ï½¸ï¾ï¾ï½¯ï½¸"
+cinema.playlist.43: "[12æ¥ å¤ ]ï¾ï¾ï½°ï½±ï½¹ï¾ï½²ï¾ï½¥ï¾ï½ªï¾ï½¯ï½¸ï½½"
+cinema.playlist.44: "[12æ¥ å¤ ]ï¾ï¾ï¾ï½¼ï½¶ï½ºï¾"
+cinema.playlist.45: "[12æ¥ å¤ ]ï¾ï¾ï¾ï½¼ï½¶ï½ºï¾ï½¥ï½¼ï¾ï½ï¾ï½±"
+cinema.playlist.46: "[13æ¥ æ ]ï¾ï¾ï¾ï½¼ï½¶ï½ºï¾"
+cinema.playlist.47: "[13æ¥ æ ]å¸è¦ï½¥ï¾ï½¯ï½¾ï¾"
+cinema.playlist.48: "[13æ¥åå]オスï¾ï¾ï¾ï½°ï¾ã®ï½±ï¾ï¾ï½°ï¾"
+cinema.playlist.49: "[13æ¥åå]ï½¾ï¾ï¾ï¾ï¾ç
é¢"
+cinema.playlist.50: "[13æ¥åå]ï¾ï¾ï½²ï¾ï½¸ï¾ï¾ï½¯ï½¸"
+cinema.playlist.51: "[13æ¥åå]ï¾ï¾ï½²ï¾ï½¸ï¾ï¾ï½¯ï½¸ï½¥æç´¢"
+cinema.playlist.52: "[13æ¥åå]ï¾ï½°ï¾å®¶ï½¥ï½¼ï¾ï½ªï½°ï¾ï½½"
+cinema.playlist.53: "[13æ¥åå]ï¾ï½²ï½½ï¾å®¶"
+cinema.playlist.54: "[13æ¥åå¾]ï¾ï¾ï¾ï½¯ï¾ï¾ï½¨ï¾ï¾ï½°"
+cinema.playlist.55: "[13æ¥åå¾]ï¾ï¾ï½ï½°ï¾ï½¨ï½³ï¾ï½«ï½°ï½¸ï¾ï½¥ï¾ï¾ï½²ï½¼ï¾"
+cinema.playlist.56: "[13æ¥åå¾]BRï½¶ï¾ï¾ï¾ï¾ï½°ï½¥ï¾ï½¯ï¾"
+cinema.playlist.57: "[13æ¥å¤æ¹]å¸è¦ï½¥ï½¼ï¾ï¾ï¾ï½¨"
+cinema.playlist.58: "[13æ¥ å¤ ]ï½»ï¾ï¾ï½²ï¾ï½¥ï½¼ï¾ï½ï¾ï½±"
+cinema.playlist.59: "[13æ¥ å¤ ]ï½»ï¾ï¾ï½²ï¾ï½¥æç´¢"
+cinema.playlist.60: "[13æ¥ å¤ ]ï½»ï¾ï¾ï½²ï¾ï½¥ï½¼ï¾ï½ï¾ï½±"
+cinema.playlist.61: "[13æ¥ å¤ ]ï¾ï¾ï½°ï½±ï½¹ï¾ï½²ï¾ï½¥ï¾ï½¯ï½¾ï¾"
+cinema.playlist.62: "[13æ¥ å¤ ]ï¾ï¾ï¾ï½¼ï½¶ï½ºï¾"
+cinema.playlist.63: "[14æ¥ æ ]å¸è¦ï½¥ï¾ï½ªï¾ï½¯ï½¸ï½½"
+cinema.playlist.64: "[14æ¥åå]åã調ã¹ï½¥ï½¼ï¾ï½ªï½°ï¾ï½½"
+cinema.playlist.65: "[14æ¥åå]åäºé¨å±ï½¥ï¾ï¾ï¾ï½°"
+cinema.playlist.66: "[14æ¥åå]åã調ã¹ï½¥ï¾ï½¯ï¾"
+cinema.playlist.67: "[14æ¥åå]åã調ã¹ï½¥ï½¼ï¾ï½ï¾ï½±"
+cinema.playlist.68: "[14æ¥åå]åã調ã¹ï½¥ï½¼ï¾ï¾ï¾ï½¨"
+cinema.playlist.69: "[14æ¥åå]åäºé¨å±ï½¥ï¾ï½¨ï¾ï¾"
+cinema.playlist.70: "[14æ¥åå¾]åã調ã¹ï½¥ï½¼ï¾ï½ï¾ï½±"
+cinema.playlist.71: "[14æ¥åå¾]åã調ã¹ï½¥ï½¼ï¾ï½ªï½°ï¾ï½½"
+cinema.playlist.72: "[14æ¥åå¾]åã調ã¹ï½¥ï¾ï½¯ï¾"
+cinema.playlist.73: "[14æ¥åå¾]åã調ã¹ï½¥ï½¼ï¾ï¾ï¾ï½¨"
+cinema.playlist.74: "[14æ¥åå¾]ï½¼ï¾ï½ï¾ï½±ã®åç½"
+cinema.playlist.75: "[14æ¥åå¾]ï½¼ï¾ï½ªï½°ï¾ï½½ã®åç½"
+cinema.playlist.76: "[14æ¥åå¾]ï¾ï½¯ï¾ã®åç½"
+cinema.playlist.77: "[14æ¥ å¤ ]ï½¼ï¾ï¾ï¾ï½¨ã®åæ³"
+cinema.playlist.78: "[14æ¥ å¤ ]ï½¼ï¾ï¾ï¾ï½¨ã®åç½"
diff --git a/devtools/create_harold/files/bcb/cinema/patches/pcinm_patch.png b/devtools/create_harold/files/bcb/cinema/patches/pcinm_patch.png
new file mode 100644
index 00000000000..299cbec04b8
Binary files /dev/null and b/devtools/create_harold/files/bcb/cinema/patches/pcinm_patch.png differ
diff --git a/devtools/create_harold/files/bcb/cinema/pcinm.png b/devtools/create_harold/files/bcb/cinema/pcinm.png
new file mode 100644
index 00000000000..7b3ab3afc90
Binary files /dev/null and b/devtools/create_harold/files/bcb/cinema/pcinm.png differ
diff --git a/devtools/create_harold/files/bcb/cinema/pcinm2.png b/devtools/create_harold/files/bcb/cinema/pcinm2.png
new file mode 100644
index 00000000000..49c13e6d1a0
Binary files /dev/null and b/devtools/create_harold/files/bcb/cinema/pcinm2.png differ
diff --git a/devtools/create_harold/files/bcb/cinema/pcinm3.png b/devtools/create_harold/files/bcb/cinema/pcinm3.png
new file mode 100644
index 00000000000..237a91fdbcc
Binary files /dev/null and b/devtools/create_harold/files/bcb/cinema/pcinm3.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_1_2.png b/devtools/create_harold/files/bcb/computer_cards/card_1_2.png
new file mode 100644
index 00000000000..66a9ebcde50
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_1_2.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_1_3.png b/devtools/create_harold/files/bcb/computer_cards/card_1_3.png
new file mode 100644
index 00000000000..2f5a231c514
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_1_3.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_1_4.png b/devtools/create_harold/files/bcb/computer_cards/card_1_4.png
new file mode 100644
index 00000000000..159574ec05b
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_1_4.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_2_2.png b/devtools/create_harold/files/bcb/computer_cards/card_2_2.png
new file mode 100644
index 00000000000..95f0bba33b9
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_2_2.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_2_3.png b/devtools/create_harold/files/bcb/computer_cards/card_2_3.png
new file mode 100644
index 00000000000..aa343d0ea06
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_2_3.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_2_4.png b/devtools/create_harold/files/bcb/computer_cards/card_2_4.png
new file mode 100644
index 00000000000..075fbf95a9a
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_2_4.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_3_3.png b/devtools/create_harold/files/bcb/computer_cards/card_3_3.png
new file mode 100644
index 00000000000..088f1c71603
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_3_3.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_3_4.png b/devtools/create_harold/files/bcb/computer_cards/card_3_4.png
new file mode 100644
index 00000000000..db5e5203d90
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_3_4.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_4_4.png b/devtools/create_harold/files/bcb/computer_cards/card_4_4.png
new file mode 100644
index 00000000000..2e263b7233c
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_4_4.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/card_plain.png b/devtools/create_harold/files/bcb/computer_cards/card_plain.png
new file mode 100644
index 00000000000..70ff7cf5a0a
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/card_plain.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/id_required.png b/devtools/create_harold/files/bcb/computer_cards/id_required.png
new file mode 100644
index 00000000000..8b3baa51671
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/id_required.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/text_1_3.png b/devtools/create_harold/files/bcb/computer_cards/text_1_3.png
new file mode 100644
index 00000000000..a006c8e60f5
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/text_1_3.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/text_2_3.png b/devtools/create_harold/files/bcb/computer_cards/text_2_3.png
new file mode 100644
index 00000000000..9bc4bfefbb7
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/text_2_3.png differ
diff --git a/devtools/create_harold/files/bcb/computer_cards/text_3_3.png b/devtools/create_harold/files/bcb/computer_cards/text_3_3.png
new file mode 100644
index 00000000000..d9ddc72c122
Binary files /dev/null and b/devtools/create_harold/files/bcb/computer_cards/text_3_3.png differ
diff --git a/devtools/create_harold/files/bcb/patches/16mtitle_patch.png b/devtools/create_harold/files/bcb/patches/16mtitle_patch.png
new file mode 100644
index 00000000000..6ecc66f3abb
Binary files /dev/null and b/devtools/create_harold/files/bcb/patches/16mtitle_patch.png differ
diff --git a/devtools/create_harold/files/bcb/patches/256com_clean.png b/devtools/create_harold/files/bcb/patches/256com_clean.png
new file mode 100644
index 00000000000..8052616653f
Binary files /dev/null and b/devtools/create_harold/files/bcb/patches/256com_clean.png differ
diff --git a/devtools/create_harold/files/bcb/patches/ending_clean.png b/devtools/create_harold/files/bcb/patches/ending_clean.png
new file mode 100644
index 00000000000..1ef0c714e87
Binary files /dev/null and b/devtools/create_harold/files/bcb/patches/ending_clean.png differ
diff --git a/devtools/create_harold/files/bcb/patches/pcinm_patch.png b/devtools/create_harold/files/bcb/patches/pcinm_patch.png
new file mode 100644
index 00000000000..595b4e9efd8
Binary files /dev/null and b/devtools/create_harold/files/bcb/patches/pcinm_patch.png differ
diff --git a/devtools/create_harold/files/bcb/patches/pstill_1_patch.png b/devtools/create_harold/files/bcb/patches/pstill_1_patch.png
new file mode 100644
index 00000000000..664f4156989
Binary files /dev/null and b/devtools/create_harold/files/bcb/patches/pstill_1_patch.png differ
diff --git a/devtools/create_harold/files/bcb/patches/pstill_2_patch.png b/devtools/create_harold/files/bcb/patches/pstill_2_patch.png
new file mode 100644
index 00000000000..65f583aa12e
Binary files /dev/null and b/devtools/create_harold/files/bcb/patches/pstill_2_patch.png differ
diff --git a/devtools/create_harold/files/bcb/patches/pstill_3_patch.png b/devtools/create_harold/files/bcb/patches/pstill_3_patch.png
new file mode 100644
index 00000000000..b6d9184939c
Binary files /dev/null and b/devtools/create_harold/files/bcb/patches/pstill_3_patch.png differ
diff --git a/devtools/create_harold/files/bcb/patches/pstill_4_patch.png b/devtools/create_harold/files/bcb/patches/pstill_4_patch.png
new file mode 100644
index 00000000000..ed1df0e7f4a
Binary files /dev/null and b/devtools/create_harold/files/bcb/patches/pstill_4_patch.png differ
diff --git a/devtools/create_harold/files/bcb/patches/pstill_5_patch.png b/devtools/create_harold/files/bcb/patches/pstill_5_patch.png
new file mode 100644
index 00000000000..40a15883c33
Binary files /dev/null and b/devtools/create_harold/files/bcb/patches/pstill_5_patch.png differ
diff --git a/devtools/create_harold/files/bcb/version.txt b/devtools/create_harold/files/bcb/version.txt
new file mode 100644
index 00000000000..d3827e75a5c
--- /dev/null
+++ b/devtools/create_harold/files/bcb/version.txt
@@ -0,0 +1 @@
+1.0
diff --git a/devtools/create_harold/module.mk b/devtools/create_harold/module.mk
new file mode 100644
index 00000000000..af678fc9caa
--- /dev/null
+++ b/devtools/create_harold/module.mk
@@ -0,0 +1,4 @@
+harold.dat:
+ cd $(srcdir)/devtools/create_harold/files && zip -FS -r9 $(abspath $(srcdir)/dists/engine-data/harold.dat) .
+
+.PHONY: harold.dat
Commit: 6ad5245fe49418f732c405843f1fc5ed0989f802
https://github.com/scummvm/scummvm/commit/6ad5245fe49418f732c405843f1fc5ed0989f802
Author: Scorp (scorp at mrs.mn)
Date: 2026-11-19T18:10:33+03:00
Commit Message:
HAROLD: BCB: Load shared engine data
Changed paths:
engines/harold/bcb/bcb.cpp
engines/harold/bcb/bcb.h
engines/harold/bcb/cinema.cpp
engines/harold/bcb/cinema.h
engines/harold/bcb/cinema_data.cpp
engines/harold/bcb/cinema_tables.cpp
engines/harold/bcb/options.cpp
engines/harold/bcb/resources.cpp
engines/harold/bcb/screens.cpp
engines/harold/bcb/translation_images.cpp
engines/harold/configure.engine
diff --git a/engines/harold/bcb/bcb.cpp b/engines/harold/bcb/bcb.cpp
index 44963ce81a3..c9f92972f11 100644
--- a/engines/harold/bcb/bcb.cpp
+++ b/engines/harold/bcb/bcb.cpp
@@ -21,6 +21,7 @@
#include "harold/bcb/bcb.h"
#include "common/config-manager.h"
+#include "common/engine_data.h"
#include "common/system.h"
#include "common/textconsole.h"
#include "engines/util.h"
@@ -88,6 +89,8 @@ BCBEngine::BCBEngine(OSystem *syst, const HaroldGameDescription *desc)
BCBEngine::~BCBEngine() {
delete _cinemaMenu;
+ if (_engineDataAvailable)
+ SearchMan.remove("data");
delete _screen;
if (_uiBitmap) {
_uiBitmap->free();
@@ -129,6 +132,11 @@ Common::Error BCBEngine::run() {
if (!initializeSearchPaths())
return Common::kPathDoesNotExist;
+ Common::U32String engineDataError;
+ _engineDataAvailable = Common::load_engine_data("harold.dat", "bcb", 1, 0, engineDataError, true);
+ if (!_engineDataAvailable)
+ warning("BCB: Engine data unavailable: %s", engineDataError.encode().c_str());
+
const Common::String languageCode = ConfMan.get("bcb_text_language");
_selectedTextLanguagePackageAvailable = !languageCode.empty() &&
loadTranslationPackage(Common::FSNode(ConfMan.getPath("path")), languageCode, _textTranslation);
diff --git a/engines/harold/bcb/bcb.h b/engines/harold/bcb/bcb.h
index 84f2bd1ef8f..a0e7879980a 100644
--- a/engines/harold/bcb/bcb.h
+++ b/engines/harold/bcb/bcb.h
@@ -278,6 +278,7 @@ private:
Graphics::Surface *_titleBitmap = nullptr;
CinemaViewer *_cinemaViewer = nullptr;
CinemaViewer *_cinemaMenu = nullptr;
+ bool _engineDataAvailable = false;
bool _cinemaAvailable = false;
Graphics::Surface *_uiBitmap = nullptr;
Common::String _uiBitmapName;
diff --git a/engines/harold/bcb/cinema.cpp b/engines/harold/bcb/cinema.cpp
index 4c439689c0b..15899fddbb7 100644
--- a/engines/harold/bcb/cinema.cpp
+++ b/engines/harold/bcb/cinema.cpp
@@ -86,7 +86,7 @@ void CinemaViewer::pressTitleButton(BCBEngine &engine) {
void BCBEngine::runCinemaViewer() {
if (!_cinemaMenu) {
- warning("BCB: Unable to load bcb-cinema.dat");
+ warning("BCB: Unable to load Cinema resources");
restoreTitleScreenRegion(CinemaViewer::titleButtonRect());
return;
}
diff --git a/engines/harold/bcb/cinema.h b/engines/harold/bcb/cinema.h
index 932903232c0..b24964edad0 100644
--- a/engines/harold/bcb/cinema.h
+++ b/engines/harold/bcb/cinema.h
@@ -30,10 +30,6 @@
#include "graphics/managed_surface.h"
#include "harold/bcb/cinema_tables.h"
-namespace Common {
-class Archive;
-class SeekableReadStream;
-}
namespace Graphics {
class Font;
class Screen;
@@ -53,7 +49,6 @@ public:
bool load();
void run();
void pause(bool paused);
- static Common::SeekableReadStream *openPackage(BCBEngine &engine);
static Common::Rect titleButtonRect();
static void drawTitleButton(BCBEngine &engine, Graphics::Surface &surface);
static void pressTitleButton(BCBEngine &engine);
@@ -105,7 +100,6 @@ private:
Common::U32String translate(const Common::String &key, const Common::U32String &original) const;
BCBEngine &_engine;
- Common::ScopedPtr<Common::Archive> _archive;
Graphics::ManagedSurface _sheets[3];
Graphics::ManagedSurface _background;
Canvas _canvas;
diff --git a/engines/harold/bcb/cinema_data.cpp b/engines/harold/bcb/cinema_data.cpp
index 3c064cef1e8..0f2b21cce47 100644
--- a/engines/harold/bcb/cinema_data.cpp
+++ b/engines/harold/bcb/cinema_data.cpp
@@ -19,7 +19,6 @@
*/
#include "common/archive.h"
-#include "common/compression/unzip.h"
#include "common/memstream.h"
#include "common/str-enc.h"
#include "common/system.h"
@@ -32,14 +31,9 @@
namespace BCB {
-Common::SeekableReadStream *CinemaViewer::openPackage(BCBEngine &engine) {
- Common::SeekableReadStream *stream = engine.createProgramReadStream("bcb-cinema.dat");
- return stream ? stream : SearchMan.createReadStreamForMember("bcb-cinema.dat");
-}
-
bool CinemaViewer::loadLabels() {
TextStringTable labels;
- if (!labels.load(_archive->createReadStreamForMember("cinema.yml")))
+ if (!labels.load(SearchMan.createReadStreamForMember("data/cinema/cinema.yml")))
return false;
for (uint i = 0; i < ARRAYSIZE(kCinemaPlaylists); ++i) {
const Common::String key = Common::String::format("cinema.playlist.%u", i + 1);
@@ -65,13 +59,13 @@ bool CinemaViewer::loadPicture(uint index, Graphics::ManagedSurface &surface) {
}
const char *path = kCinemaPicturePaths[index];
Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> picture(
- _engine.loadImageFromStream(_archive->createReadStreamForMember(Common::Path(path)), path));
+ _engine.loadImageFromStream(SearchMan.createReadStreamForMember(Common::Path(path, '/')), path));
if (!picture) {
warning("BCB Cinema: Missing picture %s", path);
return false;
}
if (index == 0) {
- if (!applyPatchImage(*picture, _archive->createReadStreamForMember("patches/pcinm_patch.png"), "BCB Cinema")) {
+ if (!applyPatchImage(*picture, SearchMan.createReadStreamForMember("data/cinema/patches/pcinm_patch.png"), "BCB Cinema")) {
warning("BCB Cinema: Missing or invalid menu patch");
return false;
}
@@ -82,11 +76,7 @@ bool CinemaViewer::loadPicture(uint index, Graphics::ManagedSurface &surface) {
}
bool CinemaViewer::load() {
- Common::SeekableReadStream *stream = openPackage(_engine);
- if (!stream)
- return false;
- _archive.reset(Common::makeZipArchive(stream));
- if (!_archive)
+ if (!_engine._engineDataAvailable)
return false;
if (!loadLabels()) {
warning("BCB Cinema: Missing or invalid cinema.yml");
diff --git a/engines/harold/bcb/cinema_tables.cpp b/engines/harold/bcb/cinema_tables.cpp
index e4d6c1c2922..bef8677f819 100644
--- a/engines/harold/bcb/cinema_tables.cpp
+++ b/engines/harold/bcb/cinema_tables.cpp
@@ -23,9 +23,9 @@
namespace BCB {
const char *const kCinemaPicturePaths[3] = {
- "Cinepict/PCINM.PIC",
- "Cinepict/PCINM2.pic",
- "Cinepict/PCINM3.PIC"
+ "data/cinema/pcinm.png",
+ "data/cinema/pcinm2.png",
+ "data/cinema/pcinm3.png"
};
const CinemaButton kCinemaButtons[26] = {
diff --git a/engines/harold/bcb/options.cpp b/engines/harold/bcb/options.cpp
index f712d67b71b..b2ac17a847e 100644
--- a/engines/harold/bcb/options.cpp
+++ b/engines/harold/bcb/options.cpp
@@ -107,11 +107,10 @@ bool BCBOptionsWidget::save() {
void BCBOptionsWidget::defineLayout(GUI::ThemeEval &layouts, const Common::String &layoutName, const Common::String &overlayedLayout) const {
layouts.addDialog(layoutName, overlayedLayout);
const bool lowResGui = g_gui.useLowResGUI();
- const int labelWidth = lowResGui ? 125 : 115;
- const int leftInset = 1;
+ const int labelWidth = layouts.getVar("Globals.GameOptionsLabel.Width", layouts.getVar("Globals.OptionsLabel.Width"));
const int rowSpacing = lowResGui ? 6 : 10;
const int lineHeight = layouts.getVar("Globals.Line.Height");
- layouts.addLayout(GUI::ThemeLayout::kLayoutVertical).addPadding(leftInset, 0, 0, 0);
+ layouts.addLayout(GUI::ThemeLayout::kLayoutVertical).addPadding(0, 0, 0, 0);
layouts.addLayout(GUI::ThemeLayout::kLayoutHorizontal, rowSpacing, GUI::ThemeLayout::kItemAlignCenter).addPadding(0, 0, 0, 0);
layouts.addWidget("text_language_desc", "", labelWidth, lineHeight, Graphics::kTextAlignEnd);
layouts.addWidget("text_language", "PopUp").closeLayout();
diff --git a/engines/harold/bcb/resources.cpp b/engines/harold/bcb/resources.cpp
index 27e27df0636..767d8904413 100644
--- a/engines/harold/bcb/resources.cpp
+++ b/engines/harold/bcb/resources.cpp
@@ -30,6 +30,7 @@
#include "harold/bcb/static_data.h"
#include "image/bmp.h"
#include "image/pict.h"
+#include "image/png.h"
namespace BCB {
@@ -108,7 +109,9 @@ Graphics::Surface *BCBEngine::loadImageFromStream(Common::SeekableReadStream *st
Common::String name(fileName);
name.toLowercase();
Common::ScopedPtr<Image::ImageDecoder> decoder;
- if (name.hasSuffix(".pic") || name.hasSuffix(".pict"))
+ if (name.hasSuffix(".png"))
+ decoder.reset(new Image::PNGDecoder());
+ else if (name.hasSuffix(".pic") || name.hasSuffix(".pict"))
decoder.reset(new Image::PICTDecoder());
else
decoder.reset(new Image::BitmapDecoder());
diff --git a/engines/harold/bcb/screens.cpp b/engines/harold/bcb/screens.cpp
index 838ee442c31..a584584017f 100644
--- a/engines/harold/bcb/screens.cpp
+++ b/engines/harold/bcb/screens.cpp
@@ -63,7 +63,7 @@ bool BCBEngine::showTitleScreen() {
const Common::String &target = ConfMan.getActiveDomainName();
const bool completed = ConfMan.hasKey("bcb_completed", target) && ConfMan.getBool("bcb_completed", target);
- if (completed && !_cinemaMenu) {
+ if (completed && _engineDataAvailable && !_cinemaMenu) {
_cinemaMenu = new CinemaViewer(*this);
if (!_cinemaMenu->load()) {
delete _cinemaMenu;
diff --git a/engines/harold/bcb/translation_images.cpp b/engines/harold/bcb/translation_images.cpp
index fdaed461211..ced02488ece 100644
--- a/engines/harold/bcb/translation_images.cpp
+++ b/engines/harold/bcb/translation_images.cpp
@@ -32,6 +32,10 @@
namespace BCB {
namespace {
+Common::SeekableReadStream *openTranslationPatch(const Common::String &path) {
+ return SearchMan.createReadStreamForMember(Common::Path("data/" + path, '/'));
+}
+
bool parseTranslationInt(const char *text, int &value) {
if (!text || !text[0])
return false;
@@ -216,7 +220,7 @@ bool drawTranslatedEnding(Graphics::Surface &surface, const TextTranslationData
HighQualityTextRenderer *renderer = font ? translation.getImageFont(font) : nullptr;
if (!translation.packageArchive || !patch || !renderer || !renderer->isValid() || !strings.getString(prefix + "line1"))
return false;
- if (!applyPatchImage(surface, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "drawTranslatedEnding"))
+ if (!applyPatchImage(surface, openTranslationPatch(patch), "drawTranslatedEnding"))
return false;
const int scale = 4;
@@ -361,7 +365,7 @@ void applyTranslatedComputerCard(Graphics::Surface &card, const char *path, cons
return;
Graphics::Surface result;
result.copyFrom(card);
- if (applyPatchImage(result, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "applyTranslatedComputerCard") &&
+ if (applyPatchImage(result, openTranslationPatch(patch), "applyTranslatedComputerCard") &&
drawConfiguredHighQualityTextLines(result, translation, prefix, "LiberationSans-Regular.ttf", 218, 218, 236, 0, 0, 0, true))
card.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
result.free();
@@ -372,7 +376,7 @@ void applyTranslatedStillImage(Graphics::Surface &still, int stillIndex, const T
if (translation.packageArchive && stillIndex >= 0 && stillIndex < 5) {
Graphics::Surface result;
result.copyFrom(still);
- if (applyPatchImage(result, translation.packageArchive->createReadStreamForMember(Common::Path(Common::String::format("patches/pstill_%d_patch.png", stillIndex + 1), '/')), "applyTranslatedStillImage") &&
+ if (applyPatchImage(result, openTranslationPatch(Common::String::format("patches/pstill_%d_patch.png", stillIndex + 1)), "applyTranslatedStillImage") &&
drawTranslatedStillHeading(result, stillIndex, translation))
still.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
result.free();
@@ -452,7 +456,7 @@ void applyTranslatedCinemaMenu(Graphics::Surface &menu, const TextTranslationDat
return;
Graphics::Surface result;
result.copyFrom(menu);
- if (applyPatchImage(result, translation.packageArchive->createReadStreamForMember(Common::Path(patch, '/')), "applyTranslatedCinemaMenu") &&
+ if (applyPatchImage(result, openTranslationPatch(patch), "applyTranslatedCinemaMenu") &&
drawConfiguredHighQualityTextLines(result, translation, "cinema_menu.buttons.", "LiberationSans-BoldItalic.ttf", 32, 40, 48, 0, 0, 0) &&
drawConfiguredHighQualityTextLines(result, translation, "cinema_menu.instruction.", "LiberationSerif-Regular.ttf", 216, 176, 32, 0, 0, 0))
menu.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
@@ -466,7 +470,7 @@ void applyTranslatedTitleMenu(Graphics::Surface &title, const TextTranslationDat
Graphics::Surface result;
result.copyFrom(title);
- if (applyPatchImage(result, translation.packageArchive->createReadStreamForMember(Common::Path("patches/16mtitle_patch.png", '/')), "applyTranslatedTitleMenu") &&
+ if (applyPatchImage(result, openTranslationPatch("patches/16mtitle_patch.png"), "applyTranslatedTitleMenu") &&
drawConfiguredHighQualityTextLines(result, translation, "title_menu.", "LiberationSans-BoldItalic.ttf", 53, 55, 106, 142, 146, 232) &&
drawConfiguredHighQualityTextLines(result, translation, "title_menu_pressed.", "LiberationSans-BoldItalic.ttf", 136, 90, 155, 183, 169, 211))
title.copyRectToSurface(result, 0, 0, Common::Rect(result.w, result.h));
diff --git a/engines/harold/configure.engine b/engines/harold/configure.engine
index bac5e97c2b5..6cd5f5f4961 100644
--- a/engines/harold/configure.engine
+++ b/engines/harold/configure.engine
@@ -1,4 +1,4 @@
# This file is included from the main "configure" script
# add_engine [name] [desc] [build-by-default] [subengines] [base games] [deps] [components]
add_engine harold "J.B. Harold series" no "bcb"
-add_engine bcb "J.B. Harold: Blue Chicago Blues" no "" "" "highres 16bit sjis" "msmpeg4"
+add_engine bcb "J.B. Harold: Blue Chicago Blues" no "" "" "highres 16bit sjis png" "msmpeg4"
More information about the Scummvm-git-logs
mailing list