From: Holger Schemel Date: Sun, 23 Feb 2003 20:05:21 +0000 (+0100) Subject: rnd-20030223-3-src X-Git-Tag: 3.0.0^2~134 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=9ec014a4e4a6a2332bb45c6cea8cccc46c64c6ae;p=rocksndiamonds.git rnd-20030223-3-src --- diff --git a/src/conf_fnt.c b/src/conf_fnt.c index d94f047d..2ec5e1be 100644 --- a/src/conf_fnt.c +++ b/src/conf_fnt.c @@ -91,10 +91,6 @@ font_to_graphic[] = FONT_SMALL_4, -1, IMG_FONT_SMALL_4 }, - { - FONT_SMALL_3, GFX_SPECIAL_ARG_EDITOR, - IMG_FONT_SMALL_3 - }, { FONT_TAPE, -1, IMG_FONT_TAPE diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 58cd51b6..d73f922a 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -2984,12 +2984,6 @@ struct ConfigInfo image_config[] = { "font.small_4.width", "14" }, { "font.small_4.height", "14" }, - { "font.small_3.EDITOR", "RocksFontSmall.pcx" }, - { "font.small_3.EDITOR.x", "0" }, - { "font.small_3.EDITOR.y", "0" }, - { "font.small_3.EDITOR.width", "14" }, - { "font.small_3.EDITOR.height", "14" }, - { "font.tape", "RocksFontSmall.pcx" }, { "font.tape.x", "0" }, { "font.tape.y", "224" }, diff --git a/src/conf_gfx.h b/src/conf_gfx.h index de87a85d..73418226 100644 --- a/src/conf_gfx.h +++ b/src/conf_gfx.h @@ -820,26 +820,25 @@ #define IMG_FONT_SMALL_2 799 #define IMG_FONT_SMALL_3 800 #define IMG_FONT_SMALL_4 801 -#define IMG_FONT_SMALL_3_EDITOR 802 -#define IMG_FONT_TAPE 803 -#define IMG_FONT_GAME 804 -#define IMG_FONT_NARROW 805 -#define IMG_GLOBAL_BORDER 806 -#define IMG_GLOBAL_DOOR 807 -#define IMG_BACKGROUND 808 -#define IMG_BACKGROUND_MAIN 809 -#define IMG_BACKGROUND_LEVELS 810 -#define IMG_BACKGROUND_SCORES 811 -#define IMG_BACKGROUND_EDITOR 812 -#define IMG_BACKGROUND_INFO 813 -#define IMG_BACKGROUND_SETUP 814 -#define IMG_BACKGROUND_DOOR 815 -#define IMG_INFO_FONT_EM_1 816 -#define IMG_INFO_FONT_EM_2 817 -#define IMG_INFO_FONT_EM_3 818 -#define IMG_INFO_FONT_EM_4 819 -#define IMG_INFO_FONT_EM_5 820 +#define IMG_FONT_TAPE 802 +#define IMG_FONT_GAME 803 +#define IMG_FONT_NARROW 804 +#define IMG_GLOBAL_BORDER 805 +#define IMG_GLOBAL_DOOR 806 +#define IMG_BACKGROUND 807 +#define IMG_BACKGROUND_MAIN 808 +#define IMG_BACKGROUND_LEVELS 809 +#define IMG_BACKGROUND_SCORES 810 +#define IMG_BACKGROUND_EDITOR 811 +#define IMG_BACKGROUND_INFO 812 +#define IMG_BACKGROUND_SETUP 813 +#define IMG_BACKGROUND_DOOR 814 +#define IMG_INFO_FONT_EM_1 815 +#define IMG_INFO_FONT_EM_2 816 +#define IMG_INFO_FONT_EM_3 817 +#define IMG_INFO_FONT_EM_4 818 +#define IMG_INFO_FONT_EM_5 819 -#define NUM_IMAGE_FILES 821 +#define NUM_IMAGE_FILES 820 #endif /* CONF_GFX_H */ diff --git a/src/conftime.h b/src/conftime.h index 349eb876..200c6135 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-02-23 18:48]" +#define COMPILE_DATE_STRING "[2003-02-23 21:04]" diff --git a/src/init.c b/src/init.c index 3d1ef64f..8026ab9d 100644 --- a/src/init.c +++ b/src/init.c @@ -28,6 +28,7 @@ #include "conf_e2g.c" /* include auto-generated data structure definitions */ #include "conf_esg.c" /* include auto-generated data structure definitions */ +#include "conf_fnt.c" /* include auto-generated data structure definitions */ #define CONFIG_TOKEN_FONT_INITIAL "font.initial" @@ -163,11 +164,11 @@ static void InitArtworkInfo() static void InitArtworkConfig() { - static char *element_prefix[MAX_NUM_ELEMENTS + 1]; - static char *sound_class_prefix[MAX_NUM_ELEMENTS + 1]; - static char *action_suffix[NUM_ACTIONS + 1]; - static char *direction_suffix[NUM_DIRECTIONS + 1]; - static char *special_suffix[NUM_SPECIAL_GFX_ARGS + 1]; + static char *image_id_prefix[MAX_NUM_ELEMENTS + NUM_FONTS + 1]; + static char *sound_id_prefix[MAX_NUM_ELEMENTS + 1]; + static char *action_id_suffix[NUM_ACTIONS + 1]; + static char *direction_id_suffix[NUM_DIRECTIONS + 1]; + static char *special_id_suffix[NUM_SPECIAL_GFX_ARGS + 1]; static char *dummy[1] = { NULL }; static char *ignore_image_tokens[] = { @@ -185,22 +186,28 @@ static void InitArtworkConfig() }; int i; + for (i=0; i -1; i++) CreateImageWithSmallImages(element_to_special_graphic[i].graphic); - /* !!! CHECK FOR ELEMENT-ONLY GRAPHICS !!! */ /* initialize images from dynamic configuration */ for (i=0; i < num_property_mappings; i++) - CreateImageWithSmallImages(property_mapping[i].artwork_index); + if (property_mapping[i].artwork_index < MAX_NUM_ELEMENTS) + CreateImageWithSmallImages(property_mapping[i].artwork_index); +} + +static int getFontBitmapID(int font_nr) +{ + if (game_status == LEVELED) + return font_info[font_nr].special_bitmap_id[GFX_SPECIAL_ARG_EDITOR]; + else + return font_nr; } void InitFontGraphicInfo() { - static struct FontBitmapInfo font_bitmap_info[NUM_IMG_FONTS]; - int num_fonts = NUM_IMG_FONTS; - int i; + static struct FontBitmapInfo *font_bitmap_info = NULL; + struct PropertyMapping *property_mapping = getImageListPropertyMapping(); + int num_property_mappings = getImageListPropertyMappingSize(); + int num_font_bitmaps = NUM_FONTS; + int i, j; if (graphic_info == NULL) /* still at startup phase */ - num_fonts = NUM_INITIAL_FONTS; + { + InitFontInfo(font_initial, NUM_INITIAL_FONTS, getFontBitmapID); + + return; + } + + /* ---------- initialize font graphic definitions ---------- */ + + /* always start with reliable default values (normal font graphics) */ + for (i=0; i < NUM_FONTS; i++) + font_info[i].graphic = FONT_INITIAL_1; + + /* initialize normal font/graphic mapping from static configuration */ + 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 (special != -1) + continue; + + font_info[font_nr].graphic = graphic; + } + + /* always start with reliable default values (special font graphics) */ + for (i=0; i < NUM_FONTS; i++) + { + for (j=0; j < NUM_SPECIAL_GFX_ARGS; j++) + { + font_info[i].special_graphic[j] = font_info[i].graphic; + font_info[i].special_bitmap_id[j] = i; + } + } + + /* initialize special font/graphic mapping from static configuration */ + 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 (special >= 0 && special < NUM_SPECIAL_GFX_ARGS) + { + font_info[font_nr].special_graphic[special] = graphic; + font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps; + num_font_bitmaps++; + } + } + + /* initialize special element/graphic mapping from dynamic configuration */ + for (i=0; i < num_property_mappings; i++) + { + int font_nr = property_mapping[i].base_index - MAX_NUM_ELEMENTS; + int special = property_mapping[i].ext3_index; + int graphic = property_mapping[i].artwork_index; + + if (font_nr < 0) + continue; + + if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS) + { + font_info[font_nr].special_graphic[special] = graphic; + font_info[font_nr].special_bitmap_id[special] = num_font_bitmaps; + num_font_bitmaps++; + } + } + + /* ---------- initialize font bitmap array ---------- */ - for (i=0; i < num_fonts; i++) + if (font_bitmap_info != NULL) + free(font_bitmap_info); + + font_bitmap_info = + checked_calloc(num_font_bitmaps * sizeof(struct FontBitmapInfo)); + + /* ---------- initialize font bitmap definitions ---------- */ + + for (i=0; i < NUM_FONTS; i++) { if (i < NUM_INITIAL_FONTS) + { font_bitmap_info[i] = font_initial[i]; - else + continue; + } + + for (j=0; j < NUM_SPECIAL_GFX_ARGS; j++) { + int font_bitmap_id = font_info[i].special_bitmap_id[j]; + int graphic = font_info[i].special_graphic[j]; + /* copy font relevant information from graphics information */ - font_bitmap_info[i].bitmap = graphic_info[FIRST_IMG_FONT + i].bitmap; - font_bitmap_info[i].src_x = graphic_info[FIRST_IMG_FONT + i].src_x; - font_bitmap_info[i].src_y = graphic_info[FIRST_IMG_FONT + i].src_y; - font_bitmap_info[i].width = graphic_info[FIRST_IMG_FONT + i].width; - font_bitmap_info[i].height = graphic_info[FIRST_IMG_FONT + i].height; - font_bitmap_info[i].draw_x = graphic_info[FIRST_IMG_FONT + i].draw_x; - font_bitmap_info[i].draw_y = graphic_info[FIRST_IMG_FONT + i].draw_y; + font_bitmap_info[font_bitmap_id].bitmap = graphic_info[graphic].bitmap; + font_bitmap_info[font_bitmap_id].src_x = graphic_info[graphic].src_x; + font_bitmap_info[font_bitmap_id].src_y = graphic_info[graphic].src_y; + font_bitmap_info[font_bitmap_id].width = graphic_info[graphic].width; + font_bitmap_info[font_bitmap_id].height = graphic_info[graphic].height; + font_bitmap_info[font_bitmap_id].draw_x = graphic_info[graphic].draw_x; + font_bitmap_info[font_bitmap_id].draw_y = graphic_info[graphic].draw_y; } } - InitFontInfo(font_bitmap_info, num_fonts); + InitFontInfo(font_bitmap_info, num_font_bitmaps, getFontBitmapID); } void InitElementGraphicInfo() @@ -775,16 +875,6 @@ void InitElementGraphicInfo() } } -#if 0 - for (i=EL_CHAR_START; i<=EL_CHAR_END; i++) - element_info[i].graphic[ACTION_DEFAULT] = - IMG_CHAR_START + (i - EL_CHAR_START); - - for (i=EL_CUSTOM_START; i<=EL_CUSTOM_END; i++) - element_info[i].graphic[ACTION_DEFAULT] = - IMG_CUSTOM_START + (i - EL_CUSTOM_START); -#endif - /* initialize normal element/graphic mapping from static configuration */ for (i=0; element_to_graphic[i].element > -1; i++) { @@ -811,7 +901,7 @@ void InitElementGraphicInfo() int special = property_mapping[i].ext3_index; int graphic = property_mapping[i].artwork_index; - if (special != -1) + if (element >= MAX_NUM_ELEMENTS || special != -1) continue; if (action < 0) @@ -910,6 +1000,9 @@ void InitElementSpecialGraphicInfo() int special = property_mapping[i].ext3_index; int graphic = property_mapping[i].artwork_index; + if (element >= MAX_NUM_ELEMENTS) + continue; + if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS) element_info[element].special_graphic[special] = graphic; } diff --git a/src/libgame/image.c b/src/libgame/image.c index b7634e85..a1cc3865 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -915,6 +915,10 @@ void CreateImageWithSmallImages(int pos) CreateBitmapWithSmallBitmaps(img_info->bitmap); img_info->contains_small_images = TRUE; + +#if 0 + printf("CreateImageWithSmallImages: '%s' done\n", img_info->source_filename); +#endif } void FreeAllImages() diff --git a/src/libgame/system.h b/src/libgame/system.h index bce82b93..d9cd579a 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -325,7 +325,8 @@ struct GfxInfo boolean menu_main_hide_static_text; int num_fonts; - struct FontBitmapInfo *font; + struct FontBitmapInfo *font_bitmap_info; + int (*select_font_function)(int); int anim_random_frame; }; diff --git a/src/libgame/text.c b/src/libgame/text.c index 2e4262d0..d0015164 100644 --- a/src/libgame/text.c +++ b/src/libgame/text.c @@ -35,25 +35,25 @@ static void InitFontClipmasks() GC copy_clipmask_gc; int i, j; - if (gfx.num_fonts == 0 || gfx.font[0].bitmap == NULL) + if (gfx.num_fonts == 0 || gfx.font_bitmap_info[0].bitmap == NULL) return; if (!clipmasks_initialized) { for (i=0; i < gfx.num_fonts; i++) - gfx.font[i].clip_mask = NULL; + gfx.font_bitmap_info[i].clip_mask = NULL; clipmasks_initialized = TRUE; } for (i=0; i < gfx.num_fonts; i++) { - if (gfx.font[i].clip_mask) + if (gfx.font_bitmap_info[i].clip_mask) for (j=0; j < NUM_FONT_CHARS; j++) - XFreePixmap(display, gfx.font[i].clip_mask[j]); - free(gfx.font[i].clip_mask); + XFreePixmap(display, gfx.font_bitmap_info[i].clip_mask[j]); + free(gfx.font_bitmap_info[i].clip_mask); - gfx.font[i].clip_mask = NULL; + gfx.font_bitmap_info[i].clip_mask = NULL; } if (font_clip_gc) @@ -73,32 +73,34 @@ static void InitFontClipmasks() /* create graphic context structures needed for clipping */ clip_gc_values.graphics_exposures = False; clip_gc_valuemask = GCGraphicsExposures; - copy_clipmask_gc = XCreateGC(display, gfx.font[0].bitmap->clip_mask, + copy_clipmask_gc = XCreateGC(display, + gfx.font_bitmap_info[0].bitmap->clip_mask, clip_gc_valuemask, &clip_gc_values); /* create only those clipping Pixmaps we really need */ for (i=0; i < gfx.num_fonts; i++) { - if (gfx.font[i].bitmap == NULL) + if (gfx.font_bitmap_info[i].bitmap == NULL) continue; - gfx.font[i].clip_mask = checked_calloc(NUM_FONT_CHARS * sizeof(Pixmap)); + gfx.font_bitmap_info[i].clip_mask = + checked_calloc(NUM_FONT_CHARS * sizeof(Pixmap)); for (j=0; j < NUM_FONT_CHARS; j++) { - Bitmap *src_bitmap = gfx.font[i].bitmap; + Bitmap *src_bitmap = gfx.font_bitmap_info[i].bitmap; Pixmap src_pixmap = src_bitmap->clip_mask; int xpos = j % FONT_CHARS_PER_LINE; int ypos = j / FONT_CHARS_PER_LINE; - int width = gfx.font[i].width; - int height = gfx.font[i].height; - int src_x = gfx.font[i].src_x + xpos * width; - int src_y = gfx.font[i].src_y + ypos * height; + int width = gfx.font_bitmap_info[i].width; + int height = gfx.font_bitmap_info[i].height; + int src_x = gfx.font_bitmap_info[i].src_x + xpos * width; + int src_y = gfx.font_bitmap_info[i].src_y + ypos * height; - gfx.font[i].clip_mask[j] = + gfx.font_bitmap_info[i].clip_mask[j] = XCreatePixmap(display, window->drawable, width, height, 1); - XCopyArea(display, src_pixmap, gfx.font[i].clip_mask[j], + XCopyArea(display, src_pixmap, gfx.font_bitmap_info[i].clip_mask[j], copy_clipmask_gc, src_x, src_y, width, height, 0, 0); } } @@ -107,10 +109,12 @@ static void InitFontClipmasks() } #endif /* TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND */ -void InitFontInfo(struct FontBitmapInfo *font_info, int num_fonts) +void InitFontInfo(struct FontBitmapInfo *font_bitmap_info, int num_fonts, + int (*select_font_function)(int)) { gfx.num_fonts = num_fonts; - gfx.font = font_info; + gfx.font_bitmap_info = font_bitmap_info; + gfx.select_font_function = select_font_function; #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) InitFontClipmasks(); @@ -119,28 +123,30 @@ void InitFontInfo(struct FontBitmapInfo *font_info, int num_fonts) int getFontWidth(int font_nr) { - return gfx.font[font_nr].width; + return gfx.font_bitmap_info[font_nr].width; } int getFontHeight(int font_nr) { - return gfx.font[font_nr].height; + return gfx.font_bitmap_info[font_nr].height; } void DrawInitText(char *text, int ypos, int font_nr) { - if (window && gfx.num_fonts > 0 && gfx.font[font_nr].bitmap != NULL) + if (window && + gfx.num_fonts > 0 && + gfx.font_bitmap_info[font_nr].bitmap != NULL) { - int text_width = strlen(text) * gfx.font[font_nr].width; + int text_width = strlen(text) * getFontWidth(font_nr); - ClearRectangle(window, 0, ypos, video.width, gfx.font[font_nr].height); + ClearRectangle(window, 0, ypos, video.width, getFontHeight(font_nr)); DrawTextExt(window, (video.width - text_width) / 2, ypos, text, font_nr, FONT_OPAQUE); FlushDisplay(); } } -void DrawTextFCentered(int y, int font, char *format, ...) +void DrawTextFCentered(int y, int font_nr, char *format, ...) { char buffer[MAX_OUTPUT_LINESIZE + 1]; va_list ap; @@ -152,11 +158,11 @@ void DrawTextFCentered(int y, int font, char *format, ...) if (strlen(buffer) > MAX_OUTPUT_LINESIZE) Error(ERR_EXIT, "string too long in DrawTextFCentered() -- aborting"); - DrawText(gfx.sx + (gfx.sxsize - strlen(buffer) * gfx.font[font].width) / 2, - gfx.sy + y, buffer, font); + DrawText(gfx.sx + (gfx.sxsize - strlen(buffer) * getFontWidth(font_nr)) / 2, + gfx.sy + y, buffer, font_nr); } -void DrawTextF(int x, int y, int font, char *format, ...) +void DrawTextF(int x, int y, int font_nr, char *format, ...) { char buffer[MAX_OUTPUT_LINESIZE + 1]; va_list ap; @@ -168,17 +174,17 @@ void DrawTextF(int x, int y, int font, char *format, ...) if (strlen(buffer) > MAX_OUTPUT_LINESIZE) Error(ERR_EXIT, "string too long in DrawTextF() -- aborting"); - DrawText(gfx.sx + x, gfx.sy + y, buffer, font); + DrawText(gfx.sx + x, gfx.sy + y, buffer, font_nr); } -void DrawText(int x, int y, char *text, int font) +void DrawText(int x, int y, char *text, int font_nr) { int mask_mode = FONT_OPAQUE; if (DrawingOnBackground(x, y)) mask_mode = FONT_MASKED; - DrawTextExt(drawto, x, y, text, font, mask_mode); + DrawTextExt(drawto, x, y, text, font_nr, mask_mode); if (x < gfx.dx) redraw_mask |= REDRAW_FIELD; @@ -189,7 +195,8 @@ void DrawText(int x, int y, char *text, int font) void DrawTextExt(DrawBuffer *dst_bitmap, int dst_x, int dst_y, char *text, int font_nr, int mask_mode) { - struct FontBitmapInfo *font = &gfx.font[font_nr]; + int font_bitmap_id = gfx.select_font_function(font_nr); + struct FontBitmapInfo *font = &gfx.font_bitmap_info[font_bitmap_id]; boolean print_inverse = FALSE; if (font->bitmap == NULL) diff --git a/src/libgame/text.h b/src/libgame/text.h index 18dd2ba4..5f8fb21d 100644 --- a/src/libgame/text.h +++ b/src/libgame/text.h @@ -62,7 +62,8 @@ /* font structure definitions */ -void InitFontInfo(struct FontBitmapInfo *, int); +void InitFontInfo(struct FontBitmapInfo *, int, + int (*select_font_function)(int)); int getFontWidth(int); int getFontHeight(int); void DrawInitText(char *, int, int); diff --git a/src/main.c b/src/main.c index 1ef7deeb..7c91f3a9 100644 --- a/src/main.c +++ b/src/main.c @@ -2978,6 +2978,33 @@ struct SpecialSuffixInfo special_suffix_info[NUM_SPECIAL_GFX_ARGS + 1] = { NULL, 0, } }; +/* ------------------------------------------------------------------------- */ +/* font definitions */ +/* ------------------------------------------------------------------------- */ + +struct FontInfo font_info[NUM_FONTS + 1] = +{ + { "font.initial_1" }, + { "font.initial_2" }, + { "font.initial_3" }, + { "font.initial_4" }, + { "font.big_1" }, + { "font.big_2" }, + { "font.big_3" }, + { "font.big_4" }, + { "font.medium_1" }, + { "font.medium_2" }, + { "font.medium_3" }, + { "font.medium_4" }, + { "font.small_1" }, + { "font.small_2" }, + { "font.small_3" }, + { "font.small_4" }, + { "font.tape" }, + { "font.game" }, + { "font.narrow" }, +}; + /* ========================================================================= */ /* main() */ diff --git a/src/main.h b/src/main.h index 281fc47e..b4589dcc 100644 --- a/src/main.h +++ b/src/main.h @@ -1049,34 +1049,30 @@ struct GlobalInfo struct ElementInfo { - char *token_name; /* element token prefix used in config files */ + char *token_name; /* element token used in config files */ char *sound_class_name; /* classification for custom sound effects */ char *editor_description; /* short description for level editor */ char *custom_description; /* custom description for level editor */ int graphic[NUM_ACTIONS]; /* default graphics for several actions */ - int direction_graphic[NUM_ACTIONS][NUM_DIRECTIONS]; /* special graphics for left/right/up/down */ - int special_graphic[NUM_SPECIAL_GFX_ARGS]; /* special graphics for certain screens */ - int editor_graphic; /* graphic displayed in level editor */ - int preview_graphic; /* graphic displayed in level preview */ - int sound[NUM_ACTIONS]; /* default sounds for several actions */ }; -#if 0 struct FontInfo { - int graphic; /* default graphic for this font */ + char *token_name; /* font token used in config files */ + int graphic; /* default graphic for this font */ int special_graphic[NUM_SPECIAL_GFX_ARGS]; /* special graphics for certain screens */ + int special_bitmap_id[NUM_SPECIAL_GFX_ARGS]; + /* internal bitmap ID for special graphics */ }; -#endif struct GraphicInfo { @@ -1202,6 +1198,7 @@ extern struct ElementInfo element_info[]; extern struct ElementActionInfo element_action_info[]; extern struct ElementDirectionInfo element_direction_info[]; extern struct SpecialSuffixInfo special_suffix_info[]; +extern struct FontInfo font_info[]; extern struct GraphicInfo *graphic_info; extern struct SoundInfo *sound_info; extern struct ConfigInfo image_config[], sound_config[];