+
+#if 0
+#if DEBUG
+ if (options.verbose)
+ {
+ for (i=0; i<MAX_NUM_ELEMENTS; i++)
+ if (element_info[i].graphic[ACTION_DEFAULT] == IMG_CHAR_QUESTION &&
+ i != EL_CHAR_QUESTION)
+ Error(ERR_RETURN, "warning: no graphic for element '%s' (%d)",
+ element_info[i].token_name, i);
+ }
+#endif
+#endif
+}
+
+void InitElementSpecialGraphicInfo()
+{
+ struct PropertyMapping *property_mapping = getImageListPropertyMapping();
+ int num_property_mappings = getImageListPropertyMappingSize();
+ int i;
+
+ /* 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];
+ }
+
+ /* initialize special element/graphic mapping from static configuration */
+ for (i=0; element_to_special_graphic[i].element > -1; i++)
+ {
+ int element = element_to_special_graphic[i].element;
+ int special = element_to_special_graphic[i].special;
+ int graphic = element_to_special_graphic[i].graphic;
+ boolean base_redefined = getImageListEntry(el2img(element))->redefined;
+ boolean special_redefined = getImageListEntry(graphic)->redefined;
+
+ 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;
+ }
+
+ /* initialize special element/graphic mapping from dynamic configuration */
+ for (i=0; i < num_property_mappings; i++)
+ {
+ int element = property_mapping[i].base_index;
+ 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;
+ }
+}
+
+static void set_graphic_parameters(int graphic, char **parameter_raw)
+{
+ Bitmap *src_bitmap = getBitmapFromImageID(graphic);
+ int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
+ int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
+ int parameter[NUM_GFX_ARGS];
+ int i;
+
+ /* 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]);
+
+ graphic_info[graphic].bitmap = src_bitmap;
+
+ /* start with reliable default values */
+ graphic_info[graphic].src_x = 0;
+ graphic_info[graphic].src_y = 0;
+ graphic_info[graphic].width = TILEX;
+ graphic_info[graphic].height = TILEY;
+ graphic_info[graphic].offset_x = 0; /* one or both of these values ... */
+ graphic_info[graphic].offset_y = 0; /* ... will be corrected later */
+
+ /* optional x and y tile position of animation frame sequence */
+ if (parameter[GFX_ARG_XPOS] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
+ if (parameter[GFX_ARG_YPOS] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
+
+ /* optional x and y pixel position of animation frame sequence */
+ if (parameter[GFX_ARG_X] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].src_x = parameter[GFX_ARG_X];
+ if (parameter[GFX_ARG_Y] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].src_y = parameter[GFX_ARG_Y];
+
+ /* optional width and height of each animation frame */
+ if (parameter[GFX_ARG_WIDTH] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].width = parameter[GFX_ARG_WIDTH];
+ if (parameter[GFX_ARG_HEIGHT] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].height = parameter[GFX_ARG_HEIGHT];
+
+ /* correct x or y offset dependant of vertical or horizontal frame order */
+ if (parameter[GFX_ARG_VERTICAL]) /* frames are ordered vertically */
+ {
+ if (parameter[GFX_ARG_OFFSET] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
+ else
+ graphic_info[graphic].offset_y = graphic_info[graphic].height;
+ }
+ else /* frames are ordered horizontally */
+ {
+ if (parameter[GFX_ARG_OFFSET] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
+ else
+ graphic_info[graphic].offset_x = graphic_info[graphic].width;
+ }
+
+ /* optionally, the x and y offset of frames can be specified directly */
+ if (parameter[GFX_ARG_XOFFSET] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].offset_x = parameter[GFX_ARG_XOFFSET];
+ if (parameter[GFX_ARG_YOFFSET] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].offset_y = parameter[GFX_ARG_YOFFSET];
+
+ /* automatically determine correct number of frames, if not defined */
+ if (parameter[GFX_ARG_FRAMES] != ARG_UNDEFINED_VALUE)
+ graphic_info[graphic].anim_frames = parameter[GFX_ARG_FRAMES];
+ else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
+ graphic_info[graphic].anim_frames = num_xtiles;
+ else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
+ graphic_info[graphic].anim_frames = num_ytiles;
+ else
+ graphic_info[graphic].anim_frames = 1;
+
+ graphic_info[graphic].anim_delay = parameter[GFX_ARG_DELAY];
+ 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;
+ 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)
+ graphic_info[graphic].anim_start_frame = 0;
+ else if (graphic_info[graphic].anim_mode & ANIM_REVERSE)
+ graphic_info[graphic].anim_start_frame =
+ graphic_info[graphic].anim_frames - parameter[GFX_ARG_START_FRAME] - 1;
+ else
+ graphic_info[graphic].anim_start_frame = parameter[GFX_ARG_START_FRAME];
+
+ /* animation synchronized with global frame counter, not move position */
+ graphic_info[graphic].anim_global_sync = parameter[GFX_ARG_GLOBAL_SYNC];
+
+ /* 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];