X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Finit.c;h=a8017155d78226cad43a2891794f528a7bc913b6;hb=884012f34f9f3c22bf75d1468e4ed57d7795a24b;hp=4e715dff4ab4c80abc3e19cc4cfc1cf35d6c9ab7;hpb=db0cf963a41d958dc11ee1d3cfb2b1f88cba7f76;p=rocksndiamonds.git diff --git a/src/init.c b/src/init.c index 4e715dff..a8017155 100644 --- a/src/init.c +++ b/src/init.c @@ -167,12 +167,15 @@ static int getFontBitmapID(int font_nr) { int special = -1; - if (game_status >= GAME_MODE_TITLE && game_status <= GAME_MODE_PSEUDO_PREVIEW) + if (game_status >= GAME_MODE_TITLE_INITIAL && + game_status <= GAME_MODE_PSEUDO_PREVIEW) special = game_status; else if (game_status == GAME_MODE_PSEUDO_TYPENAME) special = GFX_SPECIAL_ARG_MAIN; +#if 0 else if (game_status == GAME_MODE_PLAYING) special = GFX_SPECIAL_ARG_DOOR; +#endif if (special != -1) return font_info[font_nr].special_bitmap_id[special]; @@ -180,6 +183,19 @@ static int getFontBitmapID(int font_nr) return font_nr; } +static int getFontFromToken(char *token) +{ + int i; + + /* !!! OPTIMIZE THIS BY USING HASH !!! */ + for (i = 0; i < NUM_FONTS; i++) + if (strEqual(token, font_info[i].token_name)) + return i; + + /* if font not found, use reliable default value */ + return FONT_INITIAL_1; +} + void InitFontGraphicInfo() { static struct FontBitmapInfo *font_bitmap_info = NULL; @@ -190,7 +206,8 @@ void InitFontGraphicInfo() if (graphic_info == NULL) /* still at startup phase */ { - InitFontInfo(font_initial, NUM_INITIAL_FONTS, getFontBitmapID); + InitFontInfo(font_initial, NUM_INITIAL_FONTS, + getFontBitmapID, getFontFromToken); return; } @@ -232,18 +249,21 @@ void InitFontGraphicInfo() int graphic = font_to_graphic[i].graphic; int base_graphic = font2baseimg(font_nr); - if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS) + if (IS_SPECIAL_GFX_ARG(special)) { boolean base_redefined = getImageListEntryFromImageID(base_graphic)->redefined; boolean special_redefined = getImageListEntryFromImageID(graphic)->redefined; + boolean special_cloned = (graphic_info[graphic].clone_from != -1); /* if the base font ("font.title_1", for example) has been redefined, but not the special font ("font.title_1.LEVELS", for example), do not use an existing (in this case considered obsolete) special font anymore, but use the automatically determined default font */ - if (base_redefined && !special_redefined) + /* special case: cloned special fonts must be explicitly redefined, + but are not automatically redefined by redefining base font */ + if (base_redefined && !special_redefined && !special_cloned) continue; font_info[font_nr].special_graphic[special] = graphic; @@ -262,7 +282,7 @@ void InitFontGraphicInfo() if (font_nr < 0) continue; - if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS) + if (IS_SPECIAL_GFX_ARG(special)) { font_info[font_nr].special_graphic[special] = graphic; font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps; @@ -270,6 +290,45 @@ void InitFontGraphicInfo() } } + /* correct special font/graphic mapping for cloned fonts for downwards + compatibility of PREVIEW fonts -- this is only needed for implicit + redefinition of special font by redefined base font, and only if other + fonts are cloned from this special font (like in the "Zelda" level set) */ + for (i = 0; font_to_graphic[i].font_nr > -1; i++) + { + int font_nr = font_to_graphic[i].font_nr; + int special = font_to_graphic[i].special; + int graphic = font_to_graphic[i].graphic; + + if (IS_SPECIAL_GFX_ARG(special)) + { + boolean special_redefined = + getImageListEntryFromImageID(graphic)->redefined; + boolean special_cloned = (graphic_info[graphic].clone_from != -1); + + if (special_cloned && !special_redefined) + { + int j; + + for (j = 0; font_to_graphic[j].font_nr > -1; j++) + { + int font_nr2 = font_to_graphic[j].font_nr; + int special2 = font_to_graphic[j].special; + int graphic2 = font_to_graphic[j].graphic; + + if (IS_SPECIAL_GFX_ARG(special2) && + graphic2 == graphic_info[graphic].clone_from) + { + font_info[font_nr].special_graphic[special] = + font_info[font_nr2].special_graphic[special2]; + font_info[font_nr].special_bitmap_id[special] = + font_info[font_nr2].special_bitmap_id[special2]; + } + } + } + } + } + /* reset non-redefined ".active" font graphics if normal font is redefined */ /* (this different treatment is needed because normal and active fonts are independently defined ("active" is not a property of font definitions!) */ @@ -367,7 +426,8 @@ void InitFontGraphicInfo() } } - InitFontInfo(font_bitmap_info, num_font_bitmaps, getFontBitmapID); + InitFontInfo(font_bitmap_info, num_font_bitmaps, + getFontBitmapID, getFontFromToken); } void InitElementGraphicInfo() @@ -866,7 +926,7 @@ void InitElementSpecialGraphicInfo() if (element >= MAX_NUM_ELEMENTS) continue; - if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS) + if (IS_SPECIAL_GFX_ARG(special)) element_info[element].special_graphic[special] = graphic; } @@ -976,6 +1036,7 @@ static void set_graphic_parameters(int graphic) graphic_info[graphic].post_delay = -1; graphic_info[graphic].auto_delay = -1; graphic_info[graphic].align = ALIGN_CENTER; /* default for title screens */ + graphic_info[graphic].valign = VALIGN_MIDDLE; /* default for title screens */ graphic_info[graphic].sort_priority = 0; /* default for title screens */ #if 1 @@ -1171,6 +1232,8 @@ static void set_graphic_parameters(int graphic) graphic_info[graphic].auto_delay = parameter[GFX_ARG_AUTO_DELAY]; if (parameter[GFX_ARG_ALIGN] != ARG_UNDEFINED_VALUE) graphic_info[graphic].align = parameter[GFX_ARG_ALIGN]; + if (parameter[GFX_ARG_VALIGN] != ARG_UNDEFINED_VALUE) + graphic_info[graphic].valign = parameter[GFX_ARG_VALIGN]; if (parameter[GFX_ARG_SORT_PRIORITY] != ARG_UNDEFINED_VALUE) graphic_info[graphic].sort_priority = parameter[GFX_ARG_SORT_PRIORITY]; } @@ -1240,8 +1303,8 @@ static void InitGraphicInfo() IMG_BACKGROUND_ENVELOPE_4, IMG_BACKGROUND, + IMG_BACKGROUND_TITLE_INITIAL, IMG_BACKGROUND_TITLE, - IMG_BACKGROUND_MESSAGE, IMG_BACKGROUND_MAIN, IMG_BACKGROUND_LEVELS, IMG_BACKGROUND_SCORES, @@ -1590,7 +1653,7 @@ static void set_sound_parameters(int sound, char **parameter_raw) sound_info[sound].volume = parameter[SND_ARG_VOLUME]; /* sound priority to give certain sounds a higher or lower priority */ - sound_info[sound].volume = parameter[SND_ARG_VOLUME]; + sound_info[sound].priority = parameter[SND_ARG_PRIORITY]; } static void InitSoundInfo() @@ -1965,7 +2028,7 @@ boolean getBitfieldProperty(int *bitfield, int property_bit_nr, int element) return FALSE; } -static void resolve_group_element(int group_element, int recursion_depth) +static void ResolveGroupElementExt(int group_element, int recursion_depth) { static int group_nr; static struct ElementGroupInfo *group; @@ -1989,10 +2052,13 @@ static void resolve_group_element(int group_element, int recursion_depth) if (recursion_depth == 0) /* initialization */ { group = actual_group; - group_nr = group_element - EL_GROUP_START; + group_nr = GROUP_NR(group_element); group->num_elements_resolved = 0; group->choice_pos = 0; + + for (i = 0; i < MAX_NUM_ELEMENTS; i++) + element_info[i].in_group[group_nr] = FALSE; } for (i = 0; i < actual_group->num_elements; i++) @@ -2003,7 +2069,7 @@ static void resolve_group_element(int group_element, int recursion_depth) break; if (IS_GROUP_ELEMENT(element)) - resolve_group_element(element, recursion_depth + 1); + ResolveGroupElementExt(element, recursion_depth + 1); else { group->element_resolved[group->num_elements_resolved++] = element; @@ -2012,6 +2078,11 @@ static void resolve_group_element(int group_element, int recursion_depth) } } +void ResolveGroupElement(int group_element) +{ + ResolveGroupElementExt(group_element, 0); +} + void InitElementPropertiesStatic() { static int ep_diggable[] = @@ -4023,14 +4094,9 @@ void InitElementPropertiesEngine(int engine_version) property (which means that conditional property changes must be set to a reliable default value before) */ - /* ---------- recursively resolve group elements ------------------------- */ - - for (i = 0; i < MAX_NUM_ELEMENTS; i++) - for (j = 0; j < NUM_GROUP_ELEMENTS; j++) - element_info[i].in_group[j] = FALSE; - + /* resolve group elements */ for (i = 0; i < NUM_GROUP_ELEMENTS; i++) - resolve_group_element(EL_GROUP_START + i, 0); + ResolveGroupElement(EL_GROUP_START + i); /* set all special, combined or engine dependent element properties */ for (i = 0; i < MAX_NUM_ELEMENTS; i++) @@ -5045,6 +5111,8 @@ void ReloadCustomArtwork(int force_reload) /* force redraw of (open or closed) door graphics */ SetDoorState(DOOR_OPEN_ALL); CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY); + + fading = fading_none; } } @@ -5129,6 +5197,8 @@ void OpenAll() return; } + fading = fading_none; + game_status = GAME_MODE_MAIN; DrawMainMenu();