#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 Bitmap *bitmap_font_initial = NULL;
+struct FontBitmapInfo font_initial[NUM_INITIAL_FONTS];
static void InitGlobal();
static void InitSetup();
static void InitGfx();
static void InitGfxBackground();
static void InitGadgets();
+static void InitFontGraphicInfo();
static void InitElementSmallImages();
static void InitElementGraphicInfo();
static void InitElementSpecialGraphicInfo();
return;
}
+ game_status = MAINMENU;
+
DrawMainMenu();
InitNetworkServer();
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);
}
InitGraphicInfo(); /* graphic properties mapping */
InitElementSmallImages(); /* create editor and preview images */
+ InitFontGraphicInfo(); /* initialize text drawing functions */
- InitFontInfo(bitmap_font_initial,
- graphic_info[IMG_FONT_BIG].bitmap,
- graphic_info[IMG_FONT_MEDIUM].bitmap,
- graphic_info[IMG_FONT_SMALL].bitmap,
- graphic_info[IMG_FONT_EM].bitmap);
-
- SetMainBackgroundImage(IMG_BACKGROUND_DEFAULT);
+ SetMainBackgroundImage(IMG_BACKGROUND);
SetDoorBackgroundImage(IMG_BACKGROUND_DOOR);
InitGadgets();
void InitGfx()
{
- char *config_token_font_initial = "font.small";
char *filename_font_initial = NULL;
- int i;
+ Bitmap *bitmap_font_initial = NULL;
+ int i, j;
- /* determine filename for initial font (for displaying startup messages) */
+ /* determine settings for initial font (for displaying startup messages) */
for (i=0; image_config[i].token != NULL; i++)
- if (strcmp(image_config[i].token, config_token_font_initial) == 0)
- filename_font_initial = image_config[i].value;
+ {
+ for (j=0; j < NUM_INITIAL_FONTS; j++)
+ {
+ char font_token[128];
+ int len_font_token;
+
+ sprintf(font_token, "%s_%d", CONFIG_TOKEN_FONT_INITIAL, j + 1);
+ len_font_token = strlen(font_token);
+
+ if (strcmp(image_config[i].token, font_token) == 0)
+ filename_font_initial = image_config[i].value;
+ else if (strlen(image_config[i].token) > len_font_token &&
+ strncmp(image_config[i].token, font_token, len_font_token) == 0)
+ {
+ if (strcmp(&image_config[i].token[len_font_token], ".x") == 0)
+ font_initial[j].src_x = atoi(image_config[i].value);
+ else if (strcmp(&image_config[i].token[len_font_token], ".y") == 0)
+ font_initial[j].src_y = atoi(image_config[i].value);
+ else if (strcmp(&image_config[i].token[len_font_token], ".width") == 0)
+ font_initial[j].width = atoi(image_config[i].value);
+ else if (strcmp(&image_config[i].token[len_font_token],".height") == 0)
+ font_initial[j].height = atoi(image_config[i].value);
+ }
+ }
+ }
if (filename_font_initial == NULL) /* should not happen */
- Error(ERR_EXIT, "cannot get filename for '%s'", config_token_font_initial);
+ Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL);
/* initialize screen properties */
InitGfxFieldInfo(SX, SY, SXSIZE, SYSIZE,
bitmap_font_initial = LoadCustomImage(filename_font_initial);
- InitFontInfo(bitmap_font_initial, NULL, NULL, NULL, NULL);
+ for (j=0; j < NUM_INITIAL_FONTS; j++)
+ font_initial[j].bitmap = bitmap_font_initial;
+
+ InitFontGraphicInfo();
DrawInitText(WINDOW_TITLE_STRING, 20, FC_YELLOW);
DrawInitText(WINDOW_SUBTITLE_STRING, 50, FC_RED);
/* 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)
+{
+ int special = -1;
+
+ if (game_status == MAINMENU || game_status == TYPENAME)
+ special = GFX_SPECIAL_ARG_MAIN;
+ else if (game_status == CHOOSELEVEL)
+ special = GFX_SPECIAL_ARG_LEVELS;
+ else if (game_status == HALLOFFAME)
+ special = GFX_SPECIAL_ARG_SCORES;
+ else if (game_status == LEVELED)
+ special = GFX_SPECIAL_ARG_EDITOR;
+ else if (game_status == HELPSCREEN)
+ special = GFX_SPECIAL_ARG_INFO;
+ else if (game_status == SETUP)
+ special = GFX_SPECIAL_ARG_SETUP;
+ else if (game_status == PSEUDO_PREVIEW)
+ special = GFX_SPECIAL_ARG_PREVIEW;
+ else if (game_status == PLAYING || game_status == PSEUDO_DOOR)
+ special = GFX_SPECIAL_ARG_DOOR;
+
+ if (special != -1)
+ return font_info[font_nr].special_bitmap_id[special];
+ else
+ return font_nr;
+}
+
+void InitFontGraphicInfo()
+{
+ 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 */
+ {
+ 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 ---------- */
+
+ 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];
+ 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[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_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)
{
struct PropertyMapping *property_mapping = getImageListPropertyMapping();
int num_property_mappings = getImageListPropertyMappingSize();
- int i;
+ int i, j;
/* always start with reliable default values */
- for (i=0; i<MAX_NUM_ELEMENTS; i++)
- {
- element_info[i].editor_graphic = element_info[i].graphic[ACTION_DEFAULT];
- element_info[i].preview_graphic = element_info[i].graphic[ACTION_DEFAULT];
- }
+ for (i=0; i < MAX_NUM_ELEMENTS; i++)
+ for (j=0; j < NUM_SPECIAL_GFX_ARGS; j++)
+ element_info[i].special_graphic[j] =
+ element_info[i].graphic[ACTION_DEFAULT];
/* initialize special element/graphic mapping from static configuration */
for (i=0; element_to_special_graphic[i].element > -1; i++)
if (base_redefined && !special_redefined)
continue;
- if (special == GFX_SPECIAL_ARG_EDITOR)
- element_info[element].editor_graphic = graphic;
- else if (special == GFX_SPECIAL_ARG_PREVIEW)
- element_info[element].preview_graphic = graphic;
+ element_info[element].special_graphic[special] = graphic;
}
/* initialize special element/graphic mapping from dynamic configuration */
int special = property_mapping[i].ext3_index;
int graphic = property_mapping[i].artwork_index;
- if (special == GFX_SPECIAL_ARG_EDITOR)
- element_info[element].editor_graphic = graphic;
- else if (special == GFX_SPECIAL_ARG_PREVIEW)
- element_info[element].preview_graphic = graphic;
+ if (element >= MAX_NUM_ELEMENTS)
+ continue;
+
+ if (special >= 0 && special < NUM_SPECIAL_GFX_ARGS)
+ element_info[element].special_graphic[special] = graphic;
}
}
/* get integer values from string parameters */
for (i=0; i < NUM_GFX_ARGS; i++)
parameter[i] =
- get_parameter_value(image_config_suffix[i].type, parameter_raw[i]);
+ get_parameter_value(image_config_suffix[i].token, parameter_raw[i],
+ image_config_suffix[i].type);
graphic_info[graphic].bitmap = src_bitmap;
if (graphic_info[graphic].anim_delay == 0) /* delay must be at least 1 */
graphic_info[graphic].anim_delay = 1;
- /* set mode for animation frame order */
- if (parameter[GFX_ARG_MODE_LOOP])
- graphic_info[graphic].anim_mode = ANIM_LOOP;
- else if (parameter[GFX_ARG_MODE_LINEAR])
- graphic_info[graphic].anim_mode = ANIM_LINEAR;
- else if (parameter[GFX_ARG_MODE_PINGPONG])
- graphic_info[graphic].anim_mode = ANIM_PINGPONG;
- else if (parameter[GFX_ARG_MODE_PINGPONG2])
- graphic_info[graphic].anim_mode = ANIM_PINGPONG2;
- else if (parameter[GFX_ARG_MODE_RANDOM])
- graphic_info[graphic].anim_mode = ANIM_RANDOM;
+ if (parameter[GFX_ARG_ANIM_MODE] != ANIM_NONE)
+ graphic_info[graphic].anim_mode = parameter[GFX_ARG_ANIM_MODE];
else if (graphic_info[graphic].anim_frames > 1)
graphic_info[graphic].anim_mode = ANIM_LOOP;
- else
- graphic_info[graphic].anim_mode = ANIM_NONE;
-
- /* set additional flag to play animation frames in reverse order */
- if (parameter[GFX_ARG_MODE_REVERSE])
- graphic_info[graphic].anim_mode |= ANIM_REVERSE;
/* automatically determine correct start frame, if not defined */
if (parameter[GFX_ARG_START_FRAME] == ARG_UNDEFINED_VALUE)
/* this is only used for toon animations */
graphic_info[graphic].step_offset = parameter[GFX_ARG_STEP_OFFSET];
graphic_info[graphic].step_delay = parameter[GFX_ARG_STEP_DELAY];
+
+ /* this is only used for drawing font characters */
+ graphic_info[graphic].draw_x = parameter[GFX_ARG_DRAW_XOFFSET];
+ graphic_info[graphic].draw_y = parameter[GFX_ARG_DRAW_YOFFSET];
}
static void InitGraphicInfo()
/* get integer values from string parameters */
for (i=0; i < NUM_SND_ARGS; i++)
parameter[i] =
- get_parameter_value(sound_config_suffix[i].type, parameter_raw[i]);
+ get_parameter_value(sound_config_suffix[i].token, parameter_raw[i],
+ sound_config_suffix[i].type);
/* explicit loop mode setting in configuration overrides default value */
if (parameter[SND_ARG_MODE_LOOP] != ARG_UNDEFINED_VALUE)
EL_DYNABOMB_NR,
EL_DYNABOMB_SZ,
EL_DYNABOMB_XL,
+ EL_SP_DISK_RED_ACTIVE,
EL_BUG,
EL_MOLE,
EL_PENGUIN,
EL_DYNABOMB_PLAYER1_ACTIVE,
EL_DYNABOMB_PLAYER2_ACTIVE,
EL_DYNABOMB_PLAYER3_ACTIVE,
- EL_DYNABOMB_PLAYER4_ACTIVE
+ EL_DYNABOMB_PLAYER4_ACTIVE,
+ EL_SP_DISK_RED_ACTIVE
};
static int ep_active_bomb_num = SIZEOF_ARRAY_INT(ep_active_bomb);
FreeAllImages();
FreeTileClipmasks();
- if (bitmap_font_initial)
- FreeBitmap(bitmap_font_initial);
-
CloseVideoDisplay();
ClosePlatformDependantStuff();