rnd-20061028-1-src
[rocksndiamonds.git] / src / tools.c
index 41ed06d693d078aa0c8d52cdce9efa773474f012..ddc8353b5c9da4a33b9d0caa3d3911f3690ac87d 100644 (file)
@@ -533,9 +533,8 @@ void FadeExt(int fade_mask, int fade_mode)
 {
   void (*draw_border_function)(void) = NULL;
   Bitmap *bitmap = (fade_mode == FADE_MODE_CROSSFADE ? bitmap_db_cross : NULL);
-  int fade_delay = menu.fade_delay;
-  int post_delay = (fade_mode == FADE_MODE_FADE_OUT ? menu.post_delay : 0);
   int x, y, width, height;
+  int fade_delay, post_delay;
 
   if (fade_mask & REDRAW_FIELD)
   {
@@ -544,6 +543,9 @@ void FadeExt(int fade_mask, int fade_mode)
     width  = FULL_SXSIZE;
     height = FULL_SYSIZE;
 
+    fade_delay = menu.fade_delay;
+    post_delay = (fade_mode == FADE_MODE_FADE_OUT ? menu.post_delay : 0);
+
     draw_border_function = DrawMaskedBorder_FIELD;
   }
   else         /* REDRAW_ALL */
@@ -552,6 +554,9 @@ void FadeExt(int fade_mask, int fade_mode)
     y = 0;
     width  = WIN_XSIZE;
     height = WIN_YSIZE;
+
+    fade_delay = title.fade_delay_final;
+    post_delay = (fade_mode == FADE_MODE_FADE_OUT ? title.post_delay_final : 0);
   }
 
   redraw_mask |= fade_mask;
@@ -622,21 +627,46 @@ void SetPanelBackground()
   SetDoorBackgroundBitmap(bitmap_db_panel);
 }
 
-void DrawBackground(int dst_x, int dst_y, int width, int height)
+void DrawBackground(int x, int y, int width, int height)
 {
-#if 1
-  ClearRectangleOnBackground(drawto, dst_x, dst_y, width, height);
+  /* !!! "drawto" might still point to playfield buffer here (see below) !!! */
+  /* (when entering hall of fame after playing) */
+#if 0
+  ClearRectangleOnBackground(drawto, x, y, width, height);
 #else
-  ClearRectangleOnBackground(backbuffer, dst_x, dst_y, width, height);
+  ClearRectangleOnBackground(backbuffer, x, y, width, height);
 #endif
 
   redraw_mask |= REDRAW_FIELD;
 }
 
+void DrawBackgroundForFont(int x, int y, int width, int height, int font_nr)
+{
+  struct FontBitmapInfo *font = getFontBitmapInfo(font_nr);
+
+  if (font->bitmap == NULL)
+    return;
+
+  DrawBackground(x, y, width, height);
+}
+
+void DrawBackgroundForGraphic(int x, int y, int width, int height, int graphic)
+{
+  struct GraphicInfo *g = &graphic_info[graphic];
+
+  if (g->bitmap == NULL)
+    return;
+
+  DrawBackground(x, y, width, height);
+}
+
 void ClearWindow()
 {
+  /* !!! "drawto" might still point to playfield buffer here (see above) !!! */
+  /* (when entering hall of fame after playing) */
   DrawBackground(REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE);
 
+  /* !!! maybe this should be done before clearing the background !!! */
   if (setup.soft_scrolling && game_status == GAME_MODE_PLAYING)
   {
     ClearRectangle(fieldbuffer, 0, 0, FXSIZE, FYSIZE);
@@ -2602,7 +2632,7 @@ boolean Request(char *text, unsigned int req_state)
 
       NextEvent(&event);
 
-      switch(event.type)
+      switch (event.type)
       {
        case EVENT_BUTTONPRESS:
        case EVENT_BUTTONRELEASE:
@@ -2634,7 +2664,7 @@ boolean Request(char *text, unsigned int req_state)
          /* this sets 'request_gadget_id' */
          HandleGadgets(mx, my, button_status);
 
-         switch(request_gadget_id)
+         switch (request_gadget_id)
          {
            case TOOL_CTRL_ID_YES:
              result = TRUE;
@@ -2667,7 +2697,7 @@ boolean Request(char *text, unsigned int req_state)
        }
 
        case EVENT_KEYPRESS:
-         switch(GetEventKey((KeyEvent *)&event, TRUE))
+         switch (GetEventKey((KeyEvent *)&event, TRUE))
          {
            case KSYM_Return:
              result = 1;
@@ -5341,7 +5371,7 @@ int map_direction_EM_to_RND(int direction)
 
 int get_next_element(int element)
 {
-  switch(element)
+  switch (element)
   {
     case EL_QUICKSAND_FILLING:         return EL_QUICKSAND_FULL;
     case EL_QUICKSAND_EMPTYING:                return EL_QUICKSAND_EMPTY;