moved code to get font for "choose tree" screen to separate function
[rocksndiamonds.git] / src / screens.c
index 5400958815c89125710267d08644d2093215f24e..49f390f973f643616266c0e1a78cfce6d6a432ce 100644 (file)
@@ -3259,7 +3259,7 @@ void HandleInfoScreen_Music(int button)
     {
       int sound = list->music;
 
-      if (sound_info[sound].loop)
+      if (IS_LOOP_SOUND(sound))
        PlaySoundLoop(sound);
       else
        PlaySound(sound);
@@ -3270,7 +3270,7 @@ void HandleInfoScreen_Music(int button)
     {
       int music = list->music;
 
-      if (music_info[music].loop)
+      if (IS_LOOP_MUSIC(music))
        PlayMusicLoop(music);
       else
        PlayMusic(music);
@@ -3338,7 +3338,7 @@ void HandleInfoScreen_Music(int button)
       FadeIn(REDRAW_FIELD);
   }
 
-  if (list != NULL && list->is_sound && sound_info[list->music].loop)
+  if (list != NULL && list->is_sound && IS_LOOP_SOUND(list->music))
     PlaySoundLoop(list->music);
 }
 
@@ -4832,6 +4832,9 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
   FreeScreenGadgets();
   CreateScreenGadgets();
 
+  if (game_status != game_status_last_screen)
+    FadeMenuSoundsAndMusic();
+
   FadeOut(fade_mask);
 
   // needed if different viewport properties defined for choosing level (set)
@@ -4853,9 +4856,20 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
 
   DrawMaskedBorder(fade_mask);
 
+  if (game_status != game_status_last_screen)
+    PlayMenuSoundsAndMusic();
+
   FadeIn(fade_mask);
 }
 
+static int getChooseTreeFont(TreeInfo *node, boolean active)
+{
+  int font_color = MENU_CHOOSE_TREE_COLOR(node, active);
+  int font_nr = MENU_CHOOSE_TREE_FONT(font_color);
+
+  return font_nr;
+}
+
 static void drawChooseTreeText(int y, boolean active, TreeInfo *ti)
 {
   int num_entries = numTreeInfoInGroup(ti);
@@ -4866,8 +4880,7 @@ static void drawChooseTreeText(int y, boolean active, TreeInfo *ti)
   int entry_pos = first_entry + y;
   TreeInfo *node_first = getTreeInfoFirstGroupEntry(ti);
   TreeInfo *node = getTreeInfoFromPos(node_first, entry_pos);
-  int font_color = MENU_CHOOSE_TREE_COLOR(node, active);
-  int font_nr = MENU_CHOOSE_TREE_FONT(font_color);
+  int font_nr = getChooseTreeFont(node, active);
   int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
   int xpos = MENU_SCREEN_START_XPOS;
   int ypos = MENU_SCREEN_START_YPOS + y;
@@ -4966,6 +4979,18 @@ static void drawChooseTreeCursorAndText(int y, boolean active, TreeInfo *ti)
   drawChooseTreeText(y, active, ti);
 }
 
+static void drawChooseTreeScreen(TreeInfo *ti)
+{
+  int num_entries = numTreeInfoInGroup(ti);
+  int num_page_entries = MIN(num_entries, NUM_MENU_ENTRIES_ON_SCREEN);
+
+  drawChooseTreeList(ti->cl_first, num_page_entries, ti);
+  drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
+  drawChooseTreeCursorAndText(ti->cl_cursor, TRUE, ti);
+
+  AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL, ti->cl_first, ti);
+}
+
 static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
                             TreeInfo **ti_ptr)
 {
@@ -5007,13 +5032,8 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
 
     if (position_set_by_scrollbar)
       ti->cl_first = dy;
-    else
-      AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
-                               ti->cl_first, ti);
 
-    drawChooseTreeList(ti->cl_first, num_page_entries, ti);
-    drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
-    drawChooseTreeCursorAndText(ti->cl_cursor, TRUE, ti);
+    drawChooseTreeScreen(ti);
 
     return;
   }
@@ -5121,14 +5141,7 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
       }
 
       if (redraw)
-      {
-       drawChooseTreeList(ti->cl_first, num_page_entries, ti);
-       drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
-       drawChooseTreeCursorAndText(ti->cl_cursor, TRUE, ti);
-
-       AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
-                                 ti->cl_first, ti);
-      }
+       drawChooseTreeScreen(ti);
 
       return;
     }
@@ -5360,8 +5373,6 @@ void DrawChoosePlayerName(void)
 {
   int i;
 
-  FadeMenuSoundsAndMusic();
-
   if (player_name != NULL)
   {
     freeTreeInfo(player_name);
@@ -5401,8 +5412,6 @@ void DrawChoosePlayerName(void)
     player_name_current = player_name;
 
   DrawChooseTree(&player_name_current);
-
-  PlayMenuSoundsAndMusic();
 }
 
 void HandleChoosePlayerName(int mx, int my, int dx, int dy, int button)
@@ -5412,11 +5421,7 @@ void HandleChoosePlayerName(int mx, int my, int dx, int dy, int button)
 
 void DrawChooseLevelSet(void)
 {
-  FadeMenuSoundsAndMusic();
-
   DrawChooseTree(&leveldir_current);
-
-  PlayMenuSoundsAndMusic();
 }
 
 void HandleChooseLevelSet(int mx, int my, int dx, int dy, int button)
@@ -5428,8 +5433,6 @@ void DrawChooseLevelNr(void)
 {
   int i;
 
-  FadeMenuSoundsAndMusic();
-
   if (level_number != NULL)
   {
     freeTreeInfo(level_number);
@@ -5475,8 +5478,6 @@ void DrawChooseLevelNr(void)
     level_number_current = level_number;
 
   DrawChooseTree(&level_number_current);
-
-  PlayMenuSoundsAndMusic();
 }
 
 void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
@@ -7311,6 +7312,7 @@ static struct TokenInfo setup_info_game[] =
   { TYPE_YES_NO,       &setup.ask_on_quit_game, "Ask on Quit Game:"    },
   { TYPE_YES_NO,       &setup.ask_on_quit_program, "Ask on Quit Program:" },
   { TYPE_SWITCH,       &setup.autorecord,      "Auto-Record Tapes:"    },
+  { TYPE_SWITCH,       &setup.auto_pause_on_start, "Start Game in Pause Mode:" },
   { TYPE_ENTER_LIST,   execSetupChooseGameSpeed, "Game Speed:"         },
   { TYPE_STRING,       &game_speed_text,       ""                      },
   { TYPE_SWITCH,       &setup.game_speed_extended, "Game Speed Extended List:" },
@@ -7558,6 +7560,10 @@ static struct TokenInfo setup_info_shortcuts_1[] =
   { TYPE_KEY,          &setup.shortcut.save_game, ""                   },
   { TYPE_KEYTEXT,      NULL,           "Quick Load Game from Tape:",   },
   { TYPE_KEY,          &setup.shortcut.load_game, ""                   },
+  { TYPE_KEYTEXT,      NULL,           "Restart Game:",                },
+  { TYPE_KEY,          &setup.shortcut.restart_game, ""                },
+  { TYPE_KEYTEXT,      NULL,           "Replay & Pause Before End:",   },
+  { TYPE_KEY,          &setup.shortcut.pause_before_end, ""            },
   { TYPE_KEYTEXT,      NULL,           "Start Game & Toggle Pause:",   },
   { TYPE_KEY,          &setup.shortcut.toggle_pause, ""                },
   { TYPE_EMPTY,                NULL,                   ""                      },