[Scummvm-git-logs] scummvm master -> f01eb895fa6b060ab2350c6ecfe46844ff7e7879
elasota
noreply at scummvm.org
Thu Apr 13 03:06:26 UTC 2023
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
fd1e0b954f VCRUISE: Fix language options, split English into GB/US for Schizm.
f01eb895fa VCRUISE: Add subtitle loader
Commit: fd1e0b954f0bc67add99942932df08dec3368e03
https://github.com/scummvm/scummvm/commit/fd1e0b954f0bc67add99942932df08dec3368e03
Author: elasota (ejlasota at gmail.com)
Date: 2023-04-12T22:19:44-04:00
Commit Message:
VCRUISE: Fix language options, split English into GB/US for Schizm.
Changed paths:
engines/vcruise/detection.cpp
engines/vcruise/detection_tables.h
diff --git a/engines/vcruise/detection.cpp b/engines/vcruise/detection.cpp
index 0c0a7fae4ba..096e9010f2e 100644
--- a/engines/vcruise/detection.cpp
+++ b/engines/vcruise/detection.cpp
@@ -63,6 +63,7 @@ public:
VCruise::VCruiseGameID gameID = reinterpret_cast<const VCruise::VCruiseGameDescription *>(adGame.desc)->gameID;
if (gameID == VCruise::GID_REAH) {
+ game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::EN_ANY));
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::NL_NLD));
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::FR_FRA));
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::IT_ITA));
@@ -70,6 +71,8 @@ public:
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::PL_POL));
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::ES_ESP));
} else if (gameID == VCruise::GID_SCHIZM) {
+ game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::EN_USA));
+ game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::EN_GRB));
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::NL_NLD));
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::FR_FRA));
game.appendGUIOptions(Common::getGameGUIOptionsDescriptionLanguage(Common::IT_ITA));
diff --git a/engines/vcruise/detection_tables.h b/engines/vcruise/detection_tables.h
index 6e1007b6d37..a6896c34f51 100644
--- a/engines/vcruise/detection_tables.h
+++ b/engines/vcruise/detection_tables.h
@@ -35,7 +35,7 @@ static const VCruiseGameDescription gameDescriptions[] = {
"reah",
"DVD",
AD_ENTRY1s("Reah.exe", "60ec19c53f1323cc7f0314f98d396283", 304128),
- Common::EN_ANY,
+ Common::UNK_LANG,
Common::kPlatformWindows,
ADGF_UNSTABLE | VCRUISE_GF_WANT_MP3,
GUIO0()
@@ -47,7 +47,7 @@ static const VCruiseGameDescription gameDescriptions[] = {
"reah",
"CD",
AD_ENTRY1s("Reah.exe", "77bc7f7819cdd443f52b193529138c87", 305664),
- Common::EN_ANY,
+ Common::UNK_LANG,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO0()
@@ -59,7 +59,7 @@ static const VCruiseGameDescription gameDescriptions[] = {
"schizm",
"CD",
AD_ENTRY1s("Schizm.exe", "296edd26d951c3bdc4d303c4c88b27cd", 364544),
- Common::EN_ANY,
+ Common::UNK_LANG,
Common::kPlatformWindows,
ADGF_UNSTABLE | VCRUISE_GF_WANT_OGG_VORBIS | VCRUISE_GF_NEED_JPEG,
GUIO0()
Commit: f01eb895fa6b060ab2350c6ecfe46844ff7e7879
https://github.com/scummvm/scummvm/commit/f01eb895fa6b060ab2350c6ecfe46844ff7e7879
Author: elasota (ejlasota at gmail.com)
Date: 2023-04-12T23:06:02-04:00
Commit Message:
VCRUISE: Add subtitle loader
Changed paths:
engines/vcruise/runtime.cpp
engines/vcruise/runtime.h
diff --git a/engines/vcruise/runtime.cpp b/engines/vcruise/runtime.cpp
index 8ff05a741f6..d34b4fd0687 100644
--- a/engines/vcruise/runtime.cpp
+++ b/engines/vcruise/runtime.cpp
@@ -20,6 +20,7 @@
*/
#include "common/formats/winexe.h"
+#include "common/config-manager.h"
#include "common/endian.h"
#include "common/file.h"
#include "common/math.h"
@@ -212,6 +213,9 @@ void Runtime::GyroState::reset() {
isWaitingForAnimation = false;
}
+Runtime::SubtitleDef::SubtitleDef() : subIndex(0), color{0, 0, 0}, unknownValue1(0), unknownValue2(0) {
+}
+
SfxPlaylistEntry::SfxPlaylistEntry() : frame(0), balance(0), volume(0), isUpdate(false) {
}
@@ -732,7 +736,8 @@ Runtime::Runtime(OSystem *system, Audio::Mixer *mixer, const Common::FSNode &roo
/*_loadedArea(0), */_lmbDown(false), _lmbDragging(false), _lmbReleaseWasClick(false), _lmbDownTime(0),
_delayCompletionTime(0),
_panoramaState(kPanoramaStateInactive),
- _listenerX(0), _listenerY(0), _listenerAngle(0), _soundCacheIndex(0) {
+ _listenerX(0), _listenerY(0), _listenerAngle(0), _soundCacheIndex(0),
+ _subtitleFont(nullptr), _subtitleExpireTime(0), _displayingSubtitles(false), _languageIndex(0) {
for (uint i = 0; i < kNumDirections; i++) {
_haveIdleAnimations[i] = false;
@@ -744,6 +749,10 @@ Runtime::Runtime(OSystem *system, Audio::Mixer *mixer, const Common::FSNode &roo
_panCursors[i] = 0;
_rng.reset(new Common::RandomSource("vcruise"));
+
+ _subtitleFont = FontMan.getFontByUsage(Graphics::FontManager::kGUIFont);
+ if (!_subtitleFont)
+ warning("Couldn't load subtitle font, subtitles will be disabled");
}
Runtime::~Runtime() {
@@ -909,12 +918,81 @@ bool Runtime::bootGame(bool newGame) {
error("Couldn't figure out what screen to start on");
}
+ Common::Language lang = Common::parseLanguage(ConfMan.get("language"));
+
+ bool foundLang = false;
+
if (_gameID == GID_REAH) {
_animSpeedRotation = Fraction(21, 1); // Probably accurate
_animSpeedStaticAnim = Fraction(21, 1); // Probably accurate
_animSpeedDefault = Fraction(16, 1); // Possibly not accurate
+
+ const Common::Language langIndexes[] = {
+ Common::PL_POL,
+ Common::EN_ANY,
+ Common::DE_DEU,
+ Common::FR_FRA,
+ Common::NL_NLD,
+ Common::ES_ESP,
+ Common::IT_ITA,
+ };
+
+ _languageIndex = 1;
+ uint langCount = sizeof(langIndexes) / sizeof(langIndexes[0]);
+
+ for (uint li = 0; li < langCount; li++) {
+ if (langIndexes[li] == lang) {
+ _languageIndex = li;
+ foundLang = true;
+ break;
+ }
+ }
+ } else if (_gameID == GID_SCHIZM) {
+ const Common::Language langIndexes[] = {
+ Common::PL_POL,
+ Common::EN_GRB,
+ Common::DE_DEU,
+ Common::FR_FRA,
+ Common::NL_NLD,
+ Common::ES_ESP,
+ Common::IT_ITA,
+ Common::RU_RUS,
+ Common::EL_GRC,
+ Common::EN_USA,
+ };
+
+ _languageIndex = 1;
+ uint langCount = sizeof(langIndexes) / sizeof(langIndexes[0]);
+
+ for (uint li = 0; li < langCount; li++) {
+ if (langIndexes[li] == lang) {
+ _languageIndex = li;
+ foundLang = true;
+ break;
+ }
+ }
+ }
+
+ if (!foundLang) {
+ // Maybe should pick this differently
+ if (_gameID == GID_REAH)
+ lang = Common::EN_ANY;
+ else if (_gameID == GID_SCHIZM)
+ lang = Common::EN_GRB;
}
+ Common::CodePage codePage = Common::CodePage::kWindows1252;
+
+ if (lang == Common::PL_POL)
+ codePage = Common::CodePage::kWindows1250;
+ else if (lang == Common::RU_RUS)
+ codePage = Common::CodePage::kWindows1251;
+ else if (lang == Common::EL_GRC)
+ codePage = Common::CodePage::kWindows1253;
+
+ loadSubtitles(codePage);
+ debug(1, "Subtitles loaded OK");
+
return true;
}
@@ -3088,6 +3166,71 @@ Common::SharedPtr<Graphics::Surface> Runtime::loadGraphic(const Common::String &
return surf;
}
+void Runtime::loadSubtitles(Common::CodePage codePage) {
+ Common::String filePath = Common::String::format("Log/Speech%02u.txt", _languageIndex);
+
+ Common::INIFile ini;
+
+ ini.allowNonEnglishCharacters();
+
+ if (!ini.loadFromFile(filePath)) {
+ warning("Couldn't load subtitle data");
+ return;
+ }
+
+ for (const Common::INIFile::Section §ion : ini.getSections()) {
+ if (section.name == "Anims")
+ continue; // Ignore
+
+ FrameToSubtitleMap_t *frameMap = nullptr;
+ bool isWave = false;
+
+ if (section.name.substr(0, 5) == "Disc-")
+ isWave = true;
+ else if (section.name.size() == 8 && section.name.substr(0, 4) == "Anim") {
+ uint animID = 0;
+ if (sscanf(section.name.substr(4, 4).c_str(), "%u", &animID) == 1)
+ frameMap = &_animSubtitles[animID];
+ }
+
+ if (frameMap != nullptr || isWave) {
+ for (const Common::INIFile::KeyValue &kv : section.getKeys()) {
+ if (kv.value.size() < 23)
+ continue;
+
+ if (kv.value[21] != '\"' || kv.value[kv.value.size() - 1] != '\"')
+ continue;
+
+ Common::String locLineParamSlice = kv.value.substr(0, 21);
+
+ int colorCode = 0;
+ uint param1 = 0;
+ uint param2 = 0;
+ if (sscanf(locLineParamSlice.c_str(), "0x%x, 0x%x, %u, ", &colorCode, ¶m1, ¶m2) == 3) {
+ SubtitleDef *subDef = nullptr;
+
+ if (isWave)
+ subDef = &_waveSubtitles[kv.key];
+ else if (frameMap) {
+ uint frameNum = 0;
+ if (kv.key.size() >= 4 && kv.key.substr(kv.key.size() - 3) == "_01" && sscanf(kv.key.substr(0, kv.key.size() - 3).c_str(), "%u", &frameNum) == 1)
+ subDef = &(*frameMap)[frameNum];
+ }
+
+ if (subDef) {
+ subDef->color[0] = ((colorCode >> 16) & 0xff);
+ subDef->color[1] = ((colorCode >> 8) & 0xff);
+ subDef->color[2] = (colorCode & 0xff);
+ subDef->unknownValue1 = param1;
+ subDef->unknownValue2 = param2;
+ subDef->str = kv.value.substr(22, kv.value.size() - 23).decode(codePage).encode(Common::kUtf8);
+ }
+ }
+ }
+ }
+ }
+}
+
void Runtime::onLButtonDown(int16 x, int16 y) {
onMouseMove(x, y);
diff --git a/engines/vcruise/runtime.h b/engines/vcruise/runtime.h
index 51cdf82e005..a7c0e9fd542 100644
--- a/engines/vcruise/runtime.h
+++ b/engines/vcruise/runtime.h
@@ -50,6 +50,7 @@ namespace Graphics {
struct PixelFormat;
struct WinCursorGroup;
class ManagedSurface;
+class Font;
} // End of namespace Graphics
@@ -592,6 +593,16 @@ private:
ValueUnion value;
};
+ struct SubtitleDef {
+ SubtitleDef();
+
+ uint subIndex;
+ uint8 color[3];
+ uint unknownValue1;
+ uint unknownValue2;
+ Common::String str;
+ };
+
bool runIdle();
bool runDelay();
bool runHorizontalPan(bool isRight);
@@ -671,6 +682,8 @@ private:
Common::String getFileNameForItemGraphic(uint itemID) const;
Common::SharedPtr<Graphics::Surface> loadGraphic(const Common::String &graphicName, bool required);
+ void loadSubtitles(Common::CodePage codePage);
+
// Script things
void scriptOpNumber(ScriptArg_t arg);
void scriptOpRotate(ScriptArg_t arg);
@@ -948,6 +961,18 @@ private:
uint _soundCacheIndex;
Common::SharedPtr<SaveGameSnapshot> _saveGame;
+
+ const Graphics::Font *_subtitleFont;
+ uint32 _subtitleExpireTime;
+ uint _languageIndex;
+ bool _displayingSubtitles;
+
+ typedef Common::HashMap<uint, SubtitleDef> FrameToSubtitleMap_t;
+ typedef Common::HashMap<uint, FrameToSubtitleMap_t> AnimSubtitleMap_t;
+ typedef Common::HashMap<Common::String, SubtitleDef> WaveSubtitleMap_t;
+
+ AnimSubtitleMap_t _animSubtitles;
+ Common::HashMap<Common::String, SubtitleDef> _waveSubtitles;
};
} // End of namespace VCruise
More information about the Scummvm-git-logs
mailing list