Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/scummvm/scummvm
Browse files Browse the repository at this point in the history
  • Loading branch information
Strangerke committed Sep 7, 2019
2 parents b1db45b + 94b9304 commit d0bc1cf
Show file tree
Hide file tree
Showing 10 changed files with 136 additions and 65 deletions.
13 changes: 12 additions & 1 deletion engines/bladerunner/bladerunner.cpp
Expand Up @@ -625,6 +625,8 @@ bool BladeRunnerEngine::startup(bool hasSavegames) {
if (!_textOptions->open("OPTIONS"))
return false;

_russianCP1251 = ((uint8)_textOptions->getText(0)[0]) == 209;

_dialogueMenu = new DialogueMenu(this);
if (!_dialogueMenu->loadText("DLGMENU"))
return false;
Expand Down Expand Up @@ -1925,13 +1927,22 @@ void BladeRunnerEngine::setSubtitlesEnabled(bool newVal) {
}

Common::SeekableReadStream *BladeRunnerEngine::getResourceStream(const Common::String &name) {
// If the file is extracted from MIX files use it directly, it is used by Russian translation patched by Siberian Studio
if (Common::File::exists(name)) {
Common::File directFile;
if (directFile.open(name)) {
Common::SeekableReadStream *stream = directFile.readStream(directFile.size());
directFile.close();
return stream;
}
}

for (int i = 0; i != kArchiveCount; ++i) {
if (!_archives[i].isOpen()) {
continue;
}

// debug("getResource: Searching archive %s for %s.", _archives[i].getName().c_str(), name.c_str());

Common::SeekableReadStream *stream = _archives[i].createReadStreamForMember(name);
if (stream) {
return stream;
Expand Down
1 change: 1 addition & 0 deletions engines/bladerunner/bladerunner.h
Expand Up @@ -126,6 +126,7 @@ class BladeRunnerEngine : public Engine {

Common::String _languageCode;
Common::Language _language;
bool _russianCP1251;

ActorDialogueQueue *_actorDialogueQueue;
ScreenEffects *_screenEffects;
Expand Down
34 changes: 28 additions & 6 deletions engines/bladerunner/detection_tables.h
Expand Up @@ -76,7 +76,18 @@ static const ADGameDescription gameDescriptions[] = {
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
},

// BladeRunner (Russian)
// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc.)
{
"bladerunner",
0,
AD_ENTRY1s("STARTUP.MIX", "bf42af841d9f4b643665013a348c81e0", 2483111),
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_TESTING,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
},

// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc. + Siberian Studio, R3)
{
"bladerunner",
0,
Expand All @@ -87,11 +98,11 @@ static const ADGameDescription gameDescriptions[] = {
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
},

// BladeRunner (Russian - Fargus version)
// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc. + Siberian Studio, R4)
{
"bladerunner",
0,
AD_ENTRY1s("STARTUP.MIX", "bf42af841d9f4b643665013a348c81e0", 2483111),
AD_ENTRY1s("STARTUP.MIX", "d62498a7415682bb3ff86a894303c836", 2810053),
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_TESTING,
Expand Down Expand Up @@ -155,7 +166,18 @@ static const ADGameDescription gameDescriptions[] = {
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
},

// BladeRunner (Russian)
// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc.)
{
"bladerunner-final",
0,
AD_ENTRY1s("STARTUP.MIX", "bf42af841d9f4b643665013a348c81e0", 2483111),
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_UNSTABLE,
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
},

// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc. + Siberian Studio, R3)
{
"bladerunner-final",
0,
Expand All @@ -166,11 +188,11 @@ static const ADGameDescription gameDescriptions[] = {
GUIO2(GAMEOPTION_SITCOM, GAMEOPTION_SHORTY)
},

// BladeRunner (Russian - Fargus version)
// BladeRunner (Russian - Fargus Multimedia + Home Systems, Inc. + Siberian Studio, R4)
{
"bladerunner-final",
0,
AD_ENTRY1s("STARTUP.MIX", "bf42af841d9f4b643665013a348c81e0", 2483111),
AD_ENTRY1s("STARTUP.MIX", "d62498a7415682bb3ff86a894303c836", 2810053),
Common::RU_RUS,
Common::kPlatformWindows,
ADGF_UNSTABLE,
Expand Down
25 changes: 18 additions & 7 deletions engines/bladerunner/ui/esper.cpp
Expand Up @@ -1039,15 +1039,26 @@ void ESPER::drawVideoFrame(Graphics::Surface &surface) {
}

void ESPER::drawTextCoords(Graphics::Surface &surface) {
const char *zm = "ZM %04.0f";
const char *ns = "NS %04d";
const char *ew = "EW %04d";
if (_vm->_language == Common::RU_RUS) {
_vm->_mainFont->drawString(&surface, Common::String::format("gh %04.0f", _zoom / _zoomMin * 2.0f ), 155, 364, surface.w, surface.format.RGBToColor(0, 0, 255));
_vm->_mainFont->drawString(&surface, Common::String::format("dh %04d", 12 * _viewport.top + 98), 260, 364, surface.w, surface.format.RGBToColor(0, 0, 255));
_vm->_mainFont->drawString(&surface, Common::String::format("uh %04d", 12 * _viewport.left + 167), 364, 364, surface.w, surface.format.RGBToColor(0, 0, 255));
} else {
_vm->_mainFont->drawString(&surface, Common::String::format("ZM %04.0f", _zoom / _zoomMin * 2.0f ), 155, 364, surface.w, surface.format.RGBToColor(0, 0, 255));
_vm->_mainFont->drawString(&surface, Common::String::format("NS %04d", 12 * _viewport.top + 98), 260, 364, surface.w, surface.format.RGBToColor(0, 0, 255));
_vm->_mainFont->drawString(&surface, Common::String::format("EW %04d", 12 * _viewport.left + 167), 364, 364, surface.w, surface.format.RGBToColor(0, 0, 255));
// ПР, ВР, ГР
if (_vm->_russianCP1251) {
// Patched transalation by Siberian Studio is using Windows-1251 encoding
zm = "\xcf\xd0 %04.0f";
ns = "\xc2\xd0 %04d";
ew = "\xc3\xd0 %04d";
} else {
// Original release uses custom encoding
zm = "gh %04.0f";
ns = "dh %04d";
ew = "uh %04d";
}
}
_vm->_mainFont->drawString(&surface, Common::String::format(zm, _zoom / _zoomMin * 2.0f ), 155, 364, surface.w, surface.format.RGBToColor(0, 0, 255));
_vm->_mainFont->drawString(&surface, Common::String::format(ns, 12 * _viewport.top + 98), 260, 364, surface.w, surface.format.RGBToColor(0, 0, 255));
_vm->_mainFont->drawString(&surface, Common::String::format(ew, 12 * _viewport.left + 167), 364, 364, surface.w, surface.format.RGBToColor(0, 0, 255));
}

void ESPER::drawMouse(Graphics::Surface &surface) {
Expand Down
42 changes: 42 additions & 0 deletions engines/bladerunner/ui/kia.cpp
Expand Up @@ -599,6 +599,48 @@ void KIA::playImage(const Graphics::Surface &image) {
_playerImage.convertToInPlace(screenPixelFormat());
}

const char *KIA::scrambleSuspectsName(const char *name) {
static char buffer[32];

unsigned char *bufferPtr = (unsigned char *)buffer;
const unsigned char *namePtr = (const unsigned char *)name;

for (int i = 0 ; i < 6; ++i) {
if (_vm->_language == Common::RU_RUS && _vm->_russianCP1251) {
// Algorithm added by Siberian Studio in R4 patch
if (*namePtr >= 0xC0) {
unsigned char upper = *namePtr & 0xDF;
if (upper < 201) {
*bufferPtr++ = upper - 143; /* Map А-И to 1-9 */
} else {
*bufferPtr++ = upper - 136; /* Map Й-Я to A-W */
}
} else {
*bufferPtr++ = '0';
}
} else {
if (Common::isAlpha(*namePtr)) {
char upper = toupper(*namePtr);
if ( upper < 'J' ) {
*bufferPtr++ = upper - 16; /* Map A-I to 1-9 */
} else {
*bufferPtr++ = upper - 9; /* Map J-Z to A-Q */
}
} else {
*bufferPtr++ = '0';
}
}
if (*namePtr) {
++namePtr;
}
if (i == 1) {
*bufferPtr++ = '-';
}
}
*bufferPtr = 0;
return buffer;
}

void KIA::mouseDownCallback(int buttonId, void *callbackData) {
KIA *self = (KIA *)callbackData;
switch (buttonId) {
Expand Down
2 changes: 2 additions & 0 deletions engines/bladerunner/ui/kia.h
Expand Up @@ -151,6 +151,8 @@ class KIA {
void playPhotograph(int photographId);
void playImage(const Graphics::Surface &image);

const char *scrambleSuspectsName(const char *name);

private:
static void mouseDownCallback(int buttonId, void *callbackData);
static void mouseUpCallback(int buttonId, void *callbackData);
Expand Down
4 changes: 2 additions & 2 deletions engines/bladerunner/ui/kia_section_crimes.cpp
Expand Up @@ -175,10 +175,10 @@ void KIASectionCrimes::draw(Graphics::Surface &surface) {
if (_suspectsWithIdentity[_suspectSelected]) {
text = suspectName;
} else if (_vm->_suspectsDatabase->get(_suspectSelected)->getSex()) {
sprintf(generatedText, "%s %s", _vm->_textKIA->getText(20), KIASectionSuspects::scrambleSuspectsName(suspectName));
sprintf(generatedText, "%s %s", _vm->_textKIA->getText(20), _vm->_kia->scrambleSuspectsName(suspectName));
text = generatedText;
} else {
sprintf(generatedText, "%s %s", _vm->_textKIA->getText(21), KIASectionSuspects::scrambleSuspectsName(suspectName));
sprintf(generatedText, "%s %s", _vm->_textKIA->getText(21), _vm->_kia->scrambleSuspectsName(suspectName));
text = generatedText;
}
}
Expand Down
46 changes: 29 additions & 17 deletions engines/bladerunner/ui/kia_section_settings.cpp
Expand Up @@ -199,25 +199,37 @@ void KIASectionSettings::draw(Graphics::Surface &surface) {

if (_vm->_subtitles->isSystemActive()) {
// Allow this to be loading as an extra text item in the resource for text options
const char *subtitlesTranslation = "Subtitles";
if (_vm->_language == Common::EN_ANY) {
subtitlesTranslation = "Subtitles"; // EN_ANY
} else if (_vm->_language == Common::DE_DEU) {
subtitlesTranslation = "Untertitel"; // DE_DEU
} else if (_vm->_language == Common::FR_FRA) {
subtitlesTranslation = "Sous-titres"; // FR_FRA
} else if (_vm->_language == Common::IT_ITA) {
subtitlesTranslation = "Sottotitoli"; // IT_ITA
} else if (_vm->_language == Common::RU_RUS) {
// The supported Russian version is using its own KIA6PT.FON
// where it has replaced the mapping of Latin characters to Russian characters
// So the character string here does not make sense, but it will appear correctly
subtitlesTranslation = "CE,NBNHS"; // RU_RUS "Subtitry"
} else if (_vm->_language == Common::ES_ESP) {
subtitlesTranslation = "Subtitulos"; // ES_ESP
const char *subtitlesTranslation = nullptr;
switch (_vm->_language) {
case Common::EN_ANY:
default:
subtitlesTranslation = "Subtitles";
break;
case Common::DE_DEU:
subtitlesTranslation = "Untertitel";
break;
case Common::FR_FRA:
subtitlesTranslation = "Sous-titres";
break;
case Common::IT_ITA:
subtitlesTranslation = "Sottotitoli";
break;
case Common::ES_ESP:
subtitlesTranslation = "Subtitulos";
break;
case Common::RU_RUS:
// субтитры
if (_vm->_russianCP1251) {
// Patched transalation by Siberian Studio is using Windows-1251 encoding
subtitlesTranslation = "\xf1\xf3\xe1\xf2\xe8\xf2\xf0\xfb";
} else {
// Original release uses custom encoding
subtitlesTranslation = "CE,NBNHS";
}
break;
}

const char *textSubtitles = strcmp(_vm->_textOptions->getText(42), "") == 0? subtitlesTranslation : _vm->_textOptions->getText(42); // +1 to the max of original index of textOptions which is 41
const char *textSubtitles = strcmp(_vm->_textOptions->getText(42), "") == 0 ? subtitlesTranslation : _vm->_textOptions->getText(42); // +1 to the max of original index of textOptions which is 41

if (_vm->_language == Common::RU_RUS) {
_vm->_mainFont->drawString(&surface, textSubtitles, 288, 376, surface.w, surface.format.RGBToColor(232, 208, 136)); // special case for Russian version, put the option in a new line to avoid overlap
Expand Down
32 changes: 2 additions & 30 deletions engines/bladerunner/ui/kia_section_suspects.cpp
Expand Up @@ -211,10 +211,10 @@ void KIASectionSuspects::draw(Graphics::Surface &surface) {
if (_suspectsWithIdentity[_suspectSelected]) {
text = suspectName;
} else if (_vm->_suspectsDatabase->get(_suspectSelected)->getSex()) {
sprintf(generatedText, "%s %s", _vm->_textKIA->getText(20), scrambleSuspectsName(suspectName));
sprintf(generatedText, "%s %s", _vm->_textKIA->getText(20), _vm->_kia->scrambleSuspectsName(suspectName));
text = generatedText;
} else {
sprintf(generatedText, "%s %s", _vm->_textKIA->getText(21), scrambleSuspectsName(suspectName));
sprintf(generatedText, "%s %s", _vm->_textKIA->getText(21), _vm->_kia->scrambleSuspectsName(suspectName));
text = generatedText;
}
}
Expand Down Expand Up @@ -283,34 +283,6 @@ void KIASectionSuspects::selectSuspect(int suspectId) {
updateSuspectPhoto();
}

const char *KIASectionSuspects::scrambleSuspectsName(const char *name) {
static char buffer[32];

char *bufferPtr = buffer;
const char *namePtr = name;

for (int i = 0 ; i < 6; ++i) {
if (Common::isAlpha(*namePtr)) {
char upper = toupper(*namePtr);
if ( upper < 'J' ) {
*bufferPtr++ = upper - 16;
} else {
*bufferPtr++ = upper - 9;
}
} else {
*bufferPtr++ = '0';
}
if (*namePtr) {
++namePtr;
}
if (i == 1) {
*bufferPtr++ = '-';
}
}
*bufferPtr = 0;
return buffer;
}

void KIASectionSuspects::scrollBoxCallback(void *callbackData, void *source, int lineData, int mouseButton) {
KIASectionSuspects *self = (KIASectionSuspects *)callbackData;

Expand Down
2 changes: 0 additions & 2 deletions engines/bladerunner/ui/kia_section_suspects.h
Expand Up @@ -105,8 +105,6 @@ class KIASectionSuspects : public KIASectionBase {

void selectSuspect(int suspectId);

static const char *scrambleSuspectsName(const char *name);

private:
static void scrollBoxCallback(void *callbackData, void *source, int lineData, int mouseButton);
static void checkBoxCallback(void *callbackData, void *source);
Expand Down

0 comments on commit d0bc1cf

Please sign in to comment.