[Scummvm-git-logs] scummvm master -> f204d3639a71193303013bcd2fb05de0eae4a10d

sev- sev at scummvm.org
Mon Aug 16 22:12:20 UTC 2021


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
f204d3639a SWORD1: Add support for Hebrew translation


Commit: f204d3639a71193303013bcd2fb05de0eae4a10d
    https://github.com/scummvm/scummvm/commit/f204d3639a71193303013bcd2fb05de0eae4a10d
Author: Zvika Haramaty (haramaty.zvika at gmail.com)
Date: 2021-08-17T00:12:18+02:00

Commit Message:
SWORD1: Add support for Hebrew translation

Changed paths:
    engines/sword1/detection.cpp
    engines/sword1/sword1.cpp
    engines/sword1/sword1.h
    engines/sword1/text.cpp


diff --git a/engines/sword1/detection.cpp b/engines/sword1/detection.cpp
index 23ccc36562..e3127e3ea6 100644
--- a/engines/sword1/detection.cpp
+++ b/engines/sword1/detection.cpp
@@ -211,6 +211,7 @@ DetectedGames SwordMetaEngineDetection::detectGames(const Common::FSList &fslist
 	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::ES_ESP));
 	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::PT_BRA));
 	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::CZ_CZE));
+	game.appendGUIOptions(getGameGUIOptionsDescriptionLanguage(Common::HE_ISR));
 
 	detectedGames.push_back(game);
 
diff --git a/engines/sword1/sword1.cpp b/engines/sword1/sword1.cpp
index 00e3240c05..286af01a14 100644
--- a/engines/sword1/sword1.cpp
+++ b/engines/sword1/sword1.cpp
@@ -126,6 +126,7 @@ Common::Error SwordEngine::init() {
 	_systemVars.forceRestart = false;
 	_systemVars.wantFade = true;
 	_systemVars.realLanguage = Common::parseLanguage(ConfMan.get("language"));
+	_systemVars.isLangRtl = false;
 
 	switch (_systemVars.realLanguage) {
 	case Common::DE_DEU:
@@ -146,6 +147,11 @@ Common::Error SwordEngine::init() {
 	case Common::CZ_CZE:
 		_systemVars.language = BS1_CZECH;
 		break;
+	case Common::HE_ISR:
+		// Hebrew is using "faked" English
+		_systemVars.language = BS1_ENGLISH;
+		_systemVars.isLangRtl = true;
+		break;
 	default:
 		_systemVars.language = BS1_ENGLISH;
 		break;
diff --git a/engines/sword1/sword1.h b/engines/sword1/sword1.h
index 3466ee68e7..228ab0164e 100644
--- a/engines/sword1/sword1.h
+++ b/engines/sword1/sword1.h
@@ -77,6 +77,7 @@ struct SystemVars {
 	bool    isSpanishDemo;
 	Common::Platform platform;
 	Common::Language realLanguage;
+	bool isLangRtl;
 };
 
 class SwordEngine : public Engine {
diff --git a/engines/sword1/text.cpp b/engines/sword1/text.cpp
index 2ef1d95b4e..088d9d5518 100644
--- a/engines/sword1/text.cpp
+++ b/engines/sword1/text.cpp
@@ -22,6 +22,8 @@
 
 
 #include "common/textconsole.h"
+#include "common/str.h"
+#include "common/unicode-bidi.h"
 
 #include "sword1/text.h"
 #include "sword1/resman.h"
@@ -99,9 +101,18 @@ void Text::makeTextSprite(uint8 slot, const uint8 *text, uint16 maxWidth, uint8
 	memset(linePtr, NO_COL, sprSize);
 	for (lineCnt = 0; lineCnt < numLines; lineCnt++) {
 		uint8 *sprPtr = linePtr + (sprWidth - lines[lineCnt].width) / 2; // center the text
+		Common::String textString;
+		const uint8 *curTextLine = text;
+		if (SwordEngine::_systemVars.isLangRtl) {
+			Common::String textLogical = Common::String((const char *)text, (uint32)lines[lineCnt].length);
+			textString = Common::convertBiDiString(textLogical, Common::kWindows1255);
+			curTextLine = (const uint8 *)textString.c_str();
+		}
 		for (uint16 pos = 0; pos < lines[lineCnt].length; pos++)
-			sprPtr += copyChar(*text++, sprPtr, sprWidth, pen) - OVERLAP;
-		text++; // skip space at the end of the line
+			sprPtr += copyChar(*curTextLine++, sprPtr, sprWidth, pen) - OVERLAP;
+		curTextLine++; // skip space at the end of the line
+		text += lines[lineCnt].length + 1;
+
 		if (SwordEngine::isPsx()) //Chars are half height in psx version
 			linePtr += (_charHeight / 2) * sprWidth;
 		else




More information about the Scummvm-git-logs mailing list