+void InitElementEditorGraphicInfo()
+{
+ 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];
+
+#if 0
+ /* initialize element/graphic mapping from static configuration */
+ for (i=0; ... ; i++)
+ {
+ int element = ... element;
+ int special = ... special;
+ int graphic = ... graphic;
+
+ if (special != GFX_SPECIAL_ARG_EDITOR)
+ continue;
+
+ element_info[element].editor_graphic = graphic;
+ }
+#endif
+
+ /* initialize 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)
+ continue;
+
+ element_info[element].editor_graphic = graphic;
+ }
+}
+
+static void InitElementSoundInfo()
+{
+ /* soon to come */
+}
+
+static void set_graphic_parameters(int graphic, int *parameter)
+{
+ 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;
+
+ graphic_info[graphic].bitmap = src_bitmap;
+
+ graphic_info[graphic].src_x = parameter[GFX_ARG_XPOS] * TILEX;
+ graphic_info[graphic].src_y = parameter[GFX_ARG_YPOS] * TILEY;
+ graphic_info[graphic].offset_x = parameter[GFX_ARG_OFFSET];
+ graphic_info[graphic].offset_y = 0;
+
+ /* animation frames are ordered vertically instead of horizontally */
+ if (parameter[GFX_ARG_VERTICAL])
+ {
+ graphic_info[graphic].offset_x = 0;
+ graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET];
+ }
+
+ /* 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];
+}
+