added showing optional level info before starting the game
authorHolger Schemel <holger.schemel@virtion.de>
Sun, 3 Nov 2024 23:47:50 +0000 (00:47 +0100)
committerHolger Schemel <holger.schemel@virtion.de>
Sun, 3 Nov 2024 23:47:50 +0000 (00:47 +0100)
src/game.c
src/screens.c
src/screens.h

index b65d2431d3c65d8fa91b21756d844a7b7baa4d92..c16b3645d0a227a7d667d92e4f61f9ceef00a6da 100644 (file)
@@ -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;
 
index 9657ca04ccc4faee9281bc2832dc3752e3c48d34..9fcd0d3aebd893ca8111d292c0a5b37ab94176e8 100644 (file)
 #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)
index deba425c28ef73df7ab8fa1ed94e0fc19841d7e5..ff05d5f71806ccd5c98db037a7fefbd911d55352 100644 (file)
@@ -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);