+}
+
+static void AdjustChooseLevelScrollbar(int id, int first_entry)
+{
+ struct GadgetInfo *gi = screen_gadget[id];
+ int items_max, items_visible, item_position;
+
+ items_max = numLevelDirInfoInGroup(leveldir_current);
+ items_visible = MAX_LEVEL_SERIES_ON_SCREEN - 1;
+ item_position = first_entry;
+
+ if (item_position > items_max - items_visible)
+ item_position = items_max - items_visible;
+
+ ModifyGadget(gi, GDI_SCROLLBAR_ITEMS_MAX, items_max,
+ GDI_SCROLLBAR_ITEM_POSITION, item_position, GDI_END);
+}
+
+static void drawChooseLevelList(int first_entry, int num_page_entries)
+{
+ int i;
+ char buffer[SCR_FIELDX * 2];
+ int max_buffer_len = (SCR_FIELDX - 2) * 2;
+ int num_leveldirs = numLevelDirInfoInGroup(leveldir_current);
+
+ ClearRectangle(backbuffer, SX, SY, SXSIZE - 32, SYSIZE);
+ redraw_mask |= REDRAW_FIELD;
+
+ DrawText(SX, SY, "Level Directories", FS_BIG, FC_GREEN);
+
+ for(i=0; i<num_page_entries; i++)
+ {
+ struct LevelDirInfo *node, *node_first;
+ int leveldir_pos = first_entry + i;
+ int ypos = i + 2;
+
+ node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
+ node = getLevelDirInfoFromPos(node_first, leveldir_pos);
+
+ strncpy(buffer, node->name , max_buffer_len);
+ buffer[max_buffer_len] = '\0';
+
+ DrawText(SX + 32, SY + ypos * 32, buffer, FS_MEDIUM, node->color);
+
+ if (node->parent_link)
+ initCursor(ypos, GFX_ARROW_BLUE_LEFT);
+ else if (node->level_group)
+ initCursor(ypos, GFX_ARROW_BLUE_RIGHT);
+ else
+ initCursor(ypos, GFX_KUGEL_BLAU);
+ }
+
+ if (first_entry > 0)
+ DrawGraphic(0, 1, GFX_ARROW_BLUE_UP);
+
+ if (first_entry + num_page_entries < num_leveldirs)
+ DrawGraphic(0, MAX_LEVEL_SERIES_ON_SCREEN + 1, GFX_ARROW_BLUE_DOWN);
+}
+
+static void drawChooseLevelInfo(int leveldir_pos)
+{
+ struct LevelDirInfo *node, *node_first;
+ int x, last_redraw_mask = redraw_mask;
+
+ node_first = getLevelDirInfoFirstGroupEntry(leveldir_current);
+ node = getLevelDirInfoFromPos(node_first, leveldir_pos);
+
+ ClearRectangle(drawto, SX + 32, SY + 32, SXSIZE - 64, 32);
+
+ if (node->parent_link)
+ DrawTextFCentered(40, FC_RED, "leave group \"%s\"", node->class_desc);
+ else if (node->level_group)
+ DrawTextFCentered(40, FC_RED, "enter group \"%s\"", node->class_desc);
+ else
+ DrawTextFCentered(40, FC_RED, "%3d levels (%s)",
+ node->levels, node->class_desc);
+
+ /* let BackToFront() redraw only what is needed */
+ redraw_mask = last_redraw_mask | REDRAW_TILES;
+ for (x=0; x<SCR_FIELDX; x++)
+ MarkTileDirty(x, 1);