+static void DrawTypeName(void)
+{
+ HandleTypeNameExt(TRUE, 0);
+}
+
+void HandleTypeName(Key key)
+{
+ HandleTypeNameExt(FALSE, key);
+}
+
+
+// ============================================================================
+// tree menu functions
+// ============================================================================
+
+static int getAlignXOffsetFromTreeInfo(TreeInfo *ti)
+{
+ if (game_status != GAME_MODE_SETUP ||
+ DRAW_MODE_SETUP(setup_mode) != SETUP_MODE_CHOOSE_OTHER)
+ return 0;
+
+ int max_text_size = 0;
+ TreeInfo *node;
+
+ for (node = getTreeInfoFirstGroupEntry(ti); node != NULL; node = node->next)
+ max_text_size = MAX(max_text_size, strlen(node->name));
+
+ int num_entries = numTreeInfoInGroup(ti);
+ boolean scrollbar_needed = (num_entries > NUM_MENU_ENTRIES_ON_SCREEN);
+ int font_nr = MENU_CHOOSE_TREE_FONT(FC_RED);
+ int text_width = max_text_size * getFontWidth(font_nr);
+ int button_width = SC_MENUBUTTON_XSIZE;
+ int scrollbar_xpos = SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
+ int screen_width = (scrollbar_needed ? scrollbar_xpos : SXSIZE);
+ int align = menu.list_setup[SETUP_MODE_CHOOSE_OTHER].align;
+ int x = ALIGNED_XPOS(0, screen_width, align) * -1;
+ int align_xoffset_raw = ALIGNED_XPOS(x, button_width + text_width, align);
+ int align_xoffset = MAX(0, align_xoffset_raw);
+
+ return align_xoffset;
+}
+
+static int getAlignYOffsetFromTreeInfo(TreeInfo *ti)
+{
+ if (game_status != GAME_MODE_SETUP ||
+ DRAW_MODE_SETUP(setup_mode) != SETUP_MODE_CHOOSE_OTHER)
+ return 0;
+
+ int num_entries = numTreeInfoInGroup(ti);
+ int num_page_entries = MIN(num_entries, NUM_MENU_ENTRIES_ON_SCREEN);
+ int font_nr = MENU_CHOOSE_TREE_FONT(FC_RED);
+ int font_height = getFontHeight(font_nr);
+ int text_height = font_height * num_page_entries;
+ int page_height = font_height * NUM_MENU_ENTRIES_ON_SCREEN;
+ int align = menu.list_setup[SETUP_MODE_CHOOSE_OTHER].valign;
+ int y = ALIGNED_YPOS(0, page_height, align) * -1;
+ int align_yoffset_raw = ALIGNED_YPOS(y, text_height, align);
+ int align_yoffset = MAX(0, align_yoffset_raw);