+ else if (screen_nr == 2)
+ {
+ DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
+ "Special thanks to");
+ DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
+ "Michael Stopp & Philip Jespersen");
+ DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
+ "for creating");
+ DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
+ "\"Supaplex\"");
+ DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
+ "in the year");
+ DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
+ "1991");
+ DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
+ "published by");
+ DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
+ "Digital Integration");
+ }
+ else if (screen_nr == 3)
+ {
+ DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
+ "Special thanks to");
+ DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
+ "Hiroyuki Imabayashi");
+ DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
+ "for creating");
+ DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
+ "\"Sokoban\"");
+ DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
+ "in the year");
+ DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
+ "1982");
+ DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
+ "published by");
+ DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_3,
+ "Thinking Rabbit");
+ }
+ else if (screen_nr == 4)
+ {
+ DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
+ "Special thanks to");
+ DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
+ "Alan Bond");
+ DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
+ "and");
+ DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
+ "J\xfcrgen Bonhagen");
+ DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
+ "for the continuous creation");
+ DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
+ "of outstanding level sets");
+ }
+ else if (screen_nr == 5)
+ {
+ DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
+ "Thanks to");
+ DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
+ "Peter Elzner");
+ DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
+ "for ideas and inspiration by");
+ DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
+ "Diamond Caves");
+
+ DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_2,
+ "Thanks to");
+ DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_3,
+ "Steffest");
+ DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
+ "for ideas and inspiration by");
+ DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_3,
+ "DX-Boulderdash");
+ }
+ else if (screen_nr == 6)
+ {
+ DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
+ "Thanks to");
+ DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
+ "David Tritscher");
+#if 1
+ DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
+ "for the code base used for the");
+ DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_2,
+ "native Emerald Mine engine");
+#else
+ DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
+ "for the new Emerald Mine engine");
+#endif
+ }
+ else if (screen_nr == 7)
+ {
+ DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
+ "Thanks to");
+ DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_3,
+ "Guido Schulz");
+ DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_2,
+ "for the initial DOS port");
+
+ DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
+ "Thanks to");
+ DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
+ "Karl H\xf6rnell");
+ DrawTextSCentered(ystart2 + 6 * ystep, FONT_TEXT_2,
+ "for some additional toons");
+ }
+ else if (screen_nr == 8)
+ {
+ DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
+ "And not to forget:");
+ DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
+ "Many thanks to");
+ DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
+ "All those who contributed");
+ DrawTextSCentered(ystart2 + 3 * ystep, FONT_TEXT_3,
+ "levels to this game");
+ DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_3,
+ "since 1995");
+ }
+
+ DrawTextSCentered(ybottom, FONT_TEXT_4,
+ "Press any key or button for next page");
+}
+
+void DrawInfoScreen_Credits()
+{
+ SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_CREDITS);
+
+ FadeSoundsAndMusic();
+
+ FadeOut(REDRAW_FIELD);
+
+ HandleInfoScreen_Credits(MB_MENU_INITIALIZE);
+
+ FadeIn(REDRAW_FIELD);
+}
+
+void HandleInfoScreen_Credits(int button)
+{
+ static int screen_nr = 0;
+ int num_screens = 9;
+
+ if (button == MB_MENU_INITIALIZE)
+ {
+ screen_nr = 0;
+
+ // DrawInfoScreen_CreditsScreen(screen_nr);
+ }
+
+ if (button == MB_MENU_LEAVE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ info_mode = INFO_MODE_MAIN;
+ DrawInfoScreen();
+
+ return;
+ }
+ else if (button == MB_MENU_CHOICE || button == MB_MENU_INITIALIZE)
+ {
+ if (button != MB_MENU_INITIALIZE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ screen_nr++;
+ }
+
+ if (screen_nr >= num_screens)
+ {
+ FadeSoundsAndMusic();
+
+ info_mode = INFO_MODE_MAIN;
+ DrawAndFadeInInfoScreen(REDRAW_FIELD);
+
+ return;
+ }
+
+ if (screen_nr > 0)
+ FadeSetNextScreen();
+
+ if (button != MB_MENU_INITIALIZE)
+ FadeOut(REDRAW_FIELD);
+
+ DrawInfoScreen_CreditsScreen(screen_nr);
+
+ if (button != MB_MENU_INITIALIZE)
+ FadeIn(REDRAW_FIELD);
+ }
+ else
+ {
+ PlayMenuSoundIfLoop();
+ }
+}
+
+void DrawInfoScreen_Program()
+{
+ int ystart1 = mSY - SY + 100;
+ int ystart2 = mSY - SY + 150;
+ int ybottom = mSY - SY + SYSIZE - 20;
+ int ystep = 30;
+
+ SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_PROGRAM);
+
+ FadeOut(REDRAW_FIELD);
+
+ ClearField();
+ DrawHeadline();
+
+ DrawTextSCentered(ystart1, FONT_TEXT_1, "Program Information:");
+
+ DrawTextSCentered(ystart2 + 0 * ystep, FONT_TEXT_2,
+ "This game is Freeware!");
+ DrawTextSCentered(ystart2 + 1 * ystep, FONT_TEXT_2,
+ "If you like it, send e-mail to:");
+ DrawTextSCentered(ystart2 + 2 * ystep, FONT_TEXT_3,
+ setup.internal.program_email);
+ DrawTextSCentered(ystart2 + 4 * ystep, FONT_TEXT_2,
+ "More information and levels:");
+ DrawTextSCentered(ystart2 + 5 * ystep, FONT_TEXT_3,
+ setup.internal.program_website);
+ DrawTextSCentered(ystart2 + 7 * ystep, FONT_TEXT_2,
+ "If you have created new levels,");
+ DrawTextSCentered(ystart2 + 8 * ystep, FONT_TEXT_2,
+ "send them to me to include them!");
+ DrawTextSCentered(ystart2 + 9 * ystep, FONT_TEXT_2,
+ ":-)");
+
+ DrawTextSCentered(ybottom, FONT_TEXT_4,
+ "Press any key or button for info menu");
+
+ FadeIn(REDRAW_FIELD);
+}
+
+void HandleInfoScreen_Program(int button)
+{
+ if (button == MB_MENU_LEAVE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ info_mode = INFO_MODE_MAIN;
+ DrawInfoScreen();
+
+ return;
+ }
+ else if (button == MB_MENU_CHOICE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ FadeSoundsAndMusic();
+
+ info_mode = INFO_MODE_MAIN;
+ DrawAndFadeInInfoScreen(REDRAW_FIELD);
+ }
+ else
+ {
+ PlayMenuSoundIfLoop();
+ }
+}
+
+void DrawInfoScreen_Version()
+{
+ int font_header = FONT_TEXT_3;
+ int font_text = FONT_TEXT_2;
+ int xstep = getFontWidth(font_text);
+ int ystep = getFontHeight(font_text);
+ int ystart1 = mSY - SY + 100;
+ int ystart2 = mSY - SY + 150;
+ int ybottom = mSY - SY + SYSIZE - 20;
+ int xstart1 = mSX - SX + 2 * xstep;
+ int xstart2 = mSX - SX + 18 * xstep;
+ int xstart3 = mSX - SX + 28 * xstep;
+ SDL_version sdl_version_compiled;
+ const SDL_version *sdl_version_linked;
+ int driver_name_len = 10;
+#if defined(TARGET_SDL2)
+ SDL_version sdl_version_linked_ext;
+ const char *driver_name = NULL;
+#else
+ char driver_name[driver_name_len];
+#endif
+
+ SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_VERSION);
+
+ FadeOut(REDRAW_FIELD);
+
+ ClearField();
+ DrawHeadline();
+
+ DrawTextSCentered(ystart1, FONT_TEXT_1, "Version Information:");
+
+ DrawTextF(xstart1, ystart2, font_header, "Name");
+ DrawTextF(xstart2, ystart2, font_text, getProgramTitleString());
+
+ ystart2 += ystep;
+ DrawTextF(xstart1, ystart2, font_header, "Version");
+ DrawTextF(xstart2, ystart2, font_text, getProgramVersionString());
+
+ ystart2 += ystep;
+ DrawTextF(xstart1, ystart2, font_header, "Platform");
+ DrawTextF(xstart2, ystart2, font_text, PLATFORM_STRING);
+
+ ystart2 += ystep;
+ DrawTextF(xstart1, ystart2, font_header, "Target");
+ DrawTextF(xstart2, ystart2, font_text, TARGET_STRING);
+
+ ystart2 += ystep;
+ DrawTextF(xstart1, ystart2, font_header, "Compile time");
+ DrawTextF(xstart2, ystart2, font_text, getCompileDateString());
+
+ ystart2 += 3 * ystep;
+ DrawTextF(xstart1, ystart2, font_header, "Library");
+ DrawTextF(xstart2, ystart2, font_header, "compiled");
+ DrawTextF(xstart3, ystart2, font_header, "linked");
+
+ SDL_VERSION(&sdl_version_compiled);
+#if defined(TARGET_SDL2)
+ SDL_GetVersion(&sdl_version_linked_ext);
+ sdl_version_linked = &sdl_version_linked_ext;
+#else
+ sdl_version_linked = SDL_Linked_Version();
+#endif
+
+ ystart2 += 2 * ystep;
+ DrawTextF(xstart1, ystart2, font_text, "SDL");
+ DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
+ sdl_version_compiled.major,
+ sdl_version_compiled.minor,
+ sdl_version_compiled.patch);
+ DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
+ sdl_version_linked->major,
+ sdl_version_linked->minor,
+ sdl_version_linked->patch);
+
+ SDL_IMAGE_VERSION(&sdl_version_compiled);
+ sdl_version_linked = IMG_Linked_Version();
+
+ ystart2 += ystep;
+ DrawTextF(xstart1, ystart2, font_text, "SDL_image");
+ DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
+ sdl_version_compiled.major,
+ sdl_version_compiled.minor,
+ sdl_version_compiled.patch);
+ DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
+ sdl_version_linked->major,
+ sdl_version_linked->minor,
+ sdl_version_linked->patch);
+
+ SDL_MIXER_VERSION(&sdl_version_compiled);
+ sdl_version_linked = Mix_Linked_Version();
+
+ ystart2 += ystep;
+ DrawTextF(xstart1, ystart2, font_text, "SDL_mixer");
+ DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
+ sdl_version_compiled.major,
+ sdl_version_compiled.minor,
+ sdl_version_compiled.patch);
+ DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
+ sdl_version_linked->major,
+ sdl_version_linked->minor,
+ sdl_version_linked->patch);
+
+ SDL_NET_VERSION(&sdl_version_compiled);
+ sdl_version_linked = SDLNet_Linked_Version();
+
+ ystart2 += ystep;
+ DrawTextF(xstart1, ystart2, font_text, "SDL_net");
+ DrawTextF(xstart2, ystart2, font_text, "%d.%d.%d",
+ sdl_version_compiled.major,
+ sdl_version_compiled.minor,
+ sdl_version_compiled.patch);
+ DrawTextF(xstart3, ystart2, font_text, "%d.%d.%d",
+ sdl_version_linked->major,
+ sdl_version_linked->minor,
+ sdl_version_linked->patch);
+
+ ystart2 += 3 * ystep;
+ DrawTextF(xstart1, ystart2, font_header, "Driver");
+ DrawTextF(xstart2, ystart2, font_header, "Requested");
+ DrawTextF(xstart3, ystart2, font_header, "Used");
+
+#if defined(TARGET_SDL2)
+ driver_name = getStringCopyNStatic(SDL_GetVideoDriver(0), driver_name_len);
+#else
+ SDL_VideoDriverName(driver_name, driver_name_len);
+#endif
+
+ ystart2 += 2 * ystep;
+ DrawTextF(xstart1, ystart2, font_text, "SDL_VideoDriver");
+ DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_videodriver);
+ DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
+
+#if defined(TARGET_SDL2)
+ driver_name = getStringCopyNStatic(SDL_GetAudioDriver(0), driver_name_len);
+#else
+ SDL_AudioDriverName(driver_name, driver_name_len);
+#endif
+
+ ystart2 += ystep;
+ DrawTextF(xstart1, ystart2, font_text, "SDL_AudioDriver");
+ DrawTextF(xstart2, ystart2, font_text, "%s", setup.system.sdl_audiodriver);
+ DrawTextF(xstart3, ystart2, font_text, "%s", driver_name);
+
+ DrawTextSCentered(ybottom, FONT_TEXT_4,
+ "Press any key or button for info menu");
+
+ FadeIn(REDRAW_FIELD);
+}
+
+void HandleInfoScreen_Version(int button)
+{
+ if (button == MB_MENU_LEAVE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ info_mode = INFO_MODE_MAIN;
+ DrawInfoScreen();
+
+ return;
+ }
+ else if (button == MB_MENU_CHOICE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ FadeSoundsAndMusic();
+
+ info_mode = INFO_MODE_MAIN;
+ DrawAndFadeInInfoScreen(REDRAW_FIELD);
+ }
+ else
+ {
+ PlayMenuSoundIfLoop();
+ }
+}
+
+void DrawInfoScreen_LevelSet()
+{
+ struct TitleMessageInfo *tmi = &readme;
+ char *filename = getLevelSetInfoFilename();
+ char *title = "Level Set Information:";
+ int ystart1 = mSY - SY + 100;
+ int ybottom = mSY - SY + SYSIZE - 20;
+
+ if (filename == NULL)
+ {
+ DrawInfoScreen_NotAvailable(title, "No information for this level set.");
+
+ return;
+ }
+
+ SetMainBackgroundImageIfDefined(IMG_BACKGROUND_INFO_LEVELSET);
+
+ FadeOut(REDRAW_FIELD);
+
+ ClearField();
+ DrawHeadline();
+
+ DrawTextSCentered(ystart1, FONT_TEXT_1, title);
+
+ /* if x position set to "-1", automatically determine by playfield width */
+ if (tmi->x == -1)
+ tmi->x = SXSIZE / 2;
+
+ /* if y position set to "-1", use static default value */
+ if (tmi->y == -1)
+ tmi->y = 150;
+
+ /* if width set to "-1", automatically determine by playfield width */
+ if (tmi->width == -1)
+ tmi->width = SXSIZE - 2 * TILEX;
+
+ /* if height set to "-1", automatically determine by playfield height */
+ if (tmi->height == -1)
+ tmi->height = SYSIZE - 20 - tmi->y - 10;
+
+ /* if chars set to "-1", automatically determine by text and font width */
+ if (tmi->chars == -1)
+ tmi->chars = tmi->width / getFontWidth(tmi->font);
+ else
+ tmi->width = tmi->chars * getFontWidth(tmi->font);
+
+ /* if lines set to "-1", automatically determine by text and font height */
+ if (tmi->lines == -1)
+ tmi->lines = tmi->height / getFontHeight(tmi->font);
+ else
+ tmi->height = tmi->lines * getFontHeight(tmi->font);
+
+ DrawTextFile(mSX + ALIGNED_TEXT_XPOS(tmi), mSY + ALIGNED_TEXT_YPOS(tmi),
+ filename, tmi->font, tmi->chars, -1, tmi->lines, 0, -1,
+ tmi->autowrap, tmi->centered, tmi->parse_comments);
+
+ DrawTextSCentered(ybottom, FONT_TEXT_4,
+ "Press any key or button for info menu");
+
+ FadeIn(REDRAW_FIELD);
+}
+
+void HandleInfoScreen_LevelSet(int button)
+{
+ if (button == MB_MENU_LEAVE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ info_mode = INFO_MODE_MAIN;
+ DrawInfoScreen();
+
+ return;
+ }
+ else if (button == MB_MENU_CHOICE)
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ FadeSoundsAndMusic();
+
+ info_mode = INFO_MODE_MAIN;
+ DrawAndFadeInInfoScreen(REDRAW_FIELD);
+ }
+ else
+ {
+ PlayMenuSoundIfLoop();
+ }
+}
+
+static void DrawInfoScreenExt(int fade_mask, boolean do_fading)
+{
+ SetMainBackgroundImage(IMG_BACKGROUND_INFO);
+
+ if (info_mode == INFO_MODE_TITLE)
+ DrawInfoScreen_TitleScreen();
+ else if (info_mode == INFO_MODE_ELEMENTS)
+ DrawInfoScreen_Elements();
+ else if (info_mode == INFO_MODE_MUSIC)
+ DrawInfoScreen_Music();
+ else if (info_mode == INFO_MODE_CREDITS)
+ DrawInfoScreen_Credits();
+ else if (info_mode == INFO_MODE_PROGRAM)
+ DrawInfoScreen_Program();
+ else if (info_mode == INFO_MODE_VERSION)
+ DrawInfoScreen_Version();
+ else if (info_mode == INFO_MODE_LEVELSET)
+ DrawInfoScreen_LevelSet();
+ else
+ DrawInfoScreen_Main(fade_mask, do_fading);
+
+ if (info_mode != INFO_MODE_MAIN &&
+ info_mode != INFO_MODE_TITLE &&
+ info_mode != INFO_MODE_MUSIC)
+ {
+ PlayMenuSound();
+ PlayMenuMusic();
+ }
+}
+
+void DrawAndFadeInInfoScreen(int fade_mask)
+{
+ DrawInfoScreenExt(fade_mask, TRUE);
+}
+
+void DrawInfoScreen()
+{
+ DrawInfoScreenExt(REDRAW_FIELD, FALSE);
+}
+
+void HandleInfoScreen(int mx, int my, int dx, int dy, int button)
+{
+ if (info_mode == INFO_MODE_TITLE)
+ HandleInfoScreen_TitleScreen(button);
+ else if (info_mode == INFO_MODE_ELEMENTS)
+ HandleInfoScreen_Elements(button);
+ else if (info_mode == INFO_MODE_MUSIC)
+ HandleInfoScreen_Music(button);
+ else if (info_mode == INFO_MODE_CREDITS)
+ HandleInfoScreen_Credits(button);
+ else if (info_mode == INFO_MODE_PROGRAM)
+ HandleInfoScreen_Program(button);
+ else if (info_mode == INFO_MODE_VERSION)
+ HandleInfoScreen_Version(button);
+ else if (info_mode == INFO_MODE_LEVELSET)
+ HandleInfoScreen_LevelSet(button);
+ else
+ HandleInfoScreen_Main(mx, my, dx, dy, button);
+}
+
+
+/* ========================================================================= */
+/* type name functions */
+/* ========================================================================= */
+
+void HandleTypeName(int newxpos, Key key)
+{
+ static char last_player_name[MAX_PLAYER_NAME_LEN + 1];
+ struct MainControlInfo *mci = getMainControlInfo(MAIN_CONTROL_NAME);
+ struct TextPosInfo *pos = mci->pos_input;
+ int startx = mSX + ALIGNED_TEXT_XPOS(pos);
+ int starty = mSY + ALIGNED_TEXT_YPOS(pos);
+ static int xpos = 0;
+ int font_nr = pos->font;
+ int font_active_nr = FONT_ACTIVE(font_nr);
+ int font_width = getFontWidth(font_active_nr);
+ char key_char = getValidConfigValueChar(getCharFromKey(key));
+ boolean is_valid_key_char = (key_char != 0 && (key_char != ' ' || xpos > 0));
+ boolean is_active = TRUE;
+
+ DrawBackgroundForFont(startx,starty, pos->width, pos->height, font_active_nr);
+
+ if (newxpos)
+ {
+ strcpy(last_player_name, setup.player_name);
+
+ xpos = newxpos;
+
+#if defined(TARGET_SDL2)
+ SDL_StartTextInput();
+#endif
+ }
+ else if (is_valid_key_char && xpos < MAX_PLAYER_NAME_LEN)
+ {
+ setup.player_name[xpos] = key_char;
+ setup.player_name[xpos + 1] = 0;
+
+ xpos++;
+ }
+ else if ((key == KSYM_Delete || key == KSYM_BackSpace) && xpos > 0)
+ {
+ xpos--;
+
+ setup.player_name[xpos] = 0;
+ }
+ else if (key == KSYM_Return && xpos > 0)
+ {
+ SaveSetup();
+
+ is_active = FALSE;
+
+ game_status = GAME_MODE_MAIN;
+ }
+ else if (key == KSYM_Escape)
+ {
+ strcpy(setup.player_name, last_player_name);
+
+ is_active = FALSE;
+
+ game_status = GAME_MODE_MAIN;
+ }
+
+ if (is_active)
+ {
+ pos->width = (strlen(setup.player_name) + 1) * font_width;
+ startx = mSX + ALIGNED_TEXT_XPOS(pos);
+
+ DrawText(startx, starty, setup.player_name, font_active_nr);
+ DrawText(startx + xpos * font_width, starty, "_", font_active_nr);
+ }
+ else
+ {
+ pos->width = strlen(setup.player_name) * font_width;
+ startx = mSX + ALIGNED_TEXT_XPOS(pos);
+
+ DrawText(startx, starty, setup.player_name, font_nr);
+
+#if defined(TARGET_SDL2)
+ SDL_StopTextInput();
+#endif
+ }
+}
+
+
+/* ========================================================================= */
+/* tree menu functions */
+/* ========================================================================= */
+
+static void DrawChooseTree(TreeInfo **ti_ptr)
+{
+ int fade_mask = (DrawingAreaChanged() ? REDRAW_ALL : REDRAW_FIELD);
+
+ if (strEqual((*ti_ptr)->subdir, STRING_TOP_DIRECTORY))
+ {
+ game_status = GAME_MODE_MAIN;
+
+ DrawMainMenuExt(REDRAW_FIELD, FALSE);
+
+ return;
+ }
+
+ UnmapAllGadgets();
+
+ FreeScreenGadgets();
+ CreateScreenGadgets();
+
+ CloseDoor(DOOR_CLOSE_2);
+
+ FadeOut(fade_mask);
+
+ ClearField();
+
+ HandleChooseTree(0, 0, 0, 0, MB_MENU_INITIALIZE, ti_ptr);
+ MapScreenTreeGadgets(*ti_ptr);
+
+ FadeIn(fade_mask);
+
+ InitAnimation();
+}
+
+static void drawChooseTreeList(int first_entry, int num_page_entries,
+ TreeInfo *ti)
+{
+ int i;
+ char *title_string = NULL;
+ int yoffset_sets = MENU_TITLE1_YPOS;
+ int yoffset_setup = 16;
+ int yoffset = (ti->type == TREE_TYPE_LEVEL_DIR ||
+ ti->type == TREE_TYPE_LEVEL_NR ? yoffset_sets : yoffset_setup);
+ int last_game_status = game_status; /* save current game status */
+
+ title_string = ti->infotext;
+
+ DrawTextSCentered(mSY - SY + yoffset, FONT_TITLE_1, title_string);
+
+ clearMenuListArea();
+
+ for (i = 0; i < num_page_entries; i++)
+ {
+ TreeInfo *node, *node_first;
+ int entry_pos = first_entry + i;
+ int xpos = MENU_SCREEN_START_XPOS;
+ int ypos = MENU_SCREEN_START_YPOS + i;
+ int startx = mSX + xpos * 32;
+ int starty = mSY + ypos * 32;
+ int font_nr = FONT_TEXT_1;
+ int font_xoffset = getFontBitmapInfo(font_nr)->draw_xoffset;
+ int startx_text = startx + font_xoffset;
+ int startx_scrollbar = mSX + SC_SCROLLBAR_XPOS + menu.scrollbar_xoffset;
+ int text_size = startx_scrollbar - startx_text;
+ int max_buffer_len = text_size / getFontWidth(font_nr);
+ char buffer[max_buffer_len + 1];
+
+ node_first = getTreeInfoFirstGroupEntry(ti);
+ node = getTreeInfoFromPos(node_first, entry_pos);
+
+ strncpy(buffer, node->name, max_buffer_len);
+ buffer[max_buffer_len] = '\0';
+
+ DrawText(startx, starty, buffer, font_nr + node->color);
+
+ if (node->parent_link)
+ initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
+ else if (node->level_group)
+ initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
+ else
+ initCursor(i, IMG_MENU_BUTTON);
+ }
+
+ game_status = last_game_status; /* restore current game status */
+
+ redraw_mask |= REDRAW_FIELD;
+}
+
+static void drawChooseTreeInfo(int entry_pos, TreeInfo *ti)
+{
+ TreeInfo *node, *node_first;
+ int x, last_redraw_mask = redraw_mask;
+ int ypos = MENU_TITLE2_YPOS;
+ int font_nr = FONT_TITLE_2;
+
+ if (ti->type == TREE_TYPE_LEVEL_NR)
+ DrawTextFCentered(ypos, font_nr, leveldir_current->name);
+
+ if (ti->type != TREE_TYPE_LEVEL_DIR)
+ return;
+
+ node_first = getTreeInfoFirstGroupEntry(ti);
+ node = getTreeInfoFromPos(node_first, entry_pos);
+
+ DrawBackgroundForFont(SX, SY + ypos, SXSIZE, getFontHeight(font_nr), font_nr);
+
+ if (node->parent_link)
+ DrawTextFCentered(ypos, font_nr, "leave \"%s\"",
+ node->node_parent->name);
+ else if (node->level_group)
+ DrawTextFCentered(ypos, font_nr, "enter \"%s\"",
+ node->name);
+ else if (ti->type == TREE_TYPE_LEVEL_DIR)
+ DrawTextFCentered(ypos, font_nr, "%3d %s (%s)",
+ node->levels, (node->levels > 1 ? "levels" : "level"),
+ node->class_desc);
+
+ /* let BackToFront() redraw only what is needed */
+ redraw_mask = last_redraw_mask;
+ for (x = 0; x < SCR_FIELDX; x++)
+ MarkTileDirty(x, 1);
+}
+
+static void HandleChooseTree(int mx, int my, int dx, int dy, int button,
+ TreeInfo **ti_ptr)
+{
+ TreeInfo *ti = *ti_ptr;
+ int x = 0;
+ int y = ti->cl_cursor;
+ int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
+ int num_entries = numTreeInfoInGroup(ti);
+ int num_page_entries;
+ int last_game_status = game_status; /* save current game status */
+ boolean position_set_by_scrollbar = (dx == 999);
+
+ if (num_entries <= NUM_MENU_ENTRIES_ON_SCREEN)
+ num_page_entries = num_entries;
+ else
+ num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
+
+ game_status = last_game_status; /* restore current game status */
+
+ if (button == MB_MENU_INITIALIZE)
+ {
+ int num_entries = numTreeInfoInGroup(ti);
+ int entry_pos = posTreeInfo(ti);
+
+ if (ti->cl_first == -1)
+ {
+ /* only on initialization */
+ ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
+ ti->cl_cursor = entry_pos - ti->cl_first;
+ }
+ else if (ti->cl_cursor >= num_page_entries ||
+ (num_entries > num_page_entries &&
+ num_entries - ti->cl_first < num_page_entries))
+ {
+ /* only after change of list size (by custom graphic configuration) */
+ ti->cl_first = MAX(0, entry_pos - num_page_entries + 1);
+ ti->cl_cursor = entry_pos - ti->cl_first;
+ }
+
+ if (position_set_by_scrollbar)
+ ti->cl_first = dy;
+ else
+ AdjustChooseTreeScrollbar(SCREEN_CTRL_ID_SCROLL_VERTICAL,
+ ti->cl_first, ti);
+
+ drawChooseTreeList(ti->cl_first, num_page_entries, ti);
+ drawChooseTreeInfo(ti->cl_first + ti->cl_cursor, ti);
+ drawChooseTreeCursor(ti->cl_cursor, TRUE);
+
+ return;
+ }
+ else if (button == MB_MENU_LEAVE)