+ }
+ }
+
+ BackToFront();
+
+ if (game_status == CHOOSELEVEL || game_status == SETUP)
+ DoAnimation();
+}
+
+void DrawChooseLevel()
+{
+ DrawChooseTree(&leveldir_current);
+}
+
+void HandleChooseLevel(int mx, int my, int dx, int dy, int button)
+{
+ HandleChooseTree(mx, my, dx, dy, button, &leveldir_current);
+}
+
+void DrawHallOfFame(int highlight_position)
+{
+ UnmapAllGadgets();
+ FadeSounds();
+ CloseDoor(DOOR_CLOSE_2);
+
+ if (highlight_position < 0)
+ LoadScore(level_nr);
+
+ FadeToFront();
+ InitAnimation();
+ HandleHallOfFame(highlight_position,0, 0,0, MB_MENU_INITIALIZE);
+ PlaySound(SND_MENU_HALL_OF_FAME);
+}
+
+static void drawHallOfFameList(int first_entry, int highlight_position)
+{
+ int i;
+
+ ClearWindow();
+ DrawText(SX + 80, SY + 8, "Hall Of Fame", FS_BIG, FC_YELLOW);
+ DrawTextFCentered(46, FC_RED, "HighScores of Level %d", level_nr);
+
+ for(i=0; i<MAX_MENU_ENTRIES_ON_SCREEN; i++)
+ {
+ int entry = first_entry + i;
+ int color = (entry == highlight_position ? FC_RED : FC_GREEN);
+
+#if 0
+ DrawText(SX, SY + 64 + i * 32, ".................", FS_BIG, color);
+ DrawText(SX, SY + 64 + i * 32, highscore[i].Name, FS_BIG, color);
+ DrawText(SX + 12 * 32, SY + 64 + i * 32,
+ int2str(highscore[i].Score, 5), FS_BIG, color);
+#else
+ DrawText(SX, SY + 64 + i * 32, "..................................",
+ FS_MEDIUM, FC_YELLOW);
+ DrawText(SX, SY + 64 + i * 32, int2str(entry + 1, 3),
+ FS_MEDIUM, FC_YELLOW);
+ DrawText(SX + 64, SY + 64 + i * 32, highscore[entry].Name, FS_BIG, color);
+ DrawText(SX + 14 * 32 + 16, SY + 64 + i * 32,
+ int2str(highscore[entry].Score, 5), FS_MEDIUM, color);
+#endif
+ }
+}
+
+void HandleHallOfFame(int mx, int my, int dx, int dy, int button)
+{
+ static int first_entry = 0;
+ static int highlight_position = 0;
+ int step = (button == 1 ? 1 : button == 2 ? 5 : 10);
+ int button_released = !button;
+
+ if (button == MB_MENU_INITIALIZE)
+ {
+ first_entry = 0;
+ highlight_position = mx;
+ drawHallOfFameList(first_entry, highlight_position);
+ return;
+ }
+
+ if (ABS(dy) == SCR_FIELDY) /* handle KSYM_Page_Up, KSYM_Page_Down */
+ step = MAX_MENU_ENTRIES_ON_SCREEN - 1;
+
+ if (dy < 0)
+ {
+ if (first_entry > 0)
+ {
+ first_entry -= step;
+ if (first_entry < 0)
+ first_entry = 0;
+
+ drawHallOfFameList(first_entry, highlight_position);
+ return;
+ }
+ }
+ else if (dy > 0)
+ {
+ if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN < MAX_SCORE_ENTRIES)
+ {
+ first_entry += step;
+ if (first_entry + MAX_MENU_ENTRIES_ON_SCREEN > MAX_SCORE_ENTRIES)
+ first_entry = MAX(0, MAX_SCORE_ENTRIES - MAX_MENU_ENTRIES_ON_SCREEN);
+
+ drawHallOfFameList(first_entry, highlight_position);
+ return;
+ }
+ }
+
+ if (button_released)
+ {
+ FadeSound(SND_MENU_HALL_OF_FAME);
+ game_status = MAINMENU;
+ DrawMainMenu();
+ }
+
+ BackToFront();
+
+ if (game_status == HALLOFFAME)
+ DoAnimation();
+}
+
+
+/* ========================================================================= */
+/* setup screen functions */
+/* ========================================================================= */
+
+static struct TokenInfo *setup_info;
+static int num_setup_info;
+
+static void execSetupMain()
+{
+ setup_mode = SETUP_MODE_MAIN;
+ DrawSetupScreen();
+}
+
+static void execSetupGraphics()
+{
+ setup.graphics_set = artwork.gfx_current->name;
+
+ setup_mode = SETUP_MODE_GRAPHICS;
+ DrawSetupScreen();
+}
+
+static void execSetupSound()
+{
+ setup.sounds_set = artwork.snd_current->name;
+ setup.music_set = artwork.mus_current->name;
+
+ setup_mode = SETUP_MODE_SOUND;
+ DrawSetupScreen();
+}
+
+static void execSetupChooseGraphics()
+{
+ setup_mode = SETUP_MODE_CHOOSE_GRAPHICS;
+ DrawSetupScreen();
+}
+
+static void execSetupChooseSounds()
+{
+ setup_mode = SETUP_MODE_CHOOSE_SOUNDS;
+ DrawSetupScreen();
+}
+
+static void execSetupChooseMusic()
+{
+ setup_mode = SETUP_MODE_CHOOSE_MUSIC;
+ DrawSetupScreen();
+}
+
+static void execSetupInput()
+{
+ setup_mode = SETUP_MODE_INPUT;
+ DrawSetupScreen();
+}
+
+static void execSetupShortcut()
+{
+ setup_mode = SETUP_MODE_SHORTCUT;
+ DrawSetupScreen();
+}
+
+static void execExitSetupChooseArtwork()
+{
+ if (setup_mode == SETUP_MODE_CHOOSE_GRAPHICS)
+ execSetupGraphics();
+ else
+ execSetupSound();
+}
+
+static void execExitSetup()
+{
+ game_status = MAINMENU;
+ DrawMainMenu();
+}
+
+static void execSaveAndExitSetup()
+{
+ SaveSetup();
+ execExitSetup();
+}
+
+static struct TokenInfo setup_info_main[] =
+{
+ { TYPE_ENTER_MENU, execSetupGraphics, "Graphics Setup" },
+ { TYPE_ENTER_MENU, execSetupSound, "Sound Setup" },
+ { TYPE_ENTER_MENU, execSetupInput, "Input Devices" },
+ { TYPE_ENTER_MENU, execSetupShortcut, "Key Shortcuts" },
+ { TYPE_EMPTY, NULL, "" },
+#if 0
+ { TYPE_SWITCH, &setup.double_buffering,"Buffered gfx:" },
+ { TYPE_SWITCH, &setup.fading, "Fading:" },
+#endif
+ { TYPE_SWITCH, &setup.quick_doors, "Quick Doors:" },
+ { TYPE_SWITCH, &setup.ask_on_escape, "Ask on Esc:" },
+ { TYPE_SWITCH, &setup.toons, "Toons:" },
+ { TYPE_SWITCH, &setup.autorecord, "Auto-Record:" },
+ { TYPE_SWITCH, &setup.team_mode, "Team-Mode:" },
+ { TYPE_SWITCH, &setup.handicap, "Handicap:" },
+ { TYPE_SWITCH, &setup.time_limit, "Timelimit:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execExitSetup, "Exit" },
+ { TYPE_LEAVE_MENU, execSaveAndExitSetup, "Save and exit" },
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_graphics[] =
+{
+ { TYPE_ENTER_MENU, execSetupChooseGraphics,"Custom Graphics" },
+ { TYPE_STRING, &setup.graphics_set, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_SWITCH, &setup.fullscreen, "Fullscreen:" },
+ { TYPE_SWITCH, &setup.scroll_delay, "Scroll Delay:" },
+ { TYPE_SWITCH, &setup.soft_scrolling, "Soft Scroll.:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_sound[] =
+{
+ { TYPE_SWITCH, &setup.sound, "Sound:", },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_SWITCH, &setup.sound_simple, "Simple Sound:" },
+ { TYPE_SWITCH, &setup.sound_loops, "Sound Loops:" },
+ { TYPE_SWITCH, &setup.sound_music, "Game Music:" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_ENTER_MENU, execSetupChooseSounds, "Custom Sounds" },
+ { TYPE_STRING, &setup.sounds_set, "" },
+ { TYPE_ENTER_MENU, execSetupChooseMusic, "Custom Music" },
+ { TYPE_STRING, &setup.music_set, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
+ { 0, NULL, NULL }
+};
+
+static struct TokenInfo setup_info_shortcut[] =
+{
+ { TYPE_KEYTEXT, NULL, "Quick Save Game:", },
+ { TYPE_KEY, &setup.shortcut.save_game, "" },
+ { TYPE_KEYTEXT, NULL, "Quick Load Game:", },
+ { TYPE_KEY, &setup.shortcut.load_game, "" },
+ { TYPE_KEYTEXT, NULL, "Toggle Pause:", },
+ { TYPE_KEY, &setup.shortcut.toggle_pause, "" },
+ { TYPE_EMPTY, NULL, "" },
+ { TYPE_LEAVE_MENU, execSetupMain, "Exit" },
+ { 0, NULL, NULL }
+};
+
+static Key getSetupKey()
+{
+ Key key = KSYM_UNDEFINED;
+ boolean got_key_event = FALSE;
+
+ while (!got_key_event)
+ {
+ if (PendingEvent()) /* got event */
+ {
+ Event event;
+
+ NextEvent(&event);
+
+ switch(event.type)
+ {
+ case EVENT_KEYPRESS:
+ {
+ key = GetEventKey((KeyEvent *)&event, TRUE);
+
+ /* press 'Escape' or 'Enter' to keep the existing key binding */
+ if (key == KSYM_Escape || key == KSYM_Return)
+ key = KSYM_UNDEFINED; /* keep old value */
+
+ got_key_event = TRUE;
+ }
+ break;
+
+ case EVENT_KEYRELEASE:
+ key_joystick_mapping = 0;
+ break;
+
+ default:
+ HandleOtherEvents(&event);
+ break;