+ if (leveldir_current != leveldir_last_valid)
+ levelset_has_changed = TRUE;
+
+ /* store valid level series information */
+ leveldir_last_valid = leveldir_current;
+
+ /* needed if last screen (level choice) changed graphics, sounds or music */
+ ReloadCustomArtwork(0);
+
+#if defined(TARGET_SDL)
+ SetDrawtoField(DRAW_BACKBUFFER);
+#endif
+
+#if 0
+ if (levelset_has_changed)
+ fading = title_default;
+#endif
+
+#if 1
+ if (CheckTitleScreen(levelset_has_changed))
+ {
+ game_status = GAME_MODE_TITLE;
+
+ DrawTitleScreen();
+
+ return;
+ }
+
+#else
+
+ if (setup.show_titlescreen &&
+ ((levelset_has_changed &&
+ (graphic_info[IMG_TITLESCREEN_1].bitmap != NULL ||
+ getLevelSetMessageFilename(1, FALSE) != NULL)) ||
+ (show_title_initial &&
+ (graphic_info[IMG_TITLESCREEN_INITIAL_1].bitmap != NULL ||
+ getLevelSetMessageFilename(1, TRUE) != NULL))))
+ {
+ game_status = GAME_MODE_TITLE;
+
+ DrawTitleScreen();
+
+ return;
+ }
+#endif
+
+ /* level_nr may have been set to value over handicap with level editor */
+ if (setup.handicap && level_nr > leveldir_current->handicap_level)
+ level_nr = leveldir_current->handicap_level;
+
+ LoadLevel(level_nr);
+
+ SetMainBackgroundImage(IMG_BACKGROUND_MAIN);
+
+#if 0
+#if XFADE
+ if (fading.anim_mode == ANIM_CROSSFADE)
+ FadeCrossSaveBackbuffer();
+ else
+ FadeOut(redraw_mask);
+#endif
+#endif
+
+#if 1
+ if (redraw_mask == REDRAW_ALL)
+ {
+ int door_state = GetDoorState();
+
+ RedrawBackground();
+
+ // OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+
+#if 0
+#if 1
+ OpenDoor(DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+#else
+ OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+#endif
+#endif
+ }
+#endif
+
+ ClearWindow();
+
+#if 1
+ InitializeMainControls();
+
+#if 1
+ DrawCursorAndText_Main(-1, FALSE);
+#else
+ for (i = 0; main_controls[i].nr != -1; i++)
+ {
+ struct MenuPosInfo *pos_button = main_controls[i].pos_button;
+ struct MenuPosInfo *pos_text = main_controls[i].pos_text;
+ struct MenuPosInfo *pos_input = main_controls[i].pos_input;
+ char *text = main_controls[i].text;
+ char *input = main_controls[i].input;
+ int button_graphic = main_controls[i].button_graphic;
+ int font_text = main_controls[i].font_text;
+ int font_input = main_controls[i].font_input;
+
+ if (pos_button != NULL)
+ DrawGraphicThruMaskExt(drawto, mSX + pos_button->x, mSY + pos_button->y,
+ button_graphic, 0);
+
+ if (pos_text != NULL && text != NULL)
+ DrawText(mSX + pos_text->x, mSY + pos_text->y, text, font_text);
+
+ if (pos_input != NULL && input != NULL)
+ DrawText(mSX + pos_input->x, mSY + pos_input->y, input, font_input);
+ }
+#endif
+
+#else
+
+ DrawHeadline();
+
+ DrawText(mSX + 32, mSY + 2 * 32, name_text, FONT_MENU_1);
+ DrawText(mSX + 32, mSY + 3 * 32, "Levelset", FONT_MENU_1);
+ DrawText(mSX + 32, mSY + 4 * 32, "Hall Of Fame", FONT_MENU_1);
+ DrawText(mSX + 32, mSY + 5 * 32, "Level Creator", FONT_MENU_1);
+ DrawText(mSX + 32, mSY + 6 * 32, "Info Screen", FONT_MENU_1);
+ DrawText(mSX + 32, mSY + 7 * 32, "Start Game", FONT_MENU_1);
+ DrawText(mSX + 32, mSY + 8 * 32, "Setup", FONT_MENU_1);
+ DrawText(mSX + 32, mSY + 9 * 32, "Quit", FONT_MENU_1);
+
+ /* calculated after (possible) reload of custom artwork */
+ name_width = getTextWidth(name_text, FONT_MENU_1);
+ level_width = 9 * 32;
+
+ DrawText(mSX + 32 + name_width, mSY + 2 * 32, setup.player_name,
+ FONT_INPUT_1);
+
+ DrawText(mSX + getCurrentLevelTextPos() * 32, mSY + 3 * 32,
+ int2str(level_nr, 3), FONT_VALUE_1);
+
+ {
+ int text_height = getFontHeight(FONT_TEXT_3);
+ int xpos = getLevelRangeTextPos() * 32 + 8;
+ int ypos2 = 3 * 32 + 16;
+ int ypos1 = ypos2 - text_height;
+
+ DrawTextF(mSX - SX + xpos, mSY - SY + ypos1, FONT_TEXT_3,
+ "%03d", leveldir_current->first_level);
+ DrawTextF(mSX - SX + xpos, mSY - SY + ypos2, FONT_TEXT_3,
+ "%03d", leveldir_current->last_level);
+ }
+
+ for (i = 0; i < 8; i++)
+ initCursor(i, (i == 1 || i == 4 || i == 6 ? IMG_MENU_BUTTON_ENTER_MENU :
+ IMG_MENU_BUTTON));
+
+ DrawTextSCentered(326, FONT_TITLE_2, PROGRAM_GAME_BY_STRING);
+#endif
+
+ DrawPreviewLevel(TRUE);
+
+ HandleMainMenu(0, 0, 0, 0, MB_MENU_INITIALIZE);
+
+ TapeStop();
+ if (TAPE_IS_EMPTY(tape))
+ LoadTape(level_nr);
+ DrawCompleteVideoDisplay();
+
+ PlayMenuSound();
+ PlayMenuMusic();
+
+ /* create gadgets for main menu screen */
+ FreeScreenGadgets();
+ CreateScreenGadgets();
+
+#if 0
+ BlitBitmap(drawto, window, VX, VY, VXSIZE, VYSIZE, VX, VY);
+ Delay(3000);
+#endif
+
+ /* map gadgets for main menu screen */
+ MapTapeButtons();
+ MapScreenMenuGadgets(SCREEN_MASK_MAIN);
+
+ DrawMaskedBorder(REDRAW_ALL);
+
+#if 1
+ if (redraw_mask == REDRAW_ALL)
+ {
+ int door_state = GetDoorState();
+
+ OpenDoor(door_state | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+ }
+#endif
+
+#if XFADE
+ if (fading.anim_mode == ANIM_CROSSFADE)
+ FadeCross(redraw_mask);
+ else
+ FadeIn(redraw_mask);
+#else
+#if 1
+ if (!do_fading)
+ BackToFront();
+ else if (fading.anim_mode == ANIM_CROSSFADE)
+ FadeCross(redraw_mask);
+ else
+ FadeIn(redraw_mask);
+#else
+ if (do_fading)
+ FadeIn(redraw_mask);
+ else
+ BackToFront();
+#endif
+#endif
+
+#if 1
+ fading = menu.navigation;
+#else
+ fading = title_default;
+#endif
+
+ SetMouseCursor(CURSOR_DEFAULT);
+
+ InitAnimation();
+
+ OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2);
+}
+
+void DrawAndFadeInMainMenu(int redraw_mask)
+{
+ DrawMainMenuExt(redraw_mask, TRUE);
+}
+
+void DrawMainMenu()
+{
+ DrawMainMenuExt(REDRAW_ALL, FALSE);
+}
+
+#if 0
+static void gotoTopLevelDir()
+{
+ /* move upwards to top level directory */
+ while (leveldir_current->node_parent)
+ {
+ /* write a "path" into level tree for easy navigation to last level */
+ if (leveldir_current->node_parent->node_group->cl_first == -1)
+ {
+ int num_leveldirs = numTreeInfoInGroup(leveldir_current);
+ int leveldir_pos = posTreeInfo(leveldir_current);
+ int num_page_entries;
+ int cl_first, cl_cursor;
+
+ if (num_leveldirs <= NUM_MENU_ENTRIES_ON_SCREEN)
+ num_page_entries = num_leveldirs;
+ else
+ num_page_entries = NUM_MENU_ENTRIES_ON_SCREEN;
+
+ cl_first = MAX(0, leveldir_pos - num_page_entries + 1);
+ cl_cursor = leveldir_pos - cl_first;
+
+ leveldir_current->node_parent->node_group->cl_first = cl_first;
+ leveldir_current->node_parent->node_group->cl_cursor = cl_cursor;
+ }
+
+ leveldir_current = leveldir_current->node_parent;
+ }
+}
+#endif
+
+void HandleTitleScreen(int mx, int my, int dx, int dy, int button)
+{
+ static unsigned long title_delay = 0;
+ static int title_screen_nr = 0;
+ static int last_sound = -1, last_music = -1;
+ boolean return_to_main_menu = FALSE;
+ boolean use_fading_main_menu = TRUE;
+#if 0
+#if 1
+ boolean use_cross_fading = FALSE;
+#else
+ boolean use_cross_fading = !show_title_initial; /* default */
+#endif
+#endif
+ struct TitleControlInfo *tci;
+ struct TitleFadingInfo fading_next;
+ int sound, music;
+
+ if (button == MB_MENU_INITIALIZE)
+ {
+#if 1
+ boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
+#endif
+
+#if 0
+ int last_game_status = game_status; /* save current game status */
+#endif
+
+ title_delay = 0;
+ title_screen_nr = 0;
+ tci = &title_controls[title_screen_nr];
+
+ last_sound = SND_UNDEFINED;
+ last_music = MUS_UNDEFINED;
+
+#if 0
+ /* determine number of title screens to display (images and messages) */
+ InitializeTitleControls();
+#endif
+
+ if (game_status == GAME_MODE_INFO)
+ {
+ if (num_title_screens == 0)
+ {
+ DrawInfoScreen_NotAvailable("Title screen information:",
+ "No title screen for this level set.");
+
+ /* use default settings for fading, but always disable auto delay */
+ fading = title_default;
+ fading.auto_delay = -1;
+
+ return;
+ }
+
+ FadeSoundsAndMusic();
+
+#if 1
+ if (use_cross_fading)
+ FadeCrossSaveBackbuffer();
+ else
+ FadeOut(REDRAW_ALL);
+#else
+ FadeOut(REDRAW_ALL);
+#endif
+ }
+
+ if (tci->is_image)
+ DrawTitleScreenImage(tci->local_nr, tci->initial);
+ else
+ DrawTitleScreenMessage(tci->local_nr, tci->initial);
+
+ fading = getTitleFading(tci);
+
+#if 1
+ sound = getTitleSound(tci);
+ music = getTitleMusic(tci);
+
+ if (sound != last_sound)
+ PlayMenuSoundExt(sound);
+ if (music != last_music)
+ PlayMenuMusicExt(music);
+
+ last_sound = sound;
+ last_music = music;
+#endif
+
+ SetMouseCursor(CURSOR_NONE);
+
+#if 1
+ if (use_cross_fading)
+ FadeCross(REDRAW_ALL);
+ else
+ FadeIn(REDRAW_ALL);
+#else
+ FadeIn(REDRAW_ALL);
+#endif
+
+ DelayReached(&title_delay, 0); /* reset delay counter */
+
+ return;
+ }
+
+ if (fading.auto_delay > -1 && DelayReached(&title_delay, fading.auto_delay))
+ button = MB_MENU_CHOICE;
+
+ if (button == MB_MENU_LEAVE)
+ {
+ return_to_main_menu = TRUE;
+ use_fading_main_menu = FALSE;
+ }
+ else if (button == MB_MENU_CHOICE)
+ {
+#if 1
+ boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
+#endif
+
+ if (game_status == GAME_MODE_INFO && num_title_screens == 0)
+ {
+#if 0
+#if XFADE
+ if (fading.anim_mode == ANIM_CROSSFADE)
+ FadeCrossSaveBackbuffer();
+ else
+ FadeOut(REDRAW_FIELD);
+#else
+ FadeOut(REDRAW_FIELD);
+#endif
+#endif
+
+ fading = menu.destination;
+
+ info_mode = INFO_MODE_MAIN;
+ DrawAndFadeInInfoScreen(REDRAW_FIELD);
+
+ return;
+ }
+
+ title_screen_nr++;
+ tci = &title_controls[title_screen_nr];
+
+ if (title_screen_nr < num_title_screens)
+ {
+#if 1
+#if 0
+ boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
+#endif
+#else
+ int anim_mode;
+
+ if (tci->is_image)
+ anim_mode =
+ graphic_info[getTitleScreenGraphic(tci->local_nr,
+ tci->initial)].anim_mode;
+ else
+ anim_mode = ANIM_FADE; /* ??? */
+
+ use_cross_fading = (anim_mode == ANIM_FADE ? FALSE :
+ anim_mode == ANIM_CROSSFADE ? TRUE :
+ use_cross_fading);
+#endif
+
+ sound = getTitleSound(tci);
+ music = getTitleMusic(tci);
+
+ if (sound == SND_UNDEFINED || sound != last_sound)
+ FadeSounds();
+ if (music == MUS_UNDEFINED || music != last_music)
+ FadeMusic();
+
+ if (use_cross_fading)
+ FadeCrossSaveBackbuffer();
+ else
+ FadeOut(REDRAW_ALL);
+
+ if (tci->is_image)
+ DrawTitleScreenImage(tci->local_nr, tci->initial);
+ else
+ DrawTitleScreenMessage(tci->local_nr, tci->initial);
+
+ fading_next = getTitleFading(tci);
+
+#if 1
+ sound = getTitleSound(tci);
+ music = getTitleMusic(tci);
+
+ if (sound != last_sound)
+ PlayMenuSoundExt(sound);
+ if (music != last_music)
+ PlayMenuMusicExt(music);
+
+ last_sound = sound;
+ last_music = music;
+#endif
+
+ /* last screen already faded out, next screen has no animation */
+ if (!use_cross_fading && fading_next.anim_mode == ANIM_NONE)
+ fading = fading_next;
+
+ if (use_cross_fading)
+ FadeCross(REDRAW_ALL);
+ else
+ FadeIn(REDRAW_ALL);
+
+ fading = fading_next;
+
+ DelayReached(&title_delay, 0); /* reset delay counter */
+ }
+ else
+ {
+ FadeSoundsAndMusic();
+
+#if 0
+#if 1
+ {
+#if 0
+ boolean use_cross_fading = (fading.anim_mode == ANIM_CROSSFADE);
+#endif
+
+ if (use_cross_fading)
+ FadeCrossSaveBackbuffer();
+ else
+ FadeOut(REDRAW_ALL);
+ }
+#else
+ FadeOut(REDRAW_ALL);
+#endif
+#endif
+
+ return_to_main_menu = TRUE;
+ }
+ }
+
+ if (return_to_main_menu)
+ {
+#if 0
+ RedrawBackground();
+#endif
+
+ SetMouseCursor(CURSOR_DEFAULT);
+
+ if (game_status == GAME_MODE_INFO)
+ {
+#if 0
+ OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+#endif
+
+ info_mode = INFO_MODE_MAIN;
+ DrawInfoScreenExt(REDRAW_ALL, use_fading_main_menu);
+ }
+ else /* default: return to main menu */
+ {
+#if 0
+ OpenDoor(DOOR_CLOSE_1 | DOOR_OPEN_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+#endif
+
+ game_status = GAME_MODE_MAIN;
+ DrawMainMenuExt(REDRAW_ALL, use_fading_main_menu);
+ }
+ }
+}
+
+void HandleMainMenu_SelectLevel(int step, int direction)
+{
+ int old_level_nr = level_nr;
+ int new_level_nr;
+
+ new_level_nr = old_level_nr + step * direction;
+ if (new_level_nr < leveldir_current->first_level)
+ new_level_nr = leveldir_current->first_level;
+ if (new_level_nr > leveldir_current->last_level)
+ new_level_nr = leveldir_current->last_level;
+
+ if (setup.handicap && new_level_nr > leveldir_current->handicap_level)
+ {
+ /* skipping levels is only allowed when trying to skip single level */
+ if (setup.skip_levels && step == 1 &&
+ Request("Level still unsolved ! Skip despite handicap ?", REQ_ASK))
+ {
+ leveldir_current->handicap_level++;
+ SaveLevelSetup_SeriesInfo();
+ }
+
+ new_level_nr = leveldir_current->handicap_level;
+ }
+
+ if (new_level_nr != old_level_nr)
+ {
+ struct MainControlInfo *mci= getMainControlInfo(MAIN_CONTROL_LEVEL_NUMBER);
+
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ level_nr = new_level_nr;
+
+#if 1
+ DrawText(mSX + mci->pos_text->x, mSY + mci->pos_text->y,
+ int2str(level_nr, 3), mci->pos_text->font);
+#else
+ DrawText(mSX + 11 * 32, mSY + 3 * 32, int2str(level_nr, 3), FONT_VALUE_1);
+#endif
+
+ LoadLevel(level_nr);
+ DrawPreviewLevel(TRUE);
+
+ TapeErase();
+ LoadTape(level_nr);
+ DrawCompleteVideoDisplay();
+
+ /* needed because DrawPreviewLevel() takes some time */
+ BackToFront();
+ SyncDisplay();
+ }
+}
+
+#if 1
+
+void HandleMainMenu(int mx, int my, int dx, int dy, int button)
+{
+ static int choice = MAIN_CONTROL_GAME;
+ int pos = choice;
+ int i;
+
+ if (button == MB_MENU_INITIALIZE)
+ {
+ DrawCursorAndText_Main(choice, TRUE);
+
+ return;
+ }
+
+ if (mx || my) /* mouse input */
+ {
+ pos = -1;
+
+ for (i = 0; main_controls[i].nr != -1; i++)
+ {
+ if (insideMenuPosRect(main_controls[i].pos_button, mx - mSX, my - mSY) ||
+ insideTextPosRect(main_controls[i].pos_text, mx - mSX, my - mSY) ||
+ insideTextPosRect(main_controls[i].pos_input, mx - mSX, my - mSY))
+ {
+ pos = main_controls[i].nr;
+
+ break;
+ }
+ }
+ }
+ else if (dx || dy) /* keyboard input */
+ {
+ if (dx > 0 && (choice == MAIN_CONTROL_INFO ||
+ choice == MAIN_CONTROL_SETUP))
+ button = MB_MENU_CHOICE;
+ else if (dy)
+ pos = choice + dy;
+ }
+
+ if (pos == MAIN_CONTROL_LEVELS && dx != 0 && button)
+ {
+ HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
+ }
+ else if (pos >= MAIN_CONTROL_NAME && pos <= MAIN_CONTROL_QUIT)
+ {
+ if (button)
+ {
+ if (pos != choice)
+ {
+ PlaySound(SND_MENU_ITEM_ACTIVATING);
+
+ DrawCursorAndText_Main(choice, FALSE);
+ DrawCursorAndText_Main(pos, TRUE);
+
+ choice = pos;
+ }
+ }
+ else
+ {
+ PlaySound(SND_MENU_ITEM_SELECTING);
+
+ if (pos == MAIN_CONTROL_NAME)
+ {
+ game_status = GAME_MODE_PSEUDO_TYPENAME;
+
+ HandleTypeName(strlen(setup.player_name), 0);
+ }
+ else if (pos == MAIN_CONTROL_LEVELS)
+ {
+ if (leveldir_first)
+ {
+ game_status = GAME_MODE_LEVELS;
+
+ SaveLevelSetup_LastSeries();
+ SaveLevelSetup_SeriesInfo();
+
+#if 0
+ gotoTopLevelDir();
+#endif
+
+ DrawChooseLevel();
+ }
+ }
+ else if (pos == MAIN_CONTROL_SCORES)
+ {
+ game_status = GAME_MODE_SCORES;
+
+ DrawHallOfFame(-1);
+ }
+ else if (pos == MAIN_CONTROL_EDITOR)
+ {
+ if (leveldir_current->readonly &&
+ !strEqual(setup.player_name, "Artsoft"))
+ Request("This level is read only !", REQ_CONFIRM);
+
+ game_status = GAME_MODE_EDITOR;
+
+ fading = menu.destination;
+
+ DrawLevelEd();
+ }
+ else if (pos == MAIN_CONTROL_INFO)
+ {
+ game_status = GAME_MODE_INFO;
+ info_mode = INFO_MODE_MAIN;
+
+ fading = menu.navigation;
+
+ DrawInfoScreen();
+ }
+ else if (pos == MAIN_CONTROL_GAME)
+ {
+ StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
+ }
+ else if (pos == MAIN_CONTROL_SETUP)
+ {
+ game_status = GAME_MODE_SETUP;
+ setup_mode = SETUP_MODE_MAIN;
+
+ DrawSetupScreen();
+ }
+ else if (pos == MAIN_CONTROL_QUIT)
+ {
+ SaveLevelSetup_LastSeries();
+ SaveLevelSetup_SeriesInfo();
+
+ if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
+ game_status = GAME_MODE_QUIT;
+ }
+ }
+ }
+
+ if (game_status == GAME_MODE_MAIN)
+ {
+ DrawPreviewLevel(FALSE);
+ DoAnimation();
+ }
+}
+
+#else
+
+void HandleMainMenu(int mx, int my, int dx, int dy, int button)
+{
+ static int choice = 5;
+ int x = 0;
+ int y = choice;
+
+ if (button == MB_MENU_INITIALIZE)
+ {
+ drawCursor(choice, TRUE);
+
+ return;
+ }
+
+ if (mx || my) /* mouse input */
+ {
+ x = (mx - mSX) / 32;
+ y = (my - mSY) / 32 - MENU_SCREEN_START_YPOS;
+ }
+ else if (dx || dy) /* keyboard input */
+ {
+ if (dx && choice == 1)
+ x = (dx < 0 ? 10 : 14);
+ else if (dx > 0)
+ {
+ if (choice == 4 || choice == 6)
+ button = MB_MENU_CHOICE;
+ }
+ else if (dy)
+ y = choice + dy;
+ }
+
+ if (y == 1 && dx != 0 && button)
+ {
+ HandleMainMenu_SelectLevel(1, dx < 0 ? -1 : +1);
+ }
+ else if (IN_VIS_FIELD(x, y) &&
+ y >= 0 && y <= 7 && (y != 1 || x < 10))
+ {
+ if (button)
+ {
+ if (y != choice)
+ {
+ drawCursor(choice, FALSE);
+ drawCursor(y, TRUE);
+
+ choice = y;
+ }
+ }
+ else
+ {
+ if (y == 0)
+ {
+ game_status = GAME_MODE_PSEUDO_TYPENAME;
+ HandleTypeName(strlen(setup.player_name), 0);
+ }
+ else if (y == 1)
+ {
+ if (leveldir_first)
+ {
+ game_status = GAME_MODE_LEVELS;
+ SaveLevelSetup_LastSeries();
+ SaveLevelSetup_SeriesInfo();
+
+#if 0
+ gotoTopLevelDir();
+#endif
+
+ DrawChooseLevel();
+ }
+ }
+ else if (y == 2)
+ {
+ game_status = GAME_MODE_SCORES;
+ DrawHallOfFame(-1);
+ }
+ else if (y == 3)
+ {
+ if (leveldir_current->readonly &&
+ !strEqual(setup.player_name, "Artsoft"))
+ Request("This level is read only !", REQ_CONFIRM);
+ game_status = GAME_MODE_EDITOR;
+ DrawLevelEd();
+ }
+ else if (y == 4)
+ {
+ game_status = GAME_MODE_INFO;
+ info_mode = INFO_MODE_MAIN;
+ DrawInfoScreen();
+ }
+ else if (y == 5)
+ {
+ StartGameActions(options.network, setup.autorecord, NEW_RANDOMIZE);
+ }
+ else if (y == 6)
+ {
+ game_status = GAME_MODE_SETUP;
+ setup_mode = SETUP_MODE_MAIN;
+
+ DrawSetupScreen();
+ }
+ else if (y == 7)
+ {
+ SaveLevelSetup_LastSeries();
+ SaveLevelSetup_SeriesInfo();
+
+ if (Request("Do you really want to quit ?", REQ_ASK | REQ_STAY_CLOSED))
+ game_status = GAME_MODE_QUIT;
+ }
+ }
+ }
+
+ if (game_status == GAME_MODE_MAIN)
+ {
+ DrawPreviewLevel(FALSE);
+ DoAnimation();
+ }
+}
+
+#endif
+
+
+/* ========================================================================= */
+/* info screen functions */
+/* ========================================================================= */
+
+static struct TokenInfo *info_info;
+static int num_info_info;
+
+static void execInfoTitleScreen()
+{
+ fading = menu.destination;
+
+ info_mode = INFO_MODE_TITLE;
+ DrawInfoScreen();
+}
+
+static void execInfoElements()
+{
+ fading = menu.destination;
+
+ info_mode = INFO_MODE_ELEMENTS;
+ DrawInfoScreen();
+}
+
+static void execInfoMusic()
+{
+ fading = menu.destination;
+
+ info_mode = INFO_MODE_MUSIC;
+ DrawInfoScreen();
+}
+
+static void execInfoCredits()
+{
+ fading = menu.destination;
+
+ info_mode = INFO_MODE_CREDITS;
+ DrawInfoScreen();
+}
+
+static void execInfoProgram()
+{
+ fading = menu.destination;
+
+ info_mode = INFO_MODE_PROGRAM;
+ DrawInfoScreen();
+}
+
+static void execInfoVersion()
+{
+ fading = menu.destination;
+
+ info_mode = INFO_MODE_VERSION;
+ DrawInfoScreen();
+}
+
+static void execInfoLevelSet()
+{
+ fading = menu.destination;
+
+ info_mode = INFO_MODE_LEVELSET;
+ DrawInfoScreen();
+}
+
+static void execExitInfo()
+{
+ fading = menu.navigation;
+
+ game_status = GAME_MODE_MAIN;
+#if 1
+ DrawMainMenuExt(REDRAW_FIELD, FALSE);
+#else
+ DrawMainMenu();
+#endif
+}
+
+static struct TokenInfo info_info_main[] =
+{
+ { TYPE_ENTER_SCREEN, execInfoTitleScreen, "Title Screen" },
+ { TYPE_ENTER_SCREEN, execInfoElements, "Elements Info" },
+ { TYPE_ENTER_SCREEN, execInfoMusic, "Music Info" },
+ { TYPE_ENTER_SCREEN, execInfoCredits, "Credits" },
+ { TYPE_ENTER_SCREEN, execInfoProgram, "Program Info" },
+ { TYPE_ENTER_SCREEN, execInfoVersion, "Version Info" },
+ { TYPE_ENTER_SCREEN, execInfoLevelSet, "Level Set Info" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execExitInfo, "Exit" },
+
+ { 0, NULL, NULL }
+};
+
+static void DrawCursorAndText_Info(int pos, boolean active)
+{
+ int xpos = MENU_SCREEN_START_XPOS;
+ int ypos = MENU_SCREEN_START_YPOS + pos;
+ int font_nr = FONT_MENU_1;
+
+ if (active)
+ font_nr = FONT_ACTIVE(font_nr);
+
+ DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[pos].text, font_nr);
+
+ if (info_info[pos].type & ~TYPE_SKIP_ENTRY)
+ drawCursor(pos, active);
+}
+
+static void DrawInfoScreen_Main(int redraw_mask, boolean do_fading)
+{
+ int i;
+
+ UnmapAllGadgets();
+ CloseDoor(DOOR_CLOSE_2);
+
+#if XFADE
+ if (fading.anim_mode == ANIM_CROSSFADE)
+ FadeCrossSaveBackbuffer();
+ else
+ FadeOut(redraw_mask);
+#endif
+
+#if 1
+ if (redraw_mask == REDRAW_ALL)
+ {
+ RedrawBackground();
+ OpenDoor(DOOR_CLOSE_1 | DOOR_CLOSE_2 | DOOR_NO_DELAY | DOOR_FORCE_REDRAW);
+ }
+#endif
+
+ ClearWindow();
+
+ DrawTextSCentered(mSY - SY + 16, FONT_TITLE_1, "Info Screen");
+
+ info_info = info_info_main;
+ num_info_info = 0;
+
+ for (i = 0; info_info[i].type != 0 && i < NUM_MENU_ENTRIES_ON_SCREEN; i++)
+ {
+#if 0
+ int xpos = MENU_SCREEN_START_XPOS;
+ int ypos = MENU_SCREEN_START_YPOS + i;
+ int font_nr = FONT_MENU_1;
+#endif
+
+ if (info_info[i].type & (TYPE_ENTER_MENU|TYPE_ENTER_LIST))
+ initCursor(i, IMG_MENU_BUTTON_ENTER_MENU);
+ else if (info_info[i].type & (TYPE_LEAVE_MENU|TYPE_LEAVE_LIST))
+ initCursor(i, IMG_MENU_BUTTON_LEAVE_MENU);
+ else if (info_info[i].type & ~TYPE_SKIP_ENTRY)
+ initCursor(i, IMG_MENU_BUTTON);
+
+#if 1
+ DrawCursorAndText_Info(i, FALSE);
+#else
+ DrawText(mSX + xpos * 32, mSY + ypos * 32, info_info[i].text, font_nr);
+#endif
+
+ num_info_info++;
+ }
+
+ HandleInfoScreen_Main(0, 0, 0, 0, MB_MENU_INITIALIZE);
+
+ PlayMenuSound();
+ PlayMenuMusic();
+
+ DrawMaskedBorder(REDRAW_ALL);
+
+#if XFADE
+ if (fading.anim_mode == ANIM_CROSSFADE)
+ FadeCross(redraw_mask);
+ else
+ FadeIn(redraw_mask);
+#else
+#if 1
+ if (!do_fading)
+ BackToFront();
+ else if (fading.anim_mode == ANIM_CROSSFADE)
+ FadeCross(redraw_mask);
+ else
+ FadeIn(redraw_mask);
+#else
+ if (do_fading)
+ FadeIn(redraw_mask);
+ else
+ BackToFront();
+#endif
+#endif
+
+ InitAnimation();
+}
+
+void HandleInfoScreen_Main(int mx, int my, int dx, int dy, int button)
+{
+ static int choice_store[MAX_INFO_MODES];
+ int choice = choice_store[info_mode]; /* always starts with 0 */
+ int x = 0;
+ int y = choice;
+
+ if (button == MB_MENU_INITIALIZE)
+ {
+ /* advance to first valid menu entry */
+ while (choice < num_info_info &&
+ info_info[choice].type & TYPE_SKIP_ENTRY)
+ choice++;
+ choice_store[info_mode] = choice;
+
+#if 1
+ DrawCursorAndText_Info(choice, TRUE);
+#else
+ drawCursor(choice, TRUE);
+#endif
+
+ return;
+ }
+ else if (button == MB_MENU_LEAVE)
+ {
+ for (y = 0; y < num_info_info; y++)
+ {
+ if (info_info[y].type & TYPE_LEAVE_MENU)
+ {
+ void (*menu_callback_function)(void) = info_info[y].value;
+
+ menu_callback_function();
+
+ break; /* absolutely needed because function changes 'info_info'! */
+ }