From: Holger Schemel Date: Sun, 3 Nov 2024 23:47:50 +0000 (+0100) Subject: added showing optional level info before starting the game X-Git-Tag: 4.4.0.0-test-4~87 X-Git-Url: https://git.artsoft.org/?a=commitdiff_plain;h=949f22f9c95b244b066ab33fe6ec16b1b3f61f86;p=rocksndiamonds.git added showing optional level info before starting the game --- diff --git a/src/game.c b/src/game.c index b65d2431..c16b3645 100644 --- a/src/game.c +++ b/src/game.c @@ -3676,11 +3676,17 @@ void InitGame(void) int full_lev_fieldy = lev_fieldy + (BorderElement != EL_EMPTY ? 2 : 0); int fade_mask = REDRAW_FIELD; boolean restarting = (game_status == GAME_MODE_PLAYING); + boolean level_info = (game_status == GAME_MODE_INFO); boolean emulate_bd = TRUE; // unless non-BOULDERDASH elements found boolean emulate_sp = TRUE; // unless non-SUPAPLEX elements found int initial_move_dir = MV_DOWN; int i, j, x, y; + // show level info before starting the game (if any exists) + if (!level_editor_test_game && !restarting && !level_info && !tape.playing) + if (ShowInfoScreen_FromInitGame()) + return; + // required to prevent handling game actions when moving doors (via "checkGameEnded()") game.InitGameRequested = TRUE; diff --git a/src/screens.c b/src/screens.c index 9657ca04..9fcd0d3a 100644 --- a/src/screens.c +++ b/src/screens.c @@ -158,8 +158,10 @@ #define TEXT_MAIN_MENU "Press any key or button for main menu" #define TEXT_INFO_MENU "Press any key or button for info menu" #define TEXT_NEXT_PAGE "Press any key or button for next page" -#define TEXT_NEXT_MENU (info_screens_from_main ? \ - TEXT_MAIN_MENU : TEXT_INFO_MENU) +#define TEXT_INIT_GAME "Press any key or button to start game" +#define TEXT_NEXT_MENU (info_screens_from_main ? TEXT_MAIN_MENU : \ + info_screens_from_game ? TEXT_INIT_GAME : \ + TEXT_INFO_MENU) // for input setup functions #define SETUPINPUT_SCREEN_POS_START 0 @@ -370,6 +372,7 @@ static int info_mode = INFO_MODE_MAIN; static int setup_mode = SETUP_MODE_MAIN; static boolean info_screens_from_main = FALSE; +static boolean info_screens_from_game = FALSE; static TreeInfo *window_sizes = NULL; static TreeInfo *window_size_current = NULL; @@ -2894,6 +2897,16 @@ static void DrawInfoScreen_Main(void) return; } + // (needed after displaying info sub-screens directly from init game) + if (info_screens_from_game) + { + info_screens_from_game = FALSE; + + InitGame(); + + return; + } + if (redraw_mask & REDRAW_ALL) fade_mask = REDRAW_ALL; @@ -4347,6 +4360,10 @@ void HandleInfoScreen_Generic(int mx, int my, int dx, int dy, int button) { PlaySound(SND_MENU_ITEM_SELECTING); + // if escaping from level info screen on game start, go back to main menu + if (info_screens_from_game) + info_screens_from_main = TRUE; + info_mode = INFO_MODE_MAIN; DrawInfoScreen(); } @@ -4435,19 +4452,25 @@ static void DrawInfoScreen(void) DrawInfoScreen_Main(); } -void DrawInfoScreen_FromMainMenu(int nr) +static void DrawInfoScreen_FromMainMenuOrInitGame(int nr, boolean from_game_status) { int fade_mask = REDRAW_FIELD; if (nr < INFO_MODE_MAIN || nr >= MAX_INFO_MODES) return; + if (from_game_status == GAME_MODE_MAIN) + info_screens_from_main = TRUE; + else if (from_game_status == GAME_MODE_PLAYING) + info_screens_from_game = TRUE; + else + return; + CloseDoor(DOOR_CLOSE_2); SetGameStatus(GAME_MODE_INFO); info_mode = nr; - info_screens_from_main = TRUE; if (redraw_mask & REDRAW_ALL) fade_mask = REDRAW_ALL; @@ -4472,6 +4495,26 @@ void DrawInfoScreen_FromMainMenu(int nr) DrawInfoScreen(); } +void DrawInfoScreen_FromMainMenu(int nr) +{ + DrawInfoScreen_FromMainMenuOrInitGame(nr, GAME_MODE_MAIN); +} + +void DrawInfoScreen_FromInitGame(int nr) +{ + DrawInfoScreen_FromMainMenuOrInitGame(nr, GAME_MODE_PLAYING); +} + +boolean ShowInfoScreen_FromInitGame(void) +{ + if (!hasLevelInfo()) + return FALSE; + + DrawInfoScreen_FromInitGame(INFO_MODE_LEVEL); + + return TRUE; +} + void HandleInfoScreen(int mx, int my, int dx, int dy, int button) { if (info_mode == INFO_MODE_TITLE) diff --git a/src/screens.h b/src/screens.h index deba425c..ff05d5f7 100644 --- a/src/screens.h +++ b/src/screens.h @@ -25,6 +25,8 @@ void DrawMainMenu(void); void DrawHallOfFame(int); void DrawScreenAfterAddingSet(char *, int); void DrawInfoScreen_FromMainMenu(int); +void DrawInfoScreen_FromInitGame(int); +boolean ShowInfoScreen_FromInitGame(void); void RedrawSetupScreenAfterFullscreenToggle(void); void RedrawSetupScreenAfterScreenRotation(int);