moved converting score to time from high score screen to score file loader
[rocksndiamonds.git] / src / screens.c
index d1629867c96a2668cb0f1f282e4c54ab04c64936..8e4fb8c9a3d6638cb19fc040cc6814b6e6a5c734 100644 (file)
@@ -1739,15 +1739,7 @@ void DrawMainMenu(void)
 
   OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
 
-#if defined(PLATFORM_EMSCRIPTEN)
-  EM_ASM
-  (
-    FS.syncfs(function(err)
-    {
-      assert(!err);
-    });
-  );
-#endif
+  SyncEmscriptenFilesystem();
 }
 
 static void gotoTopLevelDir(void)
@@ -5077,6 +5069,28 @@ void DrawHallOfFame(int level_nr, int highlight_position)
   FadeIn(fade_mask);
 }
 
+static char *getHallOfFameScoreText(int nr)
+{
+  // use playing time instead of score for Supaplex levels
+  if (level.rate_time_over_score ||
+      level.game_engine_type == GAME_ENGINE_TYPE_SP)
+  {
+    if (level.use_step_counter)
+      return int2str(scores.entry[nr].time, 5);
+
+    static char score_text[10];
+    int time_seconds = scores.entry[nr].time / FRAMES_PER_SECOND;
+    int mm = (time_seconds / 60) % 60;
+    int ss = (time_seconds % 60);
+
+    sprintf(score_text, "%02d:%02d", mm, ss);
+
+    return score_text;
+  }
+
+  return int2str(scores.entry[nr].score, 5);
+}
+
 static void drawHallOfFameList(int level_nr, int first_entry,
                               int highlight_position)
 {
@@ -5113,7 +5127,7 @@ static void drawHallOfFameList(int level_nr, int first_entry,
     if (!strEqual(scores.entry[entry].name, EMPTY_PLAYER_NAME))
       DrawText(mSX + dx2, sy, scores.entry[entry].name, font_nr2);
 
-    DrawText(mSX + dx3, sy, int2str(scores.entry[entry].score, 5), font_nr4);
+    DrawText(mSX + dx3, sy, getHallOfFameScoreText(entry), font_nr4);
   }
 
   redraw_mask |= REDRAW_FIELD;