From 9a038e0ab575eb3556118e88158e5a5a4a977eec Mon Sep 17 00:00:00 2001 From: Holger Schemel Date: Wed, 23 Feb 2022 23:45:43 +0100 Subject: [PATCH] added basic score info page --- src/events.c | 16 +++++++++ src/screens.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++ src/screens.h | 1 + 3 files changed, 106 insertions(+) diff --git a/src/events.c b/src/events.c index b883452c..9b4d733c 100644 --- a/src/events.c +++ b/src/events.c @@ -1784,6 +1784,10 @@ void HandleButton(int mx, int my, int button, int button_nr) HandleHallOfFame(mx, my, 0, 0, button); break; + case GAME_MODE_SCOREINFO: + HandleScoreInfo(mx, my, 0, 0, button); + break; + case GAME_MODE_EDITOR: HandleLevelEditorIdle(); break; @@ -2339,6 +2343,7 @@ void HandleKey(Key key, int key_status) case GAME_MODE_SETUP: case GAME_MODE_INFO: case GAME_MODE_SCORES: + case GAME_MODE_SCOREINFO: if (anyTextGadgetActiveOrJustFinished && key != KSYM_Escape) break; @@ -2363,6 +2368,8 @@ void HandleKey(Key key, int key_status) HandleInfoScreen(0, 0, 0, 0, MB_MENU_CHOICE); else if (game_status == GAME_MODE_SCORES) HandleHallOfFame(0, 0, 0, 0, MB_MENU_CHOICE); + else if (game_status == GAME_MODE_SCOREINFO) + HandleScoreInfo(0, 0, 0, 0, MB_MENU_CHOICE); break; case KSYM_Escape: @@ -2383,6 +2390,8 @@ void HandleKey(Key key, int key_status) HandleInfoScreen(0, 0, 0, 0, MB_MENU_LEAVE); else if (game_status == GAME_MODE_SCORES) HandleHallOfFame(0, 0, 0, 0, MB_MENU_LEAVE); + else if (game_status == GAME_MODE_SCOREINFO) + HandleScoreInfo(0, 0, 0, 0, MB_MENU_LEAVE); break; case KSYM_Page_Up: @@ -2398,6 +2407,8 @@ void HandleKey(Key key, int key_status) HandleInfoScreen(0, 0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); else if (game_status == GAME_MODE_SCORES) HandleHallOfFame(0, 0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); + else if (game_status == GAME_MODE_SCOREINFO) + HandleScoreInfo(0, 0, 0, -1 * SCROLL_PAGE, MB_MENU_MARK); break; case KSYM_Page_Down: @@ -2413,6 +2424,8 @@ void HandleKey(Key key, int key_status) HandleInfoScreen(0, 0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); else if (game_status == GAME_MODE_SCORES) HandleHallOfFame(0, 0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); + else if (game_status == GAME_MODE_SCOREINFO) + HandleScoreInfo(0, 0, 0, +1 * SCROLL_PAGE, MB_MENU_MARK); break; default: @@ -2644,6 +2657,7 @@ void HandleJoystick(void) case GAME_MODE_SETUP: case GAME_MODE_INFO: case GAME_MODE_SCORES: + case GAME_MODE_SCOREINFO: { if (anyTextGadgetActive()) break; @@ -2664,6 +2678,8 @@ void HandleJoystick(void) HandleInfoScreen(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); else if (game_status == GAME_MODE_SCORES) HandleHallOfFame(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); + else if (game_status == GAME_MODE_SCOREINFO) + HandleScoreInfo(0,0,dx,dy, newbutton ? MB_MENU_CHOICE : MB_MENU_MARK); break; } diff --git a/src/screens.c b/src/screens.c index 4156383e..f07f7030 100644 --- a/src/screens.c +++ b/src/screens.c @@ -262,6 +262,7 @@ static void HandleChooseTree(int, int, int, int, int, TreeInfo **); static void DrawChoosePlayerName(void); static void DrawChooseLevelSet(void); static void DrawChooseLevelNr(void); +static void DrawScoreInfo(int); static void DrawInfoScreen(void); static void DrawSetupScreen(void); static void DrawTypeName(void); @@ -5563,6 +5564,14 @@ static void HandleChooseTree(int mx, int my, int dx, int dy, int button, level.random_seed); return; } + else + { + SetGameStatus(GAME_MODE_SCOREINFO); + + DrawScoreInfo(node_cursor->pos); + + return; + } } SetGameStatus(GAME_MODE_MAIN); @@ -5836,6 +5845,86 @@ 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) +{ + struct ScoreEntry *entry = &scores.entry[pos]; + int font_title = MENU_INFO_FONT_TITLE; + int font_head = MENU_INFO_FONT_HEAD; + int font_text = MENU_INFO_FONT_TEXT; + int font_foot = MENU_INFO_FONT_FOOT; + int spacing_title = menu.headline1_spacing[GAME_MODE_SCOREINFO]; + int spacing_para = menu.paragraph_spacing[GAME_MODE_SCOREINFO]; + int spacing_line = menu.line_spacing[GAME_MODE_SCOREINFO]; + int xstep = getFontWidth(font_text); + int ystep_title = getMenuTextStep(spacing_title, font_title); + int ystep_para = getMenuTextStep(spacing_para, font_text); + int ystep_line = getMenuTextStep(spacing_line, font_text); + 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); + + FadeOut(REDRAW_FIELD); + + ClearField(); + + drawChooseTreeHead(score_entries); + drawChooseTreeInfo(score_entries); + + DrawTextSCentered(ystart, font_title, "Score Information:"); + ystart += ystep_title; + + DrawTextF(xstart1, ystart, font_head, "Level Set"); + DrawTextF(xstart2, ystart, font_text, leveldir_current->name); + ystart += ystep_line; + + DrawTextF(xstart1, ystart, font_head, "Level Name"); + DrawTextF(xstart2, ystart, font_text, level.name); + ystart += ystep_para; + + DrawTextF(xstart1, ystart, font_head, "Player"); + DrawTextF(xstart2, ystart, font_text, entry->name); + ystart += ystep_line; + + if (level.use_step_counter) + { + DrawTextF(xstart1, ystart, font_head, "Steps"); + DrawTextF(xstart2, ystart, font_text, int2str(entry->time, 5)); + ystart += ystep_line; + } + else + { + DrawTextF(xstart1, ystart, font_head, "Time"); + DrawTextF(xstart2, ystart, font_text, getHallOfFameTimeText(pos)); + ystart += ystep_line; + } + + if (!level.rate_time_over_score || entry->score > 0) + { + DrawTextF(xstart1, ystart, font_head, "Score"); + DrawTextF(xstart2, ystart, font_text, int2str(entry->score, 5)); + ystart += ystep_line; + } + + DrawTextSCentered(ybottom, font_foot, "Press any key or button to go back"); + + FadeIn(REDRAW_FIELD); +} + +void HandleScoreInfo(int mx, int my, int dx, int dy, int button) +{ + if (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE) + { + PlaySound(SND_MENU_ITEM_SELECTING); + + SetGameStatus(GAME_MODE_SCORES); + + DrawHallOfFame(level_nr); + } +} + // ============================================================================ // setup screen functions diff --git a/src/screens.h b/src/screens.h index 0694a59a..70b1fd49 100644 --- a/src/screens.h +++ b/src/screens.h @@ -34,6 +34,7 @@ void HandleChoosePlayerName(int, int, int, int, int); void HandleChooseLevelSet(int, int, int, int, int); void HandleChooseLevelNr(int, int, int, int, int); void HandleHallOfFame(int, int, int, int, int); +void HandleScoreInfo(int, int, int, int, int); void HandleInfoScreen(int, int, int, int, int); void HandleSetupScreen(int, int, int, int, int); void HandleTypeName(Key); -- 2.34.1