aboutsummaryrefslogtreecommitdiff
path: root/backends/sdl/graphics.cpp
diff options
context:
space:
mode:
authorMax Horn2004-03-15 19:07:56 +0000
committerMax Horn2004-03-15 19:07:56 +0000
commitb29b07fadc61ce36b340208ae1d0dc817468ba66 (patch)
tree70961088d37492a79074ebce01f61815f3fccc52 /backends/sdl/graphics.cpp
parent7410f041ee8bb18f1d8a6a5999b81ca202a1a38c (diff)
downloadscummvm-rg350-b29b07fadc61ce36b340208ae1d0dc817468ba66.tar.gz
scummvm-rg350-b29b07fadc61ce36b340208ae1d0dc817468ba66.tar.bz2
scummvm-rg350-b29b07fadc61ce36b340208ae1d0dc817468ba66.zip
Allow multi-line OSD messages; display virtual/real screen resolutions when chaning the scaler or the aspect ratio correction
svn-id: r13309
Diffstat (limited to 'backends/sdl/graphics.cpp')
-rw-r--r--backends/sdl/graphics.cpp44
1 files changed, 38 insertions, 6 deletions
diff --git a/backends/sdl/graphics.cpp b/backends/sdl/graphics.cpp
index 09040f5c63..8a2ff446f5 100644
--- a/backends/sdl/graphics.cpp
+++ b/backends/sdl/graphics.cpp
@@ -134,7 +134,11 @@ bool OSystem_SDL::setGraphicsMode(int mode) {
}
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 @@ void OSystem_SDL::undraw_mouse() {
#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 @@ void OSystem_SDL::displayMessageOnOSD(const char *msg) {
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 @@ void OSystem_SDL::displayMessageOnOSD(const char *msg) {
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