moved code to draw content of score info screen to separate function
[rocksndiamonds.git] / src / screens.c
index b5cef16637aba7a2cee5e1428b95cc5609d06fea..459fd00143a5e88e441f8af09d5d8ec71107249d 100644 (file)
@@ -296,6 +296,7 @@ static void execOfferUploadTapes(void);
 
 static void DrawHallOfFame_setScoreEntries(void);
 static void HandleHallOfFame_SelectLevel(int, int);
+static char *getHallOfFameRankText(int);
 static char *getHallOfFameScoreText(int);
 
 static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS];
@@ -4943,8 +4944,7 @@ static void drawChooseTreeText(TreeInfo *ti, int y, boolean active)
     int startx3 = startx + dx3;
     int startx4 = startx + dx4;
     int pos = node->pos;
-    boolean forced = (scores.force_last_added && pos == scores.last_added);
-    char *pos_text = (forced ? "???" : int2str(pos + 1, 3));
+    char *pos_text = getHallOfFameRankText(pos);
     char *dot_text = ".";
     int i;
 
@@ -5783,6 +5783,13 @@ void DrawHallOfFame(int level_nr)
   DrawChooseTree(&score_entry_current);
 }
 
+static char *getHallOfFameRankText(int nr)
+{
+  boolean forced = (scores.force_last_added && nr == scores.last_added);
+
+  return (forced ? "???" : int2str(nr + 1, 3));
+}
+
 static char *getHallOfFameTimeText(int nr)
 {
   static char score_text[10];
@@ -5848,9 +5855,10 @@ 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 pos)
+static void DrawScoreInfo_Content(int entry_nr)
 {
-  struct ScoreEntry *entry = &scores.entry[pos];
+  struct ScoreEntry *entry = &scores.entry[entry_nr];
+  char *pos_text = getHallOfFameRankText(entry_nr);
   int font_title = MENU_INFO_FONT_TITLE;
   int font_head  = MENU_INFO_FONT_HEAD;
   int font_text  = MENU_INFO_FONT_TEXT;
@@ -5867,12 +5875,6 @@ static void DrawScoreInfo(int pos)
   int xstart1 = mSX - SX + 2 * xstep;
   int xstart2 = mSX - SX + 14 * xstep;
 
-  SetMainBackgroundImageIfDefined(IMG_BACKGROUND_SCOREINFO);
-
-  UnmapAllGadgets();
-
-  FadeOut(REDRAW_FIELD);
-
   ClearField();
 
   drawChooseTreeHead(score_entries);
@@ -5889,6 +5891,10 @@ static void DrawScoreInfo(int pos)
   DrawTextF(xstart2, ystart, font_text, level.name);
   ystart += ystep_para;
 
+  DrawTextF(xstart1, ystart, font_head, "Rank");
+  DrawTextF(xstart2, ystart, font_text, pos_text);
+  ystart += ystep_line;
+
   DrawTextF(xstart1, ystart, font_head, "Player");
   DrawTextF(xstart2, ystart, font_text, entry->name);
   ystart += ystep_line;
@@ -5902,7 +5908,7 @@ static void DrawScoreInfo(int pos)
   else
   {
     DrawTextF(xstart1, ystart, font_head, "Time");
-    DrawTextF(xstart2, ystart, font_text, getHallOfFameTimeText(pos));
+    DrawTextF(xstart2, ystart, font_text, getHallOfFameTimeText(entry_nr));
     ystart += ystep_line;
   }
 
@@ -5914,6 +5920,17 @@ static void DrawScoreInfo(int pos)
   }
 
   DrawTextSCentered(ybottom, font_foot, "Press any key or button to go back");
+}
+
+static void DrawScoreInfo(int entry_nr)
+{
+  SetMainBackgroundImageIfDefined(IMG_BACKGROUND_SCOREINFO);
+
+  UnmapAllGadgets();
+
+  FadeOut(REDRAW_FIELD);
+
+  DrawScoreInfo_Content(entry_nr);
 
   FadeIn(REDRAW_FIELD);
 }