From 5c94351c5b8a12d8615b447b6275dd2f68615be4 Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 21 Mar 2007 20:46:36 +0100 Subject: [PATCH] rnd-20070321-1-src * improved menu fading, adding separate fading definitions for entering and leaving a menu and for fading between menu and "content" screens --- ChangeLog | 4 + src/conf_gfx.c | 44 ++-- src/conf_var.c | 92 +++++---- src/conftime.h | 2 +- src/editor.c | 19 +- src/events.c | 2 + src/files.c | 12 +- src/game.c | 42 ++-- src/init.c | 21 +- src/libgame/misc.c | 9 +- src/libgame/system.h | 23 ++- src/main.c | 8 - src/main.h | 25 ++- src/screens.c | 465 +++++++++++++++++++------------------------ src/tools.c | 91 ++++++++- src/tools.h | 7 + 16 files changed, 466 insertions(+), 400 deletions(-) diff --git a/ChangeLog b/ChangeLog index 82551132..94704133 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2007-03-21 + * improved menu fading, adding separate fading definitions for entering + and leaving a menu and for fading between menu and "content" screens + 2007-03-20 * improved menu fading, adding separate fading definitions for fading between menu screens and fading between menu and "destination" screens diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 5e26e68f..62727950 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -60,6 +60,7 @@ struct ConfigTypeInfo image_config_suffix[] = { ".name", ARG_UNDEFINED, TYPE_STRING }, { ".scale_up_factor", ARG_UNDEFINED, TYPE_INTEGER }, { ".clone_from", ARG_UNDEFINED, TYPE_TOKEN }, + { ".fade_mode", ARG_UNDEFINED, TYPE_INTEGER }, { ".fade_delay", ARG_UNDEFINED, TYPE_INTEGER }, { ".post_delay", ARG_UNDEFINED, TYPE_INTEGER }, { ".auto_delay", ARG_UNDEFINED, TYPE_INTEGER }, @@ -4980,11 +4981,11 @@ struct ConfigInfo image_config[] = /* keyword to start parser: "CONFIG_VARS_START" <-- do not change! */ - { "[title_initial].anim_mode", "fade" }, + { "[title_initial].fade_mode", "fade" }, { "[title_initial].fade_delay", "500" }, { "[title_initial].post_delay", "250" }, { "[title_initial].auto_delay", "-1" }, - { "[title].anim_mode", "fade" }, + { "[title].fade_mode", "fade" }, { "[title].fade_delay", "500" }, { "[title].post_delay", "250" }, { "[title].auto_delay", "-1" }, @@ -5002,7 +5003,7 @@ struct ConfigInfo image_config[] = { "[titlemessage_initial].centered", "false" }, { "[titlemessage_initial].parse_comments", "false" }, { "[titlemessage_initial].sort_priority", "0" }, - { "[titlemessage_initial].anim_mode", ARG_DEFAULT }, + { "[titlemessage_initial].fade_mode", ARG_DEFAULT }, { "[titlemessage_initial].fade_delay", ARG_DEFAULT }, { "[titlemessage_initial].post_delay", ARG_DEFAULT }, { "[titlemessage_initial].auto_delay", ARG_DEFAULT }, @@ -5019,7 +5020,7 @@ struct ConfigInfo image_config[] = { "[titlemessage].centered", "false" }, { "[titlemessage].parse_comments", "false" }, { "[titlemessage].sort_priority", "0" }, - { "[titlemessage].anim_mode", ARG_DEFAULT }, + { "[titlemessage].fade_mode", ARG_DEFAULT }, { "[titlemessage].fade_delay", ARG_DEFAULT }, { "[titlemessage].post_delay", ARG_DEFAULT }, { "[titlemessage].auto_delay", ARG_DEFAULT }, @@ -5037,7 +5038,7 @@ struct ConfigInfo image_config[] = { "titlemessage_initial_1.centered", ARG_DEFAULT }, { "titlemessage_initial_1.parse_comments", ARG_DEFAULT }, { "titlemessage_initial_1.sort_priority", ARG_DEFAULT }, - { "titlemessage_initial_1.anim_mode", ARG_DEFAULT }, + { "titlemessage_initial_1.fade_mode", ARG_DEFAULT }, { "titlemessage_initial_1.fade_delay", ARG_DEFAULT }, { "titlemessage_initial_1.post_delay", ARG_DEFAULT }, { "titlemessage_initial_1.auto_delay", ARG_DEFAULT }, @@ -5054,7 +5055,7 @@ struct ConfigInfo image_config[] = { "titlemessage_initial_2.centered", ARG_DEFAULT }, { "titlemessage_initial_2.parse_comments", ARG_DEFAULT }, { "titlemessage_initial_2.sort_priority", ARG_DEFAULT }, - { "titlemessage_initial_2.anim_mode", ARG_DEFAULT }, + { "titlemessage_initial_2.fade_mode", ARG_DEFAULT }, { "titlemessage_initial_2.fade_delay", ARG_DEFAULT }, { "titlemessage_initial_2.post_delay", ARG_DEFAULT }, { "titlemessage_initial_2.auto_delay", ARG_DEFAULT }, @@ -5071,7 +5072,7 @@ struct ConfigInfo image_config[] = { "titlemessage_initial_3.centered", ARG_DEFAULT }, { "titlemessage_initial_3.parse_comments", ARG_DEFAULT }, { "titlemessage_initial_3.sort_priority", ARG_DEFAULT }, - { "titlemessage_initial_3.anim_mode", ARG_DEFAULT }, + { "titlemessage_initial_3.fade_mode", ARG_DEFAULT }, { "titlemessage_initial_3.fade_delay", ARG_DEFAULT }, { "titlemessage_initial_3.post_delay", ARG_DEFAULT }, { "titlemessage_initial_3.auto_delay", ARG_DEFAULT }, @@ -5088,7 +5089,7 @@ struct ConfigInfo image_config[] = { "titlemessage_initial_4.centered", ARG_DEFAULT }, { "titlemessage_initial_4.parse_comments", ARG_DEFAULT }, { "titlemessage_initial_4.sort_priority", ARG_DEFAULT }, - { "titlemessage_initial_4.anim_mode", ARG_DEFAULT }, + { "titlemessage_initial_4.fade_mode", ARG_DEFAULT }, { "titlemessage_initial_4.fade_delay", ARG_DEFAULT }, { "titlemessage_initial_4.post_delay", ARG_DEFAULT }, { "titlemessage_initial_4.auto_delay", ARG_DEFAULT }, @@ -5105,7 +5106,7 @@ struct ConfigInfo image_config[] = { "titlemessage_initial_5.centered", ARG_DEFAULT }, { "titlemessage_initial_5.parse_comments", ARG_DEFAULT }, { "titlemessage_initial_5.sort_priority", ARG_DEFAULT }, - { "titlemessage_initial_5.anim_mode", ARG_DEFAULT }, + { "titlemessage_initial_5.fade_mode", ARG_DEFAULT }, { "titlemessage_initial_5.fade_delay", ARG_DEFAULT }, { "titlemessage_initial_5.post_delay", ARG_DEFAULT }, { "titlemessage_initial_5.auto_delay", ARG_DEFAULT }, @@ -5122,7 +5123,7 @@ struct ConfigInfo image_config[] = { "titlemessage_1.centered", ARG_DEFAULT }, { "titlemessage_1.parse_comments", ARG_DEFAULT }, { "titlemessage_1.sort_priority", ARG_DEFAULT }, - { "titlemessage_1.anim_mode", ARG_DEFAULT }, + { "titlemessage_1.fade_mode", ARG_DEFAULT }, { "titlemessage_1.fade_delay", ARG_DEFAULT }, { "titlemessage_1.post_delay", ARG_DEFAULT }, { "titlemessage_1.auto_delay", ARG_DEFAULT }, @@ -5139,7 +5140,7 @@ struct ConfigInfo image_config[] = { "titlemessage_2.centered", ARG_DEFAULT }, { "titlemessage_2.parse_comments", ARG_DEFAULT }, { "titlemessage_2.sort_priority", ARG_DEFAULT }, - { "titlemessage_2.anim_mode", ARG_DEFAULT }, + { "titlemessage_2.fade_mode", ARG_DEFAULT }, { "titlemessage_2.fade_delay", ARG_DEFAULT }, { "titlemessage_2.post_delay", ARG_DEFAULT }, { "titlemessage_2.auto_delay", ARG_DEFAULT }, @@ -5156,7 +5157,7 @@ struct ConfigInfo image_config[] = { "titlemessage_3.centered", ARG_DEFAULT }, { "titlemessage_3.parse_comments", ARG_DEFAULT }, { "titlemessage_3.sort_priority", ARG_DEFAULT }, - { "titlemessage_3.anim_mode", ARG_DEFAULT }, + { "titlemessage_3.fade_mode", ARG_DEFAULT }, { "titlemessage_3.fade_delay", ARG_DEFAULT }, { "titlemessage_3.post_delay", ARG_DEFAULT }, { "titlemessage_3.auto_delay", ARG_DEFAULT }, @@ -5173,7 +5174,7 @@ struct ConfigInfo image_config[] = { "titlemessage_4.centered", ARG_DEFAULT }, { "titlemessage_4.parse_comments", ARG_DEFAULT }, { "titlemessage_4.sort_priority", ARG_DEFAULT }, - { "titlemessage_4.anim_mode", ARG_DEFAULT }, + { "titlemessage_4.fade_mode", ARG_DEFAULT }, { "titlemessage_4.fade_delay", ARG_DEFAULT }, { "titlemessage_4.post_delay", ARG_DEFAULT }, { "titlemessage_4.auto_delay", ARG_DEFAULT }, @@ -5190,7 +5191,7 @@ struct ConfigInfo image_config[] = { "titlemessage_5.centered", ARG_DEFAULT }, { "titlemessage_5.parse_comments", ARG_DEFAULT }, { "titlemessage_5.sort_priority", ARG_DEFAULT }, - { "titlemessage_5.anim_mode", ARG_DEFAULT }, + { "titlemessage_5.fade_mode", ARG_DEFAULT }, { "titlemessage_5.fade_delay", ARG_DEFAULT }, { "titlemessage_5.post_delay", ARG_DEFAULT }, { "titlemessage_5.auto_delay", ARG_DEFAULT }, @@ -5221,12 +5222,15 @@ struct ConfigInfo image_config[] = { "border.draw_masked.PLAYING", "false" }, { "border.draw_masked.DOOR", "false" }, - { "menu.navigation.anim_mode", "none" }, - { "menu.navigation.fade_delay", "250" }, - { "menu.navigation.post_delay", "125" }, - { "menu.destination.anim_mode", "fade" }, - { "menu.destination.fade_delay", "250" }, - { "menu.destination.post_delay", "125" }, + { "menu.enter_menu.fade_mode", "none" }, + { "menu.enter_menu.fade_delay", "250" }, + { "menu.enter_menu.post_delay", "125" }, + { "menu.leave_menu.fade_mode", "none" }, + { "menu.leave_menu.fade_delay", "250" }, + { "menu.leave_menu.post_delay", "125" }, + { "menu.start_item.fade_mode", "fade" }, + { "menu.start_item.fade_delay", "250" }, + { "menu.start_item.post_delay", "125" }, { "menu.draw_xoffset", "0" }, { "menu.draw_yoffset", "0" }, diff --git a/src/conf_var.c b/src/conf_var.c index bd0662df..f9e708ef 100644 --- a/src/conf_var.c +++ b/src/conf_var.c @@ -21,8 +21,8 @@ struct TokenIntPtrInfo image_config_vars[] = { { - "[title_initial].anim_mode", - &title_initial_default.anim_mode + "[title_initial].fade_mode", + &title_initial_default.fade_mode }, { "[title_initial].fade_delay", @@ -37,8 +37,8 @@ struct TokenIntPtrInfo image_config_vars[] = &title_initial_default.auto_delay }, { - "[title].anim_mode", - &title_default.anim_mode + "[title].fade_mode", + &title_default.fade_mode }, { "[title].fade_delay", @@ -105,8 +105,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage_initial_default.sort_priority }, { - "[titlemessage_initial].anim_mode", - &titlemessage_initial_default.anim_mode + "[titlemessage_initial].fade_mode", + &titlemessage_initial_default.fade_mode }, { "[titlemessage_initial].fade_delay", @@ -173,8 +173,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage_default.sort_priority }, { - "[titlemessage].anim_mode", - &titlemessage_default.anim_mode + "[titlemessage].fade_mode", + &titlemessage_default.fade_mode }, { "[titlemessage].fade_delay", @@ -241,8 +241,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage_initial[0].sort_priority }, { - "titlemessage_initial_1.anim_mode", - &titlemessage_initial[0].anim_mode + "titlemessage_initial_1.fade_mode", + &titlemessage_initial[0].fade_mode }, { "titlemessage_initial_1.fade_delay", @@ -309,8 +309,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage_initial[1].sort_priority }, { - "titlemessage_initial_2.anim_mode", - &titlemessage_initial[1].anim_mode + "titlemessage_initial_2.fade_mode", + &titlemessage_initial[1].fade_mode }, { "titlemessage_initial_2.fade_delay", @@ -377,8 +377,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage_initial[2].sort_priority }, { - "titlemessage_initial_3.anim_mode", - &titlemessage_initial[2].anim_mode + "titlemessage_initial_3.fade_mode", + &titlemessage_initial[2].fade_mode }, { "titlemessage_initial_3.fade_delay", @@ -445,8 +445,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage_initial[3].sort_priority }, { - "titlemessage_initial_4.anim_mode", - &titlemessage_initial[3].anim_mode + "titlemessage_initial_4.fade_mode", + &titlemessage_initial[3].fade_mode }, { "titlemessage_initial_4.fade_delay", @@ -513,8 +513,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage_initial[4].sort_priority }, { - "titlemessage_initial_5.anim_mode", - &titlemessage_initial[4].anim_mode + "titlemessage_initial_5.fade_mode", + &titlemessage_initial[4].fade_mode }, { "titlemessage_initial_5.fade_delay", @@ -581,8 +581,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage[0].sort_priority }, { - "titlemessage_1.anim_mode", - &titlemessage[0].anim_mode + "titlemessage_1.fade_mode", + &titlemessage[0].fade_mode }, { "titlemessage_1.fade_delay", @@ -649,8 +649,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage[1].sort_priority }, { - "titlemessage_2.anim_mode", - &titlemessage[1].anim_mode + "titlemessage_2.fade_mode", + &titlemessage[1].fade_mode }, { "titlemessage_2.fade_delay", @@ -717,8 +717,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage[2].sort_priority }, { - "titlemessage_3.anim_mode", - &titlemessage[2].anim_mode + "titlemessage_3.fade_mode", + &titlemessage[2].fade_mode }, { "titlemessage_3.fade_delay", @@ -785,8 +785,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage[3].sort_priority }, { - "titlemessage_4.anim_mode", - &titlemessage[3].anim_mode + "titlemessage_4.fade_mode", + &titlemessage[3].fade_mode }, { "titlemessage_4.fade_delay", @@ -853,8 +853,8 @@ struct TokenIntPtrInfo image_config_vars[] = &titlemessage[4].sort_priority }, { - "titlemessage_5.anim_mode", - &titlemessage[4].anim_mode + "titlemessage_5.fade_mode", + &titlemessage[4].fade_mode }, { "titlemessage_5.fade_delay", @@ -961,28 +961,40 @@ struct TokenIntPtrInfo image_config_vars[] = &border.draw_masked[GFX_SPECIAL_ARG_DOOR] }, { - "menu.navigation.anim_mode", - &menu.navigation.anim_mode + "menu.enter_menu.fade_mode", + &menu.enter_menu.fade_mode }, { - "menu.navigation.fade_delay", - &menu.navigation.fade_delay + "menu.enter_menu.fade_delay", + &menu.enter_menu.fade_delay }, { - "menu.navigation.post_delay", - &menu.navigation.post_delay + "menu.enter_menu.post_delay", + &menu.enter_menu.post_delay }, { - "menu.destination.anim_mode", - &menu.destination.anim_mode + "menu.leave_menu.fade_mode", + &menu.leave_menu.fade_mode }, { - "menu.destination.fade_delay", - &menu.destination.fade_delay + "menu.leave_menu.fade_delay", + &menu.leave_menu.fade_delay }, { - "menu.destination.post_delay", - &menu.destination.post_delay + "menu.leave_menu.post_delay", + &menu.leave_menu.post_delay + }, + { + "menu.start_item.fade_mode", + &menu.start_item.fade_mode + }, + { + "menu.start_item.fade_delay", + &menu.start_item.fade_delay + }, + { + "menu.start_item.post_delay", + &menu.start_item.post_delay }, { "menu.draw_xoffset", diff --git a/src/conftime.h b/src/conftime.h index 3b496277..0ef70a99 100644 --- a/src/conftime.h +++ b/src/conftime.h @@ -1 +1 @@ -#define COMPILE_DATE_STRING "2007-03-20 21:54" +#define COMPILE_DATE_STRING "2007-03-21 20:42" diff --git a/src/editor.c b/src/editor.c index aceedf17..134a3fcb 100644 --- a/src/editor.c +++ b/src/editor.c @@ -7051,24 +7051,14 @@ void DrawLevelEd() #endif MapControlButtons(); -#if 0 - fading = menu.navigation; -#endif - #if 1 - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); + FadeOut(REDRAW_FIELD); #endif DrawEditModeWindow(); #if 1 - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(REDRAW_FIELD); - else - FadeIn(REDRAW_FIELD); + FadeIn(REDRAW_FIELD); #endif /* copy actual editor door content to door double buffer for OpenDoor() */ @@ -11361,8 +11351,13 @@ void RequestExitLevelEditor(boolean ask_if_level_has_changed, CloseDoor(DOOR_CLOSE_1); SetDoorState(DOOR_CLOSE_2); +#if 1 + if (quick_quit) + FadeSkipNextFadeIn(); +#else if (quick_quit) fading = fading_none; +#endif game_status = GAME_MODE_MAIN; #if 1 diff --git a/src/events.c b/src/events.c index d08de9ed..2dc5a016 100644 --- a/src/events.c +++ b/src/events.c @@ -811,6 +811,8 @@ void HandleKey(Key key, int key_status) break; case KSYM_Escape: + FadeSkipNextFadeIn(); + if (game_status == GAME_MODE_TITLE) HandleTitleScreen(0, 0, 0, 0, MB_MENU_LEAVE); else if (game_status == GAME_MODE_LEVELS) diff --git a/src/files.c b/src/files.c index f41465f4..daff33b9 100644 --- a/src/files.c +++ b/src/files.c @@ -8339,7 +8339,7 @@ static void LoadSpecialMenuDesignSettingsFromFilename(char *filename) { TYPE_BOOLEAN, &tmi.centered, ".centered" }, { TYPE_BOOLEAN, &tmi.parse_comments, ".parse_comments" }, { TYPE_INTEGER, &tmi.sort_priority, ".sort_priority" }, - { TYPE_INTEGER, &tmi.anim_mode, ".anim_mode" }, + { TYPE_INTEGER, &tmi.fade_mode, ".fade_mode" }, { TYPE_INTEGER, &tmi.fade_delay, ".fade_delay" }, { TYPE_INTEGER, &tmi.post_delay, ".post_delay" }, { TYPE_INTEGER, &tmi.auto_delay, ".auto_delay" }, @@ -8400,7 +8400,7 @@ static void LoadSpecialMenuDesignSettingsFromFilename(char *filename) } /* special case: initialize with default values that may be overwritten */ - /* (e.g., init "titlemessage_1.anim_mode" from "[titlemessage].anim_mode") */ + /* (e.g., init "titlemessage_1.fade_mode" from "[titlemessage].fade_mode") */ for (i = 0; titlemessage_arrays[i].array != NULL; i++) { struct TitleMessageInfo *array = titlemessage_arrays[i].array; @@ -8461,18 +8461,18 @@ void LoadSpecialMenuDesignSettings() /* the following initializes hierarchical values from static configuration */ /* special case: initialize "ARG_DEFAULT" values in static default config */ - /* (e.g., initialize "[titlemessage].anim_mode" from "[title].anim_mode") */ - titlemessage_initial_default.anim_mode = title_initial_default.anim_mode; + /* (e.g., initialize "[titlemessage].fade_mode" from "[title].fade_mode") */ + titlemessage_initial_default.fade_mode = title_initial_default.fade_mode; titlemessage_initial_default.fade_delay = title_initial_default.fade_delay; titlemessage_initial_default.post_delay = title_initial_default.post_delay; titlemessage_initial_default.auto_delay = title_initial_default.auto_delay; - titlemessage_default.anim_mode = title_default.anim_mode; + titlemessage_default.fade_mode = title_default.fade_mode; titlemessage_default.fade_delay = title_default.fade_delay; titlemessage_default.post_delay = title_default.post_delay; titlemessage_default.auto_delay = title_default.auto_delay; /* special case: initialize "ARG_DEFAULT" values in static default config */ - /* (e.g., init "titlemessage_1.anim_mode" from "[titlemessage].anim_mode") */ + /* (e.g., init "titlemessage_1.fade_mode" from "[titlemessage].fade_mode") */ for (i = 0; i < MAX_NUM_TITLE_MESSAGES; i++) { titlemessage_initial[i] = titlemessage_initial_default; diff --git a/src/game.c b/src/game.c index 593a8bac..4f5731e4 100644 --- a/src/game.c +++ b/src/game.c @@ -2596,7 +2596,9 @@ void InitGame() boolean emulate_bd = TRUE; /* unless non-BOULDERDASH elements found */ boolean emulate_sb = TRUE; /* unless non-SOKOBAN elements found */ boolean emulate_sp = TRUE; /* unless non-SUPAPLEX elements found */ +#if 0 boolean do_fading = (game_status == GAME_MODE_MAIN); +#endif int i, j, x, y; game_status = GAME_MODE_PLAYING; @@ -3155,16 +3157,20 @@ void InitGame() if (!game.restart_level) CloseDoor(DOOR_CLOSE_1); +#if 1 + if (level_editor_test_game) + FadeSkipNextFadeIn(); + else + FadeSetStartItem(); +#else if (level_editor_test_game) fading = fading_none; else fading = menu.destination; +#endif #if 1 - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); + FadeOut(REDRAW_FIELD); #else if (do_fading) FadeOut(REDRAW_FIELD); @@ -3196,10 +3202,7 @@ void InitGame() /* !!! FIX THIS (END) !!! */ #if 1 - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(redraw_mask); - else - FadeIn(redraw_mask); + FadeIn(REDRAW_FIELD); #else if (do_fading) FadeIn(REDRAW_FIELD); @@ -3668,11 +3671,6 @@ void GameEnd() if (!local_player->LevelSolved_SaveScore) { #if 1 - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); #endif @@ -3707,11 +3705,6 @@ void GameEnd() else { #if 1 - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); #endif @@ -14131,7 +14124,13 @@ void RequestQuitGameExt(boolean skip_request, boolean quick_quit, char *message) if (quick_quit) { #if 1 + +#if 1 + FadeSkipNextFadeIn(); +#else fading = fading_none; +#endif + #else OpenDoor(DOOR_CLOSE_1); #endif @@ -14147,14 +14146,7 @@ void RequestQuitGameExt(boolean skip_request, boolean quick_quit, char *message) else { #if 0 -#if 1 - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); -#endif #endif game_status = GAME_MODE_MAIN; diff --git a/src/init.c b/src/init.c index a8017155..0a9e7967 100644 --- a/src/init.c +++ b/src/init.c @@ -1032,6 +1032,7 @@ static void set_graphic_parameters(int graphic) graphic_info[graphic].anim_delay_random = 0; graphic_info[graphic].post_delay_fixed = 0; graphic_info[graphic].post_delay_random = 0; + graphic_info[graphic].fade_mode = FADE_MODE_DEFAULT; graphic_info[graphic].fade_delay = -1; graphic_info[graphic].post_delay = -1; graphic_info[graphic].auto_delay = -1; @@ -1223,7 +1224,9 @@ static void set_graphic_parameters(int graphic) if (parameter[GFX_ARG_CLONE_FROM] != ARG_UNDEFINED_VALUE) graphic_info[graphic].clone_from = parameter[GFX_ARG_CLONE_FROM]; - /* optional settings for drawing title screens */ + /* optional settings for drawing title screens and title messages */ + if (parameter[GFX_ARG_FADE_MODE] != ARG_UNDEFINED_VALUE) + graphic_info[graphic].fade_mode = parameter[GFX_ARG_FADE_MODE]; if (parameter[GFX_ARG_FADE_DELAY] != ARG_UNDEFINED_VALUE) graphic_info[graphic].fade_delay = parameter[GFX_ARG_FADE_DELAY]; if (parameter[GFX_ARG_POST_DELAY] != ARG_UNDEFINED_VALUE) @@ -5112,7 +5115,17 @@ void ReloadCustomArtwork(int force_reload) SetDoorState(DOOR_OPEN_ALL); CloseDoor(DOOR_CLOSE_ALL | DOOR_NO_DELAY); +#if 1 +#if 1 + FadeSetStartItem(); + // FadeSkipNextFadeOut(); + // FadeSetDisabled(); +#else + FadeSkipNext(); +#endif +#else fading = fading_none; +#endif } } @@ -5197,7 +5210,13 @@ void OpenAll() return; } +#if 1 + FadeSetStartItem(); + FadeSkipNextFadeOut(); + // FadeSetDisabled(); +#else fading = fading_none; +#endif game_status = GAME_MODE_MAIN; diff --git a/src/libgame/misc.c b/src/libgame/misc.c index 3fcf5af1..7a780511 100644 --- a/src/libgame/misc.c +++ b/src/libgame/misc.c @@ -1811,8 +1811,6 @@ int get_parameter_value(char *value_raw, char *suffix, int type) string_has_parameter(value, "horizontal") ? ANIM_HORIZONTAL : string_has_parameter(value, "vertical") ? ANIM_VERTICAL : string_has_parameter(value, "centered") ? ANIM_CENTERED : - string_has_parameter(value, "fade") ? ANIM_FADE : - string_has_parameter(value, "crossfade") ? ANIM_CROSSFADE : ANIM_DEFAULT); if (string_has_parameter(value, "reverse")) @@ -1824,6 +1822,13 @@ int get_parameter_value(char *value_raw, char *suffix, int type) if (string_has_parameter(value, "static_panel")) result |= ANIM_STATIC_PANEL; } + else if (strEqual(suffix, ".fade_mode")) + { + result = (string_has_parameter(value, "none") ? FADE_MODE_NONE : + string_has_parameter(value, "fade") ? FADE_MODE_FADE : + string_has_parameter(value, "crossfade") ? FADE_MODE_CROSSFADE : + FADE_MODE_DEFAULT); + } else if (strEqual(suffix, ".font")) { result = gfx.get_font_from_token_function(value); diff --git a/src/libgame/system.h b/src/libgame/system.h index a2b75b14..5ba6da71 100644 --- a/src/libgame/system.h +++ b/src/libgame/system.h @@ -196,11 +196,26 @@ #define ANIM_VERTICAL (1 << 11) #define ANIM_CENTERED (1 << 12) #define ANIM_STATIC_PANEL (1 << 13) -#define ANIM_FADE (1 << 14) -#define ANIM_CROSSFADE (1 << 15) #define ANIM_DEFAULT ANIM_LOOP +/* values for fade mode */ +#define FADE_TYPE_NONE 0 +#define FADE_TYPE_FADE_IN (1 << 0) +#define FADE_TYPE_FADE_OUT (1 << 1) +#define FADE_TYPE_CROSS (1 << 2) +#define FADE_TYPE_SKIP (1 << 3) + +#define FADE_MODE_NONE (FADE_TYPE_NONE) +#define FADE_MODE_FADE_IN (FADE_TYPE_FADE_IN) +#define FADE_MODE_FADE_OUT (FADE_TYPE_FADE_OUT) +#define FADE_MODE_FADE (FADE_TYPE_FADE_IN | FADE_TYPE_FADE_OUT) +#define FADE_MODE_CROSSFADE (FADE_TYPE_FADE_IN | FADE_TYPE_CROSS) +#define FADE_MODE_SKIP_FADE_IN (FADE_TYPE_SKIP | FADE_TYPE_FADE_IN) +#define FADE_MODE_SKIP_FADE_OUT (FADE_TYPE_SKIP | FADE_TYPE_FADE_OUT) + +#define FADE_MODE_DEFAULT FADE_MODE_FADE + /* values for text alignment */ #define ALIGN_LEFT (1 << 0) #define ALIGN_RIGHT (1 << 1) @@ -244,10 +259,6 @@ #define REDRAW_FPS (1 << 11) #define REDRAWTILES_THRESHOLD (SCR_FIELDX * SCR_FIELDY / 2) -#define FADE_MODE_FADE_IN 0 -#define FADE_MODE_FADE_OUT 1 -#define FADE_MODE_CROSSFADE 2 - #define IN_GFX_SCREEN(x, y) (x >= gfx.sx && x < gfx.sx + gfx.sxsize && \ y >= gfx.sy && y < gfx.sy + gfx.sysize) #define IN_GFX_DOOR(x, y) (x >= gfx.dx && x < gfx.dx + gfx.dxsize && \ diff --git a/src/main.c b/src/main.c index d978a588..5174a162 100644 --- a/src/main.c +++ b/src/main.c @@ -5449,14 +5449,6 @@ struct MusicPrefixInfo music_prefix_info[NUM_MUSIC_PREFIXES + 1] = { NULL, 0 } }; -struct TitleFadingInfo fading_none = -{ - ANIM_NONE, - 0, - 0, - 0 -}; - /* ========================================================================= */ /* main() */ diff --git a/src/main.h b/src/main.h index e400c20e..a9c8c3cb 100644 --- a/src/main.h +++ b/src/main.h @@ -1788,14 +1788,15 @@ #define GFX_ARG_NAME 36 #define GFX_ARG_SCALE_UP_FACTOR 37 #define GFX_ARG_CLONE_FROM 38 -#define GFX_ARG_FADE_DELAY 39 -#define GFX_ARG_POST_DELAY 40 -#define GFX_ARG_AUTO_DELAY 41 -#define GFX_ARG_ALIGN 42 -#define GFX_ARG_VALIGN 43 -#define GFX_ARG_SORT_PRIORITY 44 +#define GFX_ARG_FADE_MODE 39 +#define GFX_ARG_FADE_DELAY 40 +#define GFX_ARG_POST_DELAY 41 +#define GFX_ARG_AUTO_DELAY 42 +#define GFX_ARG_ALIGN 43 +#define GFX_ARG_VALIGN 44 +#define GFX_ARG_SORT_PRIORITY 45 -#define NUM_GFX_ARGS 45 +#define NUM_GFX_ARGS 46 /* values for sound configuration suffixes */ @@ -2049,7 +2050,7 @@ struct MenuMainInfo struct TitleFadingInfo { - int anim_mode; + int fade_mode; int fade_delay; int post_delay; int auto_delay; @@ -2067,7 +2068,7 @@ struct TitleMessageInfo boolean parse_comments; int sort_priority; - int anim_mode; + int fade_mode; int fade_delay; int post_delay; int auto_delay; @@ -2084,8 +2085,9 @@ struct MenuInfo int list_size[NUM_SPECIAL_GFX_ARGS]; - struct TitleFadingInfo navigation; - struct TitleFadingInfo destination; + struct TitleFadingInfo enter_menu; + struct TitleFadingInfo leave_menu; + struct TitleFadingInfo start_item; int sound[NUM_SPECIAL_GFX_ARGS]; int music[NUM_SPECIAL_GFX_ARGS]; @@ -2518,6 +2520,7 @@ struct GraphicInfo int draw_masked; /* optional setting for drawing envelope gfx */ + int fade_mode; /* optional setting for drawing title screens */ int fade_delay; /* optional setting for drawing title screens */ int post_delay; /* optional setting for drawing title screens */ int auto_delay; /* optional setting for drawing title screens */ diff --git a/src/screens.c b/src/screens.c index 6b96420a..a1126a79 100644 --- a/src/screens.c +++ b/src/screens.c @@ -204,8 +204,6 @@ static struct { -1, NULL }, }; -#define XFADE 1 - #define DRAW_MODE(s) ((s) >= GAME_MODE_MAIN && \ (s) <= GAME_MODE_SETUP ? (s) : \ (s) == GAME_MODE_PSEUDO_TYPENAME ? \ @@ -616,8 +614,8 @@ static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci) ti = (initial ? title_initial_default : title_default); /* override default settings with image config settings, if defined */ - if (graphic_info[graphic].anim_mode != ANIM_DEFAULT) - ti.anim_mode = graphic_info[graphic].anim_mode; + if (graphic_info[graphic].fade_mode != FADE_MODE_DEFAULT) + ti.fade_mode = graphic_info[graphic].fade_mode; if (graphic_info[graphic].fade_delay > -1) ti.fade_delay = graphic_info[graphic].fade_delay; if (graphic_info[graphic].post_delay > -1) @@ -629,14 +627,14 @@ static struct TitleFadingInfo getTitleFading(struct TitleControlInfo *tci) { if (initial) { - ti.anim_mode = titlemessage_initial[nr].anim_mode; + ti.fade_mode = titlemessage_initial[nr].fade_mode; ti.fade_delay = titlemessage_initial[nr].fade_delay; ti.post_delay = titlemessage_initial[nr].post_delay; ti.auto_delay = titlemessage_initial[nr].auto_delay; } else { - ti.anim_mode = titlemessage[nr].anim_mode; + ti.fade_mode = titlemessage[nr].fade_mode; ti.fade_delay = titlemessage[nr].fade_delay; ti.post_delay = titlemessage[nr].post_delay; ti.auto_delay = titlemessage[nr].auto_delay; @@ -1238,12 +1236,7 @@ void DrawMainMenuExt(int redraw_mask, boolean do_fading) #endif #if 1 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(redraw_mask); -#endif + FadeOut(redraw_mask); #endif UnmapAllGadgets(); @@ -1333,18 +1326,15 @@ void DrawMainMenuExt(int redraw_mask, boolean do_fading) SetMainBackgroundImage(IMG_BACKGROUND_MAIN); #if 0 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(redraw_mask); -#endif + FadeOut(redraw_mask); #endif #if 1 if (redraw_mask == REDRAW_ALL) { +#if 0 int door_state = GetDoorState(); +#endif RedrawBackground(); @@ -1469,11 +1459,8 @@ void DrawMainMenuExt(int redraw_mask, boolean do_fading) } #endif -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(redraw_mask); - else - FadeIn(redraw_mask); +#if 1 + FadeIn(redraw_mask); #else #if 1 if (!do_fading) @@ -1491,7 +1478,7 @@ void DrawMainMenuExt(int redraw_mask, boolean do_fading) #endif #if 1 - fading = menu.navigation; + FadeSetEnterMenu(); #else fading = title_default; #endif @@ -1559,12 +1546,13 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) #endif #endif struct TitleControlInfo *tci; + struct TitleFadingInfo fading_last = fading; struct TitleFadingInfo fading_next; int sound, music; if (button == MB_MENU_INITIALIZE) { -#if 1 +#if 0 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE); #endif @@ -1601,11 +1589,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) FadeSoundsAndMusic(); #if 1 - if (use_cross_fading) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_ALL); -#else FadeOut(REDRAW_ALL); #endif } @@ -1615,7 +1598,11 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) else DrawTitleScreenMessage(tci->local_nr, tci->initial); - fading = getTitleFading(tci); + fading = fading_next = getTitleFading(tci); + + if (fading_last.fade_mode != FADE_MODE_CROSSFADE && + fading_next.fade_mode == FADE_MODE_CROSSFADE) + fading.fade_mode = FADE_MODE_FADE; #if 1 sound = getTitleSound(tci); @@ -1633,14 +1620,11 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) SetMouseCursor(CURSOR_NONE); #if 1 - if (use_cross_fading) - FadeCross(REDRAW_ALL); - else - FadeIn(REDRAW_ALL); -#else FadeIn(REDRAW_ALL); #endif + fading = fading_next; + DelayReached(&title_delay, 0); /* reset delay counter */ return; @@ -1656,24 +1640,17 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) } else if (button == MB_MENU_CHOICE) { -#if 1 +#if 0 boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE); #endif if (game_status == GAME_MODE_INFO && num_title_screens == 0) { #if 0 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); -#endif #endif - fading = menu.destination; + FadeSetStartItem(); info_mode = INFO_MODE_MAIN; DrawAndFadeInInfoScreen(REDRAW_FIELD); @@ -1713,10 +1690,9 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) if (music == MUS_UNDEFINED || music != last_music) FadeMusic(); - if (use_cross_fading) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_ALL); +#if 1 + FadeOut(REDRAW_ALL); +#endif if (tci->is_image) DrawTitleScreenImage(tci->local_nr, tci->initial); @@ -1738,14 +1714,18 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) last_music = music; #endif +#if 0 + printf("::: %d -> %d\n", fading.fade_mode, fading_next.fade_mode); +#endif + /* last screen already faded out, next screen has no animation */ - if (!use_cross_fading && fading_next.anim_mode == ANIM_NONE) + if (fading.fade_mode != FADE_MODE_CROSSFADE && + fading_next.fade_mode == FADE_MODE_NONE) fading = fading_next; - if (use_cross_fading) - FadeCross(REDRAW_ALL); - else - FadeIn(REDRAW_ALL); +#if 1 + FadeIn(REDRAW_ALL); +#endif fading = fading_next; @@ -1762,10 +1742,9 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE); #endif - if (use_cross_fading) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_ALL); +#if 1 + FadeOut(REDRAW_ALL); +#endif } #else FadeOut(REDRAW_ALL); @@ -1955,7 +1934,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) game_status = GAME_MODE_EDITOR; - fading = menu.destination; + FadeSetStartItem(); DrawLevelEd(); } @@ -1964,7 +1943,9 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) game_status = GAME_MODE_INFO; info_mode = INFO_MODE_MAIN; +#if 0 fading = menu.navigation; +#endif DrawInfoScreen(); } @@ -2129,7 +2110,9 @@ static int num_info_info; static void execInfoTitleScreen() { - fading = menu.destination; +#if 0 + FadeSetStartItem(); +#endif info_mode = INFO_MODE_TITLE; DrawInfoScreen(); @@ -2137,7 +2120,9 @@ static void execInfoTitleScreen() static void execInfoElements() { - fading = menu.destination; +#if 0 + FadeSetStartItem(); +#endif info_mode = INFO_MODE_ELEMENTS; DrawInfoScreen(); @@ -2145,7 +2130,9 @@ static void execInfoElements() static void execInfoMusic() { - fading = menu.destination; +#if 0 + FadeSetStartItem(); +#endif info_mode = INFO_MODE_MUSIC; DrawInfoScreen(); @@ -2153,7 +2140,9 @@ static void execInfoMusic() static void execInfoCredits() { - fading = menu.destination; +#if 0 + FadeSetStartItem(); +#endif info_mode = INFO_MODE_CREDITS; DrawInfoScreen(); @@ -2161,7 +2150,9 @@ static void execInfoCredits() static void execInfoProgram() { - fading = menu.destination; +#if 0 + FadeSetStartItem(); +#endif info_mode = INFO_MODE_PROGRAM; DrawInfoScreen(); @@ -2169,7 +2160,9 @@ static void execInfoProgram() static void execInfoVersion() { - fading = menu.destination; +#if 0 + FadeSetStartItem(); +#endif info_mode = INFO_MODE_VERSION; DrawInfoScreen(); @@ -2177,7 +2170,9 @@ static void execInfoVersion() static void execInfoLevelSet() { - fading = menu.destination; +#if 0 + FadeSetStartItem(); +#endif info_mode = INFO_MODE_LEVELSET; DrawInfoScreen(); @@ -2185,7 +2180,9 @@ static void execInfoLevelSet() static void execExitInfo() { - fading = menu.navigation; +#if 0 + FadeSetLeaveMenu(); +#endif game_status = GAME_MODE_MAIN; #if 1 @@ -2232,11 +2229,8 @@ static void DrawInfoScreen_Main(int redraw_mask, boolean do_fading) UnmapAllGadgets(); CloseDoor(DOOR_CLOSE_2); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(redraw_mask); +#if 1 + FadeOut(redraw_mask); #endif #if 1 @@ -2283,13 +2277,10 @@ static void DrawInfoScreen_Main(int redraw_mask, boolean do_fading) PlayMenuSound(); PlayMenuMusic(); - DrawMaskedBorder(REDRAW_ALL); + DrawMaskedBorder(redraw_mask); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(redraw_mask); - else - FadeIn(redraw_mask); +#if 1 + FadeIn(redraw_mask); #else #if 1 if (!do_fading) @@ -2340,6 +2331,8 @@ void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button) { void (*menu_callback_function)(void) = info_info[y].value; + FadeSetLeaveMenu(); + menu_callback_function(); break; /* absolutely needed because function changes 'info_info'! */ @@ -2402,6 +2395,8 @@ void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button) { void (*menu_callback_function)(void) = info_info[choice].value; + FadeSetFromType(info_info[y].type); + menu_callback_function(); } } @@ -2422,12 +2417,7 @@ void DrawInfoScreen_NotAvailable(char *text_title, char *text_error) SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else +#if 1 FadeOut(REDRAW_FIELD); #endif @@ -2440,12 +2430,7 @@ void DrawInfoScreen_NotAvailable(char *text_title, char *text_error) DrawTextSCentered(ybottom, FONT_TEXT_4, "Press any key or button for info menu"); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(REDRAW_FIELD); - else - FadeIn(REDRAW_FIELD); -#else +#if 1 FadeIn(REDRAW_FIELD); #endif } @@ -2636,12 +2621,7 @@ void DrawInfoScreen_Elements() { SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else +#if 1 FadeOut(REDRAW_FIELD); #endif @@ -2650,12 +2630,7 @@ void DrawInfoScreen_Elements() HandleInfoScreen_Elements(MB_MENU_INITIALIZE); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(REDRAW_FIELD); - else - FadeIn(REDRAW_FIELD); -#else +#if 1 FadeIn(REDRAW_FIELD); #endif @@ -2715,14 +2690,7 @@ void HandleInfoScreen_Elements(int button) FadeSoundsAndMusic(); #if 0 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); -#endif #endif info_mode = INFO_MODE_MAIN; @@ -2753,12 +2721,7 @@ void DrawInfoScreen_Music() { SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else +#if 1 FadeOut(REDRAW_FIELD); #endif @@ -2769,12 +2732,7 @@ void DrawInfoScreen_Music() HandleInfoScreen_Music(MB_MENU_INITIALIZE); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(REDRAW_FIELD); - else - FadeIn(REDRAW_FIELD); -#else +#if 1 FadeIn(REDRAW_FIELD); #endif } @@ -2836,14 +2794,7 @@ void HandleInfoScreen_Music(int button) FadeSoundsAndMusic(); #if 0 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); -#endif #endif info_mode = INFO_MODE_MAIN; @@ -3110,23 +3061,13 @@ void DrawInfoScreen_Credits() FadeSoundsAndMusic(); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else +#if 1 FadeOut(REDRAW_FIELD); #endif HandleInfoScreen_Credits(MB_MENU_INITIALIZE); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(REDRAW_FIELD); - else - FadeIn(REDRAW_FIELD); -#else +#if 1 FadeIn(REDRAW_FIELD); #endif } @@ -3171,14 +3112,7 @@ void HandleInfoScreen_Credits(int button) FadeSoundsAndMusic(); #if 0 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); -#endif #endif info_mode = INFO_MODE_MAIN; @@ -3200,12 +3134,7 @@ void DrawInfoScreen_Program() SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else +#if 1 FadeOut(REDRAW_FIELD); #endif @@ -3244,12 +3173,7 @@ void DrawInfoScreen_Program() DrawTextSCentered(ybottom, FONT_TEXT_4, "Press any key or button for info menu"); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(REDRAW_FIELD); - else - FadeIn(REDRAW_FIELD); -#else +#if 1 FadeIn(REDRAW_FIELD); #endif } @@ -3272,14 +3196,7 @@ void HandleInfoScreen_Program(int button) FadeSoundsAndMusic(); #if 0 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); -#endif #endif info_mode = INFO_MODE_MAIN; @@ -3312,12 +3229,7 @@ void DrawInfoScreen_Version() SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else +#if 1 FadeOut(REDRAW_FIELD); #endif @@ -3430,12 +3342,7 @@ void DrawInfoScreen_Version() DrawTextSCentered(ybottom, FONT_TEXT_4, "Press any key or button for info menu"); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(REDRAW_FIELD); - else - FadeIn(REDRAW_FIELD); -#else +#if 1 FadeIn(REDRAW_FIELD); #endif } @@ -3458,14 +3365,7 @@ void HandleInfoScreen_Version(int button) FadeSoundsAndMusic(); #if 0 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); -#endif #endif info_mode = INFO_MODE_MAIN; @@ -3496,12 +3396,7 @@ void DrawInfoScreen_LevelSet() SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else +#if 1 FadeOut(REDRAW_FIELD); #endif @@ -3521,12 +3416,7 @@ void DrawInfoScreen_LevelSet() DrawTextCentered(mSY + SYSIZE - 20, FONT_TEXT_4, "Press any key or button for info menu"); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(REDRAW_FIELD); - else - FadeIn(REDRAW_FIELD); -#else +#if 1 FadeIn(REDRAW_FIELD); #endif } @@ -3549,14 +3439,7 @@ void HandleInfoScreen_LevelSet(int button) FadeSoundsAndMusic(); #if 0 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); -#endif #endif info_mode = INFO_MODE_MAIN; @@ -3605,7 +3488,7 @@ void DrawAndFadeInInfoScreen(int redraw_mask) void DrawInfoScreen() { - DrawInfoScreenExt(REDRAW_ALL, FALSE); + DrawInfoScreenExt(REDRAW_FIELD, FALSE); } void HandleInfoScreen(int mx, int my, int dx, int dy, int button) @@ -3771,11 +3654,8 @@ static void DrawChooseTree(TreeInfo **ti_ptr) CloseDoor(DOOR_CLOSE_2); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); +#if 1 + FadeOut(REDRAW_FIELD); #endif ClearWindow(); @@ -3783,13 +3663,8 @@ static void DrawChooseTree(TreeInfo **ti_ptr) HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr); MapScreenTreeGadgets(*ti_ptr); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(redraw_mask); - else - FadeIn(redraw_mask); -#else - FadeToFront(); +#if 1 + FadeIn(REDRAW_FIELD); #endif InitAnimation(); @@ -3966,6 +3841,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } else if (button == MB_MENU_LEAVE) { + FadeSetLeaveMenu(); + PlaySound(SND_MENU_ITEM_SELECTING); if (ti->node_parent) @@ -4071,6 +3948,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (node_cursor->node_group) { + FadeSetEnterMenu(); + PlaySound(SND_MENU_ITEM_SELECTING); node_cursor->cl_first = ti->cl_first; @@ -4083,6 +3962,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } else if (dx == -1 && ti->node_parent) { + FadeSetLeaveMenu(); + PlaySound(SND_MENU_ITEM_SELECTING); *ti_ptr = ti->node_parent; @@ -4121,6 +4002,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, if (node_cursor->node_group) { + FadeSetEnterMenu(); + node_cursor->cl_first = ti->cl_first; node_cursor->cl_cursor = ti->cl_cursor; *ti_ptr = node_cursor->node_group; @@ -4128,11 +4011,15 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, } else if (node_cursor->parent_link) { + FadeSetLeaveMenu(); + *ti_ptr = node_cursor->node_parent; DrawChooseTree(ti_ptr); } else { + FadeSetStartItem(); + node_cursor->cl_first = ti->cl_first; node_cursor->cl_cursor = ti->cl_cursor; *ti_ptr = node_cursor; @@ -4200,14 +4087,9 @@ void DrawHallOfFame(int highlight_position) if (highlight_position < 0) LoadScore(level_nr); - fading = menu.destination; + FadeSetStartItem(); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else +#if 1 FadeOut(REDRAW_FIELD); #endif @@ -4218,12 +4100,7 @@ void DrawHallOfFame(int highlight_position) HandleHallOfFame(highlight_position, 0, 0, 0, MB_MENU_INITIALIZE); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(REDRAW_FIELD); - else - FadeIn(REDRAW_FIELD); -#else +#if 1 FadeIn(REDRAW_FIELD); #endif } @@ -4322,14 +4199,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) FadeSound(SND_BACKGROUND_SCORES); #if 0 -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); -#else FadeOut(REDRAW_FIELD); -#endif #endif game_status = GAME_MODE_MAIN; @@ -4359,12 +4229,20 @@ static char *music_set_name; static void execSetupMain() { +#if 0 + FadeSetLeaveMenu(); +#endif + setup_mode = SETUP_MODE_MAIN; DrawSetupScreen(); } static void execSetupGame() { +#if 0 + FadeSetEnterMenu(); +#endif + if (game_speeds == NULL) { int i; @@ -4418,18 +4296,30 @@ static void execSetupGame() static void execSetupChooseGameSpeed() { +#if 0 + FadeSetEnterMenu(); +#endif + setup_mode = SETUP_MODE_CHOOSE_GAME_SPEED; DrawSetupScreen(); } static void execSetupEditor() { +#if 0 + FadeSetEnterMenu(); +#endif + setup_mode = SETUP_MODE_EDITOR; DrawSetupScreen(); } static void execSetupGraphics() { +#if 0 + FadeSetEnterMenu(); +#endif + if (video.fullscreen_available && screen_modes == NULL) { int i; @@ -4492,6 +4382,10 @@ static void execSetupGraphics() static void execSetupChooseScreenMode() { +#if 0 + FadeSetEnterMenu(); +#endif + if (!video.fullscreen_available) return; @@ -4501,12 +4395,20 @@ static void execSetupChooseScreenMode() static void execSetupSound() { +#if 0 + FadeSetEnterMenu(); +#endif + setup_mode = SETUP_MODE_SOUND; DrawSetupScreen(); } static void execSetupArtwork() { +#if 0 + FadeSetEnterMenu(); +#endif + setup.graphics_set = artwork.gfx_current->identifier; setup.sounds_set = artwork.snd_current->identifier; setup.music_set = artwork.mus_current->identifier; @@ -4525,42 +4427,70 @@ static void execSetupArtwork() static void execSetupChooseGraphics() { +#if 0 + FadeSetEnterMenu(); +#endif + setup_mode = SETUP_MODE_CHOOSE_GRAPHICS; DrawSetupScreen(); } static void execSetupChooseSounds() { +#if 0 + FadeSetEnterMenu(); +#endif + setup_mode = SETUP_MODE_CHOOSE_SOUNDS; DrawSetupScreen(); } static void execSetupChooseMusic() { +#if 0 + FadeSetEnterMenu(); +#endif + setup_mode = SETUP_MODE_CHOOSE_MUSIC; DrawSetupScreen(); } static void execSetupInput() { +#if 0 + FadeSetEnterMenu(); +#endif + setup_mode = SETUP_MODE_INPUT; DrawSetupScreen(); } static void execSetupShortcut1() { +#if 0 + FadeSetEnterMenu(); +#endif + setup_mode = SETUP_MODE_SHORTCUT_1; DrawSetupScreen(); } static void execSetupShortcut2() { +#if 0 + FadeSetEnterMenu(); +#endif + setup_mode = SETUP_MODE_SHORTCUT_2; DrawSetupScreen(); } static void execExitSetup() { +#if 0 + FadeSetLeaveMenu(); +#endif + game_status = GAME_MODE_MAIN; #if 1 DrawMainMenuExt(REDRAW_FIELD, FALSE); @@ -4961,11 +4891,8 @@ static void DrawSetupScreen_Generic() UnmapAllGadgets(); CloseDoor(DOOR_CLOSE_2); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); +#if 1 + FadeOut(REDRAW_FIELD); #endif ClearWindow(); @@ -5062,13 +4989,8 @@ static void DrawSetupScreen_Generic() HandleSetupScreen_Generic(0, 0, 0, 0, MB_MENU_INITIALIZE); #endif -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(redraw_mask); - else - FadeIn(redraw_mask); -#else - FadeToFront(); +#if 1 + FadeIn(REDRAW_FIELD); #endif InitAnimation(); @@ -5110,6 +5032,8 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) { void (*menu_callback_function)(void) = setup_info[y].value; + FadeSetLeaveMenu(); + menu_callback_function(); break; /* absolutely needed because function changes 'setup_info'! */ @@ -5180,6 +5104,8 @@ void HandleSetupScreen_Generic(int mx, int my, int dx, int dy, int button) { void (*menu_callback_function)(void) = setup_info[y].value; + FadeSetFromType(setup_info[y].type); + menu_callback_function(); } else @@ -5197,11 +5123,8 @@ void DrawSetupScreen_Input() int i; #endif -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCrossSaveBackbuffer(); - else - FadeOut(REDRAW_FIELD); +#if 1 + FadeOut(REDRAW_FIELD); #endif ClearWindow(); @@ -5252,13 +5175,8 @@ void DrawSetupScreen_Input() HandleSetupScreen_Input(0, 0, 0, 0, MB_MENU_INITIALIZE); -#if XFADE - if (fading.anim_mode == ANIM_CROSSFADE) - FadeCross(redraw_mask); - else - FadeIn(redraw_mask); -#else - FadeToFront(); +#if 1 + FadeIn(REDRAW_FIELD); #endif InitAnimation(); @@ -5502,6 +5420,8 @@ void HandleSetupScreen_Input(int mx, int my, int dx, int dy, int button) { InitJoysticks(); + FadeSetLeaveMenu(); + setup_mode = SETUP_MODE_MAIN; DrawSetupScreen(); } @@ -5532,12 +5452,17 @@ void CustomizeKeyboard(int player_nr) /* read existing key bindings from player setup */ custom_key = setup.input[player_nr].key; + FadeSetEnterMenu(); + FadeOut(REDRAW_FIELD); + ClearWindow(); DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Keyboard Input"); +#if 0 BackToFront(); InitAnimation(); +#endif step_nr = 0; DrawText(mSX, mSY + (2 + 2 * step_nr) * 32, @@ -5547,6 +5472,12 @@ void CustomizeKeyboard(int player_nr) DrawText(mSX + 4 * 32, mSY + (2 + 2 * step_nr + 1) * 32, getKeyNameFromKey(*customize_step[step_nr].key), FONT_VALUE_OLD); +#if 1 + FadeIn(REDRAW_FIELD); + + InitAnimation(); +#endif + while (!finished) { if (PendingEvent()) /* got event */ @@ -5563,6 +5494,9 @@ void CustomizeKeyboard(int player_nr) if (key == KSYM_Escape || (key == KSYM_Return && step_nr == 6)) { + if (key == KSYM_Escape) + FadeSkipNextFadeIn(); + finished = TRUE; break; } @@ -5661,6 +5595,9 @@ static boolean CalibrateJoystickMain(int player_nr) if (joystick_fd < 0 || !setup.input[player_nr].use_joystick) return FALSE; + FadeSetEnterMenu(); + FadeOut(REDRAW_FIELD); + ClearWindow(); for (y = 0; y < 3; y++) @@ -5692,7 +5629,12 @@ static boolean CalibrateJoystickMain(int player_nr) new_joystick_ymiddle = joy_y; DrawGraphic(xpos + last_x, ypos + last_y, IMG_MENU_CALIBRATE_RED, 0); + +#if 1 + FadeIn(REDRAW_FIELD); +#else BackToFront(); +#endif while (Joystick(player_nr) & JOY_BUTTON); /* wait for released button */ InitAnimation(); @@ -5716,6 +5658,7 @@ static boolean CalibrateJoystickMain(int player_nr) break; case KSYM_Escape: + FadeSkipNextFadeIn(); result = 0; break; diff --git a/src/tools.c b/src/tools.c index c820bff1..d3909d5e 100644 --- a/src/tools.c +++ b/src/tools.c @@ -521,11 +521,39 @@ void FadeToFront() void FadeExt(int fade_mask, int fade_mode) { + static int fade_mode_skip = FADE_MODE_NONE; void (*draw_border_function)(void) = NULL; Bitmap *bitmap = (fade_mode == FADE_MODE_CROSSFADE ? bitmap_db_cross : NULL); int x, y, width, height; int fade_delay, post_delay; + redraw_mask |= fade_mask; + + if (fade_mode & FADE_TYPE_SKIP) + { + fade_mode_skip = fade_mode; + + return; + } + + if (fade_mode_skip & FADE_TYPE_SKIP) + { +#if 0 + printf("::: skipping %d ... [%d]\n", fade_mode, fade_mode_skip); +#endif + + /* skip all fade operations until specified fade operation */ + if (fade_mode & fade_mode_skip) + fade_mode_skip = FADE_MODE_NONE; + + return; + } + +#if 1 + if (fading.fade_mode == FADE_MODE_NONE) + return; +#endif + if (fade_mask & REDRAW_FIELD) { x = REAL_SX; @@ -549,13 +577,6 @@ void FadeExt(int fade_mask, int fade_mode) post_delay = (fade_mode == FADE_MODE_FADE_OUT ? fading.post_delay : 0); } - redraw_mask |= fade_mask; - -#if 1 - if (fading.anim_mode == ANIM_NONE) - return; -#endif - #if 1 if (!setup.fade_screens || fade_delay == 0) #else @@ -578,12 +599,26 @@ void FadeExt(int fade_mask, int fade_mode) void FadeIn(int fade_mask) { +#if 1 + if (fading.fade_mode == FADE_MODE_CROSSFADE) + FadeExt(fade_mask, FADE_MODE_CROSSFADE); + else + FadeExt(fade_mask, FADE_MODE_FADE_IN); +#else FadeExt(fade_mask, FADE_MODE_FADE_IN); +#endif } void FadeOut(int fade_mask) { +#if 1 + if (fading.fade_mode == FADE_MODE_CROSSFADE) + FadeCrossSaveBackbuffer(); + else + FadeExt(fade_mask, FADE_MODE_FADE_OUT); +#else FadeExt(fade_mask, FADE_MODE_FADE_OUT); +#endif } void FadeCross(int fade_mask) @@ -596,6 +631,48 @@ void FadeCrossSaveBackbuffer() BlitBitmap(backbuffer, bitmap_db_cross, 0, 0, WIN_XSIZE, WIN_YSIZE, 0, 0); } +void FadeSetEnterMenu() +{ + fading = menu.enter_menu; +} + +void FadeSetLeaveMenu() +{ + fading = menu.leave_menu; +} + +void FadeSetStartItem() +{ + fading = menu.start_item; +} + +void FadeSetFromType(int type) +{ + if (type & TYPE_ENTER_SCREEN) + FadeSetStartItem(); + else if (type & TYPE_ENTER) + FadeSetEnterMenu(); + else if (type & TYPE_LEAVE) + FadeSetLeaveMenu(); +} + +void FadeSetDisabled() +{ + static struct TitleFadingInfo fading_none = { FADE_MODE_NONE, -1, -1, -1 }; + + fading = fading_none; +} + +void FadeSkipNextFadeIn() +{ + FadeExt(0, FADE_MODE_SKIP_FADE_IN); +} + +void FadeSkipNextFadeOut() +{ + FadeExt(0, FADE_MODE_SKIP_FADE_OUT); +} + void SetWindowBackgroundImageIfDefined(int graphic) { if (graphic_info[graphic].bitmap) diff --git a/src/tools.h b/src/tools.h index 7cdd23a5..fa67ae23 100644 --- a/src/tools.h +++ b/src/tools.h @@ -78,6 +78,13 @@ void FadeIn(int); void FadeOut(int); void FadeCross(int); void FadeCrossSaveBackbuffer(); +void FadeSetEnterMenu(); +void FadeSetLeaveMenu(); +void FadeSetStartItem(); +void FadeSetFromType(int); +void FadeSetDisabled(); +void FadeSkipNextFadeIn(); +void FadeSkipNextFadeOut(); void ClearWindow(); void SetWindowBackgroundImageIfDefined(int); -- 2.34.1