added support for background image for loading screen
authorHolger Schemel <info@artsoft.org>
Mon, 14 Mar 2022 00:53:55 +0000 (01:53 +0100)
committerHolger Schemel <info@artsoft.org>
Tue, 15 Mar 2022 23:52:29 +0000 (00:52 +0100)
src/conf_gfx.c
src/init.c
src/libgame/text.c
src/screens.c

index 9d5db3f167eed1e00132329664ae3e82be7069fc..3b39306a53007f4df03272fb227bd04cddd41765 100644 (file)
@@ -7343,6 +7343,7 @@ struct ConfigInfo image_config[] =
   { "global.tile_cursor.frames",               "1"                     },
 
   { "background",                              UNDEFINED_FILENAME      },
+  { "background.LOADING",                      UNDEFINED_FILENAME      },
   { "background.TITLE_INITIAL",                        UNDEFINED_FILENAME      },
   { "background.TITLE",                                UNDEFINED_FILENAME      },
   { "background.MAIN",                         UNDEFINED_FILENAME      },
index 09cc36264890c39b235c6c8d2be0d0d8cc94dbd5..041098f2665f427118e8e5a8bce1b539d17e50f2 100644 (file)
 
 #define CONFIG_TOKEN_FONT_INITIAL              "font.initial"
 #define CONFIG_TOKEN_GLOBAL_BUSY               "global.busy"
+#define CONFIG_TOKEN_BACKGROUND_LOADING                "background.LOADING"
 
 #define INITIAL_IMG_GLOBAL_BUSY                        0
+#define INITIAL_IMG_BACKGROUND_LOADING         1
 
-#define NUM_INITIAL_IMAGES                     1
+#define NUM_INITIAL_IMAGES                     2
 
 
 static struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS];
@@ -97,6 +99,20 @@ static int copy_properties[][5] =
 static int get_graphic_parameter_value(char *, char *, int);
 
 
+static void SetLoadingBackgroundImage(void)
+{
+  struct GraphicInfo *graphic_info_last = graphic_info;
+
+  graphic_info = image_initial;
+
+  SetDrawDeactivationMask(REDRAW_NONE);
+  SetDrawBackgroundMask(REDRAW_ALL);
+
+  SetWindowBackgroundImage(INITIAL_IMG_BACKGROUND_LOADING);
+
+  graphic_info = graphic_info_last;
+}
+
 static void DrawInitAnim(void)
 {
   struct GraphicInfo *graphic_info_last = graphic_info;
@@ -136,8 +152,12 @@ static void DrawInitAnim(void)
     int height = graphic_info[graphic].height;
     int frame = getGraphicAnimationFrame(graphic, sync_frame);
 
+    ClearRectangleOnBackground(drawto, x, y, width, height);
+
     getFixedGraphicSource(graphic, frame, &src_bitmap, &src_x, &src_y);
-    BlitBitmap(src_bitmap, window, src_x, src_y, width, height, x, y);
+    BlitBitmapMasked(src_bitmap, drawto, src_x, src_y, width, height, x, y);
+
+    BlitBitmap(drawto, window, x, y, width, height, x, y);
   }
 
   graphic_info = graphic_info_last;
@@ -2280,11 +2300,6 @@ static void ReinitializeGraphics(void)
   InitGraphicCompatibilityInfo();
   print_timestamp_time("InitGraphicCompatibilityInfo");
 
-  SetMainBackgroundImage(IMG_BACKGROUND);
-  print_timestamp_time("SetMainBackgroundImage");
-  SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
-  print_timestamp_time("SetDoorBackgroundImage");
-
   InitGadgets();
   print_timestamp_time("InitGadgets");
   InitDoors();
@@ -5551,7 +5566,8 @@ static void InitGfx(void)
   char *filename_image_initial[NUM_INITIAL_IMAGES] = { NULL };
   char *image_token[NUM_INITIAL_IMAGES] =
   {
-    CONFIG_TOKEN_GLOBAL_BUSY
+    CONFIG_TOKEN_GLOBAL_BUSY,
+    CONFIG_TOKEN_BACKGROUND_LOADING
   };
   Bitmap *bitmap_font_initial = NULL;
   int parameter[NUM_INITIAL_IMAGES][NUM_GFX_ARGS];
@@ -5717,8 +5733,9 @@ static void InitGfx(void)
 
   graphic_info = graphic_info_last;
 
-  init.busy.width  = image_initial[INITIAL_IMG_GLOBAL_BUSY].width;
-  init.busy.height = image_initial[INITIAL_IMG_GLOBAL_BUSY].height;
+  SetLoadingBackgroundImage();
+
+  ClearRectangleOnBackground(window, 0, 0, WIN_XSIZE, WIN_YSIZE);
 
   InitGfxDrawBusyAnimFunction(DrawInitAnim);
   InitGfxDrawGlobalAnimFunction(DrawGlobalAnimations);
@@ -6158,11 +6175,15 @@ void ReloadCustomArtwork(int force_reload)
 
   FadeOut(REDRAW_ALL);
 
-  ClearRectangle(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
-  print_timestamp_time("ClearRectangle");
+  SetLoadingBackgroundImage();
+
+  ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE);
+  print_timestamp_time("ClearRectangleOnBackground");
 
   FadeIn(REDRAW_ALL);
 
+  UPDATE_BUSY_STATE();
+
   if (gfx_new_identifier != NULL || force_reload_gfx)
   {
 #if 0
@@ -6194,8 +6215,6 @@ void ReloadCustomArtwork(int force_reload)
 
   SetGameStatus(last_game_status);     // restore current game status
 
-  init_last = init;                    // switch to new busy animation
-
   FadeOut(REDRAW_ALL);
 
   RedrawGlobalBorder();
index 0c586f10d6ae251e4d600e644bb8a1c33b4303fa..36096240203880ba31d6744f0c9bab2d9cc05eb0 100644 (file)
@@ -152,8 +152,8 @@ static void DrawInitTextExt(char *text, int ypos, int font_nr, boolean update)
     int width = video.width;
     int height = getFontHeight(font_nr);
 
-    ClearRectangle(drawto, 0, y, width, height);
-    DrawTextExt(drawto, x, y, text, font_nr, BLIT_OPAQUE);
+    ClearRectangleOnBackground(drawto, 0, y, width, height);
+    DrawTextExt(drawto, x, y, text, font_nr, BLIT_MASKED);
 
     if (update)
       BlitBitmap(drawto, window, 0, 0, video.width, video.height, 0, 0);
index c47d19f2679f50e267310a3a22063825920fcec5..8b70372f58931af42d77a303e8f2a071502b6fed 100644 (file)
@@ -1688,8 +1688,6 @@ void DrawMainMenu(void)
   // store valid level series information
   leveldir_last_valid = leveldir_current;
 
-  init_last = init;                    // switch to new busy animation
-
   // needed if last screen (level choice) changed graphics, sounds or music
   ReloadCustomArtwork(0);