added drawing global borders when fading screens
authorHolger Schemel <info@artsoft.org>
Tue, 22 Mar 2016 09:21:58 +0000 (10:21 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 22 Mar 2016 09:21:58 +0000 (10:21 +0100)
src/init.c
src/libgame/sdl.c
src/libgame/system.h
src/tools.c

index 149b4ef2709e0ef6d6d26cf17cf798c897f85b88..943839edba5acecd02e708e51bce2e444158806a 100644 (file)
@@ -5325,6 +5325,8 @@ void InitGfx()
   InitGfxDrawGlobalAnimFunction(DrawGlobalAnim);
   InitGfxDrawGlobalBorderFunction(DrawMaskedBorderToTarget);
 
+  gfx.fade_border_source_status = global.border_status;
+  gfx.fade_border_target_status = global.border_status;
   gfx.masked_border_bitmap_ptr = backbuffer;
 
   /* use copy of busy animation to prevent change while reloading artwork */
index 6b38ce15ba6fd28bcac51149c2629914932f0376..2e03378df85eb285caff378748294fed1ba59d41 100644 (file)
@@ -1148,16 +1148,23 @@ void SDLFadeRectangle(Bitmap *bitmap_cross, int x, int y, int width, int height,
   {
     SDL_BlitSurface(surface_cross,  &src_rect, surface_source, &src_rect);
     SDL_BlitSurface(surface_screen, &dst_rect, surface_target, &src_rect);
+
+    draw_global_border_function(DRAW_BORDER_TO_FADE_SOURCE);
+    draw_global_border_function(DRAW_BORDER_TO_FADE_TARGET);
   }
   else if (fade_mode & FADE_TYPE_FADE_IN)
   {
     SDL_BlitSurface(surface_black,  &src_rect, surface_source, &src_rect);
     SDL_BlitSurface(surface_screen, &dst_rect, surface_target, &src_rect);
+
+    draw_global_border_function(DRAW_BORDER_TO_FADE_TARGET);
   }
   else         /* FADE_TYPE_FADE_OUT */
   {
     SDL_BlitSurface(surface_screen, &dst_rect, surface_source, &src_rect);
     SDL_BlitSurface(surface_black,  &src_rect, surface_target, &src_rect);
+
+    draw_global_border_function(DRAW_BORDER_TO_FADE_SOURCE);
   }
 
   time_current = SDL_GetTicks();
index 7e6bcc1f812150d0d2ea611f80951871f5be0b85..98aa9c734422c31ac6b867feab2dc92539e49ccb 100644 (file)
 /* values for drawing target for global border */
 #define DRAW_BORDER_TO_BACKBUFFER      0
 #define DRAW_BORDER_TO_SCREEN          1
+#define DRAW_BORDER_TO_FADE_SOURCE     2
+#define DRAW_BORDER_TO_FADE_TARGET     3
 
 /* values for move directions and special "button" key bitmasks */
 #define MV_NONE                        0
@@ -819,6 +821,8 @@ struct GfxInfo
   Bitmap *fade_bitmap_target;
   Bitmap *fade_bitmap_black;
 
+  int fade_border_source_status;
+  int fade_border_target_status;
   Bitmap *masked_border_bitmap_ptr;
 
 #if USE_FINAL_SCREEN_BITMAP
index d72c99d09329fd1081e3ce962909089b4ca2fe85..3dcf88af26d04ebdcc2cff721e38734d10bcdc03 100644 (file)
@@ -384,7 +384,30 @@ void DrawMaskedBorder(int redraw_mask)
 
 void DrawMaskedBorderToTarget(int draw_target)
 {
-  DrawMaskedBorderExt(REDRAW_ALL, draw_target);
+  if (draw_target == DRAW_BORDER_TO_SCREEN)
+  {
+    DrawMaskedBorderExt(REDRAW_ALL, draw_target);
+  }
+  else
+  {
+    int last_border_status = global.border_status;
+
+    if (draw_target == DRAW_BORDER_TO_FADE_SOURCE)
+    {
+      global.border_status = gfx.fade_border_source_status;
+      gfx.masked_border_bitmap_ptr = gfx.fade_bitmap_source;
+    }
+    else
+    {
+      global.border_status = gfx.fade_border_target_status;
+      gfx.masked_border_bitmap_ptr = gfx.fade_bitmap_target;
+    }
+
+    DrawMaskedBorderExt(REDRAW_ALL, draw_target);
+
+    global.border_status = last_border_status;
+    gfx.masked_border_bitmap_ptr = backbuffer;
+  }
 }
 
 void BlitScreenToBitmap_RND(Bitmap *target_bitmap)
@@ -689,6 +712,9 @@ static void SetScreenStates_BeforeFadingIn()
 
 static void SetScreenStates_AfterFadingIn()
 {
+  // store new source screen (to use correct masked border for fading)
+  gfx.fade_border_source_status = global.border_status;
+
   global.anim_status = global.anim_status_next;
 
   // force update of global animation status in case of rapid screen changes
@@ -698,6 +724,9 @@ static void SetScreenStates_AfterFadingIn()
 
 static void SetScreenStates_BeforeFadingOut()
 {
+  // store new target screen (to use correct masked border for fading)
+  gfx.fade_border_target_status = game_status;
+
   global.anim_status = GAME_MODE_PSEUDO_FADING;
 }