changed text on score info page
[rocksndiamonds.git] / src / screens.c
index 8e95e47beb1e93aa44d6c024e330312f128cc88f..526f1d5ac3a168f221952868d287c69625521c9d 100644 (file)
@@ -296,6 +296,7 @@ static void execOfferUploadTapes(void);
 
 static void DrawHallOfFame_setScoreEntries(void);
 static void HandleHallOfFame_SelectLevel(int, int);
+static void HandleHallOfFame_SelectLevelOrScore(int, int);
 static char *getHallOfFameRankText(int);
 static char *getHallOfFameScoreText(int);
 
@@ -5831,6 +5832,7 @@ static void HandleHallOfFame_SelectLevel(int step, int direction)
 
     scores.last_level_nr = level_nr = new_level_nr;
 
+    LoadLevel(level_nr);
     LoadLocalAndServerScore(level_nr, TRUE);
 
     DrawHallOfFame_setScoreEntries();
@@ -5855,7 +5857,7 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
   HandleChooseTree(mx, my, dx, dy, button, &score_entry_current);
 }
 
-static void DrawScoreInfo(int entry_nr)
+static void DrawScoreInfo_Content(int entry_nr)
 {
   struct ScoreEntry *entry = &scores.entry[entry_nr];
   char *pos_text = getHallOfFameRankText(entry_nr);
@@ -5873,16 +5875,20 @@ static void DrawScoreInfo(int entry_nr)
   int ystart  = mSY - SY + menu.top_spacing[GAME_MODE_SCOREINFO];
   int ybottom = mSY - SY + SYSIZE - menu.bottom_spacing[GAME_MODE_SCOREINFO];
   int xstart1 = mSX - SX + 2 * xstep;
-  int xstart2 = mSX - SX + 14 * xstep;
-
-  SetMainBackgroundImageIfDefined(IMG_BACKGROUND_SCOREINFO);
-
-  UnmapAllGadgets();
-
-  FadeOut(REDRAW_FIELD);
+  int xstart2 = mSX - SX + 13 * xstep;
+  int font_width = getFontWidth(font_text);
+  int font_height = getFontHeight(font_text);
+  int pad_left = xstart2;
+  int pad_right = MENU_SCREEN_INFO_SPACE_RIGHT;
+  int max_chars_per_line = (SXSIZE - pad_left - pad_right) / font_width;
+  int max_lines_per_text = 5;
+  int lines;
 
   ClearField();
 
+  // redraw score selection buttons (which have just been erased)
+  RedrawScreenMenuGadgets(SCREEN_MASK_SCORES);
+
   drawChooseTreeHead(score_entries);
   drawChooseTreeInfo(score_entries);
 
@@ -5890,12 +5896,16 @@ static void DrawScoreInfo(int entry_nr)
   ystart += ystep_title;
 
   DrawTextF(xstart1, ystart, font_head, "Level Set");
-  DrawTextF(xstart2, ystart, font_text, leveldir_current->name);
-  ystart += ystep_line;
+  lines = DrawTextBufferS(xstart2, ystart, leveldir_current->name, font_text,
+                         max_chars_per_line, -1, max_lines_per_text, 0, -1,
+                         TRUE, FALSE, FALSE);
+  ystart += ystep_line + (lines > 0 ? lines - 1 : 0) * font_height;
 
-  DrawTextF(xstart1, ystart, font_head, "Level Name");
-  DrawTextF(xstart2, ystart, font_text, level.name);
-  ystart += ystep_para;
+  DrawTextF(xstart1, ystart, font_head, "Level");
+  lines = DrawTextBufferS(xstart2, ystart, level.name, font_text,
+                         max_chars_per_line, -1, max_lines_per_text, 0, -1,
+                         TRUE, FALSE, FALSE);
+  ystart += ystep_para + (lines > 0 ? lines - 1 : 0) * font_height;
 
   DrawTextF(xstart1, ystart, font_head, "Rank");
   DrawTextF(xstart2, ystart, font_text, pos_text);
@@ -5905,6 +5915,24 @@ static void DrawScoreInfo(int entry_nr)
   DrawTextF(xstart2, ystart, font_text, entry->name);
   ystart += ystep_line;
 
+  DrawTextF(xstart1, ystart, font_head, "Platform");
+  DrawTextF(xstart2, ystart, font_text, entry->platform);
+  ystart += ystep_line;
+
+  DrawTextF(xstart1, ystart, font_head, "Version");
+  DrawTextF(xstart2, ystart, font_text, entry->version);
+  ystart += ystep_line;
+
+  DrawTextF(xstart1, ystart, font_head, "Country");
+  lines = DrawTextBufferS(xstart2, ystart, entry->country_name, font_text,
+                         max_chars_per_line, -1, max_lines_per_text, 0, -1,
+                         TRUE, FALSE, FALSE);
+  ystart += ystep_line + (lines > 0 ? lines - 1 : 0) * font_height;
+
+  DrawTextF(xstart1, ystart, font_head, "Tape Date");
+  DrawTextF(xstart2, ystart, font_text, entry->tape_date);
+  ystart += ystep_line;
+
   if (level.use_step_counter)
   {
     DrawTextF(xstart1, ystart, font_head, "Steps");
@@ -5926,13 +5954,53 @@ static void DrawScoreInfo(int entry_nr)
   }
 
   DrawTextSCentered(ybottom, font_foot, "Press any key or button to go back");
+}
+
+static void DrawScoreInfo(int entry_nr)
+{
+  scores.last_entry_nr = entry_nr;
+
+  SetMainBackgroundImageIfDefined(IMG_BACKGROUND_SCOREINFO);
+
+  UnmapAllGadgets();
+
+  FadeOut(REDRAW_FIELD);
+
+  // map gadgets for score info screen
+  MapScreenMenuGadgets(SCREEN_MASK_SCORES);
+
+  DrawScoreInfo_Content(entry_nr);
 
   FadeIn(REDRAW_FIELD);
 }
 
