From: Holger Schemel Date: Sat, 8 Feb 2003 10:56:37 +0000 (+0100) Subject: rnd-20030208-1-src X-Git-Tag: 3.0.0^2~148 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=7119b5d2e756b1ab23818ea39d19aece0563bab0;p=rocksndiamonds.git rnd-20030208-1-src --- diff --git a/src/cartoons.c b/src/cartoons.c index 5f7407de..eb43b98d 100644 --- a/src/cartoons.c +++ b/src/cartoons.c @@ -17,7 +17,11 @@ /* values for toon definition */ +#if 0 #define NUM_TOONS 18 +#else +#define NUM_TOONS 6 +#endif #define DWARF_XSIZE 40 #define DWARF_YSIZE 48 @@ -53,6 +57,7 @@ struct ToonInfo toons[NUM_TOONS] = { +#if 0 { IMG_GLOBAL_TOONS, DWARF_XSIZE, DWARF_YSIZE, @@ -119,6 +124,76 @@ struct ToonInfo toons[NUM_TOONS] = ANIMDIR_LEFT, ANIMPOS_UPPER }, +#else + { + IMG_TOON_1, + -1, -1, + -1, -1, + -1, + -1, + -1, + -1, + ANIMDIR_RIGHT, + ANIMPOS_DOWN + }, + { + IMG_TOON_2, + -1, -1, + -1, -1, + -1, + -1, + -1, + -1, + ANIMDIR_LEFT, + ANIMPOS_DOWN + }, + { + IMG_TOON_3, + -1, -1, + -1, -1, + -1, + -1, + -1, + -1, + ANIMDIR_RIGHT, + ANIMPOS_DOWN + }, + { + IMG_TOON_4, + -1, -1, + -1, -1, + -1, + -1, + -1, + -1, + ANIMDIR_UP, + ANIMPOS_ANY + }, + { + IMG_TOON_5, + -1, -1, + -1, -1, + -1, + -1, + -1, + -1, + ANIMDIR_RIGHT, + ANIMPOS_UPPER + }, + { + IMG_TOON_6, + -1, -1, + -1, -1, + -1, + -1, + -1, + -1, + ANIMDIR_LEFT, + ANIMPOS_UPPER + }, +#endif + +#if 0 { IMG_PLAYER1_MOVING_LEFT, -1, -1, @@ -251,6 +326,8 @@ struct ToonInfo toons[NUM_TOONS] = ANIMDIR_RIGHT, ANIMPOS_ANY }, +#endif + }; static void PrepareBackbuffer() @@ -299,32 +376,19 @@ void InitToons() toons[i].bitmap = graphic_info[graphic].bitmap; - if (toons[i].src_x == -1 && toons[i].src_y == -1) - { - int anim_frames = graphic_info[graphic].anim_frames; - int anim_delay = graphic_info[graphic].anim_delay; - int anim_mode = graphic_info[graphic].anim_mode; - int start_frame = graphic_info[graphic].anim_start_frame; - - toons[i].src_x = graphic_info[graphic].src_x; - toons[i].src_y = graphic_info[graphic].src_y; + toons[i].src_x = graphic_info[graphic].src_x; + toons[i].src_y = graphic_info[graphic].src_y; - toons[i].width = TILEX; - toons[i].height = TILEY; + toons[i].width = graphic_info[graphic].width; + toons[i].height = graphic_info[graphic].height; - toons[i].anim_frames = anim_frames; - toons[i].anim_delay = anim_delay; - toons[i].anim_mode = anim_mode; - toons[i].start_frame = start_frame; + toons[i].anim_frames = graphic_info[graphic].anim_frames; + toons[i].anim_delay = graphic_info[graphic].anim_delay; + toons[i].anim_mode = graphic_info[graphic].anim_mode; + toons[i].anim_start_frame = graphic_info[graphic].anim_start_frame; - toons[i].move_delay = 1; - toons[i].stepsize = TILEX / 8; - } - else - { - toons[i].anim_delay = 1; /* no delay between frames */ - toons[i].start_frame = 0; /* always start with first */ - } + toons[i].step_offset = graphic_info[graphic].step_offset; + toons[i].step_delay = graphic_info[graphic].step_delay; } InitToonScreen(bitmap_db_door, diff --git a/src/conf_gfx.c b/src/conf_gfx.c index d693881c..e96e5de5 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -21,9 +21,13 @@ struct ConfigInfo image_config_suffix[] = { - { ".xpos", "0", TYPE_INTEGER }, - { ".ypos", "0", TYPE_INTEGER }, - { ".offset", "32", TYPE_INTEGER }, + { ".x", ARG_UNDEFINED, TYPE_INTEGER }, + { ".y", ARG_UNDEFINED, TYPE_INTEGER }, + { ".xpos", ARG_UNDEFINED, TYPE_INTEGER }, + { ".ypos", ARG_UNDEFINED, TYPE_INTEGER }, + { ".width", ARG_UNDEFINED, TYPE_INTEGER }, + { ".height", ARG_UNDEFINED, TYPE_INTEGER }, + { ".offset", ARG_UNDEFINED, TYPE_INTEGER }, { ".vertical", "false", TYPE_BOOLEAN }, { ".xoffset", ARG_UNDEFINED, TYPE_INTEGER }, { ".yoffset", ARG_UNDEFINED, TYPE_INTEGER }, @@ -37,6 +41,8 @@ struct ConfigInfo image_config_suffix[] = { ".mode_random", "false", TYPE_BOOLEAN }, { ".mode_reverse", "false", TYPE_BOOLEAN }, { ".global_sync", "false", TYPE_BOOLEAN }, + { ".step_offset", "4", TYPE_INTEGER }, + { ".step_delay", "1", TYPE_INTEGER }, { ".name", ARG_UNDEFINED, TYPE_STRING }, { NULL, NULL, 0 } @@ -2691,6 +2697,68 @@ struct ConfigInfo image_config[] = { "global.door", "RocksDoor.pcx" }, { "global.toons", "RocksToons.pcx" }, + { "toon_1", "RocksToons.pcx" }, + { "toon_1.x", "2" }, + { "toon_1.y", "72" }, + { "toon_1.width", "40" }, + { "toon_1.height", "48" }, + { "toon_1.frames", "8" }, + { "toon_1.delay", "1" }, + { "toon_1.step_offset", "4" }, + { "toon_1.step_delay", "5" }, + + { "toon_2", "RocksToons.pcx" }, + { "toon_2.x", "2" }, + { "toon_2.y", "186" }, + { "toon_2.width", "40" }, + { "toon_2.height", "48" }, + { "toon_2.frames", "8" }, + { "toon_2.delay", "1" }, + { "toon_2.step_offset", "4" }, + { "toon_2.step_delay", "5" }, + + { "toon_3", "RocksToons.pcx" }, + { "toon_3.x", "2" }, + { "toon_3.y", "125" }, + { "toon_3.width", "48" }, + { "toon_3.height", "56" }, + { "toon_3.frames", "8" }, + { "toon_3.delay", "1" }, + { "toon_3.step_offset", "4" }, + { "toon_3.step_delay", "5" }, + + { "toon_4", "RocksToons.pcx" }, + { "toon_4.x", "327" }, + { "toon_4.y", "10" }, + { "toon_4.width", "80" }, + { "toon_4.height", "110" }, + { "toon_4.frames", "1" }, + { "toon_4.delay", "1" }, + { "toon_4.step_offset", "1" }, + { "toon_4.step_delay", "1" }, + + { "toon_5", "RocksToons.pcx" }, + { "toon_5.x", "2" }, + { "toon_5.y", "2" }, + { "toon_5.width", "32" }, + { "toon_5.height", "30" }, + { "toon_5.frames", "8" }, + { "toon_5.delay", "2" }, + { "toon_5.mode_pingpong2", "true" }, + { "toon_5.step_offset", "2" }, + { "toon_5.step_delay", "1" }, + + { "toon_6", "RocksToons.pcx" }, + { "toon_6.x", "2" }, + { "toon_6.y", "37" }, + { "toon_6.width", "32" }, + { "toon_6.height", "30" }, + { "toon_6.frames", "8" }, + { "toon_6.delay", "2" }, + { "toon_6.mode_pingpong2", "true" }, + { "toon_6.step_offset", "2" }, + { "toon_6.step_delay", "1" }, + { "font.big", "RocksFontBig.pcx" }, { "font.medium", "RocksFontMedium.pcx" }, { "font.small", "RocksFontSmall.pcx" }, diff --git a/src/conf_gfx.h b/src/conf_gfx.h index b285f733..b2b0dab0 100644 --- a/src/conf_gfx.h +++ b/src/conf_gfx.h @@ -788,25 +788,31 @@ #define IMG_GLOBAL_BORDER 767 #define IMG_GLOBAL_DOOR 768 #define IMG_GLOBAL_TOONS 769 -#define IMG_FONT_BIG 770 -#define IMG_FONT_MEDIUM 771 -#define IMG_FONT_SMALL 772 -#define IMG_FONT_EM 773 -#define IMG_BACKGROUND_DEFAULT 774 -#define IMG_BACKGROUND_DOOR 775 -#define IMG_BACKGROUND_MAIN 776 -#define IMG_BACKGROUND_LEVEL_SERIES 777 -#define IMG_BACKGROUND_HALL_OF_FAME 778 -#define IMG_BACKGROUND_EDITOR_SETTINGS_LEVEL 779 -#define IMG_BACKGROUND_EDITOR_SETTINGS_ELEMENT 780 -#define IMG_BACKGROUND_INFO 781 -#define IMG_BACKGROUND_SETUP 782 -#define IMG_INFO_FONT_EM_1 783 -#define IMG_INFO_FONT_EM_2 784 -#define IMG_INFO_FONT_EM_3 785 -#define IMG_INFO_FONT_EM_4 786 -#define IMG_INFO_FONT_EM_5 787 +#define IMG_TOON_1 770 +#define IMG_TOON_2 771 +#define IMG_TOON_3 772 +#define IMG_TOON_4 773 +#define IMG_TOON_5 774 +#define IMG_TOON_6 775 +#define IMG_FONT_BIG 776 +#define IMG_FONT_MEDIUM 777 +#define IMG_FONT_SMALL 778 +#define IMG_FONT_EM 779 +#define IMG_BACKGROUND_DEFAULT 780 +#define IMG_BACKGROUND_DOOR 781 +#define IMG_BACKGROUND_MAIN 782 +#define IMG_BACKGROUND_LEVEL_SERIES 783 +#define IMG_BACKGROUND_HALL_OF_FAME 784 +#define IMG_BACKGROUND_EDITOR_SETTINGS_LEVEL 785 +#define IMG_BACKGROUND_EDITOR_SETTINGS_ELEMENT 786 +#define IMG_BACKGROUND_INFO 787 +#define IMG_BACKGROUND_SETUP 788 +#define IMG_INFO_FONT_EM_1 789 +#define IMG_INFO_FONT_EM_2 790 +#define IMG_INFO_FONT_EM_3 791 +#define IMG_INFO_FONT_EM_4 792 +#define IMG_INFO_FONT_EM_5 793 -#define NUM_IMAGE_FILES 788 +#define NUM_IMAGE_FILES 794 #endif /* CONF_GFX_H */ diff --git a/src/conftime.h b/src/conftime.h index 4b36fc24..07d88bf1 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2003-02-04 03:17]" +#define COMPILE_DATE_STRING "[2003-02-08 11:56]" diff --git a/src/init.c b/src/init.c index f6985eb9..31214f1d 100644 --- a/src/init.c +++ b/src/init.c @@ -837,7 +837,7 @@ void InitElementGraphicInfo() } } -#if 0 +#if 1 #if DEBUG if (options.verbose) { @@ -870,6 +870,11 @@ void InitElementSpecialGraphicInfo() 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; @@ -904,16 +909,46 @@ static void set_graphic_parameters(int graphic, int *parameter) 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]) + /* 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 */ { - graphic_info[graphic].offset_x = 0; - graphic_info[graphic].offset_y = parameter[GFX_ARG_OFFSET]; + 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 */ @@ -967,11 +1002,18 @@ static void set_graphic_parameters(int graphic, int *parameter) /* 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]; } static void InitGraphicInfo() { static boolean clipmasks_initialized = FALSE; + int fallback_graphic = IMG_CHAR_EXCLAM; + struct FileInfo *fallback_image = getImageListEntry(fallback_graphic); + Bitmap *fallback_bitmap = getBitmapFromImageID(fallback_graphic); int num_images = getImageListSize(); int i; #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) @@ -1034,9 +1076,15 @@ static void InitGraphicInfo() "error: first animation frame out of bounds (%d, %d)", src_x, src_y); Error(ERR_RETURN, "custom graphic rejected for this element/action"); + + if (i == fallback_graphic) + Error(ERR_EXIT, "fatal error: no fallback graphic available"); + + Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic"); Error(ERR_RETURN_LINE, "-"); - set_graphic_parameters(i, image->default_parameter); + set_graphic_parameters(i, fallback_image->default_parameter); + graphic_info[i].bitmap = fallback_bitmap; } last_frame = graphic_info[i].anim_frames - 1; @@ -1057,9 +1105,15 @@ static void InitGraphicInfo() "error: last animation frame (%d) out of bounds (%d, %d)", last_frame, src_x, src_y); Error(ERR_RETURN, "custom graphic rejected for this element/action"); + + if (i == fallback_graphic) + Error(ERR_EXIT, "fatal error: no fallback graphic available"); + + Error(ERR_RETURN, "fallback done to 'char_exclam' for this graphic"); Error(ERR_RETURN_LINE, "-"); - set_graphic_parameters(i, image->default_parameter); + set_graphic_parameters(i, fallback_image->default_parameter); + graphic_info[i].bitmap = fallback_bitmap; } #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) diff --git a/src/libgame/misc.c b/src/libgame/misc.c index b5dab8f7..75fd4434 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1675,6 +1675,8 @@ static void read_token_parameters(struct SetupFileList *setup_file_list, file_list_entry->filename = getStringCopy(filename); + file_list_entry->redefined = TRUE; + /* mark config file token as well known from default config */ setTokenValue(setup_file_list, file_list_entry->token, known_token_value); } @@ -1782,6 +1784,8 @@ void LoadArtworkConfig(struct ArtworkListInfo *artwork_info) for (j=0; jdirection & (ANIMDIR_LEFT | ANIMDIR_RIGHT)); vert_move = (anim->direction & (ANIMDIR_UP | ANIMDIR_DOWN)); - anim_delay_value = anim->move_delay * screen_info.frame_delay_value; + anim_delay_value = anim->step_delay * screen_info.frame_delay_value; frame = getAnimationFrame(anim->anim_frames, anim->anim_delay, - anim->anim_mode, anim->start_frame, + anim->anim_mode, anim->anim_start_frame, animation_frame_counter++); if (horiz_move) @@ -178,12 +178,12 @@ boolean AnimateToon(int toon_nr, boolean restart) if (anim->direction == ANIMDIR_RIGHT) { - delta_x = anim->stepsize; + delta_x = anim->step_offset; pos_x = -anim->width + delta_x; } else { - delta_x = -anim->stepsize; + delta_x = -anim->step_offset; pos_x = screen_info.width + delta_x; } delta_y = 0; @@ -199,22 +199,22 @@ boolean AnimateToon(int toon_nr, boolean restart) if (anim->direction == ANIMDIR_DOWN) { - delta_y = anim->stepsize; + delta_y = anim->step_offset; pos_y = -anim->height + delta_y; } else { - delta_y = -anim->stepsize; + delta_y = -anim->step_offset; pos_y = screen_info.width + delta_y; } delta_x = 0; } } - if (pos_x <= -anim->width - anim->stepsize || - pos_x >= screen_info.width + anim->stepsize || - pos_y <= -anim->height - anim->stepsize || - pos_y >= screen_info.height + anim->stepsize) + if (pos_x <= -anim->width - anim->step_offset || + pos_x >= screen_info.width + anim->step_offset || + pos_y <= -anim->height - anim->step_offset || + pos_y >= screen_info.height + anim->step_offset) return TRUE; if (!DelayReached(&anim_delay, anim_delay_value)) @@ -239,8 +239,8 @@ boolean AnimateToon(int toon_nr, boolean restart) else if (pos_y > screen_info.height) pos_y = screen_info.height; - pad_x = (horiz_move ? anim->stepsize : 0); - pad_y = (vert_move ? anim->stepsize : 0); + pad_x = (horiz_move ? anim->step_offset : 0); + pad_y = (vert_move ? anim->step_offset : 0); src_x = anim->src_x + frame * anim->width; src_y = anim->src_y; dest_x = pos_x; @@ -278,7 +278,7 @@ boolean AnimateToon(int toon_nr, boolean restart) pos_y += delta_y; frame = getAnimationFrame(anim->anim_frames, anim->anim_delay, - anim->anim_mode, anim->start_frame, + anim->anim_mode, anim->anim_start_frame, animation_frame_counter++); return FALSE; diff --git a/src/libgame/toons.h b/src/libgame/toons.h index 4ed43abe..8ea41d18 100644 --- a/src/libgame/toons.h +++ b/src/libgame/toons.h @@ -62,15 +62,27 @@ struct ToonInfo int width, height; int src_x, src_y; int anim_frames; - int move_delay; - int stepsize; + int step_delay; + int step_offset; int anim_mode; int direction; int position; int anim_delay; - int start_frame; + int anim_start_frame; Bitmap *bitmap; /* dynamically initialized */ + +#if 0 + Bitmap *bitmap; + int src_x, src_y; + int width, height; + int anim_frames; + int anim_start_frame; + int anim_delay; + int anim_mode; + int step_offset; + int step_delay; +#endif }; diff --git a/src/main.h b/src/main.h index 6c56974a..f4c5cc39 100644 --- a/src/main.h +++ b/src/main.h @@ -793,24 +793,30 @@ /* values for image configuration suffixes */ -#define GFX_ARG_XPOS 0 -#define GFX_ARG_YPOS 1 -#define GFX_ARG_OFFSET 2 -#define GFX_ARG_VERTICAL 3 -#define GFX_ARG_XOFFSET 4 -#define GFX_ARG_YOFFSET 5 -#define GFX_ARG_FRAMES 6 -#define GFX_ARG_START_FRAME 7 -#define GFX_ARG_DELAY 8 -#define GFX_ARG_MODE_LOOP 9 -#define GFX_ARG_MODE_LINEAR 10 -#define GFX_ARG_MODE_PINGPONG 11 -#define GFX_ARG_MODE_PINGPONG2 12 -#define GFX_ARG_MODE_RANDOM 13 -#define GFX_ARG_MODE_REVERSE 14 -#define GFX_ARG_GLOBAL_SYNC 15 - -#define NUM_GFX_ARGS 16 +#define GFX_ARG_X 0 +#define GFX_ARG_Y 1 +#define GFX_ARG_XPOS 2 +#define GFX_ARG_YPOS 3 +#define GFX_ARG_WIDTH 4 +#define GFX_ARG_HEIGHT 5 +#define GFX_ARG_OFFSET 6 +#define GFX_ARG_VERTICAL 7 +#define GFX_ARG_XOFFSET 8 +#define GFX_ARG_YOFFSET 9 +#define GFX_ARG_FRAMES 10 +#define GFX_ARG_START_FRAME 11 +#define GFX_ARG_DELAY 12 +#define GFX_ARG_MODE_LOOP 13 +#define GFX_ARG_MODE_LINEAR 14 +#define GFX_ARG_MODE_PINGPONG 15 +#define GFX_ARG_MODE_PINGPONG2 16 +#define GFX_ARG_MODE_RANDOM 17 +#define GFX_ARG_MODE_REVERSE 18 +#define GFX_ARG_GLOBAL_SYNC 19 +#define GFX_ARG_STEP_OFFSET 20 +#define GFX_ARG_STEP_DELAY 21 + +#define NUM_GFX_ARGS 22 /* values for sound configuration suffixes */ @@ -1052,13 +1058,16 @@ struct ElementInfo struct GraphicInfo { Bitmap *bitmap; - int src_x, src_y; /* derived from (tile sized) .xpos/.ypos */ + int src_x, src_y; /* start position of animation frames */ + int width, height; /* width/height of each animation frame */ int offset_x, offset_y; /* x/y offset to next animation frame */ int anim_frames; int anim_start_frame; int anim_delay; /* important: delay of 1 means "no delay"! */ int anim_mode; boolean anim_global_sync; + int step_offset; /* optional step offset of toon animations */ + int step_delay; /* optional step delay of toon animations */ #if defined(TARGET_X11_NATIVE_PERFORMANCE_WORKAROUND) Pixmap clip_mask; /* single-graphic-only clip mask for X11 */