+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
{ "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" },
-#define COMPILE_DATE_STRING "[2006-08-10 08:17]"
+#define COMPILE_DATE_STRING "[2006-08-12 16:00]"
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 */
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;
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, }
};
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];
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 */
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[];
#endif
#endif
- DrawMicroLevel(MICROLEVEL_XPOS, MICROLEVEL_YPOS, TRUE);
+ DrawPreviewLevel(TRUE);
#if 1
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();
}
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();
if (game_status == GAME_MODE_MAIN)
{
- DrawMicroLevel(MICROLEVEL_XPOS, MICROLEVEL_YPOS, FALSE);
+ DrawPreviewLevel(FALSE);
DoAnimation();
}
}
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;
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)
{
*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()
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);
}
}
#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;
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;
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);
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;
break;
}
- DrawMicroLevelExt(xpos, ypos, from_x, from_y);
+ DrawPreviewLevelExt(from_x, from_y);
}
/* !!! THIS ALL SUCKS -- SHOULD BE CLEANLY REWRITTEN !!! */
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 */
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);