rnd-20051125-1-src
[rocksndiamonds.git] / src / screens.c
index 8d4fa2826875c6f1a0b6c967d56636b344f6fbe6..43a9b6079252a0fc2b42de9f09d1a6ad48659ced 100644 (file)
@@ -97,12 +97,13 @@ static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
 static int setup_mode = SETUP_MODE_MAIN;
 static int info_mode = INFO_MODE_MAIN;
 
-#define mSX (SX + (game_status >= GAME_MODE_MAIN &&    \
-                  game_status <= GAME_MODE_SETUP ?     \
-                  menu.draw_xoffset[game_status] : menu.draw_xoffset_default))
-#define mSY (SY + (game_status >= GAME_MODE_MAIN &&    \
-                  game_status <= GAME_MODE_SETUP ?     \
-                  menu.draw_yoffset[game_status] : menu.draw_yoffset_default))
+#define DRAW_OFFSET_MODE(x)    (x >= GAME_MODE_MAIN &&                 \
+                                x <= GAME_MODE_SETUP ? x :             \
+                                x == GAME_MODE_PSEUDO_TYPENAME ?       \
+                                GAME_MODE_MAIN : GAME_MODE_DEFAULT)
+
+#define mSX (SX + menu.draw_xoffset[DRAW_OFFSET_MODE(game_status)])
+#define mSY (SY + menu.draw_yoffset[DRAW_OFFSET_MODE(game_status)])
 
 #define NUM_MENU_ENTRIES_ON_SCREEN (menu.list_size[game_status] > 2 ?  \
                                    menu.list_size[game_status] :       \
@@ -510,6 +511,9 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
       }
       else if (y == 5)
       {
+#if 1
+       StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
+#else
        if (setup.autorecord)
          TapeStartRecording();
 
@@ -523,6 +527,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button)
          StopAnimation();
          InitGame();
        }
+#endif
       }
       else if (y == 6)
       {
@@ -745,7 +750,10 @@ void DrawInfoScreen_HelpAnim(int start, int max_anims, boolean init)
     for (i = 0; i < MAX_INFO_ELEMENTS_ON_SCREEN; i++)
       infoscreen_step[i] = infoscreen_frame[i] = 0;
 
+#if 0
     SetMainBackgroundImage(IMG_BACKGROUND_INFO);
+#endif
+
     ClearWindow();
     DrawHeadline();
 
@@ -891,6 +899,8 @@ void DrawInfoScreen_HelpText(int element, int action, int direction, int ypos)
 
 void DrawInfoScreen_Elements()
 {
+  SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_ELEMENTS);
+
   LoadHelpAnimInfo();
   LoadHelpTextInfo();
 
@@ -966,6 +976,8 @@ void HandleInfoScreen_Elements(int button)
 
 void DrawInfoScreen_Music()
 {
+  SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_MUSIC);
+
   ClearWindow();
   DrawHeadline();
 
@@ -1098,6 +1110,8 @@ void DrawInfoScreen_Credits()
   int ystart = 150, ystep = 30;
   int ybottom = SYSIZE - 20;
 
+  SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
+
   FadeSoundsAndMusic();
 
   ClearWindow();
@@ -1146,6 +1160,8 @@ void DrawInfoScreen_Program()
   int ystart = 150, ystep = 30;
   int ybottom = SYSIZE - 20;
 
+  SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
+
   ClearWindow();
   DrawHeadline();
 
@@ -1223,6 +1239,8 @@ void DrawInfoScreen_LevelSet()
   int max_chars_per_line = (SXSIZE - 2 * pad_x) / font_width;
   int max_lines_per_screen = (SYSIZE - pad_y) / font_height - 1;
 
+  SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
+
   ClearWindow();
   DrawHeadline();
 
@@ -3081,6 +3099,9 @@ void HandleGameActions()
   }
   else
   {
+    if (game.restart_level)
+      StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
+
     if (local_player->LevelSolved)
       GameWon();
 
@@ -3095,6 +3116,30 @@ void HandleGameActions()
   }
 }
 
+void StartGameActions(boolean init_network_game, boolean record_tape,
+                     long random_seed)
+{
+  if (record_tape)
+    TapeStartRecording(random_seed);
+
+#if defined(NETWORK_AVALIABLE)
+  if (init_network_game)
+  {
+    SendToServer_StartPlaying();
+
+    return;
+  }
+#endif
+
+  StopAnimation();
+
+  game_status = GAME_MODE_PLAYING;
+
+  InitRND(random_seed);
+
+  InitGame();
+}
+
 /* ---------- new screen button stuff -------------------------------------- */
 
 /* graphic position and size values for buttons and scrollbars */