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

antoniou79 antoniou at cti.gr
Fri Nov 8 16:02:40 CET 2019


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:
6fde4e89f8 GUI: Fix crash on low resolutions
b8c26508c9 ANDROID: Fix OSD message display crash or fail


Commit: 6fde4e89f85b8091b40569ac5d8e4a34b6007ace
    https://github.com/scummvm/scummvm/commit/6fde4e89f85b8091b40569ac5d8e4a34b6007ace
Author: Thanasis Antoniou (a.antoniou79 at gmail.com)
Date: 2019-11-08T16:58:16+02:00

Commit Message:
GUI: Fix crash on low resolutions

Related to about cls() and easter egg. Crashed on Android port on small screen devices

Changed paths:
    gui/about.cpp


diff --git a/gui/about.cpp b/gui/about.cpp
index 825aab4..d6571c7 100644
--- a/gui/about.cpp
+++ b/gui/about.cpp
@@ -451,11 +451,11 @@ bool EEHandler::handleKeyDown(Common::KeyState &state) {
 }
 
 EE::EE() {
-	_windowX = (g_system->getOverlayWidth() - 320) / 2;
-	_windowY = (g_system->getOverlayHeight() - 200) / 2;
+	_windowX = (g_system->getOverlayWidth() > 320) ? (g_system->getOverlayWidth() - 320) / 2 : 0;
+	_windowY = (g_system->getOverlayHeight() > 200) ? (g_system->getOverlayHeight() - 200) / 2 : 0;
 
 	_format = g_system->getOverlayFormat();
-	_back.create(320, 200, _format);
+	_back.create(MIN<int>(g_system->getOverlayWidth(), 320), MIN<int>(g_system->getOverlayHeight(), 200), _format);
 
 	_colorBlue   = _format.RGBToColor(5 * 16, 7 * 16, 8 * 16);
 	_colorOrange = _format.RGBToColor(15 * 16, 7 * 16, 8 * 16);
@@ -467,10 +467,10 @@ EE::~EE() {
 }
 
 void EE::cls(bool update) {
-	_back.fillRect(Common::Rect(0, 0, 320, 200), 0);
+	_back.fillRect(Common::Rect(0, 0, MIN<int>(g_system->getOverlayWidth(), 320), MIN<int>(g_system->getOverlayHeight(), 200)), 0);
 
 	if (update)
-		g_system->copyRectToOverlay(_back.getPixels(), _back.pitch, _windowX, _windowY, 320, 200);
+		g_system->copyRectToOverlay(_back.getPixels(), _back.pitch, _windowX, _windowY, MIN<int>(g_system->getOverlayWidth(), 320), MIN<int>(g_system->getOverlayHeight(), 200));
 }
 
 void EE::run() {
@@ -1107,7 +1107,12 @@ void EE::drawStatus(Common::String str, int x, uint32 color, int y, int color2,
 
 void EE::draw(int sn, int x, int y) {
 	_back.transBlitFrom(_sp[sn], Common::Point(x, y), 0);
-	g_system->copyRectToOverlay(_back.getBasePtr(x, y), _back.pitch, _windowX + x, _windowY + y, _sp[sn].w, _sp[sn].h);
+	g_system->copyRectToOverlay(_back.getBasePtr(x, y),
+	                           _back.pitch,
+	                           MIN<int>(_windowX + x, g_system->getOverlayWidth()),
+	                           MIN<int>(_windowY + y, g_system->getOverlayHeight()),
+	                           MIN<int>(_sp[sn].w, g_system->getOverlayWidth() - MIN<int>(_windowX + x, g_system->getOverlayWidth())),
+	                           MIN<int>(_sp[sn].h, g_system->getOverlayHeight() - MIN<int>(_windowY + y, g_system->getOverlayHeight()) ));
 }
 
 const char *codes =
@@ -1120,9 +1125,24 @@ void EE::putshapes() {
 	cls(false);
 
 	if (_oCoords) {
-		g_system->copyRectToOverlay(_back.getBasePtr(_obx, _oby), _back.pitch, _windowX + _obx, _windowY + _oby, _sp[kSpB1].w, _sp[kSpB1].h);
-		g_system->copyRectToOverlay(_back.getBasePtr(_olx, _oly), _back.pitch, _windowX + _olx, _windowY + _oly, _sp[kSpL1].w, _sp[kSpL1].h);
-		g_system->copyRectToOverlay(_back.getBasePtr(_orx, _ory), _back.pitch, _windowX + _orx, _windowY + _ory, _sp[kSpR1].w, _sp[kSpR1].h);
+		g_system->copyRectToOverlay(_back.getBasePtr(_obx, _oby),
+		                            _back.pitch,
+		                            MIN<int>(_windowX + _obx, g_system->getOverlayWidth()),
+		                            MIN<int>(_windowY + _oby, g_system->getOverlayHeight()),
+		                            MIN<int>(_sp[kSpB1].w, g_system->getOverlayWidth() - MIN<int>(_windowX + _obx, g_system->getOverlayWidth())),
+		                            MIN<int>(_sp[kSpB1].h, g_system->getOverlayHeight() - MIN<int>(_windowY + _oby, g_system->getOverlayHeight()) ));
+		g_system->copyRectToOverlay(_back.getBasePtr(_olx, _oly),
+		                            _back.pitch,
+		                            MIN<int>(_windowX + _olx, g_system->getOverlayWidth()),
+		                            MIN<int>(_windowY + _oly, g_system->getOverlayHeight()),
+		                            MIN<int>(_sp[kSpL1].w, g_system->getOverlayWidth() - MIN<int>(_windowX + _olx, g_system->getOverlayWidth())),
+		                            MIN<int>(_sp[kSpL1].h, g_system->getOverlayHeight() - MIN<int>(_windowY + _oly, g_system->getOverlayHeight()) ));
+		g_system->copyRectToOverlay(_back.getBasePtr(_orx, _ory),
+		                            _back.pitch,
+		                            MIN<int>(_windowX + _orx, g_system->getOverlayWidth()),
+		                            MIN<int>(_windowY + _ory, g_system->getOverlayHeight()),
+		                            MIN<int>(_sp[kSpR1].w, g_system->getOverlayWidth() - MIN<int>(_windowX + _orx, g_system->getOverlayWidth())),
+		                            MIN<int>(_sp[kSpR1].h, g_system->getOverlayHeight() - MIN<int>(_windowY + _ory, g_system->getOverlayHeight()) ));
 	}
 
 	sprite = kSpB1 + (_tbx / 16) % 4;
@@ -1172,7 +1192,12 @@ void EE::putshapes() {
 	for (int i = 0; i < 6; i++, ptr += 4) {
 		Common::Rect r(ptr[0], ptr[1], ptr[2], ptr[3]);
 		_back.fillRect(r, (i < 5 ? color1 : color2));
-		g_system->copyRectToOverlay(_back.getBasePtr(ptr[0], ptr[1]), _back.pitch, _windowX + ptr[0], _windowY + ptr[1], r.width(), r.height());
+		g_system->copyRectToOverlay(_back.getBasePtr(ptr[0], ptr[1]),
+		                            _back.pitch,
+		                            MIN<int>(_windowX + ptr[0], g_system->getOverlayWidth()),
+		                            MIN<int>(_windowY + ptr[1], g_system->getOverlayHeight()),
+		                            MIN<int>(r.width(), g_system->getOverlayWidth() - MIN<int>(_windowX + ptr[0], g_system->getOverlayWidth())),
+		                            MIN<int>(r.height(), g_system->getOverlayHeight() - MIN<int>(_windowY + ptr[1], g_system->getOverlayHeight()) ));
 	}
 
 	int startx = 32;
@@ -1210,10 +1235,21 @@ void EE::putshapes() {
 			break;
 	}
 
-	g_system->copyRectToOverlay(_back.getPixels(), _back.pitch, _windowX, _windowY, 320, 10);
+	g_system->copyRectToOverlay(_back.getPixels(),
+	                            _back.pitch,
+	                            MIN<int>(_windowX, g_system->getOverlayWidth()),
+	                            MIN<int>(_windowY, g_system->getOverlayHeight()),
+	                            MIN<int>(320, g_system->getOverlayWidth() - MIN<int>(_windowX, g_system->getOverlayWidth())),
+	                            MIN<int>(10, g_system->getOverlayHeight() - MIN<int>(_windowY, g_system->getOverlayHeight()) ));
 
-	if (_mode == kModeMenu)
-		g_system->copyRectToOverlay(_back.getBasePtr(92, 30), _back.pitch, _windowX + 92, _windowY + 30, 135, 5 * 10);
+	if (_mode == kModeMenu) {
+		g_system->copyRectToOverlay(_back.getBasePtr(92, 30),
+		                            _back.pitch,
+		                            MIN<int>(_windowX + 92, g_system->getOverlayWidth()),
+		                            MIN<int>(_windowY + 30, g_system->getOverlayHeight()),
+		                            MIN<int>(135, g_system->getOverlayWidth() - MIN<int>(_windowX + 92, g_system->getOverlayWidth())),
+		                            MIN<int>(5 * 10, g_system->getOverlayHeight() - MIN<int>(_windowY + 30, g_system->getOverlayHeight()) ));
+	}
 }
 
 void EE::doMenu(Common::Event &e) {


Commit: b8c26508c90b7926ea44b40e5bcb2f530b8d1464
    https://github.com/scummvm/scummvm/commit/b8c26508c90b7926ea44b40e5bcb2f530b8d1464
Author: Thanasis Antoniou (a.antoniou79 at gmail.com)
Date: 2019-11-08T16:59:52+02:00

Commit Message:
ANDROID: Fix OSD message display crash or fail

For translated message text. Android expected UTF-8 format for the message

Also makeToast for OSD needed to be run from the main UI thread

Changed paths:
    backends/platform/android/jni.cpp
    backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java


diff --git a/backends/platform/android/jni.cpp b/backends/platform/android/jni.cpp
index 8c330c0..cedee38 100644
--- a/backends/platform/android/jni.cpp
+++ b/backends/platform/android/jni.cpp
@@ -46,6 +46,7 @@
 #include "common/error.h"
 #include "common/textconsole.h"
 #include "common/translation.h"
+#include "common/encoding.h"
 #include "engines/engine.h"
 
 #include "backends/platform/android/android.h"
@@ -225,8 +226,24 @@ void JNI::getDPI(float *values) {
 }
 
 void JNI::displayMessageOnOSD(const char *msg) {
+	// called from common/osd_message_queue, method: OSDMessageQueue::pollEvent()
 	JNIEnv *env = JNI::getEnv();
-	jstring java_msg = env->NewStringUTF(msg);
+//	LOGD("OSD orig MESSAGE: %s", msg);
+	Common::String fromEncoding = "ISO-8859-1";
+#ifdef USE_TRANSLATION
+	if (TransMan.getCurrentCharset() != "ASCII") {
+		fromEncoding = TransMan.getCurrentCharset();
+	}
+#endif
+	Common::Encoding converter("UTF-8", fromEncoding.c_str());
+
+	const char *utf8Msg = converter.convert(msg, converter.stringLength(msg, fromEncoding) );
+	if (utf8Msg == nullptr) {
+		LOGE("Failed to convert message to UTF-8 for OSD!");
+		return;
+	}
+//	LOGD("OSD target MESSAGE: %s", utf8Msg);
+	jstring java_msg = env->NewStringUTF(utf8Msg);
 
 	env->CallVoidMethod(_jobj, _MID_displayMessageOnOSD, java_msg);
 
@@ -693,6 +710,7 @@ void JNI::setPause(JNIEnv *env, jobject self, jboolean value) {
 jstring JNI::getCurrentCharset(JNIEnv *env, jobject self) {
 #ifdef USE_TRANSLATION
 	if (TransMan.getCurrentCharset() != "ASCII") {
+//		LOGD("getCurrentCharset: %s", TransMan.getCurrentCharset().c_str());
 		return env->NewStringUTF(TransMan.getCurrentCharset().c_str());
 	}
 #endif
diff --git a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
index dca52a9..f55639f 100644
--- a/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
+++ b/backends/platform/android/org/scummvm/scummvm/ScummVMActivity.java
@@ -76,9 +76,15 @@ public class ScummVMActivity extends Activity {
 		}
 
 		@Override
-		protected void displayMessageOnOSD(String msg) {
-			Log.i(LOG_TAG, "OSD: " + msg);
-			Toast.makeText(ScummVMActivity.this, msg, Toast.LENGTH_LONG).show();
+		protected void displayMessageOnOSD(final String msg) {
+			if (msg != null) {
+				Log.i(LOG_TAG, "MessageOnOSD: " + msg + " " + getCurrentCharset());
+				runOnUiThread(new Runnable() {
+					public void run() {
+						Toast.makeText(ScummVMActivity.this, msg, Toast.LENGTH_SHORT).show();
+					}
+				});
+			}
 		}
 
 		@Override





More information about the Scummvm-git-logs mailing list