From: Holger Schemel Date: Sat, 12 Aug 2006 14:02:46 +0000 (+0200) Subject: rnd-20060812-1-src X-Git-Tag: 3.2.1^2~16 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=db796e071bbe21db45ac516e55eaf2ea7cee33d5;p=rocksndiamonds.git rnd-20060812-1-src * added configurable level preview position, tile size and dimensions --- diff --git a/ChangeLog b/ChangeLog index 6c7adba7..91e84c11 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2006-08-12 + * added configurable level preview position, tile size and dimensions + 2006-08-10 * fixed small bug with time displayed incorrectly when collecting CEs diff --git a/src/conf_gfx.c b/src/conf_gfx.c index cc9c1366..44a4ca80 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -4547,10 +4547,15 @@ struct ConfigInfo image_config[] = { "door_2.step_delay", "10" }, { "door_2.anim_mode", "default" }, -#if DEBUG - { "preview.x", "-1" }, - { "preview.y", "-1" }, + { "preview.x", "148" }, + { "preview.y", "388" }, + { "preview.xsize", "66" }, + { "preview.ysize", "34" }, + { "preview.tile_size", "4" }, + { "preview.step_offset", "1" }, + { "preview.step_delay", "50" }, +#if DEBUG { "game.level.x", "-1" }, { "game.level.y", "-1" }, { "game.gems.x", "-1" }, diff --git a/src/conftime.h b/src/conftime.h index 51e949f6..ff232cef 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-08-10 08:17]" +#define COMPILE_DATE_STRING "[2006-08-12 16:00]" diff --git a/src/init.c b/src/init.c index 48cd370b..eebf70c4 100644 --- a/src/init.c +++ b/src/init.c @@ -295,7 +295,7 @@ void InitFontGraphicInfo() if (graphic_info[graphic].anim_frames < MIN_NUM_CHARS_PER_FONT) { graphic_info[graphic].anim_frames = DEFAULT_NUM_CHARS_PER_FONT; - graphic_info[graphic].anim_frames_per_line= DEFAULT_NUM_CHARS_PER_LINE; + graphic_info[graphic].anim_frames_per_line = DEFAULT_NUM_CHARS_PER_LINE; } /* copy font relevant information from graphics information */ diff --git a/src/main.c b/src/main.c index c9c29c8b..e300b54f 100644 --- a/src/main.c +++ b/src/main.c @@ -109,6 +109,7 @@ struct GameInfo game; struct GlobalInfo global; struct MenuInfo menu; struct DoorInfo door_1, door_2; +struct PreviewInfo preview; struct GraphicInfo *graphic_info = NULL; struct SoundInfo *sound_info = NULL; struct MusicInfo *music_info = NULL; @@ -4638,47 +4639,55 @@ struct SpecialSuffixInfo special_suffix_info[NUM_SPECIAL_GFX_ARGS + 1 + 1] = struct TokenIntPtrInfo image_config_vars[] = { - { "global.num_toons", &global.num_toons }, + { "global.num_toons", &global.num_toons }, - { "menu.draw_xoffset", &menu.draw_xoffset[GFX_SPECIAL_ARG_DEFAULT]}, - { "menu.draw_yoffset", &menu.draw_yoffset[GFX_SPECIAL_ARG_DEFAULT]}, - { "menu.draw_xoffset.MAIN", &menu.draw_xoffset[GFX_SPECIAL_ARG_MAIN] }, - { "menu.draw_yoffset.MAIN", &menu.draw_yoffset[GFX_SPECIAL_ARG_MAIN] }, - { "menu.draw_xoffset.LEVELS", &menu.draw_xoffset[GFX_SPECIAL_ARG_LEVELS] }, - { "menu.draw_yoffset.LEVELS", &menu.draw_yoffset[GFX_SPECIAL_ARG_LEVELS] }, - { "menu.draw_xoffset.SCORES", &menu.draw_xoffset[GFX_SPECIAL_ARG_SCORES] }, - { "menu.draw_yoffset.SCORES", &menu.draw_yoffset[GFX_SPECIAL_ARG_SCORES] }, - { "menu.draw_xoffset.EDITOR", &menu.draw_xoffset[GFX_SPECIAL_ARG_EDITOR] }, - { "menu.draw_yoffset.EDITOR", &menu.draw_yoffset[GFX_SPECIAL_ARG_EDITOR] }, - { "menu.draw_xoffset.INFO", &menu.draw_xoffset[GFX_SPECIAL_ARG_INFO] }, - { "menu.draw_yoffset.INFO", &menu.draw_yoffset[GFX_SPECIAL_ARG_INFO] }, - { "menu.draw_xoffset.SETUP", &menu.draw_xoffset[GFX_SPECIAL_ARG_SETUP] }, - { "menu.draw_yoffset.SETUP", &menu.draw_yoffset[GFX_SPECIAL_ARG_SETUP] }, + { "menu.draw_xoffset", &menu.draw_xoffset[GFX_SPECIAL_ARG_DEFAULT] }, + { "menu.draw_yoffset", &menu.draw_yoffset[GFX_SPECIAL_ARG_DEFAULT] }, + { "menu.draw_xoffset.MAIN", &menu.draw_xoffset[GFX_SPECIAL_ARG_MAIN] }, + { "menu.draw_yoffset.MAIN", &menu.draw_yoffset[GFX_SPECIAL_ARG_MAIN] }, + { "menu.draw_xoffset.LEVELS", &menu.draw_xoffset[GFX_SPECIAL_ARG_LEVELS] }, + { "menu.draw_yoffset.LEVELS", &menu.draw_yoffset[GFX_SPECIAL_ARG_LEVELS] }, + { "menu.draw_xoffset.SCORES", &menu.draw_xoffset[GFX_SPECIAL_ARG_SCORES] }, + { "menu.draw_yoffset.SCORES", &menu.draw_yoffset[GFX_SPECIAL_ARG_SCORES] }, + { "menu.draw_xoffset.EDITOR", &menu.draw_xoffset[GFX_SPECIAL_ARG_EDITOR] }, + { "menu.draw_yoffset.EDITOR", &menu.draw_yoffset[GFX_SPECIAL_ARG_EDITOR] }, + { "menu.draw_xoffset.INFO", &menu.draw_xoffset[GFX_SPECIAL_ARG_INFO] }, + { "menu.draw_yoffset.INFO", &menu.draw_yoffset[GFX_SPECIAL_ARG_INFO] }, + { "menu.draw_xoffset.SETUP", &menu.draw_xoffset[GFX_SPECIAL_ARG_SETUP] }, + { "menu.draw_yoffset.SETUP", &menu.draw_yoffset[GFX_SPECIAL_ARG_SETUP] }, - { "menu.scrollbar_xoffset", &menu.scrollbar_xoffset }, + { "menu.scrollbar_xoffset", &menu.scrollbar_xoffset }, - { "menu.list_size", &menu.list_size[GFX_SPECIAL_ARG_DEFAULT] }, - { "menu.list_size.LEVELS", &menu.list_size[GFX_SPECIAL_ARG_LEVELS] }, - { "menu.list_size.SCORES", &menu.list_size[GFX_SPECIAL_ARG_SCORES] }, - { "menu.list_size.INFO", &menu.list_size[GFX_SPECIAL_ARG_INFO] }, + { "menu.list_size", &menu.list_size[GFX_SPECIAL_ARG_DEFAULT] }, + { "menu.list_size.LEVELS", &menu.list_size[GFX_SPECIAL_ARG_LEVELS] }, + { "menu.list_size.SCORES", &menu.list_size[GFX_SPECIAL_ARG_SCORES] }, + { "menu.list_size.INFO", &menu.list_size[GFX_SPECIAL_ARG_INFO] }, - { "door_1.width", &door_1.width }, - { "door_1.height", &door_1.height }, - { "door_1.step_offset", &door_1.step_offset }, - { "door_1.step_delay", &door_1.step_delay }, - { "door_1.anim_mode", &door_1.anim_mode }, - { "door_2.width", &door_2.width }, - { "door_2.height", &door_2.height }, - { "door_2.step_offset", &door_2.step_offset }, - { "door_2.step_delay", &door_2.step_delay }, - { "door_2.anim_mode", &door_2.anim_mode }, + { "door_1.width", &door_1.width }, + { "door_1.height", &door_1.height }, + { "door_1.step_offset", &door_1.step_offset }, + { "door_1.step_delay", &door_1.step_delay }, + { "door_1.anim_mode", &door_1.anim_mode }, + { "door_2.width", &door_2.width }, + { "door_2.height", &door_2.height }, + { "door_2.step_offset", &door_2.step_offset }, + { "door_2.step_delay", &door_2.step_delay }, + { "door_2.anim_mode", &door_2.anim_mode }, - { "[player].boring_delay_fixed", &game.player_boring_delay_fixed }, - { "[player].boring_delay_random", &game.player_boring_delay_random }, - { "[player].sleeping_delay_fixed", &game.player_sleeping_delay_fixed }, - { "[player].sleeping_delay_random", &game.player_sleeping_delay_random }, + { "preview.x", &preview.x }, + { "preview.y", &preview.y }, + { "preview.xsize", &preview.xsize }, + { "preview.ysize", &preview.ysize }, + { "preview.tile_size", &preview.tile_size }, + { "preview.step_offset", &preview.step_offset }, + { "preview.step_delay", &preview.step_delay }, - { NULL, NULL, } + { "[player].boring_delay_fixed", &game.player_boring_delay_fixed }, + { "[player].boring_delay_random", &game.player_boring_delay_random }, + { "[player].sleeping_delay_fixed", &game.player_sleeping_delay_fixed }, + { "[player].sleeping_delay_random", &game.player_sleeping_delay_random }, + + { NULL, NULL, } }; diff --git a/src/main.h b/src/main.h index 24cc61c8..1019c618 100644 --- a/src/main.h +++ b/src/main.h @@ -1852,6 +1852,15 @@ struct DoorInfo int anim_mode; }; +struct PreviewInfo +{ + int x, y; + int xsize, ysize; + int tile_size; + int step_offset; + int step_delay; +}; + struct HiScore { char Name[MAX_PLAYER_NAME_LEN + 1]; @@ -2221,20 +2230,28 @@ struct GraphicInfo 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 offset2_x, offset2_y; /* x/y offset to second movement tile */ + boolean double_movement; /* animation has second movement tile */ int swap_double_tiles; /* explicitely force or forbid tile swapping */ + int anim_frames; int anim_frames_per_line; int anim_start_frame; int anim_delay; /* important: delay of 1 means "no delay"! */ int anim_mode; + boolean anim_global_sync; + int crumbled_like; /* element for cloning crumble graphics */ int diggable_like; /* element for cloning digging graphics */ + int border_size; /* border size for "crumbled" graphics */ + int scale_up_factor; /* optional factor for scaling image up */ + int clone_from; /* graphic for cloning *all* settings */ int anim_delay_fixed; /* optional delay values for bored and */ @@ -2414,6 +2431,7 @@ extern struct TapeInfo tape; extern struct GlobalInfo global; extern struct MenuInfo menu; extern struct DoorInfo door_1, door_2; +extern struct PreviewInfo preview; extern struct ElementInfo element_info[]; extern struct ElementNameInfo element_name_info[]; extern struct ElementActionInfo element_action_info[]; diff --git a/src/screens.c b/src/screens.c index cc395c8f..aa03e16a 100644 --- a/src/screens.c +++ b/src/screens.c @@ -425,7 +425,7 @@ static void DrawMainMenuExt(int fade_delay) #endif #endif - DrawMicroLevel(MICROLEVEL_XPOS, MICROLEVEL_YPOS, TRUE); + DrawPreviewLevel(TRUE); #if 1 @@ -728,13 +728,13 @@ void HandleMainMenu_SelectLevel(int step, int direction) DrawText(mSX + 11 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1); LoadLevel(level_nr); - DrawMicroLevel(MICROLEVEL_XPOS, MICROLEVEL_YPOS, TRUE); + DrawPreviewLevel(TRUE); TapeErase(); LoadTape(level_nr); DrawCompleteVideoDisplay(); - /* needed because DrawMicroLevel() takes some time */ + /* needed because DrawPreviewLevel() takes some time */ BackToFront(); SyncDisplay(); } @@ -824,13 +824,13 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) FONT_VALUE_1); LoadLevel(level_nr); - DrawMicroLevel(MICROLEVEL_XPOS, MICROLEVEL_YPOS, TRUE); + DrawPreviewLevel(TRUE); TapeErase(); LoadTape(level_nr); DrawCompleteVideoDisplay(); - /* needed because DrawMicroLevel() takes some time */ + /* needed because DrawPreviewLevel() takes some time */ BackToFront(); SyncDisplay(); @@ -920,7 +920,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) if (game_status == GAME_MODE_MAIN) { - DrawMicroLevel(MICROLEVEL_XPOS, MICROLEVEL_YPOS, FALSE); + DrawPreviewLevel(FALSE); DoAnimation(); } } diff --git a/src/tools.c b/src/tools.c index f7a3011e..866870a2 100644 --- a/src/tools.c +++ b/src/tools.c @@ -44,8 +44,6 @@ static int el_act2crm(int, int); static struct GadgetInfo *tool_gadget[NUM_TOOL_BUTTONS]; static int request_gadget_id = -1; -static int preview_tilesize = TILEX / 4; - static char *print_if_not_empty(int element) { static char *s = NULL; @@ -1482,19 +1480,6 @@ void ShowEnvelope(int envelope_nr) BackToFront(); } -void getMicroGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y) -{ - Bitmap *src_bitmap = graphic_info[graphic].bitmap; - int mini_startx = src_bitmap->width * 3 / 4; - int mini_starty = src_bitmap->height * 2 / 3; - int src_x = mini_startx + graphic_info[graphic].src_x / 8; - int src_y = mini_starty + graphic_info[graphic].src_y / 8; - - *bitmap = src_bitmap; - *x = src_x; - *y = src_y; -} - void getPreviewGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y, int tilesize) { @@ -1526,25 +1511,14 @@ void getPreviewGraphicSource(int graphic, Bitmap **bitmap, int *x, int *y, *y = src_y; } -void DrawMicroElement(int xpos, int ypos, int element) -{ - Bitmap *src_bitmap; - int src_x, src_y; - int graphic = el2preimg(element); - - getMicroGraphicSource(graphic, &src_bitmap, &src_x, &src_y); - BlitBitmap(src_bitmap, drawto, src_x, src_y, MICRO_TILEX, MICRO_TILEY, - xpos, ypos); -} - -void DrawPreviewElement(int xpos, int ypos, int element, int tilesize) +void DrawPreviewElement(int dst_x, int dst_y, int element, int tilesize) { Bitmap *src_bitmap; int src_x, src_y; int graphic = el2preimg(element); getPreviewGraphicSource(graphic, &src_bitmap, &src_x, &src_y, tilesize); - BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize, tilesize, xpos, ypos); + BlitBitmap(src_bitmap, drawto, src_x, src_y, tilesize, tilesize, dst_x,dst_y); } void DrawLevel() @@ -1572,34 +1546,36 @@ void DrawMiniLevel(int size_x, int size_y, int scroll_x, int scroll_y) redraw_mask |= REDRAW_FIELD; } -static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y) +static void DrawPreviewLevelExt(int from_x, int from_y) { boolean show_level_border = (BorderElement != EL_EMPTY); - int level_size_x = lev_fieldx + (show_level_border ? 2 : 0); - int level_size_y = lev_fieldy + (show_level_border ? 2 : 0); - int preview_size_x = MICROLEVEL_XSIZE / preview_tilesize; - int preview_size_y = MICROLEVEL_YSIZE / preview_tilesize; - int real_preview_size_x = MIN(level_size_x, preview_size_x); - int real_preview_size_y = MIN(level_size_y, preview_size_y); + int dst_x = preview.x; + int dst_y = preview.y; + int level_xsize = lev_fieldx + (show_level_border ? 2 : 0); + int level_ysize = lev_fieldy + (show_level_border ? 2 : 0); + int tile_size = preview.tile_size; + int preview_width = preview.xsize * tile_size; + int preview_height = preview.ysize * tile_size; + int real_preview_xsize = MIN(level_xsize, preview.xsize); + int real_preview_ysize = MIN(level_ysize, preview.ysize); int x, y; - DrawBackground(xpos, ypos, MICROLEVEL_XSIZE, MICROLEVEL_YSIZE); + DrawBackground(dst_x, dst_y, preview_width, preview_height); - xpos += (MICROLEVEL_XSIZE - real_preview_size_x * preview_tilesize) / 2; - ypos += (MICROLEVEL_YSIZE - real_preview_size_y * preview_tilesize) / 2; + dst_x += (preview_width - real_preview_xsize * tile_size) / 2; + dst_y += (preview_height - real_preview_ysize * tile_size) / 2; - for (x = 0; x < real_preview_size_x; x++) + for (x = 0; x < real_preview_xsize; x++) { - for (y = 0; y < real_preview_size_y; y++) + for (y = 0; y < real_preview_ysize; y++) { int lx = from_x + x + (show_level_border ? -1 : 0); int ly = from_y + y + (show_level_border ? -1 : 0); int element = (IN_LEV_FIELD(lx, ly) ? level.field[lx][ly] : getBorderElement(lx, ly)); - DrawPreviewElement(xpos + x * preview_tilesize, - ypos + y * preview_tilesize, - element, preview_tilesize); + DrawPreviewElement(dst_x + x * tile_size, dst_y + y * tile_size, + element, tile_size); } } @@ -1615,7 +1591,7 @@ static void DrawMicroLevelExt(int xpos, int ypos, int from_x, int from_y) #define MICROLABEL_IMPORTED_BY_HEAD 6 #define MICROLABEL_IMPORTED_BY 7 -static void DrawMicroLevelLabelExt(int mode) +static void DrawPreviewLevelLabelExt(int mode) { char label_text[MAX_OUTPUT_LINESIZE + 1]; int max_len_label_text; @@ -1663,20 +1639,17 @@ static void DrawMicroLevelLabelExt(int mode) redraw_mask |= REDRAW_MICROLEVEL; } -void DrawMicroLevel(int xpos, int ypos, boolean restart) +void DrawPreviewLevel(boolean restart) { static unsigned long scroll_delay = 0; static unsigned long label_delay = 0; static int from_x, from_y, scroll_direction; static int label_state, label_counter; - int delay_factor = preview_tilesize / MICRO_TILESIZE; - unsigned long scroll_delay_value = MICROLEVEL_SCROLL_DELAY * delay_factor; + unsigned long scroll_delay_value = preview.step_delay; boolean show_level_border = (BorderElement != EL_EMPTY); - int level_size_x = lev_fieldx + (show_level_border ? 2 : 0); - int level_size_y = lev_fieldy + (show_level_border ? 2 : 0); - int preview_size_x = MICROLEVEL_XSIZE / preview_tilesize; - int preview_size_y = MICROLEVEL_YSIZE / preview_tilesize; - int last_game_status = game_status; /* save current game status */ + int level_xsize = lev_fieldx + (show_level_border ? 2 : 0); + int level_ysize = lev_fieldy + (show_level_border ? 2 : 0); + int last_game_status = game_status; /* save current game status */ /* force PREVIEW font on preview level */ game_status = GAME_MODE_PSEUDO_PREVIEW; @@ -1688,8 +1661,8 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) label_state = 1; label_counter = 0; - DrawMicroLevelExt(xpos, ypos, from_x, from_y); - DrawMicroLevelLabelExt(label_state); + DrawPreviewLevelExt(from_x, from_y); + DrawPreviewLevelLabelExt(label_state); /* initialize delay counters */ DelayReached(&scroll_delay, 0); @@ -1716,36 +1689,50 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) return; } - /* scroll micro level, if needed */ - if ((level_size_x > preview_size_x || level_size_y > preview_size_y) && + /* scroll preview level, if needed */ + if ((level_xsize > preview.xsize || level_ysize > preview.ysize) && DelayReached(&scroll_delay, scroll_delay_value)) { switch (scroll_direction) { case MV_LEFT: if (from_x > 0) - from_x--; + { + from_x -= preview.step_offset; + from_x = (from_x < 0 ? 0 : from_x); + } else scroll_direction = MV_UP; break; case MV_RIGHT: - if (from_x < level_size_x - preview_size_x) - from_x++; + if (from_x < level_xsize - preview.xsize) + { + from_x += preview.step_offset; + from_x = (from_x > level_xsize - preview.xsize ? + level_xsize - preview.xsize : from_x); + } else scroll_direction = MV_DOWN; break; case MV_UP: if (from_y > 0) - from_y--; + { + from_y -= preview.step_offset; + from_y = (from_y < 0 ? 0 : from_y); + } else scroll_direction = MV_RIGHT; break; case MV_DOWN: - if (from_y < level_size_y - preview_size_y) - from_y++; + if (from_y < level_ysize - preview.ysize) + { + from_y += preview.step_offset; + from_y = (from_y > level_ysize - preview.ysize ? + level_ysize - preview.ysize : from_y); + } else scroll_direction = MV_LEFT; break; @@ -1754,7 +1741,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) break; } - DrawMicroLevelExt(xpos, ypos, from_x, from_y); + DrawPreviewLevelExt(from_x, from_y); } /* !!! THIS ALL SUCKS -- SHOULD BE CLEANLY REWRITTEN !!! */ @@ -1795,7 +1782,7 @@ void DrawMicroLevel(int xpos, int ypos, boolean restart) label_state = (label_state == MICROLABEL_IMPORTED_FROM_HEAD ? MICROLABEL_IMPORTED_BY_HEAD : MICROLABEL_IMPORTED_BY); - DrawMicroLevelLabelExt(label_state); + DrawPreviewLevelLabelExt(label_state); } game_status = last_game_status; /* restore current game status */ diff --git a/src/tools.h b/src/tools.h index a06527ae..7e8f53c5 100644 --- a/src/tools.h +++ b/src/tools.h @@ -124,11 +124,9 @@ void DrawMiniElementOrWall(int, int, int, int); void ShowEnvelope(); -void getMicroGraphicSource(int, Bitmap **, int *, int *); -void DrawMicroElement(int, int, int); void DrawLevel(void); void DrawMiniLevel(int, int, int, int); -void DrawMicroLevel(int, int, boolean); +void DrawPreviewLevel(boolean); void WaitForEventToContinue(); boolean Request(char *, unsigned int);