From 064971ae82e2e3f98dc55e75b15c192c9165fb4e Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 9 Dec 2015 21:26:49 +0100 Subject: [PATCH] improved and extended definitions for title screen transitions --- build-scripts/create_element_defs.pl | 2 +- src/conf_gfx.c | 18 +++++- src/files.c | 84 +++++++++++++++++++++++++++- src/main.h | 2 +- src/screens.c | 35 ++++-------- src/tools.c | 2 +- 6 files changed, 110 insertions(+), 33 deletions(-) diff --git a/build-scripts/create_element_defs.pl b/build-scripts/create_element_defs.pl index 3c080a7a..c8a6cd06 100755 --- a/build-scripts/create_element_defs.pl +++ b/build-scripts/create_element_defs.pl @@ -2408,7 +2408,7 @@ sub print_image_config_vars $var =~ s/\.([A-Z]+)$/\[GFX_SPECIAL_ARG_$1\]/; $var =~ s/\.([A-Z]+)\./\[GFX_SPECIAL_ARG_$1\]./; - if ($var =~ /^(menu.(enter|leave)_screen)(.[a-z_]+)$/) + if ($var =~ /^(menu.(enter|leave|next)_screen)(.[a-z_]+)$/) { $var = $1 . "[GFX_SPECIAL_ARG_DEFAULT]" . $3; } diff --git a/src/conf_gfx.c b/src/conf_gfx.c index 880d0632..fa001bdb 100644 --- a/src/conf_gfx.c +++ b/src/conf_gfx.c @@ -6143,12 +6143,15 @@ struct ConfigInfo image_config[] = { "menu.enter_screen.fade_mode", "fade" }, { "menu.enter_screen.fade_delay", "250" }, { "menu.enter_screen.post_delay", "125" }, - { "menu.next_screen.fade_mode", "crossfade" }, - { "menu.next_screen.fade_delay", "250" }, - { "menu.next_screen.post_delay", "125" }, { "menu.leave_screen.fade_mode", "fade" }, { "menu.leave_screen.fade_delay", "250" }, { "menu.leave_screen.post_delay", "125" }, + { "menu.next_screen.fade_mode", "crossfade" }, + { "menu.next_screen.fade_delay", "250" }, + { "menu.next_screen.post_delay", "125" }, + { "menu.enter_screen.TITLE.fade_mode", "fade" }, + { "menu.enter_screen.TITLE.fade_delay", "500" }, + { "menu.enter_screen.TITLE.post_delay", "250" }, { "menu.enter_screen.SCORES.fade_mode", ARG_DEFAULT }, { "menu.enter_screen.SCORES.fade_delay", ARG_DEFAULT }, { "menu.enter_screen.SCORES.post_delay", ARG_DEFAULT }, @@ -6161,6 +6164,9 @@ struct ConfigInfo image_config[] = { "menu.enter_screen.PLAYING.fade_mode", ARG_DEFAULT }, { "menu.enter_screen.PLAYING.fade_delay", ARG_DEFAULT }, { "menu.enter_screen.PLAYING.post_delay", ARG_DEFAULT }, + { "menu.leave_screen.TITLE.fade_mode", "fade" }, + { "menu.leave_screen.TITLE.fade_delay", "500" }, + { "menu.leave_screen.TITLE.post_delay", "250" }, { "menu.leave_screen.SCORES.fade_mode", ARG_DEFAULT }, { "menu.leave_screen.SCORES.fade_delay", ARG_DEFAULT }, { "menu.leave_screen.SCORES.post_delay", ARG_DEFAULT }, @@ -6173,6 +6179,12 @@ struct ConfigInfo image_config[] = { "menu.leave_screen.PLAYING.fade_mode", ARG_DEFAULT }, { "menu.leave_screen.PLAYING.fade_delay", ARG_DEFAULT }, { "menu.leave_screen.PLAYING.post_delay", ARG_DEFAULT }, + { "menu.next_screen.TITLE.fade_mode", "fade" }, + { "menu.next_screen.TITLE.fade_delay", "500" }, + { "menu.next_screen.TITLE.post_delay", "250" }, + { "menu.next_screen.INFO.fade_mode", ARG_DEFAULT }, + { "menu.next_screen.INFO.fade_delay", ARG_DEFAULT }, + { "menu.next_screen.INFO.post_delay", ARG_DEFAULT }, { "menu.draw_xoffset", "0" }, { "menu.draw_yoffset", "0" }, diff --git a/src/files.c b/src/files.c index c357e2c7..d1b60e47 100644 --- a/src/files.c +++ b/src/files.c @@ -8778,8 +8778,12 @@ static void InitMenuDesignSettings_SpecialPreProcessing() /* (eg, init "menu.enter_screen.SCORES.xyz" from "menu.enter_screen.xyz") */ for (i = 0; i < NUM_SPECIAL_GFX_ARGS; i++) { + if (i == GFX_SPECIAL_ARG_TITLE) /* title values already initialized */ + continue; + menu.enter_screen[i] = menu.enter_screen[GFX_SPECIAL_ARG_DEFAULT]; menu.leave_screen[i] = menu.leave_screen[GFX_SPECIAL_ARG_DEFAULT]; + menu.next_screen[i] = menu.next_screen[GFX_SPECIAL_ARG_DEFAULT]; } /* special case: initialize "ARG_DEFAULT" values in static default config */ @@ -8790,8 +8794,10 @@ static void InitMenuDesignSettings_SpecialPreProcessing() viewport.playfield[i] = viewport.playfield[GFX_SPECIAL_ARG_DEFAULT]; viewport.door_1[i] = viewport.door_1[GFX_SPECIAL_ARG_DEFAULT]; - if (i != GFX_SPECIAL_ARG_EDITOR) /* editor value already initialized */ - viewport.door_2[i] = viewport.door_2[GFX_SPECIAL_ARG_DEFAULT]; + if (i == GFX_SPECIAL_ARG_EDITOR) /* editor values already initialized */ + continue; + + viewport.door_2[i] = viewport.door_2[GFX_SPECIAL_ARG_DEFAULT]; } } @@ -8831,7 +8837,17 @@ static void InitMenuDesignSettings_SpecialPostProcessing() static void LoadMenuDesignSettingsFromFilename(char *filename) { + static struct TitleFadingInfo tfi; static struct TitleMessageInfo tmi; + static struct TokenInfo title_tokens[] = + { + { TYPE_INTEGER, &tfi.fade_mode, ".fade_mode" }, + { TYPE_INTEGER, &tfi.fade_delay, ".fade_delay" }, + { TYPE_INTEGER, &tfi.post_delay, ".post_delay" }, + { TYPE_INTEGER, &tfi.auto_delay, ".auto_delay" }, + + { -1, NULL, NULL } + }; static struct TokenInfo titlemessage_tokens[] = { { TYPE_INTEGER, &tmi.x, ".x" }, @@ -8855,12 +8871,34 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) { -1, NULL, NULL } }; static struct + { + struct TitleFadingInfo *info; + char *text; + } + title_info[] = + { + /* initialize title screens from "next screen" definitions, if defined */ + { &title_initial_default, "menu.next_screen.TITLE" }, + { &title_default, "menu.next_screen.TITLE" }, + + { NULL, NULL } + }; + static struct { struct TitleMessageInfo *array; char *text; } titlemessage_arrays[] = { + /* initialize title messages from "next screen" definitions, if defined */ + { titlemessage_initial, "menu.next_screen.TITLE" }, + { titlemessage, "menu.next_screen.TITLE" }, + + /* overwrite title messages with title definitions, if defined */ + { titlemessage_initial, "[title_initial]" }, + { titlemessage, "[title]" }, + + /* overwrite title messages with title message definitions, if defined */ { titlemessage_initial, "[titlemessage_initial]" }, { titlemessage, "[titlemessage]" }, @@ -8934,12 +8972,18 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) char *token_4 = "menu.leave_screen.fade_mode"; char *token_5 = "menu.leave_screen.fade_delay"; char *token_6 = "menu.leave_screen.post_delay"; + char *token_7 = "menu.next_screen.fade_mode"; + char *token_8 = "menu.next_screen.fade_delay"; + char *token_9 = "menu.next_screen.post_delay"; char *value_1 = getHashEntry(setup_file_hash, token_1); char *value_2 = getHashEntry(setup_file_hash, token_2); char *value_3 = getHashEntry(setup_file_hash, token_3); char *value_4 = getHashEntry(setup_file_hash, token_4); char *value_5 = getHashEntry(setup_file_hash, token_5); char *value_6 = getHashEntry(setup_file_hash, token_6); + char *value_7 = getHashEntry(setup_file_hash, token_7); + char *value_8 = getHashEntry(setup_file_hash, token_8); + char *value_9 = getHashEntry(setup_file_hash, token_9); if (value_1 != NULL) menu.enter_screen[i].fade_mode = get_token_parameter_value(token_1, @@ -8959,6 +9003,15 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) if (value_6 != NULL) menu.leave_screen[i].post_delay = get_token_parameter_value(token_6, value_6); + if (value_7 != NULL) + menu.next_screen[i].fade_mode = get_token_parameter_value(token_7, + value_7); + if (value_8 != NULL) + menu.next_screen[i].fade_delay = get_token_parameter_value(token_8, + value_8); + if (value_9 != NULL) + menu.next_screen[i].post_delay = get_token_parameter_value(token_9, + value_9); } /* special case: initialize with default values that may be overwritten */ @@ -9041,6 +9094,33 @@ static void LoadMenuDesignSettingsFromFilename(char *filename) value_15); } + /* special case: initialize with default values that may be overwritten */ + /* (e.g., init "[title].fade_mode" from "menu.next_screen.TITLE.fade_mode") */ + for (i = 0; title_info[i].info != NULL; i++) + { + struct TitleFadingInfo *info = title_info[i].info; + char *base_token = title_info[i].text; + + for (j = 0; title_tokens[j].type != -1; j++) + { + char *token = getStringCat2(base_token, title_tokens[j].text); + char *value = getHashEntry(setup_file_hash, token); + + if (value != NULL) + { + int parameter_value = get_token_parameter_value(token, value); + + tfi = *info; + + *(boolean *)title_tokens[j].value = (boolean)parameter_value; + + *info = tfi; + } + + free(token); + } + } + /* special case: initialize with default values that may be overwritten */ /* (e.g., init "titlemessage_1.fade_mode" from "[titlemessage].fade_mode") */ for (i = 0; titlemessage_arrays[i].array != NULL; i++) diff --git a/src/main.h b/src/main.h index a8edcee7..f2e93570 100644 --- a/src/main.h +++ b/src/main.h @@ -2176,7 +2176,7 @@ struct MenuInfo struct TitleFadingInfo leave_menu; struct TitleFadingInfo enter_screen[NUM_SPECIAL_GFX_ARGS]; struct TitleFadingInfo leave_screen[NUM_SPECIAL_GFX_ARGS]; - struct TitleFadingInfo next_screen; + struct TitleFadingInfo next_screen[NUM_SPECIAL_GFX_ARGS]; int sound[NUM_SPECIAL_GFX_ARGS]; int music[NUM_SPECIAL_GFX_ARGS]; diff --git a/src/screens.c b/src/screens.c index 4461c4b7..1f94c785 100644 --- a/src/screens.c +++ b/src/screens.c @@ -1552,9 +1552,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) static int last_sound = -1, last_music = -1; boolean return_to_main_menu = FALSE; struct TitleControlInfo *tci; - struct TitleFadingInfo fading_default; - struct TitleFadingInfo fading_last = fading; - struct TitleFadingInfo fading_next; int sound, music; if (button == MB_MENU_INITIALIZE) @@ -1566,6 +1563,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) last_sound = SND_UNDEFINED; last_music = MUS_UNDEFINED; + FadeSetEnterScreen(); + if (game_status_last_screen == GAME_MODE_INFO) { if (num_title_screens == 0) @@ -1584,6 +1583,7 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) /* only required to update logic for redrawing global border */ ClearField(); + /* title screens may have different window size */ ChangeViewportPropertiesIfNeeded(); if (tci->is_image) @@ -1591,17 +1591,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) else DrawTitleScreenMessage(tci->local_nr, tci->initial); - fading_default = (tci->initial ? title_initial_default : title_default); - - fading = fading_next = getTitleFading(tci); - - if (!(fading_last.fade_mode & FADE_TYPE_TRANSFORM) && - fading_next.fade_mode & FADE_TYPE_TRANSFORM) - { - fading.fade_mode = FADE_MODE_FADE; - fading.fade_delay = fading_default.fade_delay; - } - sound = getTitleSound(tci); music = getTitleMusic(tci); @@ -1617,8 +1606,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) FadeIn(REDRAW_ALL); - fading = fading_next; - DelayReached(&title_delay, 0); /* reset delay counter */ return; @@ -1658,6 +1645,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) if (music == MUS_UNDEFINED || music != last_music) FadeMusic(); + fading = getTitleFading(tci); + FadeOut(REDRAW_ALL); if (tci->is_image) @@ -1665,8 +1654,6 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) else DrawTitleScreenMessage(tci->local_nr, tci->initial); - fading_next = getTitleFading(tci); - sound = getTitleSound(tci); music = getTitleMusic(tci); @@ -1678,15 +1665,8 @@ void HandleTitleScreen(int mx, int my, int dx, int dy, int button) last_sound = sound; last_music = music; - /* last screen already faded out, next screen has no animation */ - if (!(fading.fade_mode & FADE_TYPE_TRANSFORM) && - fading_next.fade_mode == FADE_MODE_NONE) - fading = fading_next; - FadeIn(REDRAW_ALL); - fading = fading_next; - DelayReached(&title_delay, 0); /* reset delay counter */ } else @@ -2203,6 +2183,11 @@ static void DrawInfoScreen_Main() PlayMenuSound(); PlayMenuMusic(); +#if 1 + // needed after returning from title screens with different window size + OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); +#endif + DrawMaskedBorder(fade_mask); FadeIn(fade_mask); diff --git a/src/tools.c b/src/tools.c index cda45dea..5c1f6549 100644 --- a/src/tools.c +++ b/src/tools.c @@ -649,7 +649,7 @@ void FadeSetEnterScreen() void FadeSetNextScreen() { - fading = menu.next_screen; + fading = menu.next_screen[game_status]; // (do not overwrite fade mode set by FadeSetEnterScreen) // FadeSetLeaveNext(fading, TRUE); /* (keep same fade mode) */ -- 2.34.1