X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=8b0d8ef39600de69f49b8916bea19047334d759c;hb=51cc8f17af487cc53aafccf050ff1b16fec878a9;hp=09cc36264890c39b235c6c8d2be0d0d8cc94dbd5;hpb=f224a5f80d2067f911e8fa0a19752b6783190fa7;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 09cc3626..8b0d8ef3 100644 --- a/src/init.c +++ b/src/init.c @@ -34,11 +34,17 @@ #define CONFIG_TOKEN_FONT_INITIAL "font.initial" +#define CONFIG_TOKEN_GLOBAL_BUSY_INITIAL "global.busy_initial" #define CONFIG_TOKEN_GLOBAL_BUSY "global.busy" +#define CONFIG_TOKEN_BACKGROUND_LOADING_INITIAL "background.LOADING_INITIAL" +#define CONFIG_TOKEN_BACKGROUND_LOADING "background.LOADING" -#define INITIAL_IMG_GLOBAL_BUSY 0 +#define INITIAL_IMG_GLOBAL_BUSY_INITIAL 0 +#define INITIAL_IMG_GLOBAL_BUSY 1 +#define INITIAL_IMG_BACKGROUND_LOADING_INITIAL 2 +#define INITIAL_IMG_BACKGROUND_LOADING 3 -#define NUM_INITIAL_IMAGES 1 +#define NUM_INITIAL_IMAGES 4 static struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS]; @@ -97,38 +103,61 @@ 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; + int background_image = (game_status_last_screen == -1 ? + INITIAL_IMG_BACKGROUND_LOADING_INITIAL : + INITIAL_IMG_BACKGROUND_LOADING); + + graphic_info = image_initial; + + SetDrawDeactivationMask(REDRAW_NONE); + SetDrawBackgroundMask(REDRAW_ALL); + + SetWindowBackgroundImage(background_image); + + graphic_info = graphic_info_last; +} + static void DrawInitAnim(void) { struct GraphicInfo *graphic_info_last = graphic_info; - int graphic = 0; + int graphic = (game_status_last_screen == -1 ? + INITIAL_IMG_GLOBAL_BUSY_INITIAL : + INITIAL_IMG_GLOBAL_BUSY); + struct MenuPosInfo *busy = (game_status_last_screen == -1 ? + &init_last.busy_initial : + &init_last.busy); static unsigned int action_delay = 0; unsigned int action_delay_value = GameFrameDelay; int sync_frame = FrameCounter; int x, y; + // prevent OS (Windows) from complaining about program not responding CheckQuitEvent(); if (game_status != GAME_MODE_LOADING) return; - if (image_initial[INITIAL_IMG_GLOBAL_BUSY].bitmap == NULL || window == NULL) + if (image_initial[graphic].bitmap == NULL || window == NULL) return; if (!DelayReached(&action_delay, action_delay_value)) return; - if (init_last.busy.x == -1) - init_last.busy.x = WIN_XSIZE / 2; - if (init_last.busy.y == -1) - init_last.busy.y = WIN_YSIZE / 2; + if (busy->x == -1) + busy->x = WIN_XSIZE / 2; + if (busy->y == -1) + busy->y = WIN_YSIZE / 2; - x = ALIGNED_TEXT_XPOS(&init_last.busy); - y = ALIGNED_TEXT_YPOS(&init_last.busy); + x = ALIGNED_TEXT_XPOS(busy); + y = ALIGNED_TEXT_YPOS(busy); - graphic_info = image_initial; // graphic == 0 => image_initial + graphic_info = image_initial; - if (sync_frame % image_initial[INITIAL_IMG_GLOBAL_BUSY].anim_delay == 0) + if (sync_frame % image_initial[graphic].anim_delay == 0) { Bitmap *src_bitmap; int src_x, src_y; @@ -136,8 +165,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; @@ -1698,6 +1731,8 @@ static void InitGraphicInfo(void) IMG_BACKGROUND_REQUEST, IMG_BACKGROUND, + IMG_BACKGROUND_LOADING_INITIAL, + IMG_BACKGROUND_LOADING, IMG_BACKGROUND_TITLE_INITIAL, IMG_BACKGROUND_TITLE, IMG_BACKGROUND_MAIN, @@ -1705,6 +1740,7 @@ static void InitGraphicInfo(void) IMG_BACKGROUND_LEVELS, IMG_BACKGROUND_LEVELNR, IMG_BACKGROUND_SCORES, + IMG_BACKGROUND_SCOREINFO, IMG_BACKGROUND_EDITOR, IMG_BACKGROUND_INFO, IMG_BACKGROUND_INFO_ELEMENTS, @@ -2280,11 +2316,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 +5582,10 @@ 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_INITIAL, + CONFIG_TOKEN_GLOBAL_BUSY, + CONFIG_TOKEN_BACKGROUND_LOADING_INITIAL, + CONFIG_TOKEN_BACKGROUND_LOADING }; Bitmap *bitmap_font_initial = NULL; int parameter[NUM_INITIAL_IMAGES][NUM_GFX_ARGS]; @@ -5717,8 +5751,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 +6193,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 +6233,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();