X-Git-Url: https://git.artsoft.org/?a=blobdiff_plain;f=src%2Fscreens.c;h=bc1adac0ac4b76d1a308e8dd9f5f9299b66616f5;hb=25df48564c041446cea7967bc6079d0243b3c20a;hp=a76393cb76280a7c54eb03e82b709201a13dad4f;hpb=81496b0bd11db07791c43d8f225c8e13768de97d;p=rocksndiamonds.git diff --git a/src/screens.c b/src/screens.c index a76393cb..bc1adac0 100644 --- a/src/screens.c +++ b/src/screens.c @@ -296,6 +296,8 @@ 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); static struct GadgetInfo *screen_gadget[NUM_SCREEN_GADGETS]; @@ -4943,8 +4945,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 +5784,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 +5856,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 +5876,11 @@ static void DrawScoreInfo(int pos) int xstart1 = mSX - SX + 2 * xstep; int xstart2 = mSX - SX + 14 * xstep; - SetMainBackgroundImageIfDefined(IMG_BACKGROUND_SCOREINFO); - - FadeOut(REDRAW_FIELD); - ClearField(); + // redraw score selection buttons (which have just been erased) + RedrawScreenMenuGadgets(SCREEN_MASK_SCORES); + drawChooseTreeHead(score_entries); drawChooseTreeInfo(score_entries); @@ -5887,10 +5895,30 @@ 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; + 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"); + DrawTextF(xstart2, ystart, font_text, entry->country_name); + ystart += ystep_line; + + 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"); @@ -5900,7 +5928,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; } @@ -5912,13 +5940,53 @@ static void DrawScoreInfo(int pos) } 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); @@ -5926,6 +5994,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); } @@ -10350,11 +10430,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: