X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;ds=inline;f=src%2Fscreens.c;h=843458f9fac2eb5b1b5d895201d6ed1e1fb23327;hb=543e97b9c93b941f02cad4ad3b9bd3f480978859;hp=c02e09d355d7807fe5fa7b4545d6149c9692e8cc;hpb=ab0cbae4e74040b383b7d18e5c58d27597e0b09c;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index c02e09d3..843458f9 100644 --- a/src/screens.c +++ b/src/screens.c @@ -2172,7 +2172,7 @@ void HandleMainMenu(int mx, int my, int dx, int dy, int button) SetGameStatus(GAME_MODE_SCORES); - DrawHallOfFame(level_nr, -1); + DrawHallOfFame(level_nr); } else if (pos == MAIN_CONTROL_EDITOR) { @@ -5029,7 +5029,7 @@ void HandleChooseLevelNr(int mx, int my, int dx, int dy, int button) HandleChooseTree(mx, my, dx, dy, button, &level_number_current); } -void DrawHallOfFame(int level_nr, int highlight_position) +void DrawHallOfFame(int level_nr) { int fade_mask = REDRAW_FIELD; @@ -5046,9 +5046,12 @@ void DrawHallOfFame(int level_nr, int highlight_position) SetDrawDeactivationMask(REDRAW_NONE); SetDrawBackgroundMask(REDRAW_FIELD); - if (highlight_position < 0) + if (scores.last_added < 0) LoadScore(level_nr); - else + + LoadServerScore(level_nr); + + if (scores.last_added >= 0) SetAnimStatus(GAME_MODE_PSEUDO_SCORESNEW); FadeSetEnterScreen(); @@ -5062,15 +5065,47 @@ void DrawHallOfFame(int level_nr, int highlight_position) OpenDoor(GetDoorState() | DOOR_NO_DELAY | DOOR_FORCE_REDRAW); - HandleHallOfFame(level_nr, highlight_position, 0, 0, MB_MENU_INITIALIZE); + HandleHallOfFame(level_nr, 0, 0, 0, MB_MENU_INITIALIZE); DrawMaskedBorder(fade_mask); FadeIn(fade_mask); } -static void drawHallOfFameList(int level_nr, int first_entry, - int highlight_position) +static int getHallOfFameFirstEntry(int first_entry, int step) +{ + if (step == 0) + first_entry = scores.last_added - (NUM_MENU_ENTRIES_ON_SCREEN + 1) / 2 + 1; + else + first_entry += step; + + if (first_entry < 0) + first_entry = 0; + else if (first_entry > MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN) + first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN); + + return first_entry; +} + +static char *getHallOfFameScoreText(int nr) +{ + if (!level.rate_time_over_score) + return int2str(scores.entry[nr].score, 5); // show normal score + + if (level.use_step_counter) + return int2str(scores.entry[nr].time, 5); // show number of steps + + 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); // show playing time + + return score_text; +} + +static void drawHallOfFameList(int level_nr, int first_entry) { int i, j; @@ -5084,7 +5119,7 @@ static void drawHallOfFameList(int level_nr, int first_entry, for (i = 0; i < NUM_MENU_ENTRIES_ON_SCREEN; i++) { int entry = first_entry + i; - boolean active = (entry == highlight_position); + boolean active = (entry == scores.last_added); int font_nr1 = (active ? FONT_TEXT_1_ACTIVE : FONT_TEXT_1); int font_nr2 = (active ? FONT_TEXT_2_ACTIVE : FONT_TEXT_2); int font_nr3 = (active ? FONT_TEXT_3_ACTIVE : FONT_TEXT_3); @@ -5105,7 +5140,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; @@ -5115,22 +5150,15 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) { static int level_nr = 0; static int first_entry = 0; - static int highlight_position = 0; int step = (button == 1 ? 1 : button == 2 ? 5 : 10); if (button == MB_MENU_INITIALIZE) { level_nr = mx; - highlight_position = my; - first_entry = highlight_position - (NUM_MENU_ENTRIES_ON_SCREEN + 1) / 2 + 1; + first_entry = getHallOfFameFirstEntry(0, 0); - 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); + drawHallOfFameList(level_nr, first_entry); return; } @@ -5140,25 +5168,15 @@ void HandleHallOfFame(int mx, int my, int dx, int dy, int button) if (dy < 0) { - if (first_entry > 0) - { - first_entry -= step; - if (first_entry < 0) - first_entry = 0; + first_entry = getHallOfFameFirstEntry(first_entry, -step); - drawHallOfFameList(level_nr, first_entry, highlight_position); - } + drawHallOfFameList(level_nr, first_entry); } else if (dy > 0) { - if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES) - { - first_entry += step; - if (first_entry + NUM_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES) - first_entry = MAX(0, MAX_SCORE_ENTRIES - NUM_MENU_ENTRIES_ON_SCREEN); + first_entry = getHallOfFameFirstEntry(first_entry, step); - drawHallOfFameList(level_nr, first_entry, highlight_position); - } + drawHallOfFameList(level_nr, first_entry); } else if (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE) {