From: Holger Schemel Date: Tue, 14 Oct 2014 14:31:26 +0000 (+0200) Subject: added support for animated door parts (for menu request doors) X-Git-Tag: 4.0.0.0-rc1~334 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=e2b653e9b2436d21a84b478c0d5c087bbceb8868;p=rocksndiamonds.git added support for animated door parts (for menu request doors) --- diff --git a/ChangeLog b/ChangeLog index 58a94a9c..882b5a99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2014-10-14 + * added support for animated door parts during opening/closing movement + 2014-10-13 * added automatic detection of normal/steel character elements in level editor when drawing text (depending on currently selected element) diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 4956ed8a..a505fbf1 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -5418,62 +5418,74 @@ struct ConfigInfo image_config[] = { "door_1.gfx.part_1.y", "0" }, { "door_1.gfx.part_1.width", "100" }, { "door_1.gfx.part_1.height", "77" }, + { "door_1.gfx.part_1.frames", "1" }, { "door_1.gfx.part_2", "RocksDoor.png" }, { "door_1.gfx.part_2.x", "0" }, { "door_1.gfx.part_2.y", "77" }, { "door_1.gfx.part_2.width", "100" }, { "door_1.gfx.part_2.height", "63" }, + { "door_1.gfx.part_2.frames", "1" }, { "door_1.gfx.part_3", "RocksDoor.png" }, { "door_1.gfx.part_3.x", "0" }, { "door_1.gfx.part_3.y", "140" }, { "door_1.gfx.part_3.width", "100" }, { "door_1.gfx.part_3.height", "63" }, + { "door_1.gfx.part_3.frames", "1" }, { "door_1.gfx.part_4", "RocksDoor.png" }, { "door_1.gfx.part_4.x", "0" }, { "door_1.gfx.part_4.y", "203" }, { "door_1.gfx.part_4.width", "100" }, { "door_1.gfx.part_4.height", "77" }, + { "door_1.gfx.part_4.frames", "1" }, { "door_1.gfx.part_5", "RocksDoor.png" }, { "door_1.gfx.part_5.x", "100" }, { "door_1.gfx.part_5.y", "0" }, { "door_1.gfx.part_5.width", "100" }, { "door_1.gfx.part_5.height", "77" }, + { "door_1.gfx.part_5.frames", "1" }, { "door_1.gfx.part_6", "RocksDoor.png" }, { "door_1.gfx.part_6.x", "100" }, { "door_1.gfx.part_6.y", "77" }, { "door_1.gfx.part_6.width", "100" }, { "door_1.gfx.part_6.height", "63" }, + { "door_1.gfx.part_6.frames", "1" }, { "door_1.gfx.part_7", "RocksDoor.png" }, { "door_1.gfx.part_7.x", "100" }, { "door_1.gfx.part_7.y", "140" }, { "door_1.gfx.part_7.width", "100" }, { "door_1.gfx.part_7.height", "63" }, + { "door_1.gfx.part_7.frames", "1" }, { "door_1.gfx.part_8", "RocksDoor.png" }, { "door_1.gfx.part_8.x", "100" }, { "door_1.gfx.part_8.y", "203" }, { "door_1.gfx.part_8.width", "100" }, { "door_1.gfx.part_8.height", "77" }, + { "door_1.gfx.part_8.frames", "1" }, { "door_2.gfx.part_1", "RocksDoor.png" }, { "door_2.gfx.part_1.x", "0" }, { "door_2.gfx.part_1.y", "280" }, { "door_2.gfx.part_1.width", "100" }, { "door_2.gfx.part_1.height", "50" }, + { "door_1.gfx.part_1.frames", "1" }, { "door_2.gfx.part_2", "RocksDoor.png" }, { "door_2.gfx.part_2.x", "0" }, { "door_2.gfx.part_2.y", "330" }, { "door_2.gfx.part_2.width", "100" }, { "door_2.gfx.part_2.height", "50" }, + { "door_1.gfx.part_2.frames", "1" }, { "door_2.gfx.part_3", "RocksDoor.png" }, { "door_2.gfx.part_3.x", "100" }, { "door_2.gfx.part_3.y", "280" }, { "door_2.gfx.part_3.width", "100" }, { "door_2.gfx.part_3.height", "50" }, + { "door_1.gfx.part_3.frames", "1" }, { "door_2.gfx.part_4", "RocksDoor.png" }, { "door_2.gfx.part_4.x", "100" }, { "door_2.gfx.part_4.y", "330" }, { "door_2.gfx.part_4.width", "100" }, { "door_2.gfx.part_4.height", "50" }, + { "door_1.gfx.part_4.frames", "1" }, { "door_2.gfx.part_5", UNDEFINED_FILENAME }, { "door_2.gfx.part_6", UNDEFINED_FILENAME }, { "door_2.gfx.part_7", UNDEFINED_FILENAME }, diff --git a/src/conftime.h b/src/conftime.h index 7d96b1e5..7ebc3ab5 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2014-10-13 01:31" +#define COMPILE_DATE_STRING "2014-10-14 16:13" diff --git a/src/init.c b/src/init.c index 401e59ea..b0cad9db 100644 --- a/src/init.c +++ b/src/init.c @@ -1055,11 +1055,17 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, g->height = get_scaled_graphic_height(graphic); } + /* optional width and height of each animation frame */ + if (parameter[GFX_ARG_WIDTH] != ARG_UNDEFINED_VALUE) + g->width = parameter[GFX_ARG_WIDTH]; + if (parameter[GFX_ARG_HEIGHT] != ARG_UNDEFINED_VALUE) + g->height = parameter[GFX_ARG_HEIGHT]; + /* optional x and y tile position of animation frame sequence */ if (parameter[GFX_ARG_XPOS] != ARG_UNDEFINED_VALUE) - g->src_x = parameter[GFX_ARG_XPOS] * TILEX; + g->src_x = parameter[GFX_ARG_XPOS] * g->width; if (parameter[GFX_ARG_YPOS] != ARG_UNDEFINED_VALUE) - g->src_y = parameter[GFX_ARG_YPOS] * TILEY; + g->src_y = parameter[GFX_ARG_YPOS] * g->height; /* optional x and y pixel position of animation frame sequence */ if (parameter[GFX_ARG_X] != ARG_UNDEFINED_VALUE) @@ -1067,12 +1073,6 @@ static void set_graphic_parameters_ext(int graphic, int *parameter, if (parameter[GFX_ARG_Y] != ARG_UNDEFINED_VALUE) g->src_y = parameter[GFX_ARG_Y]; - /* optional width and height of each animation frame */ - if (parameter[GFX_ARG_WIDTH] != ARG_UNDEFINED_VALUE) - g->width = parameter[GFX_ARG_WIDTH]; - if (parameter[GFX_ARG_HEIGHT] != ARG_UNDEFINED_VALUE) - g->height = parameter[GFX_ARG_HEIGHT]; - if (src_bitmap) { if (g->width <= 0) diff --git a/src/tools.c b/src/tools.c index 49e927d3..082aa5ea 100644 --- a/src/tools.c +++ b/src/tools.c @@ -4113,6 +4113,8 @@ unsigned int MoveDoor(unsigned int door_state) int max_move_delay = 0; // delay for complete animations of all doors int max_step_delay = 0; // delay (ms) between two animation frames int num_move_steps = 0; // number of animation steps for all doors + int max_move_delay_doors_only = 0; // delay for doors only (no panel) + int num_move_steps_doors_only = 0; // steps for doors only (no panel) int current_move_delay = 0; int start = 0; int k; @@ -4161,16 +4163,21 @@ unsigned int MoveDoor(unsigned int door_state) if (door_part_skip[nr]) continue; - if (!is_panel) - panel_has_doors[door_index] = TRUE; - max_move_delay = MAX(max_move_delay, move_delay); max_step_delay = (max_step_delay == 0 ? step_delay : euclid(max_step_delay, step_delay)); num_steps[nr] = move_steps; + + if (!is_panel) + { + max_move_delay_doors_only = MAX(max_move_delay_doors_only, move_delay); + + panel_has_doors[door_index] = TRUE; + } } num_move_steps = max_move_delay / max_step_delay; + num_move_steps_doors_only = max_move_delay_doors_only / max_step_delay; door_delay_value = max_step_delay; @@ -4203,6 +4210,7 @@ unsigned int MoveDoor(unsigned int door_state) int door_token = dpc->door_token; int door_index = DOOR_INDEX_FROM_TOKEN(door_token); boolean is_panel = DOOR_PART_IS_PANEL(nr); + boolean is_panel_and_door_has_closed = FALSE; struct Rect *door_rect = &door_rect_list[door_index]; Bitmap *bitmap_db_door = (door_token == DOOR_1 ? bitmap_db_door_1 : bitmap_db_door_2); @@ -4218,7 +4226,9 @@ unsigned int MoveDoor(unsigned int door_state) int step_factor = step_delay / max_step_delay; int k1 = (step_factor ? k / step_factor + 1 : k); int k2 = (part_opening ? k1 + start_step : num_steps[nr] - k1); - int kk = (k2 < 0 ? 0 : k2); + int kk = MAX(0, k2); + int g_src_x = 0; + int g_src_y = 0; int src_x, src_y, src_xx, src_yy; int dst_x, dst_y, dst_xx, dst_yy; int width, height; @@ -4232,6 +4242,16 @@ unsigned int MoveDoor(unsigned int door_state) if (!g->bitmap) continue; + if (!is_panel) + { + int k2_door = (door_opening ? k : num_move_steps_doors_only - k - 1); + int kk_door = MAX(0, k2_door); + int sync_frame = kk_door * door_delay_value; + int frame = getGraphicAnimationFrame(dpc->graphic, sync_frame); + + getGraphicSource(dpc->graphic, frame, &bitmap, &g_src_x, &g_src_y); + } + // draw door panel if (!door_panel_drawn[door_index]) @@ -4292,22 +4312,21 @@ unsigned int MoveDoor(unsigned int door_state) height = g->height - src_yy; } - if (is_panel) - { - src_x = src_xx; - src_y = src_yy; - } - else - { - src_x = g->src_x + src_xx; - src_y = g->src_y + src_yy; - } + src_x = g_src_x + src_xx; + src_y = g_src_y + src_yy; dst_x = door_rect->x + dst_xx; dst_y = door_rect->y + dst_yy; + is_panel_and_door_has_closed = + (is_panel && + door_closing && + panel_has_doors[door_index] && + k >= num_move_steps_doors_only - 1); + if (width >= 0 && width <= g->width && - height >= 0 && height <= g->height) + height >= 0 && height <= g->height && + !is_panel_and_door_has_closed) { if (is_panel || !pos->draw_masked) BlitBitmap(bitmap, drawto, src_x, src_y, width, height, @@ -4324,8 +4343,7 @@ unsigned int MoveDoor(unsigned int door_state) door_part_done[nr] = TRUE; // continue door part animations, but not panel after door has closed - if (!door_part_done[nr] && - !(is_panel && door_closing && panel_has_doors[door_index])) + if (!door_part_done[nr] && !is_panel_and_door_has_closed) door_part_done_all = FALSE; }