rnd-20070310-1-src
[rocksndiamonds.git] / src / libgame / sdl.c
index 2395cd042813bc7c043cbdb734eb44ca94380ec8..605f2342eed2b6fa162c1a1c86ead1efa5602186 100644 (file)
@@ -35,12 +35,12 @@ static int fullscreen_yoffset;
 static int video_xoffset;
 static int video_yoffset;
 
-static void setFullscreenParameters()
+static void setFullscreenParameters(char *fullscreen_mode_string)
 {
   struct ScreenModeInfo *fullscreen_mode;
   int i;
 
-  fullscreen_mode = get_screen_mode_from_string(setup.fullscreen_mode);
+  fullscreen_mode = get_screen_mode_from_string(fullscreen_mode_string);
 
   if (fullscreen_mode == NULL)
     return;
@@ -63,6 +63,10 @@ static void setFullscreenParameters()
 
 static void SDLSetWindowIcon(char *basename)
 {
+  /* (setting the window icon on Mac OS X would replace the high-quality
+     dock icon with the currently smaller (and uglier) icon from file) */
+
+#if !defined(PLATFORM_MACOSX)
   char *filename = getCustomImageFilename(basename);
   SDL_Surface *surface;
 
@@ -85,11 +89,15 @@ static void SDLSetWindowIcon(char *basename)
                  SDL_MapRGB(surface->format, 0x00, 0x00, 0x00));
 
   SDL_WM_SetIcon(surface, NULL);
+#endif
 }
 
 void SDLInitVideoDisplay(void)
 {
-  putenv("SDL_VIDEO_CENTERED=1");
+  if (!strEqual(setup.system.sdl_videodriver, ARG_DEFAULT))
+    SDL_putenv(getStringCat2("SDL_VIDEODRIVER=", setup.system.sdl_videodriver));
+
+  SDL_putenv("SDL_VIDEO_CENTERED=1");
 
   /* initialize SDL video */
   if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
@@ -235,7 +243,7 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
 
   if (fullscreen && !video.fullscreen_enabled && video.fullscreen_available)
   {
-    setFullscreenParameters();
+    setFullscreenParameters(setup.fullscreen_mode);
 
     video_xoffset = fullscreen_xoffset;
     video_yoffset = fullscreen_yoffset;
@@ -250,6 +258,7 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
 
       /* do not try it again */
       video.fullscreen_available = FALSE;
+
       success = FALSE;
     }
     else
@@ -257,6 +266,8 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
       (*backbuffer)->surface = new_surface;
 
       video.fullscreen_enabled = TRUE;
+      video.fullscreen_mode_current = setup.fullscreen_mode;
+
       success = TRUE;
     }
   }
@@ -378,7 +389,8 @@ void SDLFillRectangle(Bitmap *dst_bitmap, int x, int y, int width, int height,
 }
 
 void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,
-                     int fade_mode, int fade_delay, int post_delay)
+                     int fade_mode, int fade_delay, int post_delay,
+                     void (*draw_border_function)(void))
 {
   static boolean initialization_needed = TRUE;
   static SDL_Surface *surface_source = NULL;
@@ -492,6 +504,9 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,
     SDL_SetAlpha(surface_target, SDL_SRCALPHA, alpha_final);
     SDL_BlitSurface(surface_target, &src_rect, surface_screen, &dst_rect);
 
+    if (draw_border_function != NULL)
+      draw_border_function();
+
 #if 1
     /* only update the region of the screen that is affected from fading */
     SDL_UpdateRect(surface_screen, dst_x, dst_y, width, height);
@@ -1572,7 +1587,7 @@ void SDLSetMouseCursor(struct MouseCursorInfo *cursor_info)
 void SDLOpenAudio(void)
 {
   if (!strEqual(setup.system.sdl_audiodriver, ARG_DEFAULT))
-    putenv(getStringCat2("SDL_AUDIODRIVER=", setup.system.sdl_audiodriver));
+    SDL_putenv(getStringCat2("SDL_AUDIODRIVER=", setup.system.sdl_audiodriver));
 
   if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
   {