fixed displaying new high score entry if not on first page
authorHolger Schemel <info@artsoft.org>
Sat, 9 Jan 2021 18:10:49 +0000 (19:10 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 9 Jan 2021 18:10:49 +0000 (19:10 +0100)
src/screens.c

index 8af84590b36f2a9325874e90a7aa471fa55927ba..39650b5cf6a4f9aa32acd0fb999518ccbd6815c1 100644 (file)
@@ -5080,9 +5080,15 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
   if (button == MB_MENU_INITIALIZE)
   {
     level_nr = mx;
   if (button == MB_MENU_INITIALIZE)
   {
     level_nr = mx;
-    first_entry = 0;
     highlight_position = my;
 
     highlight_position = my;
 
+    first_entry = highlight_position - (NUM_MENU_ENTRIES_ON_SCREEN + 1) / 2 + 1;
+
+    if (first_entry < 0)
+      first_entry = 0;
+    else if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
+      first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN);
+
     drawHallOfFameList(level_nr, first_entry, highlight_position);
 
     return;
     drawHallOfFameList(level_nr, first_entry, highlight_position);
 
     return;