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
{ "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" },
#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 */
-#define COMPILE_DATE_STRING "[2003-02-23 18:48]"
+#define COMPILE_DATE_STRING "[2003-02-23 21:04]"
#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"
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[] =
{
};
int i;
+ for (i=0; i<MAX_NUM_ELEMENTS; i++)
+ image_id_prefix[i] = element_info[i].token_name;
+ for (i=0; i<NUM_FONTS + 1; i++)
+ image_id_prefix[MAX_NUM_ELEMENTS + i] = font_info[i].token_name;
+
for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
- element_prefix[i] = element_info[i].token_name;
- for (i=0; i<MAX_NUM_ELEMENTS + 1; i++)
- sound_class_prefix[i] = element_info[i].sound_class_name;
+ sound_id_prefix[i] = element_info[i].sound_class_name;
+
for (i=0; i<NUM_ACTIONS + 1; i++)
- action_suffix[i] = element_action_info[i].suffix;
+ action_id_suffix[i] = element_action_info[i].suffix;
+
for (i=0; i<NUM_DIRECTIONS + 1; i++)
- direction_suffix[i] = element_direction_info[i].suffix;
+ direction_id_suffix[i] = element_direction_info[i].suffix;
+
for (i=0; i<NUM_SPECIAL_GFX_ARGS + 1; i++)
- special_suffix[i] = special_suffix_info[i].suffix;
+ special_id_suffix[i] = special_suffix_info[i].suffix;
InitImageList(image_config, NUM_IMAGE_FILES, image_config_suffix,
- element_prefix, action_suffix, direction_suffix,
- special_suffix, ignore_image_tokens);
+ image_id_prefix, action_id_suffix, direction_id_suffix,
+ special_id_suffix, ignore_image_tokens);
InitSoundList(sound_config, NUM_SOUND_FILES, sound_config_suffix,
- sound_class_prefix, action_suffix, dummy,
+ sound_id_prefix, action_id_suffix, dummy,
dummy, ignore_sound_tokens);
}
for (i=0; element_to_special_graphic[i].element > -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()
}
}
-#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++)
{
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)
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;
}
CreateBitmapWithSmallBitmaps(img_info->bitmap);
img_info->contains_small_images = TRUE;
+
+#if 0
+ printf("CreateImageWithSmallImages: '%s' done\n", img_info->source_filename);
+#endif
}
void FreeAllImages()
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;
};
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)
/* 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);
}
}
}
#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();
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;
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;
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;
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)
/* 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);
{ 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() */
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
{
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[];