rnd-20060816-2-src
[rocksndiamonds.git] / src / tools.c
index 866870a29d10e2ba5b09daa57836bc5ba06e8139..72b5a2902aa290a0dc57f47b64a98cefaf1d2826 100644 (file)
@@ -414,48 +414,60 @@ void FadeToFront()
   BackToFront();
 }
 
-void FadeIn(int fade_delay)
+void FadeExt(int fade_mask, int fade_mode)
 {
-  if (fade_delay == 0)
-  {
-    BackToFront();
+  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;
 
-    return;
+  if (fade_mask & REDRAW_ALL)
+  {
+    x = 0;
+    y = 0;
+    width  = WIN_XSIZE;
+    height = WIN_YSIZE;
+  }
+  else if (fade_mask & REDRAW_FIELD)
+  {
+    x = REAL_SX;
+    y = REAL_SY;
+    width  = FULL_SXSIZE;
+    height = FULL_SYSIZE;
   }
 
-  FadeScreen(NULL, FADE_MODE_FADE_IN, fade_delay, 0);
+  redraw_mask |= fade_mask;
 
-  redraw_mask = REDRAW_NONE;
-}
-
-void FadeOut(int fade_delay, int post_delay)
-{
   if (fade_delay == 0)
   {
-    ClearRectangle(backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE);
+    if (fade_mode == FADE_MODE_CROSSFADE)
+      BlitBitmap(bitmap, backbuffer, x, y, width, height, x, y);
+    else if (fade_mode == FADE_MODE_FADE_OUT)
+      ClearRectangle(backbuffer, x, y, width, height);
+
     BackToFront();
 
     return;
   }
 
-  FadeScreen(NULL, FADE_MODE_FADE_OUT, fade_delay, post_delay);
+  FadeRectangle(bitmap, x, y, width, height, fade_mode, fade_delay, post_delay);
 
-  redraw_mask = REDRAW_NONE;
+  redraw_mask &= ~fade_mask;
 }
 
-void FadeCross(int fade_delay)
+void FadeIn(int fade_mask)
 {
-  if (fade_delay == 0)
-  {
-    BlitBitmap(bitmap_db_title, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0);
-    BackToFront();
-
-    return;
-  }
+  FadeExt(fade_mask, FADE_MODE_FADE_IN);
+}
 
-  FadeScreen(bitmap_db_title, FADE_MODE_CROSSFADE, fade_delay, 0);
+void FadeOut(int fade_mask)
+{
+  FadeExt(fade_mask, FADE_MODE_FADE_OUT);
+}
 
-  redraw_mask = REDRAW_NONE;
+void FadeCross(int fade_mask)
+{
+  FadeExt(fade_mask, FADE_MODE_CROSSFADE);
 }
 
 void SetMainBackgroundImageIfDefined(int graphic)
@@ -480,9 +492,21 @@ void SetDoorBackgroundImage(int graphic)
                          graphic_info[IMG_BACKGROUND].bitmap);
 }
 
+void SetPanelBackground()
+{
+  BlitBitmap(graphic_info[IMG_GLOBAL_DOOR].bitmap, bitmap_db_panel,
+             DOOR_GFX_PAGEX5, DOOR_GFX_PAGEY1, DXSIZE, DYSIZE, 0, 0);
+
+  SetDoorBackgroundBitmap(bitmap_db_panel);
+}
+
 void DrawBackground(int dst_x, int dst_y, int width, int height)
 {
+#if 1
+  ClearRectangleOnBackground(drawto, dst_x, dst_y, width, height);
+#else
   ClearRectangleOnBackground(backbuffer, dst_x, dst_y, width, height);
+#endif
 
   redraw_mask |= REDRAW_FIELD;
 }
@@ -2049,8 +2073,15 @@ void DrawPlayer(struct PlayerInfo *player)
       GfxElement[jx][jy] = EL_UNDEFINED;
 
       /* make sure that pushed elements are drawn with correct frame rate */
+#if 1
+      graphic = el_act_dir2img(element, ACTION_PUSHING, move_dir);
+
+      if (player->is_pushing && player->is_moving && !IS_ANIM_MODE_CE(graphic))
+       GfxFrame[jx][jy] = player->StepFrame;
+#else
       if (player->is_pushing && player->is_moving)
        GfxFrame[jx][jy] = player->StepFrame;
+#endif
 
       DrawLevelField(jx, jy);
     }
@@ -2110,15 +2141,26 @@ void DrawPlayer(struct PlayerInfo *player)
     int px = SCREENX(jx), py = SCREENY(jy);
     int pxx = (TILEX - ABS(sxx)) * dx;
     int pyy = (TILEY - ABS(syy)) * dy;
+    int gfx_frame = GfxFrame[jx][jy];
 
     int graphic;
+    int sync_frame;
     int frame;
 
     if (!IS_MOVING(jx, jy))            /* push movement already finished */
+    {
       element = Feld[next_jx][next_jy];
+      gfx_frame = GfxFrame[next_jx][next_jy];
+    }
 
     graphic = el_act_dir2img(element, ACTION_PUSHING, move_dir);
+
+#if 1
+    sync_frame = (IS_ANIM_MODE_CE(graphic) ? gfx_frame : player->StepFrame);
+    frame = getGraphicAnimationFrame(graphic, sync_frame);
+#else
     frame = getGraphicAnimationFrame(graphic, player->StepFrame);
+#endif
 
     /* draw background element under pushed element (like the Sokoban field) */
     if (Back[next_jx][next_jy])
@@ -2306,6 +2348,10 @@ boolean Request(char *text, unsigned int req_state)
               DOOR_GFX_PAGEX2, DOOR_GFX_PAGEY1);
   }
 
+#if 1
+  SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
+#endif
+
   SetDrawBackgroundMask(REDRAW_FIELD | REDRAW_DOOR_1);
 
   /* clear door drawing field */
@@ -2375,7 +2421,15 @@ boolean Request(char *text, unsigned int req_state)
 
   if (!(req_state & REQUEST_WAIT_FOR_INPUT))
   {
-    SetDrawBackgroundMask(REDRAW_FIELD);
+    if (game_status == GAME_MODE_PLAYING)
+    {
+      SetPanelBackground();
+      SetDrawBackgroundMask(REDRAW_DOOR_1);
+    }
+    else
+    {
+      SetDrawBackgroundMask(REDRAW_FIELD);
+    }
 
     return FALSE;
   }
@@ -2520,7 +2574,15 @@ boolean Request(char *text, unsigned int req_state)
 
   RemapAllGadgets();
 
-  SetDrawBackgroundMask(REDRAW_FIELD);
+  if (game_status == GAME_MODE_PLAYING)
+  {
+    SetPanelBackground();
+    SetDrawBackgroundMask(REDRAW_DOOR_1);
+  }
+  else
+  {
+    SetDrawBackgroundMask(REDRAW_FIELD);
+  }
 
 #if defined(NETWORK_AVALIABLE)
   /* continue network game after request */