+static void HandleScoreInfo_SelectScore(int step, int direction)
+{
+  int old_entry_nr = scores.last_entry_nr;
+  int new_entry_nr = old_entry_nr + step * direction;
+  int num_nodes = numTreeInfoInGroup(score_entry_current);
+  int num_entries = num_nodes - 1;     // score nodes only, without back link
+
+  if (new_entry_nr < 0)
+    new_entry_nr = 0;
+  if (new_entry_nr > num_entries - 1)
+    new_entry_nr = num_entries - 1;
+
+  if (new_entry_nr != old_entry_nr)
+  {
+    scores.last_entry_nr = new_entry_nr;
+
+    DrawScoreInfo_Content(new_entry_nr);
+  }
+}
+
 void HandleScoreInfo(int mx, int my, int dx, int dy, int button)
 {
-  if (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE)
+  boolean button_action = (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE);
+  boolean button_is_valid = (mx >= 0 && my >= 0);
+  boolean button_screen_clicked = (button_action && button_is_valid);
+
+  if (button_screen_clicked)
   {
     PlaySound(SND_MENU_ITEM_SELECTING);
 
@@ -5940,6 +6008,18 @@ void HandleScoreInfo(int mx, int my, int dx, int dy, int button)
 
     DrawHallOfFame(level_nr);
   }
+  else if (dx || dy)
+  {
+    HandleScoreInfo_SelectScore(1, SIGN(dx ? dx : dy));
+  }
+}
+
+static void HandleHallOfFame_SelectLevelOrScore(int step, int direction)
+{
+  if (game_status == GAME_MODE_SCORES)
+    HandleHallOfFame_SelectLevel(step, direction);
+  else
+    HandleScoreInfo_SelectScore(step, direction);
 }
 
 
@@ -10364,11 +10444,11 @@ static void HandleScreenGadgets(struct GadgetInfo *gi)
       break;
 
     case SCREEN_CTRL_ID_PREV_LEVEL2:
-      HandleHallOfFame_SelectLevel(step, -1);
+      HandleHallOfFame_SelectLevelOrScore(step, -1);
       break;
 
     case SCREEN_CTRL_ID_NEXT_LEVEL2:
-      HandleHallOfFame_SelectLevel(step, +1);
+      HandleHallOfFame_SelectLevelOrScore(step, +1);
       break;
 
     case SCREEN_CTRL_ID_FIRST_LEVEL: