From: Holger Schemel Date: Sun, 30 Apr 2006 02:18:01 +0000 (+0200) Subject: rnd-20060430-1-src X-Git-Tag: 3.2.0^2~28 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=6d7ebf6db8a9a57f2e3e398da1d2f7d8d084523f;p=rocksndiamonds.git rnd-20060430-1-src * added setup option to display element token name in level editor --- diff --git a/ChangeLog b/ChangeLog index 32736a4d..e3694fca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2006-04-28 * added "CE score gets zero [of]" to custom element trigger conditions + * added setup option to display element token name in level editor 2006-04-19 * added compatibility code for Juergen Bonhagen's menu artwork settings diff --git a/src/conf_gfx.c b/src/conf_gfx.c index b9e97c30..e2af8d07 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -4389,7 +4389,14 @@ struct ConfigInfo image_config[] = { "background.envelope_4.anim_mode", "default" }, { "background.envelope_4.draw_masked", "false" }, + { "titlescreen_1", UNDEFINED_FILENAME }, + { "titlescreen_2", UNDEFINED_FILENAME }, + { "titlescreen_3", UNDEFINED_FILENAME }, + { "titlescreen_4", UNDEFINED_FILENAME }, + { "titlescreen_5", UNDEFINED_FILENAME }, + { "background", UNDEFINED_FILENAME }, + { "background.TITLE", UNDEFINED_FILENAME }, { "background.MAIN", UNDEFINED_FILENAME }, { "background.LEVELS", UNDEFINED_FILENAME }, { "background.SCORES", UNDEFINED_FILENAME }, diff --git a/src/conf_gfx.h b/src/conf_gfx.h index d97f3095..4d6e27db 100644 --- a/src/conf_gfx.h +++ b/src/conf_gfx.h @@ -1541,20 +1541,26 @@ #define IMG_BACKGROUND_ENVELOPE_2 1520 #define IMG_BACKGROUND_ENVELOPE_3 1521 #define IMG_BACKGROUND_ENVELOPE_4 1522 -#define IMG_BACKGROUND 1523 -#define IMG_BACKGROUND_MAIN 1524 -#define IMG_BACKGROUND_LEVELS 1525 -#define IMG_BACKGROUND_SCORES 1526 -#define IMG_BACKGROUND_EDITOR 1527 -#define IMG_BACKGROUND_INFO 1528 -#define IMG_BACKGROUND_INFO_ELEMENTS 1529 -#define IMG_BACKGROUND_INFO_MUSIC 1530 -#define IMG_BACKGROUND_INFO_CREDITS 1531 -#define IMG_BACKGROUND_INFO_PROGRAM 1532 -#define IMG_BACKGROUND_INFO_LEVELSET 1533 -#define IMG_BACKGROUND_SETUP 1534 -#define IMG_BACKGROUND_DOOR 1535 +#define IMG_TITLESCREEN_1 1523 +#define IMG_TITLESCREEN_2 1524 +#define IMG_TITLESCREEN_3 1525 +#define IMG_TITLESCREEN_4 1526 +#define IMG_TITLESCREEN_5 1527 +#define IMG_BACKGROUND 1528 +#define IMG_BACKGROUND_TITLE 1529 +#define IMG_BACKGROUND_MAIN 1530 +#define IMG_BACKGROUND_LEVELS 1531 +#define IMG_BACKGROUND_SCORES 1532 +#define IMG_BACKGROUND_EDITOR 1533 +#define IMG_BACKGROUND_INFO 1534 +#define IMG_BACKGROUND_INFO_ELEMENTS 1535 +#define IMG_BACKGROUND_INFO_MUSIC 1536 +#define IMG_BACKGROUND_INFO_CREDITS 1537 +#define IMG_BACKGROUND_INFO_PROGRAM 1538 +#define IMG_BACKGROUND_INFO_LEVELSET 1539 +#define IMG_BACKGROUND_SETUP 1540 +#define IMG_BACKGROUND_DOOR 1541 -#define NUM_IMAGE_FILES 1536 +#define NUM_IMAGE_FILES 1542 #endif /* CONF_GFX_H */ diff --git a/src/conftime.h b/src/conftime.h index fe9ec95e..f421ea5d 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "[2006-04-28 20:25]" +#define COMPILE_DATE_STRING "[2006-04-30 04:12]" diff --git a/src/editor.c b/src/editor.c index 89c3de15..631a5756 100644 --- a/src/editor.c +++ b/src/editor.c @@ -7597,6 +7597,16 @@ static void DrawPropertiesInfo() int screen_line = 0; int i, x, y; +#if 1 + if (setup.editor.show_element_token) + { + DrawTextF(pad_x, pad_y + screen_line++ * font2_height, FONT_TEXT_3, + "[%s]", element_info[properties_element].token_name); + screen_line++; + } + +#else + #if DEBUG if (IS_CUSTOM_ELEMENT(properties_element)) { @@ -7610,6 +7620,7 @@ static void DrawPropertiesInfo() "[Group Element %d]", properties_element - EL_GROUP_START + 1); screen_line++; } +#endif #endif /* ----- print number of elements / percentage of this element in level */ diff --git a/src/events.c b/src/events.c index 1ae5caa9..002e4fdf 100644 --- a/src/events.c +++ b/src/events.c @@ -420,6 +420,10 @@ void HandleButton(int mx, int my, int button) switch(game_status) { + case GAME_MODE_TITLE: + HandleTitleScreen(mx,my, 0,0, button); + break; + case GAME_MODE_MAIN: HandleMainMenu(mx,my, 0,0, button); break; @@ -735,6 +739,7 @@ void HandleKey(Key key, int key_status) HandleTypeName(0, key); break; + case GAME_MODE_TITLE: case GAME_MODE_MAIN: case GAME_MODE_LEVELS: case GAME_MODE_SETUP: @@ -748,7 +753,9 @@ void HandleKey(Key key, int key_status) case KSYM_space: #endif case KSYM_Return: - if (game_status == GAME_MODE_MAIN) + if (game_status == GAME_MODE_TITLE) + HandleTitleScreen(0,0, 0,0, MB_MENU_CHOICE); + else if (game_status == GAME_MODE_MAIN) HandleMainMenu(0,0, 0,0, MB_MENU_CHOICE); else if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0, 0,0, MB_MENU_CHOICE); @@ -759,7 +766,9 @@ void HandleKey(Key key, int key_status) break; case KSYM_Escape: - if (game_status == GAME_MODE_LEVELS) + if (game_status == GAME_MODE_TITLE) + HandleTitleScreen(0,0, 0,0, MB_MENU_LEAVE); + else if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0, 0,0, MB_MENU_LEAVE); else if (game_status == GAME_MODE_SETUP) HandleSetupScreen(0,0, 0,0, MB_MENU_LEAVE); @@ -1003,7 +1012,9 @@ void HandleJoystick() !DelayReached(&joystickmove_delay, GADGET_FRAME_DELAY)) newbutton = dx = dy = 0; - if (game_status == GAME_MODE_MAIN) + if (game_status == GAME_MODE_TITLE) + HandleTitleScreen(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); + else if (game_status == GAME_MODE_MAIN) HandleMainMenu(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); else if (game_status == GAME_MODE_LEVELS) HandleChooseLevel(0,0,dx,dy,newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); diff --git a/src/files.c b/src/files.c index ea54c227..e6baec25 100644 --- a/src/files.c +++ b/src/files.c @@ -4978,8 +4978,9 @@ void SaveScore(int nr) #define SETUP_TOKEN_EDITOR_EL_HEADLINES 10 #define SETUP_TOKEN_EDITOR_EL_USER_DEFINED 11 #define SETUP_TOKEN_EDITOR_EL_DYNAMIC 12 +#define SETUP_TOKEN_EDITOR_SHOW_ELEMENT_TOKEN 13 -#define NUM_EDITOR_SETUP_TOKENS 13 +#define NUM_EDITOR_SETUP_TOKENS 14 /* editor cascade setup */ #define SETUP_TOKEN_EDITOR_CASCADE_BD 0 @@ -5097,6 +5098,7 @@ static struct TokenInfo editor_setup_tokens[] = { TYPE_SWITCH, &sei.el_headlines, "editor.el_headlines" }, { TYPE_SWITCH, &sei.el_user_defined, "editor.el_user_defined" }, { TYPE_SWITCH, &sei.el_dynamic, "editor.el_dynamic" }, + { TYPE_SWITCH, &sei.show_element_token,"editor.show_element_token" }, }; static struct TokenInfo editor_cascade_setup_tokens[] = @@ -5225,6 +5227,8 @@ static void setSetupInfoToDefaults(struct SetupInfo *si) si->editor.el_user_defined = FALSE; si->editor.el_dynamic = TRUE; + si->editor.show_element_token = FALSE; + si->shortcut.save_game = DEFAULT_KEY_SAVE_GAME; si->shortcut.load_game = DEFAULT_KEY_LOAD_GAME; si->shortcut.toggle_pause = DEFAULT_KEY_TOGGLE_PAUSE; diff --git a/src/init.c b/src/init.c index 9b487df0..a25394b6 100644 --- a/src/init.c +++ b/src/init.c @@ -143,6 +143,15 @@ void InitElementSmallImages() InitElementSmallImagesScaledUp(special_graphics[i]); } +void InitScaledImages() +{ + int i; + + /* scale normal images from static configuration, if not already scaled */ + for (i = 0; i < NUM_IMAGE_FILES; i++) + ScaleImage(i, graphic_info[i].scale_up_factor); +} + #if 1 /* !!! FIX THIS (CHANGE TO USING NORMAL ELEMENT GRAPHIC DEFINITIONS) !!! */ void SetBitmaps_EM(Bitmap **em_bitmap) @@ -1647,7 +1656,8 @@ static void ReinitializeGraphics() InitElementGraphicInfo(); /* element game graphic mapping */ InitElementSpecialGraphicInfo(); /* element special graphic mapping */ - InitElementSmallImages(); /* scale images to all needed sizes */ + InitElementSmallImages(); /* scale elements to all needed sizes */ + InitScaledImages(); /* scale all other images, if needed */ InitFontGraphicInfo(); /* initialize text drawing functions */ InitGraphicInfo_EM(); /* graphic mapping for EM engine */ @@ -4371,7 +4381,8 @@ void InitGfx() if (filename_font_initial == NULL) /* should not happen */ Error(ERR_EXIT, "cannot get filename for '%s'", CONFIG_TOKEN_FONT_INITIAL); - /* create additional image buffers for double-buffering */ + /* create additional image buffers for double-buffering and cross-fading */ + bitmap_db_title = CreateBitmap(WIN_XSIZE, WIN_YSIZE, DEFAULT_DEPTH); bitmap_db_field = CreateBitmap(FXSIZE, FYSIZE, DEFAULT_DEPTH); bitmap_db_door = CreateBitmap(3 * DXSIZE, DYSIZE + VYSIZE, DEFAULT_DEPTH); @@ -4396,6 +4407,14 @@ void InitGfx() DrawInitText("Loading graphics:", 120, FC_GREEN); } +void RedrawBackground() +{ + BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer, + 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); + + redraw_mask = REDRAW_ALL; +} + void InitGfxBackground() { int x, y; @@ -4404,8 +4423,8 @@ void InitGfxBackground() fieldbuffer = bitmap_db_field; SetDrawtoField(DRAW_BACKBUFFER); - BlitBitmap(graphic_info[IMG_GLOBAL_BORDER].bitmap, backbuffer, - 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); + RedrawBackground(); + ClearRectangle(backbuffer, REAL_SX, REAL_SY, FULL_SXSIZE, FULL_SYSIZE); ClearRectangle(bitmap_db_door, 0, 0, 3 * DXSIZE, DYSIZE + VYSIZE); @@ -4662,7 +4681,11 @@ void ReloadCustomArtwork(int force_reload) if (redraw_screen) { +#if 1 + RedrawBackground(); +#else InitGfxBackground(); +#endif /* force redraw of (open or closed) door graphics */ SetDoorState(DOOR_OPEN_ALL); diff --git a/src/init.h b/src/init.h index e3f88585..75cf288d 100644 --- a/src/init.h +++ b/src/init.h @@ -36,6 +36,7 @@ void InitElementPropertiesStatic(void); void InitElementPropertiesEngine(int); void ReloadCustomArtwork(int); +void RedrawBackground(); void KeyboardAutoRepeatOffUnlessAutoplay(); diff --git a/src/libgame/image.c b/src/libgame/image.c index 7f257751..cb8de4c8 100644 --- a/src/libgame/image.c +++ b/src/libgame/image.c @@ -1049,6 +1049,19 @@ void CreateImageWithSmallImages(int pos, int zoom_factor) img_info->scaled_up = TRUE; } +void ScaleImage(int pos, int zoom_factor) +{ + ImageInfo *img_info = getImageInfoEntryFromImageID(pos); + + if (img_info == NULL || img_info->scaled_up) + return; + + if (zoom_factor != 1) + ScaleBitmap(img_info->bitmap, zoom_factor); + + img_info->scaled_up = TRUE; +} + void FreeAllImages() { FreeCustomArtworkLists(image_info); diff --git a/src/libgame/image.h b/src/libgame/image.h index 3a2ac202..3791c4bc 100644 --- a/src/libgame/image.h +++ b/src/libgame/image.h @@ -91,6 +91,7 @@ void InitImageList(struct ConfigInfo *, int, struct ConfigTypeInfo *, void ReloadCustomImages(); void CreateImageWithSmallImages(int, int); +void ScaleImage(int, int); void FreeAllImages(); diff --git a/src/libgame/system.c b/src/libgame/system.c index 94bcccdc..adcc58ff 100644 --- a/src/libgame/system.c +++ b/src/libgame/system.c @@ -794,19 +794,17 @@ Bitmap *ZoomBitmap(Bitmap *src_bitmap, int zoom_width, int zoom_height) return dst_bitmap; } -void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor) +static void CreateScaledBitmaps(Bitmap *old_bitmap, int zoom_factor, + boolean create_small_bitmaps) { Bitmap swap_bitmap; Bitmap *new_bitmap, *tmp_bitmap_1, *tmp_bitmap_2, *tmp_bitmap_8; int width_1, height_1, width_2, height_2, width_8, height_8; int new_width, new_height; + /* calculate new image dimensions for normal sized image */ width_1 = old_bitmap->width * zoom_factor; height_1 = old_bitmap->height * zoom_factor; - width_2 = width_1 / 2; - height_2 = height_1 / 2; - width_8 = width_1 / 8; - height_8 = height_1 / 8; /* get image with normal size (this might require scaling up) */ if (zoom_factor != 1) @@ -814,17 +812,26 @@ void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor) else tmp_bitmap_1 = old_bitmap; - /* get image with 1/2 of normal size (for use in the level editor) */ - if (zoom_factor != 2) - tmp_bitmap_2 = ZoomBitmap(tmp_bitmap_1, width_1 / 2, height_1 / 2); - else - tmp_bitmap_2 = old_bitmap; + if (create_small_bitmaps) + { + /* calculate new image dimensions for small images */ + width_2 = width_1 / 2; + height_2 = height_1 / 2; + width_8 = width_1 / 8; + height_8 = height_1 / 8; + + /* get image with 1/2 of normal size (for use in the level editor) */ + if (zoom_factor != 2) + tmp_bitmap_2 = ZoomBitmap(tmp_bitmap_1, width_1 / 2, height_1 / 2); + else + tmp_bitmap_2 = old_bitmap; - /* get image with 1/8 of normal size (for use on the preview screen) */ - if (zoom_factor != 8) - tmp_bitmap_8 = ZoomBitmap(tmp_bitmap_1, width_1 / 8, height_1 / 8); - else - tmp_bitmap_8 = old_bitmap; + /* get image with 1/8 of normal size (for use on the preview screen) */ + if (zoom_factor != 8) + tmp_bitmap_8 = ZoomBitmap(tmp_bitmap_1, width_1 / 8, height_1 / 8); + else + tmp_bitmap_8 = old_bitmap; + } /* if image was scaled up, create new clipmask for normal size image */ if (zoom_factor != 1) @@ -851,25 +858,39 @@ void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor) #endif } - new_width = width_1; - new_height = height_1 + (height_1 + 1) / 2; /* prevent odd height */ + if (create_small_bitmaps) + { + new_width = width_1; + new_height = height_1 + (height_1 + 1) / 2; /* prevent odd height */ - new_bitmap = CreateBitmap(new_width, new_height, DEFAULT_DEPTH); + new_bitmap = CreateBitmap(new_width, new_height, DEFAULT_DEPTH); - BlitBitmap(tmp_bitmap_1, new_bitmap, 0, 0, width_1, height_1, 0, 0); - BlitBitmap(tmp_bitmap_2, new_bitmap, 0, 0, width_1 / 2, height_1 / 2, - 0, height_1); - BlitBitmap(tmp_bitmap_8, new_bitmap, 0, 0, width_1 / 8, height_1 / 8, - 3 * width_1 / 4, height_1); + BlitBitmap(tmp_bitmap_1, new_bitmap, 0, 0, width_1, height_1, 0, 0); + BlitBitmap(tmp_bitmap_2, new_bitmap, 0, 0, width_1 / 2, height_1 / 2, + 0, height_1); + BlitBitmap(tmp_bitmap_8, new_bitmap, 0, 0, width_1 / 8, height_1 / 8, + 3 * width_1 / 4, height_1); + } + else + { + new_width = width_1; + new_height = height_1; - if (zoom_factor != 1) - FreeBitmap(tmp_bitmap_1); + new_bitmap = tmp_bitmap_1; /* directly use tmp_bitmap_1 as new bitmap */ + } + + if (create_small_bitmaps) + { + /* if no small bitmaps created, tmp_bitmap_1 is used as new bitmap now */ + if (zoom_factor != 1) + FreeBitmap(tmp_bitmap_1); - if (zoom_factor != 2) - FreeBitmap(tmp_bitmap_2); + if (zoom_factor != 2) + FreeBitmap(tmp_bitmap_2); - if (zoom_factor != 8) - FreeBitmap(tmp_bitmap_8); + if (zoom_factor != 8) + FreeBitmap(tmp_bitmap_8); + } /* replace image with extended image (containing normal, 1/2 and 1/8 size) */ #if defined(TARGET_SDL) @@ -885,7 +906,17 @@ void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor) old_bitmap->width = new_bitmap->width; old_bitmap->height = new_bitmap->height; - FreeBitmap(new_bitmap); + FreeBitmap(new_bitmap); /* this actually frees the _old_ bitmap now */ +} + +void CreateBitmapWithSmallBitmaps(Bitmap *old_bitmap, int zoom_factor) +{ + CreateScaledBitmaps(old_bitmap, zoom_factor, TRUE); +} + +void ScaleBitmap(Bitmap *old_bitmap, int zoom_factor) +{ + CreateScaledBitmaps(old_bitmap, zoom_factor, FALSE); } diff --git a/src/libgame/system.h b/src/libgame/system.h index 8eb5d9ab..174a95ed 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -649,6 +649,8 @@ struct SetupEditorInfo boolean el_dynamic; boolean el_headlines; + + boolean show_element_token; }; struct SetupEditorCascadeInfo @@ -996,6 +998,7 @@ void ReloadCustomImage(Bitmap *, char *); Bitmap *ZoomBitmap(Bitmap *, int, int); void CreateBitmapWithSmallBitmaps(Bitmap *, int); +void ScaleBitmap(Bitmap *, int); void SetMouseCursor(int); diff --git a/src/main.c b/src/main.c index c4b8a2b1..f317b46d 100644 --- a/src/main.c +++ b/src/main.c @@ -20,7 +20,9 @@ #include "events.h" #include "config.h" -Bitmap *bitmap_db_field, *bitmap_db_door; +Bitmap *bitmap_db_title; +Bitmap *bitmap_db_field; +Bitmap *bitmap_db_door; DrawBuffer *fieldbuffer; DrawBuffer *drawto_field; diff --git a/src/main.h b/src/main.h index 67071150..774c97c7 100644 --- a/src/main.h +++ b/src/main.h @@ -780,12 +780,16 @@ #define MAX_ELEMENT_NAME_LEN 32 #define MAX_TAPES_PER_SET 1024 #define MAX_SCORE_ENTRIES 100 +#define MAX_NUM_TITLE_SCREENS 5 + #define MAX_NUM_AMOEBA 100 + #if 0 /* game.h */ #define MAX_INVENTORY_SIZE 1000 #define STD_NUM_KEYS 4 #define MAX_NUM_KEYS 8 #endif + #define NUM_BELTS 4 #define NUM_BELT_PARTS 3 #define MIN_ENVELOPE_XSIZE 1 @@ -1543,18 +1547,19 @@ /* values for special image configuration suffixes (must match game mode) */ #define GFX_SPECIAL_ARG_DEFAULT 0 -#define GFX_SPECIAL_ARG_MAIN 1 -#define GFX_SPECIAL_ARG_LEVELS 2 -#define GFX_SPECIAL_ARG_SCORES 3 -#define GFX_SPECIAL_ARG_EDITOR 4 -#define GFX_SPECIAL_ARG_INFO 5 -#define GFX_SPECIAL_ARG_SETUP 6 -#define GFX_SPECIAL_ARG_PLAYING 7 -#define GFX_SPECIAL_ARG_DOOR 8 -#define GFX_SPECIAL_ARG_PREVIEW 9 -#define GFX_SPECIAL_ARG_CRUMBLED 10 +#define GFX_SPECIAL_ARG_TITLE 1 +#define GFX_SPECIAL_ARG_MAIN 2 +#define GFX_SPECIAL_ARG_LEVELS 3 +#define GFX_SPECIAL_ARG_SCORES 4 +#define GFX_SPECIAL_ARG_EDITOR 5 +#define GFX_SPECIAL_ARG_INFO 6 +#define GFX_SPECIAL_ARG_SETUP 7 +#define GFX_SPECIAL_ARG_PLAYING 8 +#define GFX_SPECIAL_ARG_DOOR 9 +#define GFX_SPECIAL_ARG_PREVIEW 10 +#define GFX_SPECIAL_ARG_CRUMBLED 11 -#define NUM_SPECIAL_GFX_ARGS 11 +#define NUM_SPECIAL_GFX_ARGS 12 /* values for image configuration suffixes */ @@ -1655,20 +1660,21 @@ /* values for game_status (must match special image configuration suffixes) */ #define GAME_MODE_DEFAULT 0 -#define GAME_MODE_MAIN 1 -#define GAME_MODE_LEVELS 2 -#define GAME_MODE_SCORES 3 -#define GAME_MODE_EDITOR 4 -#define GAME_MODE_INFO 5 -#define GAME_MODE_SETUP 6 -#define GAME_MODE_PLAYING 7 -#define GAME_MODE_PSEUDO_DOOR 8 -#define GAME_MODE_PSEUDO_PREVIEW 9 -#define GAME_MODE_PSEUDO_CRUMBLED 10 +#define GAME_MODE_TITLE 1 +#define GAME_MODE_MAIN 2 +#define GAME_MODE_LEVELS 3 +#define GAME_MODE_SCORES 4 +#define GAME_MODE_EDITOR 5 +#define GAME_MODE_INFO 6 +#define GAME_MODE_SETUP 7 +#define GAME_MODE_PLAYING 8 +#define GAME_MODE_PSEUDO_DOOR 9 +#define GAME_MODE_PSEUDO_PREVIEW 10 +#define GAME_MODE_PSEUDO_CRUMBLED 11 /* there are no special config file suffixes for these modes */ -#define GAME_MODE_PSEUDO_TYPENAME 11 -#define GAME_MODE_QUIT 12 +#define GAME_MODE_PSEUDO_TYPENAME 12 +#define GAME_MODE_QUIT 13 /* special definitions currently only used for custom artwork configuration */ #define MUSIC_PREFIX_BACKGROUND 0 @@ -2237,10 +2243,12 @@ struct HelpAnimInfo }; -extern Bitmap *bitmap_db_field, *bitmap_db_door; +extern Bitmap *bitmap_db_title; +extern Bitmap *bitmap_db_field; +extern Bitmap *bitmap_db_door; extern Pixmap tile_clipmask[]; -extern DrawBuffer *fieldbuffer; -extern DrawBuffer *drawto_field; +extern DrawBuffer *fieldbuffer; +extern DrawBuffer *drawto_field; extern int game_status; extern boolean level_editor_test_game; diff --git a/src/screens.c b/src/screens.c index 5fd02c71..0743c514 100644 --- a/src/screens.c +++ b/src/screens.c @@ -285,9 +285,74 @@ static int getLevelRangeTextPos() return getNextLevelButtonPos() + 1; } +void DrawTitleScreenImage(int nr) +{ + int graphic = IMG_TITLESCREEN_1 + nr; + Bitmap *bitmap = graphic_info[graphic].bitmap; + int width = graphic_info[graphic].src_image_width; + int height = graphic_info[graphic].src_image_height; + int src_x = 0, src_y = 0; + int dst_x, dst_y; + + if (bitmap == NULL) + return; + + if (width > WIN_XSIZE) + { + src_x = (width - WIN_XSIZE) / 2; + width = WIN_XSIZE; + } + + if (height > WIN_YSIZE) + { + src_y = (height - WIN_YSIZE) / 2; + height = WIN_YSIZE; + } + + dst_x = (WIN_XSIZE - width) / 2; + dst_y = (WIN_YSIZE - height) / 2; + +#if 1 + ClearRectangleOnBackground(drawto, 0, 0, WIN_XSIZE, WIN_YSIZE); +#else + DrawBackground(0, 0, WIN_XSIZE, WIN_YSIZE); +#endif + + if (DrawingOnBackground(dst_x, dst_y)) + BlitBitmapMasked(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y); + else + BlitBitmap(bitmap, drawto, src_x, src_y, width, height, dst_x, dst_y); + + redraw_mask = REDRAW_ALL; +} + +void DrawTitleScreen() +{ + KeyboardAutoRepeatOff(); + + SetMainBackgroundImage(IMG_BACKGROUND_TITLE); + +#if 0 + CloseDoor(DOOR_CLOSE_1); +#endif + + HandleTitleScreen(0, 0, 0, 0, MB_MENU_INITIALIZE); + + PlayMenuSound(); + PlayMenuMusic(); + +#if 1 + FadeIn(1000); +#else + FadeToFront(); +#endif + StopAnimation(); +} + void DrawMainMenu() { static LevelDirTree *leveldir_last_valid = NULL; + boolean levelset_has_changed = FALSE; char *name_text = (!options.network && setup.team_mode ? "Team:" : "Name:"); #if 1 char *level_text = "Levelset"; @@ -327,6 +392,9 @@ void DrawMainMenu() if (!validLevelSeries(leveldir_current)) leveldir_current = getFirstValidTreeInfoEntry(leveldir_last_valid); + if (leveldir_current != leveldir_last_valid) + levelset_has_changed = TRUE; + /* store valid level series information */ leveldir_last_valid = leveldir_current; @@ -337,6 +405,14 @@ void DrawMainMenu() SetDrawtoField(DRAW_BACKBUFFER); #endif + if (levelset_has_changed && graphic_info[IMG_TITLESCREEN_1].bitmap != NULL) + { + game_status = GAME_MODE_TITLE; + DrawTitleScreen(); + + return; + } + #if 0 /* map gadgets for main menu screen */ MapTapeButtons(); @@ -502,6 +578,71 @@ static void gotoTopLevelDir() } #endif +void HandleTitleScreen(int mx, int my, int dx, int dy, int button) +{ + static int title_nr = 0; + boolean return_to_main_menu = FALSE; + boolean use_cross_fading = TRUE; + int fade_delay = 1000; + int post_delay = 500; + + if (button == MB_MENU_INITIALIZE) + { + title_nr = 0; + + DrawTitleScreenImage(title_nr); + + return; + } + else if (button == MB_MENU_LEAVE) + { + return_to_main_menu = TRUE; + } + else if (button == MB_MENU_CHOICE) + { + title_nr++; + + if (!use_cross_fading) + { + FadeOut(fade_delay); + Delay(post_delay); + } + + if (title_nr < MAX_NUM_TITLE_SCREENS && + graphic_info[IMG_TITLESCREEN_1 + title_nr].bitmap != NULL) + { + Bitmap *drawto_last = drawto; + + if (use_cross_fading) + drawto = bitmap_db_title; + + DrawTitleScreenImage(title_nr); + + drawto = drawto_last; + + if (use_cross_fading) + FadeCross(bitmap_db_title, fade_delay); + else + FadeIn(fade_delay); + } + else + { + FadeOut(fade_delay); + Delay(post_delay); + + return_to_main_menu = TRUE; + } + } + + if (return_to_main_menu) + { + RedrawBackground(); + + game_status = GAME_MODE_MAIN; + DrawMainMenu(); + } +} + void HandleMainMenu(int mx, int my, int dx, int dy, int button) { static unsigned long level_delay = 0; @@ -2146,6 +2287,7 @@ static struct TokenInfo setup_info_game[] = static struct TokenInfo setup_info_editor[] = { +#if 0 { TYPE_SWITCH, &setup.editor.el_boulderdash, "Boulder Dash:" }, { TYPE_SWITCH, &setup.editor.el_emerald_mine, "Emerald Mine:" }, { TYPE_SWITCH, &setup.editor.el_emerald_mine_club, "Emerald Mine Club:" }, @@ -2154,12 +2296,15 @@ static struct TokenInfo setup_info_editor[] = { TYPE_SWITCH, &setup.editor.el_supaplex, "Supaplex:" }, { TYPE_SWITCH, &setup.editor.el_diamond_caves, "Diamond Caves II:" }, { TYPE_SWITCH, &setup.editor.el_dx_boulderdash,"DX-Boulderdash:" }, +#endif { TYPE_SWITCH, &setup.editor.el_chars, "Text Characters:" }, { TYPE_SWITCH, &setup.editor.el_custom, "Custom & Group Elements:" }, { TYPE_SWITCH, &setup.editor.el_headlines, "Headlines:" }, { TYPE_SWITCH, &setup.editor.el_user_defined, "User defined element list:" }, { TYPE_SWITCH, &setup.editor.el_dynamic, "Dynamic level elements:" }, { TYPE_EMPTY, NULL, "" }, + { TYPE_SWITCH, &setup.editor.show_element_token, "Show element token:" }, + { TYPE_EMPTY, NULL, "" }, { TYPE_LEAVE_MENU, execSetupMain, "Back" }, { 0, NULL, NULL } diff --git a/src/screens.h b/src/screens.h index 949267f0..e895c4fe 100644 --- a/src/screens.h +++ b/src/screens.h @@ -24,6 +24,7 @@ void DrawMainMenu(void); void DrawHallOfFame(int); +void HandleTitleScreen(int, int, int, int, int); void HandleMainMenu(int, int, int, int, int); void HandleChooseLevel(int, int, int, int, int); void HandleHallOfFame(int, int, int, int, int); diff --git a/src/tools.c b/src/tools.c index b6e9f10a..6f2c96e2 100644 --- a/src/tools.c +++ b/src/tools.c @@ -241,7 +241,8 @@ void BackToFront() if (redraw_mask & REDRAW_ALL) { BlitBitmap(backbuffer, window, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); - redraw_mask = 0; + + redraw_mask = REDRAW_NONE; } if (redraw_mask & REDRAW_FIELD) @@ -413,6 +414,114 @@ void FadeToFront() BackToFront(); } +#define FADE_MODE_FADE_IN 0 +#define FADE_MODE_FADE_OUT 1 +#define FADE_MODE_CROSSFADE 2 + +static void FadeExt(Bitmap *bitmap_cross, int fade_ms, int fade_mode) +{ + SDL_Surface *surface_screen = backbuffer->surface; + SDL_Surface *surface_screen_copy = NULL; + SDL_Surface *surface_black = NULL; + SDL_Surface *surface_cross; /* initialized later */ + boolean fade_reverse; /* initialized later */ + unsigned int flags = SDL_SRCALPHA; + unsigned int time_last, time_current; + float alpha; + int alpha_final; + + /* use same surface type as screen surface */ + if ((surface_screen->flags & SDL_HWSURFACE)) + flags |= SDL_HWSURFACE; + else + flags |= SDL_SWSURFACE; + + /* create surface for copy of screen buffer */ + if ((surface_screen_copy = + SDL_CreateRGBSurface(flags, + surface_screen->w, + surface_screen->h, + surface_screen->format->BitsPerPixel, + surface_screen->format->Rmask, + surface_screen->format->Gmask, + surface_screen->format->Bmask, + surface_screen->format->Amask)) == NULL) + Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError()); + + SDL_BlitSurface(surface_screen, NULL, surface_screen_copy, NULL); + + /* create black surface for fading from/to black */ + if ((surface_black = + SDL_CreateRGBSurface(flags, + surface_screen->w, + surface_screen->h, + surface_screen->format->BitsPerPixel, + surface_screen->format->Rmask, + surface_screen->format->Gmask, + surface_screen->format->Bmask, + surface_screen->format->Amask)) == NULL) + Error(ERR_EXIT, "SDL_CreateRGBSurface() failed: %s", SDL_GetError()); + + SDL_FillRect(surface_black, NULL, SDL_MapRGB(surface_screen->format, 0,0,0)); + + fade_reverse = (fade_mode == FADE_MODE_FADE_IN ? TRUE : FALSE); + surface_cross = (fade_mode == FADE_MODE_CROSSFADE ? bitmap_cross->surface : + surface_black); + + time_current = SDL_GetTicks(); + + for (alpha = 0.0; alpha < 255.0;) + { + time_last = time_current; + time_current = SDL_GetTicks(); + alpha += 255 * ((float)(time_current - time_last) / fade_ms); + alpha_final = (int)(fade_reverse ? 255.0 - alpha : alpha); + alpha_final = MIN(MAX(0, alpha_final), 255); + + /* draw existing image to screen buffer */ + SDL_BlitSurface(surface_screen_copy, NULL, surface_screen, NULL); + + /* draw new image to screen buffer using alpha blending */ + SDL_SetAlpha(surface_cross, SDL_SRCALPHA, alpha_final); + SDL_BlitSurface(surface_cross, NULL, surface_screen, NULL); + + /* draw screen buffer to visible display */ + SDL_Flip(surface_screen); + } + + SDL_FreeSurface(surface_screen_copy); + SDL_FreeSurface(surface_black); + + redraw_mask = REDRAW_NONE; +} + +void FadeIn(int fade_ms) +{ +#ifdef TARGET_SDL + FadeExt(NULL, fade_ms, FADE_MODE_FADE_IN); +#else + BackToFront(); +#endif +} + +void FadeOut(int fade_ms) +{ +#ifdef TARGET_SDL + FadeExt(NULL, fade_ms, FADE_MODE_FADE_OUT); +#else + BackToFront(); +#endif +} + +void FadeCross(Bitmap *bitmap, int fade_ms) +{ +#ifdef TARGET_SDL + FadeExt(bitmap, fade_ms, FADE_MODE_CROSSFADE); +#else + BackToFront(); +#endif +} + void SetMainBackgroundImageIfDefined(int graphic) { if (graphic_info[graphic].bitmap) @@ -2513,7 +2622,7 @@ unsigned int MoveDoor(unsigned int door_state) door_2.height = VYSIZE; if (door_state == DOOR_GET_STATE) - return(door1 | door2); + return (door1 | door2); if (door_state & DOOR_SET_STATE) { @@ -2522,7 +2631,7 @@ unsigned int MoveDoor(unsigned int door_state) if (door_state & DOOR_ACTION_2) door2 = door_state & DOOR_ACTION_2; - return(door1 | door2); + return (door1 | door2); } if (door1 == DOOR_OPEN_1 && door_state & DOOR_OPEN_1) @@ -2765,13 +2874,15 @@ unsigned int MoveDoor(unsigned int door_state) door_2_done = (a == VXSIZE); } - BackToFront(); + if (!(door_state & DOOR_NO_DELAY)) + { + BackToFront(); - if (game_status == GAME_MODE_MAIN) - DoAnimation(); + if (game_status == GAME_MODE_MAIN) + DoAnimation(); - if (!(door_state & DOOR_NO_DELAY)) WaitUntilDelayReached(&door_delay, door_delay_value); + } } } diff --git a/src/tools.h b/src/tools.h index b1d0dd86..10b4890b 100644 --- a/src/tools.h +++ b/src/tools.h @@ -65,6 +65,11 @@ void SetDrawtoField(int); void RedrawPlayfield(boolean, int, int, int, int); void BackToFront(); void FadeToFront(); + +void FadeIn(int); +void FadeOut(int); +void FadeCross(Bitmap *, int); + void ClearWindow(); void SetMainBackgroundImageIfDefined(int); void SetMainBackgroundImage(int);