changed high score list layout in hall of fame for backward compatibility
[rocksndiamonds.git] / src / screens.c
index c036c5a2531b2c7db1cef126d03da8685488710f..0eb3a87e06c2b3bdf9a429e16e5f6f95e2587406 100644 (file)
@@ -1688,8 +1688,6 @@ void DrawMainMenu(void)
   // store valid level series information
   leveldir_last_valid = leveldir_current;
 
-  init_last = init;                    // switch to new busy animation
-
   // needed if last screen (level choice) changed graphics, sounds or music
   ReloadCustomArtwork(0);
 
@@ -4835,6 +4833,8 @@ static int getAlignYOffsetFromTreeInfo(TreeInfo *ti)
 static void DrawChooseTree(TreeInfo **ti_ptr)
 {
   int fade_mask = REDRAW_FIELD;
+  boolean restart_music = (game_status != game_status_last_screen &&
+                          game_status_last_screen != GAME_MODE_SCOREINFO);
 
   if (CheckFadeAll())
     fade_mask = REDRAW_ALL;
@@ -4860,7 +4860,7 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
   FreeScreenGadgets();
   CreateScreenGadgets();
 
-  if (game_status != game_status_last_screen)
+  if (restart_music)
     FadeMenuSoundsAndMusic();
 
   FadeOut(fade_mask);
@@ -4891,7 +4891,7 @@ static void DrawChooseTree(TreeInfo **ti_ptr)
 
   DrawMaskedBorder(fade_mask);
 
-  if (game_status != game_status_last_screen)
+  if (restart_music)
     PlayMenuSoundsAndMusic();
 
   FadeIn(fade_mask);
@@ -4943,7 +4943,7 @@ static void drawChooseTreeText(TreeInfo *ti, int y, boolean active)
     int border = amSX - SX + getFontDrawOffsetX(font_nr1);
     int dx1 = 0;
     int dx3 = text_size_1;
-    int dx4 = screen_width - startdx - 2 * border - text_size_4;
+    int dx4 = SXSIZE - 2 * startdx - 2 * border - text_size_4;
     int num_dots = (dx4 - dx3) / font_size_3;
     int startx1 = startx + dx1;
     int startx3 = startx + dx3;
@@ -5114,8 +5114,13 @@ static void drawChooseTreeScreen_Scores_NotAvailable(void)
 
 static TreeInfo *setHallOfFameActiveEntry(TreeInfo **ti_ptr)
 {
+  int score_pos = scores.last_added;
+
+  if (game_status_last_screen == GAME_MODE_SCOREINFO)
+    score_pos = scores.last_entry_nr;
+
   // set current tree entry to last added score entry
-  *ti_ptr = getTreeInfoFromIdentifier(score_entries, i_to_a(scores.last_added));
+  *ti_ptr = getTreeInfoFromIdentifier(score_entries, i_to_a(score_pos));
 
   // if that fails, set current tree entry to first entry (back link)
   if (*ti_ptr == NULL)
@@ -5710,6 +5715,9 @@ void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button)
 
 static void DrawHallOfFame_setScoreEntries(void)
 {
+  int max_empty_entries = 10;  // at least show "top ten" list, if empty
+  int max_visible_entries = NUM_MENU_ENTRIES_ON_SCREEN - 1;   // w/o back link
+  int min_score_entries = MIN(max_empty_entries, max_visible_entries);
   int score_pos = (scores.last_added >= 0 ? scores.last_added : 0);
   int i;
 
@@ -5722,9 +5730,10 @@ static void DrawHallOfFame_setScoreEntries(void)
 
   for (i = 0; i < MAX_SCORE_ENTRIES; i++)
   {
-    // do not add empty score entries
+    // do not add empty score entries if off-screen
     if (scores.entry[i].score == 0 &&
-       scores.entry[i].time == 0)
+       scores.entry[i].time == 0 &&
+       i >= min_score_entries)
       break;
 
     TreeInfo *ti = newTreeInfo_setDefaults(TREE_TYPE_SCORE_ENTRY);
@@ -5837,6 +5846,7 @@ static void HandleHallOfFame_SelectLevel(int step, int direction)
     PlaySound(SND_MENU_ITEM_SELECTING);
 
     scores.last_level_nr = level_nr = new_level_nr;
+    scores.last_entry_nr = 0;
 
     LoadLevel(level_nr);
     LoadLocalAndServerScore(level_nr, TRUE);
@@ -5858,8 +5868,6 @@ static void HandleHallOfFame_SelectLevel(int step, int direction)
     }
     else
     {
-      scores.last_entry_nr = 0;
-
       DrawScoreInfo_Content(scores.last_entry_nr);
     }