#include "main.h"
+/* List values that are not defined in the configuration file are set to
+ reliable default values. If that value is GFX_ARG_UNDEFINED, it will
+ be dynamically determined, using some of the other list values. */
+
struct ConfigInfo image_config_suffix[] =
{
{ ".xpos", "0", TYPE_INTEGER },
{ ".vertical", "false", TYPE_BOOLEAN },
{ ".xoffset", GFX_ARG_UNDEFINED, TYPE_INTEGER },
{ ".yoffset", GFX_ARG_UNDEFINED, TYPE_INTEGER },
- { ".frames", "1", TYPE_INTEGER },
+ { ".frames", GFX_ARG_UNDEFINED, TYPE_INTEGER },
{ ".start_frame", GFX_ARG_UNDEFINED, TYPE_INTEGER },
{ ".delay", "1", TYPE_INTEGER },
{ ".mode_loop", "false", TYPE_BOOLEAN },
{
static boolean clipmasks_initialized = FALSE;
static int gfx_action[NUM_IMAGE_FILES];
- Bitmap *src_bitmap;
int src_x, src_y;
int first_frame, last_frame;
int i;
for (i=0; i<NUM_IMAGE_FILES; i++)
{
+ Bitmap *src_bitmap = getBitmapFromImageID(i);
+ int num_xtiles = (src_bitmap ? src_bitmap->width : TILEX) / TILEX;
+ int num_ytiles = (src_bitmap ? src_bitmap->height * 2 / 3 : TILEY) / TILEY;
int *parameter = image_files[i].parameter;
- new_graphic_info[i].bitmap = getBitmapFromImageID(i);
+ new_graphic_info[i].bitmap = src_bitmap;
new_graphic_info[i].src_x = parameter[GFX_ARG_XPOS] * TILEX;
new_graphic_info[i].src_y = parameter[GFX_ARG_YPOS] * TILEY;
if (parameter[GFX_ARG_YOFFSET] != GFX_ARG_UNDEFINED_VALUE)
new_graphic_info[i].offset_y = parameter[GFX_ARG_YOFFSET];
- new_graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
+ /* automatically determine correct number of frames, if not defined */
+ if (parameter[GFX_ARG_FRAMES] != GFX_ARG_UNDEFINED_VALUE)
+ new_graphic_info[i].anim_frames = parameter[GFX_ARG_FRAMES];
+ else if (parameter[GFX_ARG_XPOS] == 0 && !parameter[GFX_ARG_VERTICAL])
+ new_graphic_info[i].anim_frames = num_xtiles;
+ else if (parameter[GFX_ARG_YPOS] == 0 && parameter[GFX_ARG_VERTICAL])
+ new_graphic_info[i].anim_frames = num_ytiles;
+ else
+ new_graphic_info[i].anim_frames = 1;
new_graphic_info[i].anim_delay = parameter[GFX_ARG_DELAY];
if (new_graphic_info[i].anim_delay == 0) /* delay must be at least 1 */
new_graphic_info[i].anim_mode = ANIM_PINGPONG;
else if (parameter[GFX_ARG_MODE_PINGPONG2])
new_graphic_info[i].anim_mode = ANIM_PINGPONG2;
- else if (parameter[GFX_ARG_FRAMES] > 1)
+ else if (new_graphic_info[i].anim_frames > 1)
new_graphic_info[i].anim_mode = ANIM_LOOP;
else
new_graphic_info[i].anim_mode = ANIM_NONE;
getTokenFromImageID(i));
Error(ERR_RETURN, "- image file: '%s'",
src_bitmap->source_filename);
- Error(ERR_EXIT, "error: last animation frame out of bounds (%d,%d)",
- src_x, src_y);
+ Error(ERR_EXIT, "error: last animation frame (%d) out of bounds (%d,%d)",
+ last_frame, src_x, src_y);
}
#if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND)
{
char *filename = getTokenValue(setup_file_list, file_list[i].token);
- if (filename == NULL)
+ if (filename)
+ for (j=0; j<num_suffix_list_entries; j++)
+ file_list[i].parameter[j] =
+ get_parameter_value(suffix_list[j].type, suffix_list[j].value);
+ else
filename = file_list[i].default_filename;
+
file_list[i].filename = getStringCopy(filename);
for (j=0; j<num_suffix_list_entries; j++)