+static void drawChooseTreeCursorAndText(TreeInfo *ti, boolean active)
+{
+ drawChooseTreeCursor(ti->cl_cursor, active);
+ drawChooseTreeText(ti, ti->cl_cursor, active);
+}
+
+static void drawChooseTreeScreen(TreeInfo *ti)
+{
+ drawChooseTreeHead(ti);
+ drawChooseTreeList(ti);
+ drawChooseTreeInfo(ti);
+ drawChooseTreeCursorAndText(ti, TRUE);
+
+ AdjustChooseTreeScrollbar(ti, SCREEN_CTRL_ID_SCROLL_VERTICAL);
+
+ // scroll bar and buttons may just have been added after reloading scores
+ if (game_status == GAME_MODE_SCORES)
+ MapScreenTreeGadgets(ti);
+}
+
+static void drawChooseTreeScreen_Scores_NotAvailable(void)
+{
+ // dirty workaround to use spacing definitions from info screen
+ info_mode = INFO_MODE_TITLE;
+
+ char *text_info = "HighScores of Level %d";
+ char *text_title = "Score information:";
+ char *text_error = "No scores for this level.";
+ char *text_foot = "Press any key or button for main menu";
+ int font_info = FONT_TITLE_2;
+ int font_title = FONT_INITIAL_3;
+ int font_error = FONT_INITIAL_4;
+ int font_foot = FONT_INITIAL_2;
+ int spacing_title = menu.headline1_spacing_info[INFO_MODE_TITLE];
+ int ystep_title = getMenuTextStep(spacing_title, font_title);
+ int ystart1 = mSY - SY + MENU_SCREEN_INFO_YSTART1;
+ int ystart2 = ystart1 + ystep_title;
+ int ybottom = mSY - SY + MENU_SCREEN_INFO_YBOTTOM;
+ int ystart0 = MENU_TITLE2_YPOS;
+
+ drawChooseTreeHeadExt(TREE_TYPE_SCORE_ENTRY, INFOTEXT_SCORE_ENTRY);
+ DrawTextFCentered(ystart0, font_info, text_info, scores.last_level_nr);
+
+ DrawTextSCentered(ystart1, font_title, text_title);
+ DrawTextSCentered(ystart2, font_error, text_error);
+
+ DrawTextSCentered(ybottom, font_foot, text_foot);
+}
+
+static TreeInfo *setHallOfFameActiveEntry(TreeInfo **ti_ptr)
+{
+ // set current tree entry to last added score entry
+ *ti_ptr = getTreeInfoFromIdentifier(score_entries, i_to_a(scores.last_added));
+
+ // if that fails, set current tree entry to first entry (back link)
+ if (*ti_ptr == NULL)
+ *ti_ptr = score_entries->node_group;
+
+ int num_entries = numTreeInfoInGroup(*ti_ptr);
+ int num_page_entries = MIN(num_entries, NUM_MENU_ENTRIES_ON_SCREEN);
+ int pos_score = getPosFromTreeInfo(*ti_ptr);
+ int pos_first_raw = pos_score - (num_page_entries + 1) / 2 + 1;
+ int pos_first = MIN(MAX(0, pos_first_raw), num_entries - num_page_entries);
+
+ (*ti_ptr)->cl_first = pos_first;
+ (*ti_ptr)->cl_cursor = pos_score - pos_first;
+
+ return *ti_ptr;
+}
+
+static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
+ TreeInfo **ti_ptr)
+{
+ TreeInfo *ti = *ti_ptr;
+ boolean has_scrollbar = screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->mapped;
+ int mx_scrollbar = screen_gadget[SCREEN_CTRL_ID_SCROLL_VERTICAL]->x;
+ int mx_right_border = (has_scrollbar ? mx_scrollbar : SX + SXSIZE);
+ int sx1_edit_name = getChooseTreeEditXPos(POS_LEFT);
+ int sx2_edit_name = getChooseTreeEditXPos(POS_RIGHT);
+ int x = 0;
+ int y = (ti != NULL ? ti->cl_cursor : 0);
+ int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
+ int num_entries = numTreeInfoInGroup(ti);
+ int num_page_entries = MIN(num_entries, NUM_MENU_ENTRIES_ON_SCREEN);
+ boolean position_set_by_scrollbar = (dx == 999);
+
+ if (game_status == GAME_MODE_SCORES)
+ {
+ if (server_scores.updated)
+ {
+ // reload scores, using updated server score cache file
+ LoadLocalAndServerScore(scores.last_level_nr, FALSE);
+
+ server_scores.updated = FALSE;
+
+ DrawHallOfFame_setScoreEntries();
+
+ ti = setHallOfFameActiveEntry(ti_ptr);
+
+ if (button != MB_MENU_INITIALIZE)
+ drawChooseTreeScreen(ti);
+ }
+
+ if (score_entries == NULL)
+ {
+ if (button == MB_MENU_INITIALIZE)
+ {
+ drawChooseTreeScreen_Scores_NotAvailable();
+ }
+ else if (button == MB_MENU_LEAVE || button == MB_MENU_CHOICE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ SetGameStatus(GAME_MODE_MAIN);
+
+ DrawMainMenu();
+ }