[Scummvm-cvs-logs] CVS: scummvm/backends/sdl graphics.cpp,1.5,1.6 sdl.cpp,1.67,1.68

Max Horn fingolfin at users.sourceforge.net
Mon Mar 15 11:18:00 CET 2004


Update of /cvsroot/scummvm/scummvm/backends/sdl
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8184

Modified Files:
	graphics.cpp sdl.cpp 
Log Message:
Allow multi-line OSD messages; display virtual/real screen resolutions when chaning the scaler or the aspect ratio correction

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/graphics.cpp,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- graphics.cpp	15 Mar 2004 00:45:45 -0000	1.5
+++ graphics.cpp	15 Mar 2004 19:07:55 -0000	1.6
@@ -134,7 +134,11 @@
 		}
 		if (newScalerName) {
 			char buffer[128];
-			sprintf(buffer, "Active graphics filter: %s", newScalerName);
+			sprintf(buffer, "Active graphics filter: %s\n%d x %d -> %d x %d",
+				newScalerName,
+				_screenWidth, _screenHeight,
+				_hwscreen->w, _hwscreen->h
+				);
 			displayMessageOnOSD(buffer);
 		}
 	}
@@ -1170,7 +1174,9 @@
 #ifdef USE_OSD
 void OSystem_SDL::displayMessageOnOSD(const char *msg) {
 	
-//	printf("displayMessageOnOSD(%s)\n", msg);
+	uint i;
+	
+	// Lock the OSD surface for drawing
 	if (SDL_LockSurface(_osdSurface))
 		error("displayMessageOnOSD: SDL_LockSurface failed: %s", SDL_GetError());
 
@@ -1181,14 +1187,36 @@
 	dst.pitch = _osdSurface->pitch;
 	dst.bytesPerPixel = _osdSurface->format->BytesPerPixel;
 	
+	// The font we are going to use:
+//	const GUI::Font *font = &GUI::g_sysfont;
+	const GUI::Font *font = &GUI::g_scummfont;
+	
 	// Clear everything with the "transparent" color, i.e. the colorkey
 	SDL_FillRect(_osdSurface, 0, kOSDColorKey);
+	
+	// Split the message into separate lines.
+	Common::StringList lines;
+	const char *ptr;
+	for (ptr = msg; *ptr; ++ptr) {
+		if (*ptr == '\n') {
+			lines.push_back(Common::String(msg, ptr - msg));
+			msg = ptr + 1;
+		}
+	}
+	lines.push_back(Common::String(msg, ptr - msg));
 
 	// Determine a rect which would contain the message string (clipped to the
 	// screen dimensions).
-	const int vOffset = 10;
-	int width = GUI::g_sysfont.getStringWidth(msg) + 16;
-	int height = GUI::g_sysfont.getFontHeight() + 2 * vOffset;
+	const int vOffset = 6;
+	const int lineSpacing = 1;
+	const int lineHeight = font->getFontHeight() + 2 * lineSpacing;
+	int width = 0;
+	int height = lineHeight * lines.size() + 2 * vOffset;
+	for (i = 0; i < lines.size(); i++) {
+		width = MAX(width, font->getStringWidth(lines[i]) + 14);
+	}
+	
+	// Clip the rect
 	if (width > dst.w)
 		width = dst.w;
 	if (height > dst.h)
@@ -1204,10 +1232,14 @@
 	SDL_FillRect(_osdSurface, &osdRect, SDL_MapRGB(_osdSurface->format, 64, 64, 64));
 
 	// Render the message, centered, and in white
-	GUI::g_sysfont.drawString(&dst, msg, osdRect.x, osdRect.y + vOffset, osdRect.w,
+	for (i = 0; i < lines.size(); i++) {
+		font->drawString(&dst, lines[i],
+							osdRect.x, osdRect.y + i * lineHeight + vOffset + lineSpacing, osdRect.w,
 							SDL_MapRGB(_osdSurface->format, 255, 255, 255),
 							GUI::kTextAlignCenter);
+	}
 
+	// Finished drawing, so unlock the OSD surface again
 	SDL_UnlockSurface(_osdSurface);
 
 	// Init the OSD display parameters, and the fade out

Index: sdl.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/backends/sdl/sdl.cpp,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- sdl.cpp	15 Mar 2004 01:18:37 -0000	1.67
+++ sdl.cpp	15 Mar 2004 19:07:56 -0000	1.68
@@ -151,10 +151,18 @@
 			hotswap_gfx_mode();
 			
 #ifdef USE_OSD
+			char buffer[128];
 			if (_adjustAspectRatio)
-				displayMessageOnOSD("Enabled aspect ratio correction");
+				sprintf(buffer, "Enabled aspect ratio correction\n%d x %d -> %d x %d",
+					_screenWidth, _screenHeight,
+					_hwscreen->w, _hwscreen->h
+					);
 			else
-				displayMessageOnOSD("Disabled aspect ratio correction");
+				sprintf(buffer, "Disabled aspect ratio correction\n%d x %d -> %d x %d",
+					_screenWidth, _screenHeight,
+					_hwscreen->w, _hwscreen->h
+					);
+			displayMessageOnOSD(buffer);
 #endif
 
 			// Blit everything to the screen





More information about the Scummvm-git-logs mailing list