X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=e54a016b4542caf01148424f68d24eb5cf96f529;hb=4e745044fe35b4b093b1490a6e3da0fe4ee512de;hp=f431f5b88fe49b818687a01e085aaf6e40d15c87;hpb=c4ee7a7b7a3f7184e210895b21c811680eaf8e4d;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index f431f5b8..e54a016b 100644 --- a/src/init.c +++ b/src/init.c @@ -157,10 +157,6 @@ inline void InitElementSmallImagesScaledUp(int graphic) // create small and game tile sized bitmaps (and scale up, if needed) CreateImageWithSmallImages(graphic, g->scale_up_factor, g->tile_size); - - // default (standard sized) bitmap may have changed now -- update it - if (g->bitmaps) - g->bitmap = g->bitmaps[IMG_BITMAP_STANDARD]; } void InitElementSmallImages() @@ -214,6 +210,17 @@ void InitScaledImages() ScaleImage(i, graphic_info[i].scale_up_factor); } +void InitBitmapPointers() +{ + int num_images = getImageListSize(); + int i; + + // standard size bitmap may have changed -- update default bitmap pointer + for (i = 0; i < num_images; i++) + if (graphic_info[i].bitmaps) + graphic_info[i].bitmap = graphic_info[i].bitmaps[IMG_BITMAP_STANDARD]; +} + #if 1 /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */ void SetBitmaps_EM(Bitmap **em_bitmap) @@ -1918,6 +1925,8 @@ static void ReinitializeGraphics() print_timestamp_time("InitElementSmallImages"); InitScaledImages(); /* scale all other images, if needed */ print_timestamp_time("InitScaledImages"); + InitBitmapPointers(); /* set standard size bitmap pointers */ + print_timestamp_time("InitBitmapPointers"); InitFontGraphicInfo(); /* initialize text drawing functions */ print_timestamp_time("InitFontGraphicInfo"); @@ -4469,6 +4478,33 @@ static void InitGlobal() font_info[i].token_name, int2str(i, 0)); + /* set default filenames for all cloned graphics in static configuration */ + for (i = 0; image_config[i].token != NULL; i++) + { + if (strEqual(image_config[i].value, UNDEFINED_FILENAME)) + { + char *token = image_config[i].token; + char *token_clone_from = getStringCat2(token, ".clone_from"); + char *token_cloned = getHashEntry(image_config_hash, token_clone_from); + + if (token_cloned != NULL) + { + char *value_cloned = getHashEntry(image_config_hash, token_cloned); + + if (value_cloned != NULL) + { + /* set default filename in static configuration */ + image_config[i].value = value_cloned; + + /* set default filename in image config hash */ + setHashEntry(image_config_hash, token, value_cloned); + } + } + + free(token_clone_from); + } + } + /* always start with reliable default values (all elements) */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) ActiveElement[i] = i; @@ -4698,6 +4734,12 @@ void Execute_Command(char *command) Error(ERR_EXIT, "image target directory '%s' not found or not writable", global.create_images_dir); } + else if (strPrefix(command, "create CE image ")) + { + CreateCustomElementImages(&command[16]); + + exit(0); + } #if DEBUG #if defined(TARGET_SDL2) @@ -4978,6 +5020,9 @@ void InitGfxBuffers() InitGfxScrollbufferInfo(FXSIZE, FYSIZE); InitGfxClipRegion(FALSE, -1, -1, -1, -1); + /* required if door size definitions have changed */ + InitGraphicCompatibilityInfo_Doors(); + InitGfxBuffers_EM(); InitGfxBuffers_SP(); } @@ -5030,6 +5075,7 @@ void InitGfx() InitGfxBuffers(); InitGfxCustomArtworkInfo(); + InitGfxOtherSettings(); bitmap_font_initial = LoadCustomImage(filename_font_initial); @@ -5041,52 +5087,79 @@ void InitGfx() font_height = getFontHeight(FC_RED); DrawInitText(getProgramInitString(), 20, FC_YELLOW); - DrawInitText(PROGRAM_COPYRIGHT_STRING, 50, FC_RED); - DrawInitText(PROGRAM_WEBSITE_STRING, WIN_YSIZE - 20 - font_height, FC_RED); + DrawInitText(setup.internal.program_copyright, 50, FC_RED); + DrawInitText(setup.internal.program_website, WIN_YSIZE - 20 - font_height, + FC_RED); DrawInitText("Loading graphics", 120, FC_GREEN); - /* initialize busy animation with default values */ + /* initialize settings for busy animation with default values */ int parameter[NUM_GFX_ARGS]; for (i = 0; i < NUM_GFX_ARGS; i++) parameter[i] = get_graphic_parameter_value(image_config_suffix[i].value, image_config_suffix[i].token, image_config_suffix[i].type); - /* determine settings for busy animation (when displaying startup messages) */ - for (i = 0; image_config[i].token != NULL; i++) + char *anim_token = CONFIG_TOKEN_GLOBAL_BUSY; + int len_anim_token = strlen(anim_token); + + /* read settings for busy animation from default custom artwork config */ + char *gfx_config_filename = getPath3(options.graphics_directory, + GFX_DEFAULT_SUBDIR, + GRAPHICSINFO_FILENAME); + + if (fileExists(gfx_config_filename)) { - char *anim_token = CONFIG_TOKEN_GLOBAL_BUSY; - int len_anim_token = strlen(anim_token); + SetupFileHash *setup_file_hash = loadSetupFileHash(gfx_config_filename); - if (strEqual(image_config[i].token, anim_token)) - filename_anim_initial = image_config[i].value; - else if (strlen(image_config[i].token) > len_anim_token && - strncmp(image_config[i].token, anim_token, len_anim_token) == 0) + if (setup_file_hash) { - for (j = 0; image_config_suffix[j].token != NULL; j++) + char *filename = getHashEntry(setup_file_hash, anim_token); + + if (filename) { - if (strEqual(&image_config[i].token[len_anim_token], - image_config_suffix[j].token)) - parameter[j] = - get_graphic_parameter_value(image_config[i].value, - image_config_suffix[j].token, - image_config_suffix[j].type); + filename_anim_initial = getStringCopy(filename); + + for (j = 0; image_config_suffix[j].token != NULL; j++) + { + int type = image_config_suffix[j].type; + char *suffix = image_config_suffix[j].token; + char *token = getStringCat2(anim_token, suffix); + char *value = getHashEntry(setup_file_hash, token); + + checked_free(token); + + if (value) + parameter[j] = get_graphic_parameter_value(value, suffix, type); + } } + + freeSetupFileHash(setup_file_hash); } } -#if defined(CREATE_SPECIAL_EDITION_RND_JUE) - filename_anim_initial = "loading.pcx"; - - parameter[GFX_ARG_X] = 0; - parameter[GFX_ARG_Y] = 0; - parameter[GFX_ARG_WIDTH] = 128; - parameter[GFX_ARG_HEIGHT] = 40; - parameter[GFX_ARG_FRAMES] = 32; - parameter[GFX_ARG_DELAY] = 4; - parameter[GFX_ARG_FRAMES_PER_LINE] = ARG_UNDEFINED_VALUE; -#endif + if (filename_anim_initial == NULL) + { + /* read settings for busy animation from static default artwork config */ + for (i = 0; image_config[i].token != NULL; i++) + { + if (strEqual(image_config[i].token, anim_token)) + filename_anim_initial = getStringCopy(image_config[i].value); + else if (strlen(image_config[i].token) > len_anim_token && + strncmp(image_config[i].token, anim_token, len_anim_token) == 0) + { + for (j = 0; image_config_suffix[j].token != NULL; j++) + { + if (strEqual(&image_config[i].token[len_anim_token], + image_config_suffix[j].token)) + parameter[j] = + get_graphic_parameter_value(image_config[i].value, + image_config_suffix[j].token, + image_config_suffix[j].type); + } + } + } + } if (filename_anim_initial == NULL) /* should not happen */ Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_GLOBAL_BUSY); @@ -5097,6 +5170,8 @@ void InitGfx() anim_initial.bitmaps[IMG_BITMAP_STANDARD] = LoadCustomImage(filename_anim_initial); + checked_free(filename_anim_initial); + graphic_info = &anim_initial; /* graphic == 0 => anim_initial */ set_graphic_parameters_ext(0, parameter, anim_initial.bitmaps); @@ -5113,7 +5188,7 @@ void InitGfx() init_last = init; } -void RedrawBackground() +void RedrawGlobalBorder() { BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); @@ -5530,7 +5605,7 @@ void ReloadCustomArtwork(int force_reload) FadeOut(REDRAW_ALL); - RedrawBackground(); + RedrawGlobalBorder(); /* force redraw of (open or closed) door graphics */ SetDoorState(DOOR_OPEN_ALL); @@ -5627,6 +5702,10 @@ void OpenAll() print_timestamp_time("[init global stuff]"); + InitSetup(); + + print_timestamp_time("[init setup/config stuff (1)]"); + if (options.execute_command) Execute_Command(options.execute_command); @@ -5641,10 +5720,6 @@ void OpenAll() exit(0); /* never reached, server loops forever */ } - InitSetup(); - - print_timestamp_time("[init setup/config stuff (1)]"); - InitGameInfo(); print_timestamp_time("[init setup/config stuff (2)]"); InitPlayerInfo();